This sample illustrates how to develop a REST server object extension (SOE) with a spatial query operation. The spatial query operation returns all the features of a map service layer that fall within the user-defined search distance of a location point. The location point and the search distance are the input parameters of the REST operation, which generate a search buffered area. This SOE will return the features that are within the buffered area and also a summary of the total areas by those features' vegetation types. At last, a JavaScript client application is provided with this sample to demonstrate how to consume this SOE's spatial query operation.
Features
- Spatial Query
- Conversion.ToGeometry()
- ISpatialFilter
- ITopologicalOperator
- Default SOE properties
Sample data
This sample uses the Vegetation map service as the sample service to test with the SOE.
Instructions
Deploy the SOE
- Log in to ArcGIS Server Manager and click the Site tab.
- Click Extensions.
- Click Add Extension.
- Click Choose File and choose the SpatialQueryREST_ent.soe file (
..\bin\Release\SpatialQueryREST_ent.soe
or..\bin\Debug\SpatialQueryREST_ent.soe
). - Click Add.
Enable the SOE on a map service
-
Make sure you have published the Vegetation map service using ArcGIS Pro. If not, refer to Vegetation map service.
-
Log in to ArcGIS Server Manager and click the Services tab. Select the Vegetation map service and select Capabilities.
-
In the list of available capabilities, find .Net Spatial Query REST SOE and check the box to enable it.
-
Keep the SOE selected to check the SOE's properties. Leave them as their default values.
-
Click the Save and Restart button to restart the service.
Test the SOE in the ArcGIS Server Services Directory
-
Open a browser and navigate to the REST services endpoint of the Vegetation map service (URL:
http://<serverdomain>/<webadaptorname>/rest/services/Veg/MapServer
). -
Scroll to the bottom of the above page. Click SpatialQueryREST in Supported Extensions.
-
Click SpatialQuery at Supported Operations, which leads to the following URL:
http://<serverdomain>/<webadaptorname>/rest/services/Veg/MapServer/exts/SpatialQueryREST/SpatialQuery
-
In location box, paste the following text:
{"x":548866.0975094471, "y":4920138.946296035, "spatialReference":26712}
-
In distance box, paste the following test:
5000
-
Click the SpatialQuery(Get) button. You should be able to see a valid result:
Test the SOE in a JavaScript REST application
-
Open the SpatialQueryClient.html file in an editor.
-
Modify soeURL at Ln 51 and serviceURL at Ln 52 to reflect your own service.
-
Save the code and deploy this JavaScript application.
-
Open this application on a browser and click on the map.
-
You should be able to see the clipped features on the map and a summary table showing the vegetation type and total area as the following: