Skip to content

Instantly share code, notes, and snippets.

@welly
Forked from gajus/gist:5487925
Last active August 29, 2015 14:23
Show Gist options
  • Save welly/54fce245bce58b0df31d to your computer and use it in GitHub Desktop.
Save welly/54fce245bce58b0df31d to your computer and use it in GitHub Desktop.
function distanceGeoPoints ($long1, $lat1, $long2, $lat2) {
$lat = deg2rad($lat2 - $lat1);
$long = deg2rad($long2 - $long1);
$a = sin($lat/2) * sin($lat/2) + cos(deg2rad($lat1)) * cos(deg2rad($lat2)) * sin($long/2) * sin($long/2);
$c = 2 * atan2(sqrt($a), sqrt(1 - $a));
$d = 6371 * $c;
return $d;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment