Working with holes of a polygon

Discussion created by maxmaxmaxmaxmax on Mar 4, 2017
Latest reply on Mar 7, 2017 by maxmaxmaxmaxmax

I have a couple of questions regarding to working with parts of polygons.


How can I know if a part is a hole?


At now there is no easy way to determine if a polygon's part is a hole. Turning the part into polygon and checking the sign of its area is the only way. If value of the Area property is a positive number we deal with exterior ring, if negative – with a hole. But it's not obvious.


It would be great if there will be some method to check orientation of a part in the Pro SDK. Since a part of a polygon is just ReadOnlySegmentCollection (which is common for polylines and polygons) maybe the more appropriate place for such method is GeometryEngine.


How can I get all holes of the specific exterior ring?


At now the only way to get all holes of the exetrior part is


var partsAsPolygons = polygon.Parts.Select(p => PolygonBuilder.CreatePolygon(p));
foreach (var exteriorPart in partsAsPolygons.Where(p => p.Area > 0))
    var interiorParts = partsAsPolygons.Where(p => p.Area < 0 && GeometryEngine.Contains(exteriorPart, p));


So we need to use GeometryEngine.Contains method to find all parts with negative area inside some part with positive area. Awful workaround. Hope you will add easy way to get interior parts of an exterior one.