Friday, January 18, 2013

Playing with Geocoding APIs...

I decided to mess around with some geocoding APIs.  I didn't really care which API I used, but I wanted it to be free and preferably a REST API.  The REST API "want" is based on the idea that the code for processing the results would be similar for all the REST based geocoding services.

I used both the Yahoo Geocoding API (http://developer.yahoo.com/maps/rest/V1/geocode.html) and the Google Geocoding API (https://developers.google.com/maps/documentation/geocoding/).  

The Yahoo Geocoding API is free and allows up to 10000 requests per day.  The downside is that the API is deprecated, and it looks like they want to use a pay for use service.  In other words, it works right now, but who knows how long?

The Google Geocoding API is free and allows up to 2500 requests per day.  If you exceed the 2500 requests per day, then Google says they may block your usage for a while.  If you continue to exceed the 2500 requests per day, then they will block you indefinitely.  There is a response value for the Google Geocoding API that will let you know you have exceeded your query limit.

I wrote an app that implements both the Yahoo and Google geocoding APIs.  It will either take in a single address/place of interest, or read in addresses from an input file.  The input file is expected to have one address or place of interest per line.

For fun I decided to create a utility class that will take an array of Coordinates (a class that holds the latitude, longitude, and location), and calculate the total distance of each of the Coordinates.  

I found the formula for calculating the distance on stackoverflow.com (providing copy/paste solutions for the masses).  

http://stackoverflow.com/questions/3715521/how-can-i-calculate-the-distance-between-two-gps-points-in-java

I was able to find that the distance between the Space Needle, CenturyLink Field, Big Ben, Taj Mahal, and the Grand Canyon is:

Total distance (km): 27492.11
Total distance (mi): 17082.80

Kind of neat!  

I posted the code on github: https://github.com/leewallen/geocodehelper

If you have any ideas for adding on to the code, then please let me know.  It would be nice to make the app useful to someone.  Also, I wouldn't mind suggestions for any refactoring ideas.

Something that might be a fun Android/Solr project would be to do the following:
  • Create a Solr index for holding information about WIFI access points (this would include the latitude and longitude for the location where the WIFI access point was discovered) 
  • Create an Android app that will log latitude/longitude whenever it finds unsecured (or secured) WIFI access points (ie, Starbucks, libraries, etc.)
  • Index the information into a Solr index
  • Create a new Android app, or add onto the first Android app, to allow you to enter an address/place of interest, and then query Solr to get a list of available WIFI access points within a specified radius
If anyone has any related project ideas, then please share!




No comments:

Post a Comment