distance (straight)
from: (lat) 48.73233 (long) 2.36618
to: lat() 48.84647 (long) 2.41026
equals some: 13096.16 meters
If I use PHP formula, I get proper result.
But when I translate same PHP formula directly into MySQL query - I get 5904.2757 etc.
Here is the code:
php:
$distance = atan2(sqrt(pow(sin((($to_lat - $from_lat) * M_PI / 180) / 2), 2) + cos(($from_lat * M_PI / 180)) * cos(($to_lat * M_PI / 180)) * pow(sin((($to_long - $from_long) * M_PI / 180) / 2), 2)), sqrt(1 - (pow(sin((($to_lat - $from_lat) * M_PI / 180) / 2), 2) + cos(($from_lat * M_PI / 180)) * cos(($to_lat * M_PI / 180)) * pow(sin((($to_long - $from_long) * M_PI / 180) / 2), 2)))) * 2 * $radiusOfEarth;
mysql:
atan2(sqrt(pow(sin(((ap.Latitude - $from_lat) * pi() / 180) / 2), 2) + cos(($from_lat * pi() / 180)) * cos((ap.Latitude * pi() / 180)) * pow(sin(((ap.Longitude - $from_long) * pi() / 180) / 2), 2)), sqrt(1 - (pow(sin(((ap.Latitude - $from_lat) * pi() / 180) / 2), 2) + cos(($from_lat * pi() / 180)) * cos((ap.Latitude * pi() / 180)) * pow(sin(((ap.Longitude - $from_long) * pi() / 180) / 2), 2)))) * 2 * 6371000 as Distance