Posted by NC on 05/04/06 18:25
MS wrote:
>
> I am looking for a geoclass, which initially will return a distance
> between point A & B referenced by Lat & Lon
You don't need a class for that. Here's the computation in its
entirety:
$distance = $r * acos(cos($lat1) * cos($lon1) * cos($lat2) * cos($lon2)
+
cos($lat1) * sin($lon1) * cos($lat2) * sin($lon2)
+
sin($lat1) * sin($lat2));
where:
$r -- radius of the Earth
$lat1 -- latitude of point 1 in radians
$lon1 -- longitude of point 1 in radians
$lat2 -- latitude of point 2 in radians
$lon2 -- longitude of point 2 in radians
Cheers,
NC
[Back to original message]
|