This week (and by this week, I mean two weeks ago), was my first foray into the wonderful world of GIS. My initial task was to prototype a read-only data store that gets its data via a RESTful interface. Specifically, I set out to write a GeoTools data store called RESTfulDatastore that gets its data from FeatureServer.org.
I spent a lot of my initial time just trying to get up to speed and figure out what’s what in the world of GIS. Needless to say, there’s a lot to learn, and I was fabulously lost at the onset. However, thanks to lots of online documentation (and, of course, Wikipedia), I was able to get a grasp on the basics. I was also fortunate to have the help of Jody Garnett’s DataStore tutorial. Jody’s PropertyDataStore example formed the basis of RESTfulDatastore and provided a helpful framework in which I could organize my understanding of how of a data store works.
I must say, however, that this entire process was not without some frustration. On the plus side, there’s a lot of documentation both for GeoServer and GeoTools, and much of it was ultimately indispensable to me. Unfortunately, a lot of the documentation is out of date. I found myself frequently starting to code things based on examples in the docs only to find that the method I was using was deprecated; sometimes I found updated versions of the docs that explained how things should be done now, but other times I didn’t.
After getting a very rough prototype of the data store working (see ticket here, and beware, when I say rough, I mean rough), I switched my focus to writing a separate class to parse GeoJSON objects, inventively named GeoJSONParser.
(A quick aside about GeoJSON: Having read some cryptic, convoluted and incomplete specs in the past, the GeoJSON spec is breath of fresh air. It’s clear, concise, and very well written. Even though it’s a simple spec to document, it’s still impressive. You should check it out.)
GeoJSONParser is essentially a complementary class to GeoJSONBuilder: Where GeoJSONBuilder takes Geometry objects and writes out strings of GeoJSON objects, GeoJSONParser does the opposite, taking JSON strings (or json-lib’s JSONObjects) and generating Java objects. Writing GeoJSONParser went much more smoothly than hacking around with the data store, mostly because I had a much better feel for what was going on having been doing geo work for several days already. A preliminary version of GeoJSONParser (along with GeoJSONBuilder) is attached to this ticket.
Lessons learned: GIS has a lot of acronyms, Java isn’t so bad, good documentation is indispensable.
