Geocode help

Update: I’m now using Yahoo PlaceFinder service to generate map coordinates from addresses. The Cyclelicious Bike Route Map seems to be almost usable now!


I’ve whipped up a bike route application using MapQuest’s bicycle routing API. MapQuest uses their directions routing algorithm and applies it to street and bike facility data available from the Open Street Map database. The generated route is available to web application developers through MapQuest’s Open Platform Web Services.

bike-directions

MapQuest’s Open Directions web service takes numeric latitude and longitude map coordinates as input for the start and destination of a trip. Most of us know our geographic locations as place names — something like “123 Main Street, Anytown, USA” or “Main Street and 2nd Avenue.” The process of converting these place names to numeric coordinates is called “geocoding.”

For this proof-of-concept, I’m using MapQuest’s Nominatim Search Service. Nominatim uses Open Street Map to convert place names to lat/lon combinations, but it doesn’t work for street addresses or zip codes. Only vague place names work with Nominatim, and even state names confound the search. I can get directions for Longmont to Niwot for example, but if I put “Colorado” in either place name, the place name search fails.

Two good Geocoding alternatives I know about are MapQuest Geocoding Web Service and Google Geocoding API. I’m not an experienced map application developer (this bike routing app that I wrote up over this Thanksgiving holiday is my very first one ever), so I’m interested in knowing from those with a little more experience what works well.

Here are pros and cons I see with Google’s geocode API:

  • It’s super simple to use and works well, but…
  • There’s no JSONP support. This means I’m required jump out of Javascript and write some server side PHP code to handle the geocoding response.
  • Google TOS says I must use this in conjunction with Google map images. Right now my default is showing OSM map images. That’s kind of okay with me to show Google’s map, except Google doesn’t have bicycle facility layers outside of the United States and a few Canadian cities, and even in the USA Google’s bike facility data is limited.
  • Google has a limit of 2,500 geolocation queries per day; since each route lookup involves two lookups, that’s effectively under 1300 route queries per day. This seems low to me.

MapQuest’s Geocoding service pros and cons:

  • MapQuest is migrating toward using OSM tiles for their maps, and there’s no restriction on the map tiles I’m allowed to show. I think MapQuest’s TOS is the least restrictive I’ve seen in a long time.
  • For addresses outside the United States, it appears I need to explicitly set a country code in the geocode request. This means some kind of web user geolocation, which I’d rather not get into right now.
  • MapQuest implements access control for cross domain scripting; I’ve never done this before so it’s something else I have to learn to make to make it work. (at least, I think that’s the problem I’m having, though I could be wrong).

I haven’t looked in detail at Yahoo’s PlaceFinder,but it seems to have a similar “You must use your map images” that Google has. Yahoo has a generous 50,000 queries per day limit, which is nice.

If you’re a somewhat experienced map web developer, what geocoding service do you recommend?

(Hat tip to Trailsnet and Recumbent Blog for letting me know about the MapQuest bicycle API. I see now that Commute By Bike also reported on this with some detail.)

6 Comments

  1. I use both Google and Yahoo! geocoding APIs. This is mainly because Yahoo! had a public API for geocoding before Google did. I made my first web application in 2004.

    I switched to Google for some applications because they offer an extremely simple API that can return results as CSV, which uses even less code than XML or JSON (I think).

    I wasn’t aware that either of them required you to use their map tiles.

    I’d stick with Yahoo! because of their higher limit.

  2. Thanks Steve. I think I’m coming to the same conclusion.

    It doesn’t appear Yahoo works (easily) w/ JSONP — I’m running into the same cross-domain access control issues I’m having w/ MapQuest. Do you know otherwise? I’m not a Javascript pro by any means so a bug in my code is highly likely.

    Regardless, I think I’ll just bite the bullet and process XML through PHP.

    Thanks again.

  3. Hey. Reading over your post, I wasn’t sure if you were aware that the geocoding limits for Google are per IP address. If you use client-side geocoding, each user has that limit, unless they’re sharing IP addresses.

    There’s more info in this article: http://code.google.com/apis/maps/articles/geocodestrat.html

    That does require using the Google Maps API and geocoding directly that way, instead of doing server side work. And you’re correct about the TOS limitations requiring that your geocodes be used on a Google Map (which includes, BTW, Google Earth). Just to point out, though, our TOS does allow you to cache your geocoding results.

    I also wasn’t sure if you saw our directions API, both JavaScript:
    http://code.google.com/apis/maps/documentation/javascript/services.html#Directions
    And web service:
    http://code.google.com/apis/maps/documentation/directions/

    Each has a separate IP based quota of 2,500. You don’t have to pre-geocode each end of your request on either end, so you get the full 2,500.

    I hope that’s helpful.

  4. It seems like OSM can indicate bicycle-only and bicycle-restricted (freeways) but is there anyway to designate routes as bicycle-friendly?

  5. Thanks so much for clarifying that, @ManoMarks, and re-reading the geocode info I see that now: “Client-side geocoding through the browser is rate limited per map session, so the geocoding is distributed across all your users and scales with your userbase.

  6. @stuart: I’m trying to figure this out as well. There doesn’t seem to be a good standard way to designate “bike friendliness” of a road. I know MapQuest makes use of maxspeed and lane width parameters to guess “bike friendliness”; setting those is discussed here. There are also tags for Local Cycling Networks (things like bike boulevards and preferred bike routes) but I don’t know what MapQuest specifically looks for. Testing this for Palo Alto, MapQuest ignores Bryant Avenue although it has a Local Cycling Network tag with the label “Ellen Fletcher Bicycle Boulevard.”

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.