If we have multiple polygons and we want to calculate the minimum bounding rectangle, how can we do this?
In the native iOS it's done http://stackoverflow.com/questions/1303265/algorithm-for-determining-minimum-bounding-rectangle-for-...
Solved! Go to Solution.
To get min bounding rectangle of a bunch of geometries, you should union them together using the geometry engine - 10.2.5: AGSGeometryEngine Union
You can then use the envelope of the resulting geometry
I haven't worked with the Runtime SDK for iOS, but I just had a look at the documentation and the 10.2.5: AGSPolygon Class Reference has a property envelope that returns a 10.2.5: AGSEnvelope Class Reference . I would have expected to find methods for the union of envelopes, but for some reason I only see methods for intersecting envelopes. Anyway, you can use the methods provided in the page you referenced, extracting the xmin, ymin, xmax, ymax properties of the AGSEnvelope.
Yes I have already tried that and I was able to get the min and max value but while plotting those values on the arcgis map.
Map is throwing the below exception:
libc++abi.dylib: terminating with uncaught exception of type Esri_runtimecore::Common::Out_of_range_exception: Out of range
As mentioned before I have no experience with the Runtime SDK for iOS, but I would verify the spatial reference of the map, the envelope and polygons. I you are inserting projected coordinates (large values) and these are being interpreted as geographic coordinates, this may cause these type of problems. Or if for some reason a value is not set of the output bounding envelope, this could also be the cause. Have you verified the values?
Xander Bakker Thanks for your help.
Yes i have debug the values and my code is correctly converting the coordinates into Arcgis coordinates.
I guess my code is correctly getting the min and max coordinates but due to some reason code is throwing exception while using those values with Arcgis.
Can you list the values you obtain and the spatial reference? I think this info might be helpful for someone with knowledge of the SDK to see what might be going wrong.
Here are the values x = 8435479.317740, y = 2595778.804307, spatial reference: [AGSSpatialReference: wkid = 3857]
Coordinates look normal, they point to Indore India for the WGS_1984_Web_Mercator_Auxiliary_Sphere projected coordinate system. You mention that you are converting the coordinates into ArcGIS coordinates. What do you exactly mean by that?
The spatial reference you mentioned applies for the map and the polygon layer?
Another question; if the polygons reside in the same featureclass (layer) does the fullEnvelope property in the 10.2.5: AGSLayer Class Reference not work for you?
Thanks for your help Xander Bakker, reply from Divesh worked for me.
To get min bounding rectangle of a bunch of geometries, you should union them together using the geometry engine - 10.2.5: AGSGeometryEngine Union
You can then use the envelope of the resulting geometry