Announcing Graticule geocoding API

geocoding | graticule | ruby October 31 2006

update: Graticule is now hosted on Rubyforge.

Graticule is a geocoding API for interpolating address data into geographic coordinates written in Ruby. The goal is to provide a consistent interface into the various geocoding services, allowing other libraries to be built on top of them while remaining agnostic of the specific service that is being used.

In its current state, Graticule is just a repackaging of the different gems produced by Eric Hodel of Robot Co-op. It currently supports the Yahoo, Google, Geocoder.us, and MetaCarta APIs. The plan is to expand upon them.

Usage

You can grab the gem or check out the code from Subversion. The Rdoc is also available.

require 'rubygems'
require 'graticule'
geocoder = Graticule.service(:google).new "api_key"
location = geocoder.locate "1600 Amphitheatre Parkway, Mountain View, CA"

Feedback

I’d love to get your feedback. There are a few places where the API is still not consistent (e.g. Yahoo returns multiple results). I’d also appreciate any help with packaging and releasing as I am a newbie at creating Gems.

posted by brandon | updated June 19th 07:29 PM
comments feed

1 comment

  1. First of all, Thanks for this great plugin! in cleans up a lot of my code! I found a small bug in the way geocoder.locate works. It calls Graticule::Location.to_s to get the formatted string to send to the geocoding service (I only tested the google service). The problem is that the to_s method insert a \n into the string, which makes the google geocoder hiccup with certain geocoding queries and give you geodata (my example was :street => ‘Kampstraße 4’ , :zipcode => ‘20357’, :locality => ‘Hamburg’, :country => ‘DE’). Changeing the to_s method to the following solves the problem:
    module Graticule
    class Location
      def to_s(options = {})
        options = {:coordinates => false, :country => true}.merge(options)
        result = "" 
        result << "#{street}," if street
        result << [locality, [region, postal_code].compact.join(" ")].compact.join(", ")
        result << " #{country}" if options[:country] && country
        result << "\nlatitude: #{latitude}, longitude: #{longitude}" if options[:coordinates] && [latitude, longitude].any?
        result
      end
    end
    end
    
    Kind regards, Andy Nahapetian link: nahapetian.com
    Andy Nahapetian Andy Nahapetian
    June 22, 2007 at 11:15 AM

Speak your mind:

(Required)

(Required)


(You may use textile in your comments.)

About

I'm Brandon Keepers, a web application developer that likes beautiful code, valid markup and adherence to standards. As a part of Collective Idea in Holland, Michigan, I practice Agile software development primarily using Ruby on Rails.

-86.103171 42.785037

Contact:

more »

Syndicate