geolocation - MySQL Distance Query -
i have query tries objects around radius of 5 km. there 1 object a, gets results, if calculate distance of center , object coordinates around 10.772 km. why results?
center (berlin)
loc_lon: 13.406290000000013
loc_lat: 52.524268
object coordinates (data inside table "objects")
long: 13.260820
lat: 52.485661
convert center coordinates radians:
$loc_lon = $loc_lon / 180 * m_pi; $loc_lat = $loc_lat / 180 * m_pi;
query:
select id, title, loc_lat, loc_lon objects ( 6368 * sqrt(2*(1-cos(radians(loc_lat)) * cos(0.9167214137999) * (sin(radians(`loc_lon`)) * sin(0.23398390097719) + cos(radians(`loc_lon`)) * cos(0.23398390097719)) - sin(radians(loc_lat)) * sin(0.9167214137999)))) between 0 , 5
Comments
Post a Comment