I'm trying to split a polygon by multipart polyline (created from multiple polylines with GeometryEngine.Union) using GeometryEngine.Cut method expecting multiple (more than 2) geometries as the result. But I get empty collection... In ArcObjects I can do this easily with ITopologicalOperator4.Cut2 method.
Test data is attached – Data.gdb.zip. If you execute this code you'll get an empty collection as the result of GeometryEngine.Cut method.
using (var geodatabase = new Geodatabase("Data.gdb"))
{
var lines = new List<Polyline>();
using (var linesFeatureClass = geodatabase.OpenDataset<FeatureClass>("Lines"))
using (var linesCursor = linesFeatureClass.Search())
{
while (linesCursor.MoveNext())
{
var polyline = GeometryEngine.SimplifyAsFeature(((Feature)linesCursor.Current).GetShape(), true) as Polyline;
lines.Add(polyline);
}
}
var unifiedLine = GeometryEngine.SimplifyAsFeature(GeometryEngine.Union(lines), true) as Polyline;
Polygon polygon = null;
using (var polygonsFeatureClass = geodatabase.OpenDataset<FeatureClass>("Building_pol"))
using (var polygonCursor = polygonsFeatureClass.Search())
{
while (polygonCursor.MoveNext())
{
polygon = GeometryEngine.SimplifyAsFeature(((Feature)polygonCursor.Current).GetShape(), true) as Polygon;
break;
}
}
var parts = GeometryEngine.Cut(polygon, unifiedLine);
}
Input data:
Expected result: