function _deg2rad($deg) { $radians = 0.0; $radians = $deg * M_PI/180.0; return($radians); } function geoDistance($lat1, $lon1, $lat2, $lon2, $unit="k") { $theta = $lon1 - $lon2; $dist = sin(_deg2rad($lat1)) * sin(_deg2rad($lat2)) + cos(_deg2rad($lat1)) * cos(_deg2rad($lat2)) * cos(_deg2rad($theta)); $dist = acos($dist); $dist = rad2deg($dist); $miles = $dist * 60 * 1.1515; $unit = strtolower($unit); if ($unit == "k") { return ($miles * 1.609344); } else { return $miles; } }
- Posted
- Filed under 프로그래밍/PHP