ArcDeveloper ArcGIS Server REST API is Breathing!
- 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 NeedVisual 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 sourceUsing 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 solutionIn 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 solutionUh, in VS2008, select "Build Solution..."
Step 4: Use Dave's StuffSo 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"
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: Which is valid GeoJson. Neat, eh? I know what you are saying. "Glenn, why would I use this when ArcGIS Server 9.3 will have a REST API?? HMMM?" Well, that is a great question. The only answer I have is that you can use this now, contribute to it, and make the world a better place. Also, you can learn about a lot of stuff, like REST, WCF, GeoJSON, AJAX, the Castle Project stuff, and much, much more. Plus, there are some real brains on this project (I am not one of them) so you can sop up their wisdom as well. Also, I heard a nasty rumor that the AGS REST API wasn't using GeoJSON, but a proprietary spatial JSON format, which is a bit disconcerting, if not totally expected. In future posts I'll break down the ArcDeveloper REST API architecture, showing how you can write your own providers and formatters. We still have a TON of work to do on it, but we're on our way.