gpt4 book ai didi

php - gps坐标+米

转载 作者:行者123 更新时间:2023-12-04 03:12:47 25 4
gpt4 key购买 nike

我需要从一些 gps 坐标中获取北、南、西和东 500 米的新坐标。

纬度:45.815005长:15.978501

可以是近似值

谢谢

最佳答案

好吧,在不知道如何开始的情况下,让我们看看我能想出什么样的解决方案。

寻找南北应该是简单的算术,因为每条经线的长度总是相同的,因此距离和度数应该联系起来,因此可以通过计算地球围绕两极的周长(以米为单位)来完成按 360 度给出每米的度数。但是每米的纬度会发生变化,因为纬度线的长度会随着距离赤道越远而减少,因此这将是一个几何/三角函数。现在,根据我对球体三角学的了解,cos(deg) * (pi * d) = 与球体赤道平面平行的圆的周长,度数为 deg,其中 deg 是北或南的度数球体赤道的半径,d 是球体的直径。

那么,让我们看看。

<?php
$lat = 45.815005;
$long = 15.978501;
$meters = 500; //Number of meters to calculate coords for north/south/east/west

$equator_circumference = 6371000; //meters
$polar_circumference = 6356800; //meters

$m_per_deg_long = 360 / $polar_circumference;

$rad_lat = ($lat * M_PI / 180); //convert to radians, cosine takes a radian argument and not a degree argument
$m_per_deg_lat = 360 / (cos($rad_lat) * $equator_circumference);

$deg_diff_long = $meters * $m_per_deg_long; //Number of degrees latitude as you move north/south along the line of longitude
$deg_diff_lat = $meters * $m_per_deg_lat; //Number of degrees longitude as you move east/west along the line of latitude

//changing north/south moves along longitude and alters latitudinal coordinates by $meters * meters per degree longitude, moving east/west moves along latitude and changes longitudinal coordinates in much the same way.

$coordinates['north']['lat'] = $lat + $deg_diff_long;
$coordinates['north']['long'] = $long;
$coordinates['south']['lat'] = $lat - $deg_diff_long;
$coordinates['south']['long'] = $long;

$coordinates['east']['lat'] = $lat;
$coordinates['east']['long'] = $long + $deg_diff_lat; //Might need to swith the long equations for these two depending on whether coordinates are east or west of the prime meridian
$coordinates['west']['lat'] = $lat;
$coordinates['west']['long'] = $long - $deg_diff_lat;

?>

至少,我认为那会得到它。我可能完全错了。它似乎生成的坐标与原点的差异足够小,距离它只有 500 米。

我还切换到度每米而不是米每度,但变量名称保持不变。

关于php - gps坐标+米,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5403455/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com