Create a new graphic from 2 graphics?

524
2
Jump to solution
02-06-2023 12:55 PM
NothernCoder
New Contributor III

Good afternoon, I currently have 2 graphics (graphic1 and graphic2) and was wondering if I can make a new graphic that has both of them in it? Sorta like a merge of graphic1 and graphic2 to make a new graphic?

SimpleMarkerSymbol* symbol = new SimpleMarkerSymbol(SimpleMarkerSymbolStyle::Square, QColor(Qt::blue), 3.0f, this);
SimpleLineSymbol* lineSymbol = new SimpleLineSymbol(SimpleLineSymbolStyle::Solid, QColor(Qt::black), 3.0f, this);
Graphic* graphic1 = new Graphic(builder1->toGeometry(), symbol, this);
Graphic* graphic2 = new Graphic(builder2->toGeometry(), lineSymbol, this);

 

Thanks for any tips / help.

0 Kudos
1 Solution

Accepted Solutions
JaredCaccamo
Esri Contributor

Hello @NothernCoder ,

 

I am not exactly sure if this is what you are looking for but we have the GeometryEngine class which performs lots of geometric operations. The two I think might suit your use case are the following:

  1. GeometryEngine::convexHull
    1. A convex hull is a geometry whose vertices are the smallest set of vertices needed to surround the input geometry. One way to visualize this is as a rubber band stretched around a polygon that has some concave sides.
    2. documentation: convexHull doc link 
  2. GeometryEngine::unionOf
    1. Which will return the union of two geometries. Both input geometries must be of the same geometry type and share the same spatial reference.
    2. documentation: unionOf doc link 

Both of these function are overloaded as well to take a list of geometries as the input if you want more than 2.

The only obvious exclusion from these suggestions that I can immediately recognize is in a situation of combining two geometries that would be disjoint. I am not sure of a viable use case for such a situation though. In any case I will ask internally just to be sure.

Also you can search ArcGIS Maps SDK for Qt Sample Viewer at www.arcgis.com and download our sample app. It contains examples for bothGeometryEngine::unionOf and GeometryEngine::convexHull for a better visual examples of each.

View solution in original post

2 Replies
JaredCaccamo
Esri Contributor

Hello @NothernCoder ,

 

I am not exactly sure if this is what you are looking for but we have the GeometryEngine class which performs lots of geometric operations. The two I think might suit your use case are the following:

  1. GeometryEngine::convexHull
    1. A convex hull is a geometry whose vertices are the smallest set of vertices needed to surround the input geometry. One way to visualize this is as a rubber band stretched around a polygon that has some concave sides.
    2. documentation: convexHull doc link 
  2. GeometryEngine::unionOf
    1. Which will return the union of two geometries. Both input geometries must be of the same geometry type and share the same spatial reference.
    2. documentation: unionOf doc link 

Both of these function are overloaded as well to take a list of geometries as the input if you want more than 2.

The only obvious exclusion from these suggestions that I can immediately recognize is in a situation of combining two geometries that would be disjoint. I am not sure of a viable use case for such a situation though. In any case I will ask internally just to be sure.

Also you can search ArcGIS Maps SDK for Qt Sample Viewer at www.arcgis.com and download our sample app. It contains examples for bothGeometryEngine::unionOf and GeometryEngine::convexHull for a better visual examples of each.

NothernCoder
New Contributor III

Perfect, much appreciated thank you. I'll go take a look see.

0 Kudos