I have a cities model defined which saves the geoname_id and location (as GeoPt) of a city. There are two things that I want to achieve.
- I want to get all cities within
500kmradius from a given city. - I want to calculate distance in
kmbetween two given cities.
What would be the best way to achieve this, keeping in mind that I have a very large database of cities and I do not want to sacrifice a lot on the performance factor. Any help or advice is appreciated.
This works perfect but is a lil slow :
Function to Calculate Distance. The Arguments passed to this function are tuples of latitude and longitude of a location or a Geopt():
Function to calculate Surrounding cities within a radius. This is a method under the City model which store all cities: