GeometryEngine.Cut doesn't split into multiple geometries

1381
7
Jump to solution
01-13-2017 11:04 PM
Highlighted
Occasional Contributor II

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:

Tags (2)
Reply
0 Kudos
1 Solution

Accepted Solutions
Highlighted
Esri Contributor

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

View solution in original post

7 Replies
Highlighted
Esri Contributor

Hi Max, 

Thanks for your post.  We're investigating - looks like a bug. We'll fix for the next release. 

Regards

Narelle

Highlighted
Occasional Contributor II

Hi Narelle,

Thanks for reply. Let me know if you need test data or more details.

Reply
0 Kudos
Highlighted
Esri Contributor

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

Reply
0 Kudos
Highlighted
Occasional Contributor II

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.

Reply
0 Kudos
Highlighted
Occasional Contributor II

nchedzey-esristaff‌, can you confirm that the bug exists?

Reply
0 Kudos
Highlighted
Esri Contributor

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

View solution in original post

Highlighted
Occasional Contributor II

Hi Narelle,

I confirm, in 2.0 the bug is fixed. Thank you.