Hi @dioG9T, thanks for taking the time to evaluate ArcGIS Runtime for Qt! I took some time to test out a concept and I believe we can achieve what you're looking for with a somewhat equivalent solution.
Instead of creating vector drawings that must be calculated and redrawn every time the map moves, I utilized ArcGIS Runtime API's GeometryEngine class. I used the `moveGeodetic` member function to calculate a new point at a specific distance and angle for every degree of the beam arc. I then used `convexHull` to create a polygon around the resulting points and then added that polygon to the map view.
I've implemented this rough proof of concept in the C++ API, but it can also be done in the QML API. I wrote this in the default template provided to our users and all of this functionality is available right out of the box.
void GeodeticMove::setMapView(MapQuickView* mapView)
{
// ** Extraneous map initialization code **
if (!mapView || mapView == m_mapView)
return;
m_mapView = mapView;
m_mapView->setMap(m_map);
// *****************************************
// initial setup
m_graphicsOverlay = new GraphicsOverlay(this);
GraphicsOverlay* arcOverlay = new GraphicsOverlay(this);
arcOverlay->setOpacity(0.5);
m_mapView->graphicsOverlays()->append(m_graphicsOverlay);
m_mapView->graphicsOverlays()->append(arcOverlay);
// Create center point (radio tower) and symbol
const Point centerPt(-119, 34, SpatialReference::wgs84());
SimpleMarkerSymbol* ptSymbol = new SimpleMarkerSymbol(SimpleMarkerSymbolStyle::Circle, QColor(Qt::blue), 10, this);
// Add center point to graphics overlay
Graphic* pointGraphic = new Graphic(centerPt, ptSymbol, this);
m_graphicsOverlay->graphics()->append(pointGraphic);
// Create a list of geometries
QList<Geometry> arcPoints;
// This is a custom function implemented below
QList<Point> result = createPointsFromMoveGeodetic(centerPt, 10000, 0, 30);
// geodeticMove returns points so let's crudely convert those (there is a better way to do this)
for (const Point& point : result)
{
arcPoints.append(point);
}
// Add center point to polygon for the full triangle
arcPoints.append(centerPt);
// Create the view polygon, make it a graphic, and display it on the map
const Geometry arcPolygon = GeometryEngine::convexHull(arcPoints, true).first();
SimpleFillSymbol* arcSymbol = new SimpleFillSymbol(SimpleFillSymbolStyle::Solid, QColor(Qt::red), this);
arcOverlay->graphics()->append(new Graphic(arcPolygon, arcSymbol, this));
m_mapView->setViewpointCenter(centerPt, 100000);
emit mapViewChanged();
}
// Custom function to create points that will make up the beam polygon
QList<Point> GeodeticMove::createPointsFromMoveGeodetic(Point initialPt, double distance, double heading, double width)
{
QList<Point> newPoints;
double startDegree = heading - width;
double endDegree = heading + width;
// Handle cases of where degrees go from 360 -> 0
int mod = 0;
if (startDegree < 0)
{
startDegree += 360;
}
if (startDegree > endDegree)
{
mod = 360;
}
for (double i = startDegree; i < endDegree+mod; ++i)
{
if (startDegree > 360)
{
startDegree -= 360;
}
newPoints.append(GeometryEngine::moveGeodetic({ initialPt }, distance, LinearUnit::meters(), i, AngularUnit::degrees(), GeodeticCurveType::Geodesic));
}
return newPoints;
}
The result is the screenshot I've attached below.
From there, for example, you can make the values variable and editable by reading from point features defined in a ArcGIS Online Feature Layer. We have a lot of sample code available for our users to reference, and the Update attributes (feature service) sample may be a good reference if you're interested in that.
I hope this helps answer your question, please don't hesitate to follow up or ask additional questions, and thanks again for evaluating the ArcGIS Runtime API for Qt!
- Tanner Yould,
ArcGIS Runtime API for Qt Sample Product Engineer
Tanner Yould
Samples Product Engineer
ArcGIS Maps SDK for Qt
Esri