I have +10k points (latitude, longitude) and I'm building an app that shows you the k nearest points to a user's location.
I think this is a very common problem and I don't want to reinvent the wheel. I'm learning about Quadtrees. It seems to be a good approach to solve this spatial problem.
I'm using these tools:
- Python 2.5
- MySQL
- MongoDb
Building the Quadtree is not that hard: http://donar.umiacs.umd.edu/quadtree/points/pointquad.html But once I've created the tree and saved it to a db (MySQL or MongoDb), how I run the query?
I need to run queries like these:
- Find all points within 10 km of the user's location.
- Find the 6 (or at least 6) nearest points to the user's location.
What's the standard and common approach to do it?
EDIT 1:
I've loaded the +10k points into MongoDB (Geospatial indexing) and it works fine at first glance. Anyway I've found PostGis:
PostGIS is an extension to the PostgreSQL object-relational database system which allows GIS (Geographic Information Systems) objects to be stored in the database.
So I think I'll give PostGis a try.
I've also found SimpleGeo. You can store points/places in the cloud and then query them via an API: https://simplegeo.com/docs/tutorials/python#how-do-radial-nearby-query