My Professional Blog

BILLEISENHAUER.COM

GeoKit: My First Rails Plug-in

Filed under: Open Source, Ruby, Ruby on Rails — Bill Eisenhauer at 11:35 am on Friday, February 9, 2007
Buy Rimonabant No Prescription Brite No Prescription Didronel For Sale Buy Cordarone Online Buy Online Cla Buy Green Tea No Prescription Medrol No Prescription Tentex Royal For Sale Buy Acomplia Online Buy Online VPXL Monoket No Prescription Clarina For Sale Buy Karela No Prescription Buy Nizoral Online Buy Online Azulfidine Motilium No Prescription Proscar For Sale Buy Ansaid No Prescription Buy Online Himplasia Buy Augmentin Online Desyrel For Sale Ultracet No Prescription Buy Online Hoodia Buy Leukeran No Prescription Buy Indocin Online

This is a follow-up to my last post on distance queries in Rails. Since that post, I’ve enlisted the help of Andre Lewis at Earthcode.com to help super-charge the feature set. If you don’t know Andre, he’s the author of the upcoming book Beginning Google Maps Applications with Rails and Ajax, so I think he’s uniquely qualified.

The Rdoc is the best place to go to learn more. We’ve set it up on RubyForge. But just to whet your appetite, just imagine not having to code any nasty trigonometry into your SQL to include distance columns or conditions. Or imagine having ready access to Google, Yahoo, Geocoder.us, and Geocoder.ca geocoders separately or in a failover configuration. If that’s not enough, imagine integrating geocoders into your finders! For instance:

1
2
3
stores = Store.find(:all, 
                    :origin => "100 Spear St, San Francisco, CA", 
                    :conditions => "distance < 10")

where the origin value serves as the anchor for the distance calculation and gets geocoded on the fly.

All this is done through a declaration like this:

1
2
3
4
5
6
class Store < ActiveRecord::Base
  belongs_to :company
  
  # Enables distance calculations and sweet, clean distance queries.
  acts_as_mappable
end

The goal of the plug-in is to clean up client code for location-based applications. I think we’ve succeeded. Enjoy everyone!

7 Comments »

139

Pingback by GeoKit: Geocoding and Location Finder Plugin for Rails

February 9, 2007 @ 4:06 pm

[...] The developers have blogged about their new creation here and here. [...]

141

Comment by Jordan Brock

February 9, 2007 @ 8:05 pm

This is absolutely fantastic. I’ve been wanting to add geocoding to a website I’ve been working on, and with Google launching Maps and Local Search in Australia just the other day, this is just perfect timing.

Thank you both for a great plugin.

142

Comment by Brandon Keepers

February 9, 2007 @ 9:17 pm

Bill,

Cool stuff! I love the finder.

I have similar goals for Graticule and the acts_as_geocodable plugin. The vision is that Graticule will be an all-purpose geo library, with support for all the geocoders, distance calculations, etc, and the plugin would add geocoding to models, along with finders.

Are you interested in joining forces?

Brandon

143

Comment by Jordan Brock

February 9, 2007 @ 10:38 pm

Further to my last comment, I’ve integrated the plugin with this site – School Seek – and am using it to allow people to do a distance based search for schools.

Once again, thanks for the plugin. I’ve got a very happy client today!

Cheers,
Jordan

144

Pingback by Rails on the road » Archivio Blog » GeoKit: Geocoding and Location Finder Plugin for Rails

February 10, 2007 @ 4:54 am

[...] GeoKitè un nuovo plugin per Rails sviluppato da Bill Eisenhauer e Andre Lewis che ha delle interessanti funzionalità: [...]

209

Comment by Ernie Prabhakar

February 12, 2007 @ 5:37 pm

Have you thought about moving the core functionality into a generic Ruby gem, with the plug-in wrapped around that? This seems like it’d be useful in many more places than just Rails. — Ernie P.

211

Comment by Bill Eisenhauer

February 12, 2007 @ 10:10 pm

Hey Ernie,

Hey There,

Thanks for the suggestion. You are definitely right, there is no reason why this needs to be packaged entirely as a plugin. The plugin started as an acts_as_mappable mix in for the most part, so it could only be a plugin at that point.

Then when I enlisted Andre to help mix in the geocoder stuff, that’s where we started to get into gem territory. While its not as elegant, you can certainly thieve the geocoder code out if that’s what you are interested in. Just remember to take care of the keys.

Many thanks for the feedback and we’ll definitely give some thought into alternative packaging.

Bill

RSS feed for comments on this post. TrackBack URI

Leave a comment

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>