feature service generalize geometries

678
6
10-19-2011 02:55 PM
LukePhilips
New Contributor III
Is there support in the iOS API to generalize the geometries of a feature service so I only get the minimum points needed to represent features on the map?

http://blogs.esri.com/Dev/blogs/arcgisserver/archive/2011/06/13/Feature-layers-can-generalize-geomet...

Could I simply force the parameter "maxAllowableOffset" in the URI to the feature service?
0 Kudos
6 Replies
NimeshJarecha
Esri Regular Contributor
Yes, you can set the AGSFeatureLayer::maxAllowableOffset property to generalize the geometry. However, please make sure feature service belongs to ArcGIS Server v10 and above.

Regards,
Nimesh
0 Kudos
LukePhilips
New Contributor III
how would I get the map width after zooming? I suspect the best way to set the maxAllowableOffset value would be a ratio of map width (in map spatial reference units) and actual pixel/point width. unless there is a better way to do this?
0 Kudos
NimeshJarecha
Esri Regular Contributor
You can get the map width in map's spatial reference from mapView's extent.

AGSEnvelope *mapEnvelope = self.mapView.visibleArea.envelope;
double width = mapEnvelope.xmax - mapEnvelope.xmin;

Based on device (retina or non-retina) you can get the point/pixel value.

Regards,
Nimesh
0 Kudos
LukePhilips
New Contributor III
I was going to ask how about getting the envelope coordinates in the geographic SR (4326), but i'm not so sure I need that. Instead, I'm not sure I'm setting maxOffset correctly. In the viewDidLoad I add a featureLayer to the mapView, setting the maxAllowableOffset equal to a NSNumber property I have declared (we'll call it NSMaxOffset). Then I have registered and listen for the MapDidEndZooming and when I get that notification I get the map envelope view area, do the above math and set a new value to the NSMaxOffset property.
0 Kudos
LukePhilips
New Contributor III
they always say talking about the issue shows the answer.. after I explained above, realizing creating a AGSFeatureLayer retain property would solve my issue. Now my issue is figuring out why the iOS api doesn't behave like the JS api; for example, in JS the api seems to divide the viewable area into a grid and make multiple calls so the map features appear fully connected when you run into that 1000 results limit while the iOS api seems to make one call for the whole viewable area, and not render the data you have previously viewed, only what you get from the latest call.
0 Kudos
NimeshJarecha
Esri Regular Contributor
You should use AGSFeatureLayer's bufferFactor property. Here is the doc for that...

This is the buffer around the current extent that features are retrieved for in OnDemand mode. Features are not retrieved again until either they expire or the map extent changes and is no longer in the buffered extent. Buffer factor can be up to 10. If it is set to 0, every time the map extent is changed a requery will take place in OnDemand mode. If the buffer factor is less than 0, then the layer will never requery from an extent change. This is not usually recommended.


Hope this helps!

Regards,
Nimesh
0 Kudos