query("SET CHARSET SET utf8"); $db->query("SET NAMES 'utf8'"); if (mysqli_connect_errno()) { echo "Error connecting to DB"; exit; } $ClientId = $_SESSION['client_id']; $_SESSION['fixed_data'] ? $table = "tms_gpsdata_fixed" : $table = "tms_gpsdata"; $GMT = $_SESSION['gmt']; //поправка gmt для сервера $Login=$_SESSION['login']; function distance($lat1, $lat2, $lon1, $lon2, $el1, $el2) { //$R = 6371; // Radius of the earth $R = 6376.402; // Radius of the earth $latDistance = deg2rad($lat2 - $lat1); $lonDistance = deg2rad($lon2 - $lon1); $a = sin($latDistance / 2) * sin($latDistance / 2) + cos(deg2rad($lat1)) * cos(deg2rad($lat2)) * sin($lonDistance / 2) * sin($lonDistance / 2); $c = 2 * atan2(sqrt($a), sqrt(1 - $a)); $distance = $R * $c * 1000; // convert to meters $height = $el1 - $el2; if ($height <> 0) { $distance = pow($distance, 2) + pow($height, 2); $distance = sqrt($distance); } return $distance; } echo $_GET['x1'].",".$_GET['y1']."
"; echo calculateDistance(50.448997,50.517156, 30.413020, 30.616267,100,100); //echo "A:".distance($_GET['x1'],$_GET['x2'],$_GET['y1'],$_GET['y2'],100,100); $gps_1['lat']=$_GET['y1']; $gps_1['lon']=$_GET['x1']; $gps_1['point_elevation']=100; $gps_2['lat']=$_GET['y2']; $gps_2['lon']=$_GET['x2']; $gps_2['point_elevation']=100; echo "D:".get_distance_between_2_points($gps_1,$gps_2)*1609.344; //echo "D:".get_distance_between_2_points(array('lat'=>$_GET['x1'], 'lon'=>$_GET['y1']),array('lat'=>$_GET['x2'], 'lon'=>$_GET['y2'])); //50.448997, 30.413020 //50.517156, 30.616267 //16,52