Created
December 13, 2018 18:17
-
-
Save usainicola/cee888a202d9f2e9a8692f7696225714 to your computer and use it in GitHub Desktop.
distance
This file contains hidden or 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
<?php | |
function distance($latitudeFrom, $longitudeFrom, $latitudeTo, $longitudeTo) { | |
$rad = M_PI / 180; | |
$theta = $longitudeFrom - $longitudeTo; | |
$dist = sin($latitudeFrom * $rad) * sin($latitudeTo * $rad) + cos($latitudeFrom * $rad) * cos($latitudeTo * $rad) * cos($theta * $rad); | |
return acos($dist) / $rad * 60 * 1.852; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment