SceneView won't render polygon with hole

945
3
Jump to solution
02-01-2017 07:57 AM
DavidHope
New Contributor III

Referencing the attached picture

polygon with hole issue

Both Views (SceneView on the left, MapView on the right) have a single, multi-part polygon added to a single graphics overlay. The problem is that the MapView correctly shows the hole in the polygon, but the sceneview doesn't.

Full project attached.

Any sugguestions?

Code looks as follows:

{
var mapOL = new GraphicsOverlay();
mapOL.SceneProperties.SurfacePlacement = SurfacePlacement.Draped;
var listpc = new List<Esri.ArcGISRuntime.Geometry.PointCollection>();
var pc1 = new Esri.ArcGISRuntime.Geometry.PointCollection(SpatialReferences.Wgs84);
pc1.Add(-5, -5, 10);
pc1.Add(5, -5, 10);
pc1.Add(5, 5, 10);
pc1.Add(-5, 5, 10);

listpc.Add(pc1);

var pc2 = new Esri.ArcGISRuntime.Geometry.PointCollection(SpatialReferences.Wgs84);
pc2.Add(-2, -2, 10);
pc2.Add(2, -2, 10);
pc2.Add(2, 2, 10);
pc2.Add(-2, 2, 10);

listpc.Add(pc2);

var poly1 = new Polygon(listpc);
var g1 = new Graphic(poly1, new SimpleFillSymbol() { Color = Colors.Red, Outline = new SimpleLineSymbol() { Color = Colors.Black, Width = 2, Style = SimpleLineSymbolStyle.Solid }, Style = SimpleFillSymbolStyle.Null }) { ZIndex = 2 };

mapOL.Graphics.Add(g1);

var poly2 = new Polygon(listpc);
var g2 = new Graphic(poly1, new SimpleFillSymbol() { Color = Colors.Red, Outline = new SimpleLineSymbol() { Color = Colors.Transparent, Width = 0, Style = SimpleLineSymbolStyle.Null }, Style = SimpleFillSymbolStyle.Solid }) { ZIndex = 1 };

mapOL.Graphics.Add(g2);

_mapgraphicsOverlays.Clear();

_mapgraphicsOverlays.Add(mapOL);
}

0 Kudos
1 Solution

Accepted Solutions
MoreHavoc
New Contributor III

David,

I ran into a maybe-related issue when building polygons.  I found that if there is a donut the inner ring must always be counter-clockwise.  You can use the Simplify command to fix them, at least I think it can always fix them.  I found the note at the bottom of the polygon builder docs:

Note: Interior rings to make donut polygons should be counter-clockwise in direction to be topology correct. If there is ever a doubt about the topological correctness of a polygon, call the Simplify(Geometry) method to correct any issues. This is especially true if you pass a polygon to ArcGIS Server for a geoprocessing task to avoid any ArcGIS Server errors being thrown.

PolygonBuilder Class 

Here is the reference for Simplify as well: GeometryEngine.Simplify Method 

Hope that helps!

Christopher

View solution in original post

3 Replies
DavidHope
New Contributor III

BTW, I've discovered that if I reverse the order of the points in the interior polygon, it then works on the SceneView also...

0 Kudos
MoreHavoc
New Contributor III

David,

I ran into a maybe-related issue when building polygons.  I found that if there is a donut the inner ring must always be counter-clockwise.  You can use the Simplify command to fix them, at least I think it can always fix them.  I found the note at the bottom of the polygon builder docs:

Note: Interior rings to make donut polygons should be counter-clockwise in direction to be topology correct. If there is ever a doubt about the topological correctness of a polygon, call the Simplify(Geometry) method to correct any issues. This is especially true if you pass a polygon to ArcGIS Server for a geoprocessing task to avoid any ArcGIS Server errors being thrown.

PolygonBuilder Class 

Here is the reference for Simplify as well: GeometryEngine.Simplify Method 

Hope that helps!

Christopher

DavidHope
New Contributor III

Christopher,

That was very helpful. Even more so, because while looking at Geometry Engine, I discovered that I could use the GeometryEngine.Difference method to do exactly what I wanted to do (and it makes sure that polygons are all spinning the correct direction).