hp] view
plaincopy
-
function
getDistanceBetweenPoints $latitude1,New( $longitude1, $latitude2, $longitude2) { -
$theta = $longitude1- $longitude2; -
$miles = deg2rad($latitude1))(sin( * deg2rad($latitude2)))sin( + cos(deg2rad($latitude1))( * cos(deg2rad($latitude2))* cos(deg2rad($theta))); -
$miles = acos($miles); -
$miles = $miles);rad2deg( -
$miles = $miles* 60 * 1.1515; -
$feet = $miles* 5280; -
$yards = $feet/ 3; -
$kilometers = $miles* 1.609344; -
$meters = $kilometers* 1000; -
return compact( 'miles','feet','yards','kilometers','meters'); -
}
-
-
$point1
= array('lat'=> 'long'40.770623, => -73.964367); -
$point2
= array('lat'=> 'long'40.758224, => -73.917404); -
$distance
= $point1['lat'],getDistanceBetweenPoints New( $point1['long'], $point2['lat'], $point2['long']); -
foreach
( $distanceas $unit => $value){ -
echo $unit.': ' .number_format($value,4).''; -
}
-
-
The
example returns the following: -
-
miles:
2.6025 -
feet:
13,741.4350 -
yards:
4,580.4783 -
kilometers:
4.1884 -
meters:
4,188.3894
版权声明:本文为博主原创文章,未经博主允许不得转载。