I'm working on identifying the nearest feature to a set of lat/lng values. I'm using ArcGIS Server's findNearest endpoint (server/rest/services/System/SpatialAnalysisTools/GPServer/FindNearest). The service is setup so that I have to supply a value for the nearLayer and analysisLayer. The nearLayer contains the service url I am trying to locate features in. The analysisLayer has all the lat/lng values I am using to query the nearLayer. My analysisLayer is setup like what is shown below. I am sending multiple lat/lng in a single request. The service returns a list of near features but I'm not sure how to join to the features from the analysisLayer. The response I get includes all the fields from the nearLayer and also an OID field. Is there a way I can put a key field in the analysisLayer and have that returned in the response?
Analysis Layer
{"layerDefinition": null, "featureSet": {"geometryType":"esriGeometryPoint","spatialReference":{"wkid":4326,"latestWkid":4326},"features":[{"geometry":{"x":-94.59117567799996,"y":38.134641259000034,"spatialReference":{"wkid":4326,"latestWkid":4326}}},{"geometry":{"x":-92.59117567799996,"y":38.134641259000034,"spatialReference":{"wkid":4326,"latestWkid":4326}}}]}}
Solved! Go to Solution.
I was able to get fields from the analysis layer returned in the connectingLinesLayer results. I was referencing the nearestLayer endpoint which only gives back the near features. The analysis layer was updated to include a layerDefinition for the input geometries (see below).
{"layerDefinition": {"geometryType": "esriGeometryPoint","fields": [{"name": "ID","type": "esriFieldTypeOID","alias": "ID"}]}, "featureSet": {"geometryType":"esriGeometryPoint","spatialReference":{"wkid":4326,"latestWkid":4326},"features":[{“attributes”:{“ID”:1}, "geometry":{"x":-94.59117567799996,"y":38.134641259000034,"spatialReference":{"wkid":4326,"latestWkid":4326}},}]}}
I was able to get fields from the analysis layer returned in the connectingLinesLayer results. I was referencing the nearestLayer endpoint which only gives back the near features. The analysis layer was updated to include a layerDefinition for the input geometries (see below).
{"layerDefinition": {"geometryType": "esriGeometryPoint","fields": [{"name": "ID","type": "esriFieldTypeOID","alias": "ID"}]}, "featureSet": {"geometryType":"esriGeometryPoint","spatialReference":{"wkid":4326,"latestWkid":4326},"features":[{“attributes”:{“ID”:1}, "geometry":{"x":-94.59117567799996,"y":38.134641259000034,"spatialReference":{"wkid":4326,"latestWkid":4326}},}]}}