[GIS] Reverse Geocoding – calculate every time, or store result in database

google-maps-apiMySQLreverse-geocoding

Several questions, such as this one, discuss whether to store only lat/long in the database & calculate the street address every time it is needed, but they seem to miss a few points & seem to be opinion, rather than authoritative.

Hence this question, seeking a final, definitive clarification, with justification.

1) reverse geocode every time
pro – smaller database size (why should everyone duplicate Google's database?)
cons – might occasionally fail whereas storing the result will not

2) store address in the database
pro – less likely to hit a Google imposed limit on the number of requests
con – could be a large amount of data. A few hundred vehicles storing a new location every 5 minutes or so, 16 hours per day… probably more coding

If I take approach 2), I plan a new MySql table for addresses, indexed by lat/long and storing the street address. Every time a vehicle reports position, look for a matching address. If none, calculate & add.

In addition: later, when a client requests movement history, if the address is blank, attempt to calculate & store if found.

I am restricted to using a MySQL database.

Best Answer

You cannot legally cache or store results from Google's Map API (with pretty narrow exceptions).

From the Terms of Service (with emphasis added):

10.1.3 Restrictions against Data Export or Copying.

...

(b) No Pre-Fetching, Caching, or Storage of Content. You must not pre-fetch, cache, or store any Content, except that you may store: (i) limited amounts of Content for the purpose of improving the performance of your Maps API Implementation if you do so temporarily (and in no event for more than 30 calendar days), securely, and in a manner that does not permit use of the Content outside of the Service; and (ii) any content identifier or key that the Maps APIs Documentation specifically permits you to store. For example, you must not use the Content to create an independent database of "places" or other local listings information.

So option 1 it is, unless you only use the geocoding for the purposes described in the Maps API ToS, and only temporarily cache.

Related Question