3 ms·
I created this to solve my own need for reverse geocoding: https://github.com/punnerud/rgcosm https://github.com/punnerud/rgcosm (Saving me thousands of $ compa
by punnerud 1y ago
I created this to solve my own need for reverse geocoding:
https://github.com/punnerud/rgcosm https://github.com/punnerud/rgcosm
(Saving me thousands of $ compared to Google API)
Uses OpenStreetmap file, Python and SQLite3.
First it finds all addresses using +/- like a square from lat/lon, then calculate distance based on the smaller list (Pythagoras), and pick the closest. It expands until a set maximum if no address is found in the first search.
- davidmurdoch 1y agoJust curious if you looked into using S2 cells for this? It's what Pokemon Go uses for its coordinate system. http://s2geometry.io/devguide/s2cell_hierarchy.html http://s2geometry.io/devguide/s2cell_hierarchy.html
- punnerud 1y agoIsn’t the main purpose of S2 to be able to scan from different “directions”? More a purpose of Google Maps when viewing the world as a spherical object compared to Sqlite3 just using a simple B-tree index on lat+lon?
- davidmurdoch 1y agoThe individual cells being sized and being able to easily to compute neighboring cells seems useful for the described algorithm. I haven't given it much thought on applicability here, but it sounded somewhat similar to a search pattern I once implemented within pgsql to locate items on a map that were within proximity of a given latlong.