I have a query which tries to get objects around a radius of 5 km. There is one object A, which gets into the results, but if i calculate the distance of the center and the object coordinates i get around 10.772 km. Why does it get into the results?
Center (Berlin)
loc_lon: 13.406290000000013
loc_lat: 52.524268
Object A Coordinates (data inside table "objects")
Long: 13.260820
Lat: 52.485661
Convert center coordinates to radians:
$loc_lon = $loc_lon / 180 * M_PI;
$loc_lat = $loc_lat / 180 * M_PI;
Query:
SELECT id, title, loc_lat, loc_lon
FROM objects
WHERE ( 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 AND 5