direct geocoding places: turn a place name into latitude longitude values

i recently found the need to grab the latitude,longitude values for some unique place names.  i didn't find anything from the major services:

  • google places is closed right now, so have to join a waiting list
  • foursquare api, google maps api, and simplegeo api all require a starting latitude and longitude

the easy hack to the starting point is to choose an arbitrary starting point and set a large radius.  the problem is that all of the services i tried have an implicit restriction on how high you can set the radius.  none of them will let you run a search for "stanford university" starting in kansas and looking at a 1,500 mile radius (1,500 is slightly over half the total diameter of the united states, starting from the "geographical center of the united states" which is in lebanon, kansas).

so i ended up finding a solution with geokit, which was my last guess because it hasn't seen an update in over a year from its github repo.



of course, if you are using this in a large script and need to check whether it worked or not:

note: if you're hosting your rails app on heroku, your lat, long columns must be type decimal.  mysql will allow lat,long colums as strings, postresql requires a decimal.  mysql is also not case-sensitive on record searches, while postgresql is.  these were kind of annoying when testing in production.