I'm implementing an Android application that needs to do some reverse-geocoding to resolve a geocoordinate to a city. What is the best way to cache this information on the smartphone so that I don't have to always call an online server to perform this reverse-geocoding?
-
This is more a Stack Overflow Exchange Question stackoverflow.com/questions/12746269/…– Mapperz ♦Commented Sep 25, 2013 at 17:46
-
No. That question pertains to caching online calls. I'm talking about caching reverse-geocoding data. For example, how can I know that I can re-use the same reverse-geocoded region?– stackoverflowuser2010Commented Sep 25, 2013 at 17:58
2 Answers
I was looking for an answer to that as well. So far what I think the best course is, to use android storage(shared preferences or disk cache) and store locations by north east and south west bounds coordinates(returned by the geocoder) and before using the geocoder by that device again, we check if the current coordinates are within the parameters of the stored bounds, and we return the results natively if possible. Given the limitations on the use of the geocoder, try to make the most of the information you get...
I was working on a solution to this problem myself, maybe this is of any use: reverse geocoder cache
This cache uses dynamically sized tiles which hold the cached information. So if you wanted to cache the results of the google places API, you would set the tile-size to maybe 10 meters (like the length of a house). In case you were caching timezone-ids, a larger tile-size might suffice.
In case two latitude-longitude-combinations fall into the same tile, they would both yield the same cached result (which is what we want in order to reduce the number of requests made to the google API). Carefully choosing the tile-size is key for the cache to work correctly for a given task.