View Single Post
Old 11-12-2010, 04:46 AM  
Maxi
Registered User
 
Join Date: May 2002
Posts: 233
Copypasta from http://www.codecodex.com/wiki/Calcul...nts_on_a_globe


Code:
function getDistance($latitude1, $longitude1, $latitude2, $longitude2) 
{  
    $earth_radius = 6371;  
      
    $dLat = deg2rad($latitude2 - $latitude1);  
    $dLon = deg2rad($longitude2 - $longitude1);  
      
    $a = sin($dLat/2) * sin($dLat/2) + cos(deg2rad($latitude1)) * cos(deg2rad($latitude2)) * sin($dLon/2) * sin($dLon/2);  
    $c = 2 * asin(sqrt($a));  
    $d = $earth_radius * $c;  
      
    return $d;  
}

Last edited by Maxi; 11-12-2010 at 04:49 AM..
Maxi is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote