Created
February 21, 2018 13:41
-
-
Save Itachi261092/5c998df02ab7a40619a5c84af937e9b4 to your computer and use it in GitHub Desktop.
Посчитать расстояние между 2 точками координат
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$R = 6371; // Earth radius in km | |
$dLat = (($q[0] - $p[0]) * pi() / 180); | |
$dLon = (($q[1] - $p[1]) * pi() / 180); | |
$a = sin($dLat / 2) * sin($dLat / 2) + | |
cos($p[0] * pi() / 180) * cos($q[0] * pi() / 180) * | |
sin($dLon / 2) * sin($dLon / 2); | |
$c = 2 * atan2(sqrt($a), sqrt(1 - $a)); | |
return $R * $c; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment