AGSGeometryEngine cutGeometry:withCutter locks CPU at 100%

2153
4
10-17-2014 03:13 PM
KevinBupp
New Contributor III

Hello:

I have created a tool that allows a user to draw a polyline that is then used to cut a polygon.  I am currently using this code:

AGSMutablePolygon* polygon = [myPolygonGraphic.geometry mutableCopy];

AGSMutablePolyline* cutline = [(AGSMutablePolyline*)self.mapView.sketchLayer.geometry mutableCopy];

NSArray* cutResults = [[AGSGeometryEngine defaultGeometryEngine] cutGeometry:polygon withCutter:cutLine];

For a majority of the polylines that I draw this works perfectly fine .. however, about 75% of the time, when I create a polyline that is similar to the letter Z, the application freezes on the cutGeometry:withCutter: call locking the CPU at 100% on the main thread.  It doesn't seem to matter which part(s) of the Z intersect the polygon.

Profiling the app in Instruments shows that the application is doing some heavy processing in the following methods:

Esri_runtimecore::Geometry::Topo_graph::update_chain_area_and_perimeter_(long long)

-> Esri_runtimecore::Geometry::Math_utils:Kahan_summator::add(double)

-> Esri_runtimecore::Geometry::Attribute_stream_of_dbl::read_point_2D(long long) const

I have tried using non-mutable copies of the geometry as well ... no luck.

So am I missing something here? is there some reason my code is failing or is it just an internal esri runtime bug? (infinite loop?)

Is there another method out there that I can use to cut the polygon (that will work in a disconnected state)?

Thanks in advance.

0 Kudos
4 Replies
ShiminCai
Occasional Contributor III

Hi,

I used the similar code to cut polygon or line and it all worked fine including the Z cutter. The only code difference is that I used AGSPolyline for the cutter instead of AGSMutablePolyline. Try this and see if it makes any difference:

     AGSPolyline* cutline = (AGSPolyline*)self.mapView.sketchLayer.geometry;

Regards,

Shimin

0 Kudos
KevinBupp
New Contributor III

I have tried that, and unfortunately it does not seem to have any effect.

0 Kudos
DiveshGoyal
Esri Regular Contributor

Kevin,

Can you try and isolate the problem in a small project? If possible, try and keep the sketch layer out of it and instead hardcode a geometry that you've seen cause the problem.

0 Kudos
KevinBupp
New Contributor III

Well, I haven't gone as far as creating a simple project to isolate the issue ... but I was able to print out the geometry information for both the polygon and the cutter polyline before the application froze:

Polygon (wkid: 3857):

Ring 0:

(-9945872.290500, 3557729.840000)

(-9945416.665400, 3557715.408400)

(-9945662.002000, 3557181.440500)

Cutter (wkid: 102100):

Path 0:

(-9945874.788078, 3557560.893746)

(-9945353.250412, 3557550.928058)

(-9945702.049488, 3557082.540727)

(-9945366.537996, 3557139.012959)