Last active
July 28, 2016 11:44
-
-
Save atomoc/b083b7efa3da57bca6a8f846a8f7b96b to your computer and use it in GitHub Desktop.
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
<?php | |
function LatLngDist($p, $q) { | |
$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
Пример использования: