Created
May 10, 2017 08:34
-
-
Save csalgueiro/761fabbd1f80d46d48394be4a0661b43 to your computer and use it in GitHub Desktop.
Funcion para medir la distancia entre dos posiciones GPS
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 distancia_gps ($punto1, $punto2) { | |
$metros = 6371000; //Circunferencia de la tierra | |
$coo1 = explode(',', $punto1); | |
$coo2 = explode(',', $punto2); | |
$distancia = $metros * acos(sin(deg2rad($coo1[0])) * sin(deg2rad($coo2[0])) + cos(deg2rad($coo1[0])) * cos(deg2rad($coo2[0])) * cos(deg2rad($coo1[1]) - deg2rad($coo2[1]))); | |
return ((is_numeric($distancia)) ? $distancia : 0); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment