Hi, here is an ActiveRecord based solution http://gist.github.com/338506 It
is based on Peter Song's solution. It also populates most of the 50 cities
found at http://www.infoplease.com/ipa/A0108477.html


Here is the same thing, but using the geocoder gem that Shandy asked about
http://gist.github.com/338523
I also added some use cases for it that work with the data it populates into
the db, such as
dallas.distance_to austin
texas_cities = City.find_all_by_state('TX').map { |city| city.lat_lon }
Geocoder.geographic_center texas_cities
near_sacramento = City.find_by_name('Sacramento').nearbys(100)

You can see the gem homepage at http://github.com/alexreisner/geocoder
Wasn't very straightforward how to use this outside of Rails, but I
eventually got it. (had to do a little code digging to understand the errors
and query some mailing lists to find solutions)
$ gem install rails-geocoder

Then get a google api key at http://code.google.com/apis/maps/signup.html
The license says your application must be available to the public, free or
charge, otherwise you should be using
http://www.google.com/enterprise/earthmaps/maps.html
They want you to list a site your app will be available through. I gave them
the URL of the gist the example is hosted at :)~

Anyway, a very simple program that correctly uses the gem to get results:
require 'net/http'
require 'rubygems'
require 'active_record'
require 'geocoder'

Geocoder::GOOGLE_MAPS_API_KEY = 'your key goes here'
p Geocoder.fetch_coordinates("Wichita,KS,US")