GeometryEngine.Cut doesn't split into multiple geometries

2725
7
Jump to solution
01-13-2017 11:04 PM
MaxMax2
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)
0 Kudos
1 Solution

Accepted Solutions
NarelleChedzey
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
NarelleChedzey
Esri Contributor

Hi Max, 

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

Regards

Narelle

MaxMax2
Occasional Contributor II

Hi Narelle,

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

0 Kudos
NarelleChedzey
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

0 Kudos
MaxMax2
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.

0 Kudos
MaxMax2
Occasional Contributor II

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

0 Kudos
NarelleChedzey
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

MaxMax2
Occasional Contributor II

Hi Narelle,

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