I'm working on an implementation for finding the nearest person based on geographic coordinates. For example, person A has coordinates(Longitude and latitude ) m, and I want to find the person within the circle of center m with radius x.
I plan to store the geographic coordinates in a MySQL database, what's the efficient way to search the nearest coordinates?
My specific question is:
- what fields should be stored in database for efficient search? I plan to store persons' coordinates only.
- what's the algorithm for finding the nearest person? I plan to calculate the distance between person A's coordinate and the coordinates stores in the database.
However, I think it is less efficient to calculate if the number of coordinates is huge in the database.
What's the better way to achieve this application?