Skip to content

Instantly share code, notes, and snippets.

@kurko
Created October 26, 2009 11:45
Show Gist options
  • Save kurko/218604 to your computer and use it in GitHub Desktop.
Save kurko/218604 to your computer and use it in GitHub Desktop.
Calcula a distância entre dois pontos com latitude e longitude.
function calcDist($lat_A, $long_A, $lat_B, $long_B) {
$distance = sin(deg2rad($lat_A))
* sin(deg2rad($lat_B))
+ cos(deg2rad($lat_A))
* cos(deg2rad($lat_B))
* cos(deg2rad($long_A - $long_B));
$distance = (rad2deg(acos($distance))) * 69.09;
return $distance;
}
// You can find the original code in http://zips.sourceforge.net/#dist_calc
// The result is in Miles.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment