Skip to content

Instantly share code, notes, and snippets.

@Itachi261092
Created February 21, 2018 13:41
Show Gist options
  • Save Itachi261092/5c998df02ab7a40619a5c84af937e9b4 to your computer and use it in GitHub Desktop.
Save Itachi261092/5c998df02ab7a40619a5c84af937e9b4 to your computer and use it in GitHub Desktop.
Посчитать расстояние между 2 точками координат
$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