I'm working on a task as part of a project which finds the places within a certain distance of a particular (lat, long) point. I know the way to get the result for a single row in my table which has the (Latitude, Longitude) point and the corresponding distance (given by Coverage_Norm_10km, in my case).
My database table (Sorted_Range_Cap_Data) is of the following form:
Place , Population, Latitude, Longitude, Altitude, Bandwidth_Required, Coverage_Range, Throughput_Range, Coverage_Norm_10km, Throughput_10km
SELECT
Place, (
6371 * acos (
cos ( radians(17.741150) )
* cos( radians(Latitude) )
* cos( radians(Longitude) - radians(73.149712) )
+ sin ( radians(17.741150) )
* sin( radians(Latitude) )
)
) AS Coverage_Norm_10km
FROM Sorted_Range_Cap_Data
HAVING Coverage_Norm_10km < (The current row's "Coverage_Norm_10km" value)
ORDER BY Coverage_Norm_10km
LIMIT 0, 20;
(Source :
http://gis.stackexchange.com/questions/31628/find-points-within-a-distance-using-mysql)
Here, (17.741150, 73.149712) is a (lat, long) point in the first row of my database table. I want to find the set of all places which are within "Coverage_Norm_10km" distance from the (lat, long) point.
I need to repeat this for each row in the table.
Finally, I want to end up with the list of places for each (lat, long) point (every row) in my table.
Any help would be highly appreciated.