Select to view content in your preferred language

Inconsistent Shape Display: ShapeTool Ellipse vs. PolygonBuilder Geometry

240
6
Jump to solution
2 weeks ago
SWE
by
Emerging Contributor

 

SWE_0-1749922281126.png

Attached image is showing a geometryediotor created circle (right) and laoded one (left)

Hey folks,

I have a feature where users can draw shapes (like rectangles and ellipses) using the Geometry Editor's ShapeTool, and then save and reload them later.

Now, this isn’t a major issue, but I’ve noticed a display inconsistency. When users draw an ellipse using ShapeTool::create(ShapeToolType::Ellipse) while being zoomed in quite far, the saved shape—once reloaded—looks distorted (e.g., the ellipse appears more like a polygon or nonagon). but drawing using geometry editor its dispalyed as a circle.

I'm considering switching away from ShapeTool for ellipses and just using center + radius with geodesic buffering for consistency. But before I do that,Is this distortion due to how ShapeTool geometries are generated and is there a recommended way to fix or normalize them before saving?




 

0 Kudos
1 Solution

Accepted Solutions
ShellyGill1
Esri Contributor

Hi @SWE - (replying on behalf of Lucas as he's now out of the office for a while). It looks like you're recreating your geometry by passing in a value of  1.0  for the maxDeviation parameter to GeometryEngine.bufferGeodetic, and I'd guess this value could be the problem. This parameter is controlling how approximate the result is - i.e. how far from a "perfect" geodesic buffer the line segments of the result geometry are allowed to be - a smaller number will make a smoother geometry and a larger one will result in a more obvious set of straight lines. Have you tried experimenting with this value at all? If you don't want to calculate a specific deviation value that's suitable for your use case, you could try passing in NaN instead-  this will calculate the result to have a maximum deviation of up to 0.2% of your buffer distance (the radius in your case), with a maximum of 0.01 meters, aiming to give a smooth looking geometry without excessive vertices. If your map scale is so large that a maximum deviation of 0.01 meters results in a rough looking geometry you may need to experiment further. Let us know if this helps.

View solution in original post

0 Kudos
6 Replies
LucasDanzinger
Esri Frequent Contributor

Hello-

 

I spoke with the team, and they confirmed that currently, when you create a circle ellipse, it will contain 36 vertices, regardless of scale. It's interesting that the polygon appears to become less dense when you "save" it. Can you provide any details about how you are saving it? Are you just calling toJson on the output geometry? Is there a simplification or any other process in there? It would be interesting to inspect the json at the various stages of serializing/deserializing and see how it differs from the geometry in the debugger.

0 Kudos
SWE
by
Emerging Contributor

Hey Lucas, thanks for the reply!
Yes, I know about circles having 36 vertices, but currently, what I'm doing is i'm not saving 36 vertices for the circle I'm only saving 2 vertices, the center point where geometry started and the point where the  user clicked to end the drawing and i calculate the radius to add to my json struct
i.e 
points[0]  center
points[1] end
radius
case exp::exp::circle: {
if (points.size() < 2) return Geometry();
double radius = GeometryEngine::distanceGeodetic(points[0], points[1], LinearUnit::meters(), AngularUnit::degrees(), GeodeticCurveType::Geodesic).distance();
return GeometryEngine::bufferGeodetic(points[0], radius, LinearUnit::meters(), 1.0, GeodeticCurveType::Geodesic);
}

Here is how I'm creating the geometry back and styling it the same like I did when creating using geoometry editor and appending it to my overlay.

Note that this minor issue is only visible when you're zommed in  the max or a bit less, i have lots of shaped and graphics which i will be saving so adding 36 vertices everytime would be a push so how do i tweak it to make it similar same is the case with rectangle one im only saving 2 points and its range.

0 Kudos
ShellyGill1
Esri Contributor

Hi @SWE - (replying on behalf of Lucas as he's now out of the office for a while). It looks like you're recreating your geometry by passing in a value of  1.0  for the maxDeviation parameter to GeometryEngine.bufferGeodetic, and I'd guess this value could be the problem. This parameter is controlling how approximate the result is - i.e. how far from a "perfect" geodesic buffer the line segments of the result geometry are allowed to be - a smaller number will make a smoother geometry and a larger one will result in a more obvious set of straight lines. Have you tried experimenting with this value at all? If you don't want to calculate a specific deviation value that's suitable for your use case, you could try passing in NaN instead-  this will calculate the result to have a maximum deviation of up to 0.2% of your buffer distance (the radius in your case), with a maximum of 0.01 meters, aiming to give a smooth looking geometry without excessive vertices. If your map scale is so large that a maximum deviation of 0.01 meters results in a rough looking geometry you may need to experiment further. Let us know if this helps.

0 Kudos
SWE
by
Emerging Contributor

Hi @ShellyGill1  – Adding NaN worked. I tried reducing the maximum deviation parameter to 0.1, but that made things look rough. Now it’s a perfect circle. One thing I forgot to mention in my initial query: even though the shapes are drawn correctly, there’s still a bit of inconsistency. For example, when the zoom level is very high and I draw a rectangle or circle, the shape loads and draws again with the correct coordinates, but its position appears slightly off. When I hover over the area, it gives me the correct location, and due to the high zoom, the hover difference is minimal. However, the shape’s visual placement is still slightly off.

0 Kudos
ShellyGill1
Esri Contributor

One thing I forgot to mention in my initial query: even though the shapes are drawn correctly, there’s still a bit of inconsistency. For example, when the zoom level is very high and I draw a rectangle or circle, the shape loads and draws again with the correct coordinates, but its position appears slightly off. When I hover over the area, it gives me the correct location, and due to the high zoom, the hover difference is minimal. However, the shape’s visual placement is still slightly off.

From your info above, the geometry you're drawing on your map is not the same geometry as the one that you get back from the geometry editor, so I imagine there will be some differences here - if you try your same workflow but save & reload exactly the same geometry as you got back from the geometry editor, do you see the same discrepancy, or does the shape then appear exactly where you expect? Other things to look at would be if you have any reprojection happening in your workflow - different transformations can vary in their accuracy a little. You might find it helpful to read the following info if you're not already familiar with how data is reprojected - https://developers.arcgis.com/qt/spatial-and-data-analysis/spatial-references/#when-you-need-to-know..., and this ref contains info on how the geometry of a GeometryEditor is returned with regard to spatial references which might help: https://developers.arcgis.com/qt/cpp/api-reference/esri-arcgisruntime-geometryeditor.html#geometry 

0 Kudos
ShellyGill1
Esri Contributor

@SWE Glad your shape is looking better.

 the shape loads and draws again with the correct coordinates, but its position appears slightly off. 

I'm not sure there's enough information here to tell what problem you're seeing, but worth mentioning a couple of things in case these help. The geometry editor is not creating a geodesic ellipse, whereas you're recreating the shape as a geodesic shape, so you might see some differences due to that I'd expect - more noticable at smaller scales though. Also you've not mentiond how you're preserving spatial references throughout your workflow, so could there be some reprojection of your recreated shape happening?

0 Kudos