A few years back, when we were evaluating ArcGIS Server, I created a geoprocessing proof-of-concept service that received a lat/long and returned polygon IDs containing said point. There's now a need to actually use this feature, and within a high-volume environment, no less, so I've been looking to redevelop properly. There appear to be a few ways to go about this - Simple enough! However, what's the fastest, most performant way?
I have a map service containing a few thousand overlapping polygons (just need the layer to make the association) - I would like to send an x,y point (lat/long) and return a list of IDs from the map service.
I came across this thread:
Should I go about it this way, or should I use GeometryService?
Solved! Go to Solution.
Ok, so, with a fresh brain, I realized I was going about this the wrong way. I had to ensure query capabilities were enabled for the layer (curiously, they had been disabled on my targeted service) - everything I needed to do was available for me to hit from asp.net by loading the service URL with querystring params:
http://yourGISserver.com/arcgis/rest/services/base_services/yourMapLayer/MapServer/0/query?where=&
text=&
objectIds=&
time=&
geometry=%7B%22x%22+%3A+-104.53%2C+%22y%22+%3A+34.74%7D%0D%0A&
geometryType=esriGeometryPoint&
inSR=4326&
spatialRel=esriSpatialRelWithin&relationParam=&
outFields=yourTargetField&
returnGeometry=false&
maxAllowableOffset=&
geometryPrecision=&
outSR=&
returnIdsOnly=false&
returnCountOnly=false&
orderByFields=&
groupByFieldsForStatistics=&
outStatistics=&
returnZ=false&
returnM=false&
gdbVersion=&
returnDistinctValues=false&
returnTrueCurves=false&
resultOffset=&
resultRecordCount=&
f=pjson
This returns a JSON object with the attributes I need!
{ "displayFieldName": "DisplayField", "fieldAliases": { "yourTargetField": "yourTargetField" }, "fields": [ { "name": "yourTargetField", "type": "esriFieldTypeString", "alias": "yourTargetField", "length": 6 } ], "features": [ { "attributes": { "yourTargetField": "FOO123" } }, { "attributes": { "yourTargetField": "BAR321" } }, { "attributes": { "yourTargetField": "BIZ789" } }, { "attributes": { "yourTargetField": "BAT987" } } ] }
I don't have the answer but your question reminds me of a Blog post by ESRI about the client-side GeometryEngine which may be faster if you're dealing with a lot of features. GeometryEngine is in beta and only available in API v3.13 & above.
I was thinking about this - ideally, I'd like to be able to hit it through REST. Really, if I could use SQL Spatial Data, I'd be set (I can't, unfortunately).
Chris,
I think using a QueryTask would be the way to go.
Robert,
1. I would be dealing with a single point at any given moment in time, such as when a user registered on the system.
2. Just one layer - technically, about 20 coincidental layers merged into one layer, with overlaps (strictly to obtain the associations)
3. I can, but what I'd really like to do is hit it from the server, e.g. something like this:
Then massage and use the returned object server-side.
I've seen a noticeable performance difference depending on whether I return the geometry or not. If all you need is data values returned, a queryTask has worked OK for me, if I have the returnGeometry set to false.
Thanks, I will probably end-up going this route... I'll let you know how it ends-up.
Ok, so, with a fresh brain, I realized I was going about this the wrong way. I had to ensure query capabilities were enabled for the layer (curiously, they had been disabled on my targeted service) - everything I needed to do was available for me to hit from asp.net by loading the service URL with querystring params:
http://yourGISserver.com/arcgis/rest/services/base_services/yourMapLayer/MapServer/0/query?where=&
text=&
objectIds=&
time=&
geometry=%7B%22x%22+%3A+-104.53%2C+%22y%22+%3A+34.74%7D%0D%0A&
geometryType=esriGeometryPoint&
inSR=4326&
spatialRel=esriSpatialRelWithin&relationParam=&
outFields=yourTargetField&
returnGeometry=false&
maxAllowableOffset=&
geometryPrecision=&
outSR=&
returnIdsOnly=false&
returnCountOnly=false&
orderByFields=&
groupByFieldsForStatistics=&
outStatistics=&
returnZ=false&
returnM=false&
gdbVersion=&
returnDistinctValues=false&
returnTrueCurves=false&
resultOffset=&
resultRecordCount=&
f=pjson
This returns a JSON object with the attributes I need!
{ "displayFieldName": "DisplayField", "fieldAliases": { "yourTargetField": "yourTargetField" }, "fields": [ { "name": "yourTargetField", "type": "esriFieldTypeString", "alias": "yourTargetField", "length": 6 } ], "features": [ { "attributes": { "yourTargetField": "FOO123" } }, { "attributes": { "yourTargetField": "BAR321" } }, { "attributes": { "yourTargetField": "BIZ789" } }, { "attributes": { "yourTargetField": "BAT987" } } ] }