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"))
{
// Construct unified line to cut by
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;
// Get polygon to be cut
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;
}
}
// Cut polygon by unified line
var parts = GeometryEngine.Cut(polygon, unifiedLine); // parts will be empty collection
}
Input data:
Expected result:
Solved! Go to Solution.
Hi Max,
Yes, there was a bug with the GeometryEngine Cut method. We have fixed it and verified with the dataset you provided. The fix will be available in the next software release. Thanks for pointing this out to us.
Narelle
Hi Max,
Thanks for your post. We're investigating - looks like a bug. We'll fix for the next release.
Regards
Narelle
Hi Narelle,
Thanks for reply. Let me know if you need test data or more details.
Hi Max,
Actually if you have some test data and it's easy to provide that would be helpful. The more real world data scenarios we have for test cases the better.
Narelle
Hi Narelle,
I've updated my first post. I've added sample data and test code along with images showing input data and expected result.
nchedzey-esristaff, can you confirm that the bug exists?
Hi Max,
Yes, there was a bug with the GeometryEngine Cut method. We have fixed it and verified with the dataset you provided. The fix will be available in the next software release. Thanks for pointing this out to us.
Narelle