Posts tagged Neogeography

Selected Saturday links

It’s always a little embarassing to realise that two or more consecutive blog postings are nothing more than a collection of links, but that’s the way it is at the moment. Busy-ness, illness and distractedness have all kept me from the blog this week. There aren’t any clear themes in this week’s links either. Chatter around OAuth has continued apace, as have musings about fuzziness, location, time, and the web (represented well by Matt Jones’ piece), but mostly this is the (to be) usual random assortment that have spent more than a few seconds open in my newsreader or web browser

New home for Rails ‘geo plugin comparison’

About eighteen months ago I compiled a series of reviews of Ruby on Rails plugins concerned with geography. I put together a comparison chart and posted it on this blog. It subsequently found a new home on a wiki, but lately that wiki has rarely been accessible so I decided it was time to move it all back into this site.

You can now find the comparison chart at: http://jystewart.net/process/resources/rails-geo-plugins/

A few updates have been lost along the way as they were solely made on the wiki, but hopefully it’s still of use. Since I published the original reviews and chart my attention has wandered a little from the geo plugin scene, so please do flag up any new plugins, changes in features or fixes that I may have missed. I’m going to be trying to check through all the existing listings to update them but that may take a while, so comments here may well encourage me to focus more quickly.

Rails Geo Plugins: GeoX

GeoX is the latest kid on the Ruby on Rails geocoding block. The plugin was announced a couple of weeks ago and I’ve been meaning to explore it ever since, just in case it had any new features and also so that I can add it to my comparison chart.

The feature set of GeoX is fairly straightforward. It supports a number of geocoding back ends: obviously google and yahoo are covered, but also mapquest’s relatively recent API. The standard lookup process is much like that provided by several other plugins—the sample given is:

require 'geox'
 
# uses the google engine
geocoder = GeoX::Geocoder.new(:geoengine => GeoX::Google) 
location = {:address => '701 Ocean St', :post_code => '95060'}
geocode = geocoder.geocode(location)
 
# geocode will be a hash containing the geocode data returned from the server
puts geocode.inspect

What is most notably lacking is any ActiveRecord integration such as that offered by acts_as_locateable or acts_as_geocodable. That is apparently by design as the intention is for the library to be usable outside rails but the plugin relies on the rails-specific blank? method and personally I prefer the graticule/acts_as_geocodable split where functionality equivalent to that of GeoX is bundled in the graticule gem and then ActiveRecord hooks are provided by the plugin. It is definitely nice to have geocoding handled manually when models are added or updated, but more than that it is very useful to have support provided for searching based on location.

Probably the most intriguing aspect of the plugin is the facility to compare the specificity of two different sets of coordinates. That’s achieved by returning an object type appropriate to the specificity. So if you have street-level data, the object returned is an instance of GeoX::Street. Operator overloading allow you to compare the objects:

puts "Street wins!" if GeoX::Street.new < GeoX::Block.new

The README file suggests putting the API keys in the file lib/geox_api_keys.rb within the plugin. That’s probably not the best of ideas, but it would be easy enough to rework it so that the configuration is done in the usual rails way and the plugin can be included with svn:externals or piston.

I can’t see myself switching to GeoX from the options I currently use and it’s a shame that its distinctive features weren’t submitted as patches to existing projects rather than adding yet another plugin to the increasingly crowded scene, but it’ll be interesting to see how it evolves over the coming months.

Comparing rails geo-plugins

There seems to be quite a plethora of Ruby/Rails libraries appearing aiming to simplify handling geography and distances. In some cases these libraries do quite distinct things (zip codes vs. longitude/latitude, map output vs. distance calculations) but they’re frequently lumped together and it’s difficult to tell which will be best to use in your projects.

I’ve used several of these projects and have previously blogged about YM4R and acts_as_locateable, but I’m still not sure which I’d pick for new projects. So I thought it would be helpful to try to put together a comparison of which libraries offer what functionality. Here I’ll just offer a quick chart, but I’m hoping to write them up in a bit more detail over the coming days/weeks. If there’s sufficient interest, I’d consider moving this out to a wiki for more general use.

Rails Geo Plugins
  Auto-geocoding ActiveRecord models Multi-provider geo-coding Distance based finds Distance based :through finds Google map output Yahoo map output
GeoKit

(plugin index)
Y Y Y N N N

acts_as_geocodable


(
plugin index
)
Y Y* Y N N N

acts_as_geocode


(plugin index)
Website currently down

actsaslocateable


(plugin index)
N N Y Y N N

YM4R


(plugin index)
N N N N Y Y

(* through companion gem)

Also worth mentioning are SpatialAdapter and GeoRuby (from the same developer as YM4R) which respectively provide ActiveRecord support for MySql Spatial and PostGIS geometric columns, and ruby data types for that information.

A recent addition is this Ruby library for the Geonames API which provides a nice way to interface with the GeoNames database of 2.2 million populated places. Properly harnessed, that service begins to make it possible to allow your users to describe their location in natural language and convert that into machine-parseable co-ordinates.

Update (8th March): Updated versions of this comparison will now appear on the foss4r wiki

Update (October 2008): The chart now lives on a separate page within this site.