Using this query find the distance between multiple points.
So you have a whole table full of members or places with latitude and longitude’s associated with them. Just replace the $lat and $lon with the center point you want to find distances from.
SET @orig_lat=15.47221; SET @orig_lon=73.813963;SET @dist=10;
SELECT dest.*,
3956 * 2 * ASIN(SQRT(POWER(SIN((@orig_lat- ABS(dest.latitude)) * PI()/180 / 2), 2)
+COS(@orig_lat * PI()/180) *COS(ABS(dest.latitude) * PI()/180) *POWER(SIN((@orig_lon -dest.longitude) * PI()/180 / 2), 2) ))
AS distance FROM table_name dest ORDER BY Distance LIMIT 10;
No comments:
Post a Comment