ArcDeveloper ArcGIS Server REST API is Breathing!
Wed, Mar 5, 2008
4-minute read
- You can query single features by id (must be OBJECTID, ugh)
- You can query features with a where clause
- You can query features with a bbox (AND a where clause, if you want)
What You'll Need
Visual Studio 2008, implying .NET 3.5. You will have to build the solution, as we haven't made an official release yet. Optionally, I would have Fiddler, Firebug, and JSONViewer.Step 1: Get the source
Using TortoiseSVN (or the svn client of your choosing), perform a checkout of the trunk (http://svn2.assembla.com/svn/arcdeveloper/ArcDeveloper.REST/trunk/)Step 2: Open the solution
In the "Product" directory, you'll find the VS2008 solution file. Like, open it or something. It consists of 5 projects, 2 of which are test projects. The other projects are the core interfaces and services, with the last one being a web project to show how to publish the REST service with WCF and a demo web page.Step 3: Build the solution
Uh, in VS2008, select "Build Solution..."Step 4: Use Dave's Stuff
So Dave Bouwman, who I think is just the cat's pajamas, has the demo site using an ArcGIS Server map service that he has been generous enough to provide. If you look in the ArcDeveloper.REST.Web project, you'll find a config directory. Opening up the components.config file will show where the endpoint of the map services is specified. Looks alot like:<component id="ags.service" lifestyle="pooled" initialPoolSize="2" maxPoolSize="2"
service="ArcDeveloper.REST.Core.Interfaces.IRESTService, ArcDeveloper.REST.Core"
type="ArcDeveloper.REST.ArcGIS.AGSMapService, ArcDeveloper.REST.ArcGIS">
<parameters>
<name>TestService</name>
<description>Base map</description>
<connectionString>http://65.101.234.201/arcgis/services/gains/gains/MapServer</connectionString>
</parameters>
</component>
http://localhost:xxxx/rest.svc/TestService/Flyways/10?g=trueLet's break down the URI, shall we? Starting with rest.svc, that is the WCF endpoint for the REST service. "TestService" points to our configuration (from above) file and tells the service which map we want to use. "Flyways" is the name of a layer in Dave's service. "10" is the id of the feature we want, and "g=true" tells the service to return the geometry (there are cases where you don't want that, b/c it can make the size of the response baloon pretty quickly.) So, that is pretty RESTy, yes? The response from that HTTP GET looks like:
{ "type": "Feature","geometry": {"type": "Polygon", "coordinates": [ [ [ 44.3231, 14.2555], [43.2827,13.6294],[ 43.285, 13.6503], (...lots more coords...) ] }, "properties": { "Ssp": "maculosus", "Species": "Burhinus capensis", "Shape_Length": "4.59630121045653", "TSN": "0", "extent": "42.9447173339071,13.6294196034485,44.3230947030963,15.0950604545328", "SpeciesCod": "BURCA", "WISDOM_SpeciesID": "557", "OBJECTID": "10", "Code": " ", "Shape.area": "1.28930099595786" } }