Rails and geo plugins

After looking into Cartographer and YM4R I started searching for other geo tools for Ruby.

I found several and started creating a list. My idea was to make a comparison between the features of the different plugins. But I soon found out James Stewart did this already in his Comparing rails geo-plugins post. He moved the information to a wiki, on which the most recent information about the different Geo plugins can be found. On this page you’ll also find some great reviews of the different plugins.

I started looking into GeoKit, acts_as_geocodable and actsaslocateable. The last one isn’t suitable for my application, because it can only deal with US addresses. That’s also true for some of the geocoding services the other two support. The only one1 with support for Dutch addresses is the Google geocoding service, so sadly no fall back mechanism for Dutch addresses when one geocoding service isn’t available.

There are a few differences between the remaining two plugins.

acts_as_geocodable makes use of a gem called Graticule. This gem takes care of the actual geocoding, communicating with external services, etc. The acts_as_geocodable plugin takes care of the Rails specific stuff (extra find methods, etc).

GeoKit has all the functionality in the plugin, but Bill Eisenhauer, one of the authors, said “there’s no reason why this needs to be packaged entirely as a plugin”. So maybe this will change one day.

Another important difference is the way the two plugins store the geocoded information. GeoKit can handle existing models with longitude and latitude columns. You can specify the names of the columns with the column_name parameters (the defaults are ‘lat’ and ‘lng’).

The acts_as_geocodable plugin creates two new tables. The first is called geocodes and stores the longitude and latitude for a given address. The second table links the geocodes into your model in a polymorphic way.

Both plugins als have a feature the other plugin doesn’t have (as far as I can tell).

acts_as_geocodable can update the address fields with the data returned from the geocoding service, just add acts_as_geocodable :normalize_address => true to your model.

GeoKit has the ability to look up a location based on the user’s IP-address.

Which of the two is better? I don’t know. They almost have the same feature set, GeoKit does IP-based location lookups, while acts_as_geocodable separates its functionality between the plugin and the gem and has the ability to normalise addresses.

I think it’s a matter of taste, which one to choose. Or is there any difference in performance? I guess I have to test this.

For now, I think I’ll start with GeoKit for my application. I really like the ability to keep my own models with the longitudes and latitudes.

1 Maybe someday I’ll write a post about addresses and zip codes in The Netherlands and why the aren’t available for free.

Book: “Beginning Google Maps Applications with Rails and Ajax”

Previous post I mentioned a new book about Google Maps and Rails: Beginning Google Maps Applications with Rails and Ajax.

I haven’t read the book, but I’ve download chapter 7 and I think it’s an awesome book. A recommendation for everybody who’s building Google Maps Mashups with Rails.

You can even get it for free. There’s a contest where you can win a copy of the book, they are giving away 3 free copies. They call it a ‘contest’, but all you have to do is leave your name and email address. You have to hurry, because they’ll randomly draw three entries on March 15th, 2007 (deadline is midnight March 14th EDT).

If you haven’t won a copy on the 15th, you could always order a hard-copy (also available as an ebook)

All the examples of the book can be viewed online and the sourcecode can be downloaded.

Google Maps and Ruby on Rails

For a new project I’m working on, I will make extensive use of Google Maps. At this moment I’m doing some research to find out what the best practices are to use Google Maps in Rails applications. I also want to find out what tools there are.

The first projects I ran into are the tools which simplify the creation of a map: Cartographer and YM4R. These two projects give the user a Ruby based approach for building maps. According to Andre Lewis in his Google Talk about Ruby and Google Maps you’ll run into the limitations of these projects very soon if you’re building complex applications. Andre is one of the writers of the new book about Google Maps and Rails, called “Beginning Google Maps Applications with Rails and Ajax: From Novice to Professional”.

These tools can be very useful if you want to build a Google Maps application fast or if you don’t want to make your hands dirty on the Javascript (or maybe you just don’t have the knowledge).

The application I’m building will be rather complex and I don’t mind programming in Javascript. So I’m not going to make use of this kind of tools. The next category of tools you can use in building maps, are the geocoding tools. These will be the subject of a future post.

B.t.w. It looks like the cartographer project is dead, so if you want to use this way of building maps, there’s only one solution left, YM4R.

About this blog (1): Custom Made

In my first post I promised to write some more about this blog and how I created it. I’m going to write a few posts about this subject, so let’s start with the first one: Why I use custom made blogging software.

Before creating my own blogging software I looked at a lot of out-of-the-box products or blogging platforms (why reinventing the wheel?).

Because I’m on a journey from Java development to Ruby on Rails development I specially looked at the Rails based blogging software, like Typo, Mephisto and SimpleLog. There are a few reasons why I decided to build my own blog from scratch:

  1. I wanted a simple blogging app. Not one with which I could maintain my complete website. Just use it for the weblog and integrate it into the website (which is also a Ruby on Rails app). This must be possible with the three programs I looked into, but all the tutorials and howto’s I found were based on building a standalone weblog.
  2. For another project I’m working on I needed the possibility to create a lot of (small) weblogs. In Mephisto it’s possible to create multiple pages which behave like a weblog, but I needed a weblog which is related to a user.
  3. I’m not that experienced with Ruby on Rails and building your own blogging app seems to be a good start 😉

Next time I’ll tell some more about the status of the software and what still needs to be done.