Created
June 11, 2013 13:26
-
-
Save ailinykh/5756808 to your computer and use it in GitHub Desktop.
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
<?php | |
/** | |
* Distance | |
* | |
* @return distance betweeb two points in meters | |
*/ | |
public function distance($lat1,$long1,$lat2,$long2) | |
{ | |
$greatCircleRadius = 6372795; | |
$rLat1 = M_PI*$lat1/180; | |
$rLong1 = M_PI*$long1/180; | |
$rLat2 = M_PI*$lat2/180; | |
$rLong2 = M_PI*$long2/180; | |
return abs($greatCircleRadius*atan( | |
sqrt( | |
pow(cos($rLat2)*sin($rLong2-$rLong1),2) | |
+ | |
pow(cos($rLat1)*sin($rLat2) | |
- | |
sin($rLat1)*cos($rLat2)*cos(abs($rLong2-$rLong1)),2) | |
) | |
/ | |
(sin($rLat1)*sin($rLat2)+cos($rLat1)*cos($rLat2)*cos(abs($rLong2-$rLong1))))); | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment