Googlemaps Geocoding API
We recently completed a geocoding-caching system that geocodes (determines Latitude and Logitude) a user’s location input. This means that the user can type in a zip code, city/state or complete address/city/state/zip and the system will determine a Longitude and Latitude of the centerpoint of the area requested. In this case the result will be used to place a location on a google map. The process I developed performs initial location lookups using the google map geocode API and employs a good/bad caching system that retains the lookups locally.
The Google Maps Geocoder
is fast, free and allows up to 50,000 queries a day. Only a year or two ago this kind of web service was expensive, in my experience it cost $10,000-30,000 or more (as part of a mapping package) from products like microsoft mappoint.
A nice benefit of the google map geocoder is that it uses a single field value for the input query string. This means no cumbersome address, city, state and zip fields. Instead, I only need to provide one field for the user to type out their query. The Google Geocoder comes back with all of the data broken out so that I can store the address, city, state, zip, etc in the caching database. So given unstructured input from the user the system ends up with a standardized stored structure.
For this application I utilize a system of good/bad caching in front of the google map geocoding API call. It uses a mysql database to build tables of queries that it determines to be good and bad. So if someone enter in ‘XYZ’ this fails the google geocoder and is then stored in the bad cache table. When a new request comes in for ‘XYZ’ the value is found in the bad cache table and the system can determine a local result without proceeding to a (more costly) remote lookup. The Good cache works the same way except that the data returned from google is stored in the table as well as the initial user input.
This system seems to work well, is fast and free. The caching system is designed to grow stale after a period of time so that any value will be rechecked again later. I cannot imagine anysituation where this system would ever come close to 50,000 geocoding calls to google.
A fringe benefit of the caching is that we can track the number of geocoding requests for each location. We also utilize the location data throughout the application, attaching it to properties as well as users.