togakangaroo/coa-nolahealth-mobile — Issue #8: Geocode clinic locations on the server on import
Author: togakangaroo
Created: 2012-02-28 15:21:49+00:00
State: open

Ok, so I was all set to flip the switch on the distances yesterday when I realized that in order to sort by distance we need the geocoded location of **every** clinic before we can even call into the distance Matrix.

However, you can only geocode one address at a time. [As far as I can tell no service allows you to geocode multiple addresses at one time for free](http://stackoverflow.com/questions/396819/geocode-multiple-addresses). And you can't issue parallel queries or you get OVER_QUERY_LIMIT back. The guidance is 200ms in between meaning at least 12 seconds to geocode all the clinics. If we want to allow for multiple users at a time then we have to double or triple that number. Even if we use localstorage this is still happening once-per-user.

So the solution as always with scaling problems is to shift read-time to write-time. Meaning that, when they do the initial data import, the ruby code needs to call the google maps api, geocode each address, and serve it as part of the json.

Rob, can you do this? If not, I'm going to be on the phone with some ruby guys this Thursday and they can hopefully help.

PS To get full address c.Street+" "+c.City+" "+c.State+" "c['Zip Code'] seems to be working fine