Документы для веб-разработчиков

<? ///////////////////////////////////////////////////////////////// // Расчет расстояний между двумя точками ///////////////////////////////////////////////////////////////// // Москва $lat1 = 55.7522200; $lon1 = 37.6155600; // Нижний новгород $lat2 = 56.3286700; $lon2 = 44.0020500; // по этой формуле будет 402 км. function distanceFromLatLonInKm($lat1, $lon1, $lat2, $lon2) { $R = 6378.1; // Radius of the earth in km $dLat = deg2rad($lat2 - $lat1); // deg2rad below $dLon = deg2rad($lon2 - $lon1); $a = sin($dLat / 2) * sin($dLat / 2) + cos(deg2rad($lat1)) * cos(deg2rad($lat2)) * sin($dLon / 2) * sin($dLon / 2); $c = 2 * atan2(sqrt($a), sqrt(1 - $a)); $d = $R * $c; // Distance in km return round($d, 3); } // Расчет расстояний между объектами function Distance($fromLat,$fromLon,$toLat,$toLon) { $DifferenceALL = 3958.75 * acos( sin($fromLat/57.2958) * sin($toLat/57.2958) + cos($fromLat/57.2958) * cos($toLat/57.2958) * cos($toLon/57.2958 - $fromLon/57.2958)); $Difference = $DifferenceALL * 1609.344; $result = ceil($Difference/10) * 10; $units = "м"; if ($result > 1000) { $Difference = $DifferenceALL * 1.609344; $result = ceil($Difference/0.25) * 0.25; $units = "км"; } return $result.' '.$units; } function Distance_in_meters($fromLat,$fromLon,$toLat,$toLon, $show_units = true) { $DifferenceALL = 3958.75 * acos( sin($fromLat/57.2958) * sin($toLat/57.2958) + cos($fromLat/57.2958) * cos($toLat/57.2958) * cos($toLon/57.2958 - $fromLon/57.2958)); $Difference = $DifferenceALL * 1609.344; $result = ceil($Difference/10) * 10; $units = "м"; if($show_units) { $result = $result.' '.$units; } return $result; } function Distance_in_km_only($fromLat,$fromLon,$toLat,$toLon) { $DifferenceALL = 3958.75 * acos( sin($fromLat/57.2958) * sin($toLat/57.2958) + cos($fromLat/57.2958) * cos($toLat/57.2958) * cos($toLon/57.2958 - $fromLon/57.2958)); $Difference = $DifferenceALL * 1609.344; $result = ceil($Difference/10) * 10; $units = "м"; return $result; }