Skip to content

Instantly share code, notes, and snippets.

@tmn
Created December 9, 2014 12:09
Show Gist options
  • Save tmn/c8f5d9cf4e63468e8a3b to your computer and use it in GitHub Desktop.
Save tmn/c8f5d9cf4e63468e8a3b to your computer and use it in GitHub Desktop.
$R = 6371;
$dLat = deg2rad($lat2-$lat1);
$dLon = deg2rad($lon2-$lon1);
$lat1 = deg2rad($lat1);
$lat2 = deg2rad($lat2);
$a = sin($dLat/2) * sin($dLat/2) + sin($dLon/2) * sin($dLon/2) * cos($lat1) * cos($lat2);
$c = 2 * atan2(sqrt($a), sqrt(1-$a));
$d = $R * $c;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment