Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/240.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 从一个坐标到另一个坐标确定航向_Php_Gps_Heading - Fatal编程技术网

Php 从一个坐标到另一个坐标确定航向

Php 从一个坐标到另一个坐标确定航向,php,gps,heading,Php,Gps,Heading,我有两点(纬度1,经度1)和(纬度2,经度2)。如何在PHP中确定从第1点到第2点需要学习的课程 课程将是北,南,东,或西,可能会转换成度 谢谢 //功能:车床轴承大圆 // Function: latlon_bearing_great_circle // Desc: This function calculates the initial bearing you need to travel // from Point A to Point B, along a great arc.

我有两点(纬度1,经度1)和(纬度2,经度2)。如何在PHP中确定从第1点到第2点需要学习的课程

课程将是北,南,东,或西,可能会转换成度

谢谢

//功能:车床轴承大圆
// Function: latlon_bearing_great_circle
// Desc:  This function calculates the initial bearing you need to travel
//   from Point A to Point B, along a great arc.  Repeated calls to this
//   could calculate the bearing at each step of the way.
function latlon_bearing_great_circle($lat_a, $lon_a, $lat_b, $lon_b) {
// Convert our degrees to radians:
list($lat1, $lon1, $lat2, $lon2) =
    _deg2rad_multi($lat_a, $lon_a, $lat_b, $lon_b);

// Run the formula and store the answer (in radians)
$rads = atan2(
        sin($lon2 - $lon1) * cos($lat2),
        (cos($lat1) * sin($lat2)) -
              (sin($lat1) * cos($lat2) * cos($lon2 - $lon1)) );

// Convert this back to degrees to use with a compass
$degrees = rad2deg($rads);

// If negative subtract it from 360 to get the bearing we are used to.
$degrees = ($degrees < 0) ? 360 + $degrees : $degrees;

return $degrees;
}

// Function: _deg2rad_multi
// Desc: A quick helper function.  Many of these functions have to convert
//   a value from degrees to radians in order to perform math on them.
function _deg2rad_multi() {
    // Grab all the arguments as an array & apply deg2rad to each element
    $arguments = func_get_args();
    return array_map('deg2rad', $arguments);
}
//Desc:此函数计算您需要行驶的初始轴承 //从A点到B点,沿着一条大弧线。一再呼吁这一点 //可以计算每个步骤的轴承。 函数latlon_轴承大圆($lat_a、$lon_a、$lat_b、$lon_b){ //将度数转换为弧度: 列表($lat1、$lon1、$lat2、$lon2)= _deg2rad_multi($lat_a、$lon_a、$lat_b、$lon_b); //运行公式并存储答案(以弧度为单位) $rads=atan2( sin($lon2-$lon1)*cos($lat2), (cos($lat1)*sin($lat2))- (sin($lat1)*cos($lat2)*cos($lon2-$lon1)); //将其转换回度数,以便与指南针一起使用 $degrees=rad2deg($rads); //如果是负数,从360减去它,得到我们习惯的方位。 $degrees=($degrees<0)?360+$degrees:$degrees; 返回$degrees; } //功能:_deg2rad_multi //Desc:一个快速助手函数。其中许多函数都必须转换 //从度到弧度的值,以便对其执行数学运算。 函数_deg2rad_multi(){ //抓取所有参数作为一个数组&将deg2rad应用于每个元素 $arguments=func_get_args(); 返回数组映射('deg2rad',$arguments); }

我查看了上面一个链接,但这会产生弧度的结果,我真的需要一些度数的东西。我将尝试一下