Created
October 26, 2009 11:45
-
-
Save kurko/218604 to your computer and use it in GitHub Desktop.
Calcula a distância entre dois pontos com latitude e longitude.
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
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