我需要从某些GPS坐标向北,南,西和东500米处获取新的坐标。
lat:45.815005 长:15.978501
它可以是近似的
谢谢
答案 0 :(得分:4)
嗯,不知道如何开始这样做,让我们看看我能提出什么样的解决方案。
寻找北/南应该是简单的算术,因为每条经度线的长度总是相同的,因此距离和度数应该相关联,因此可以通过计算围绕极点的地球周长以米为单位来划分通过360度给出每米度数。但是每米的纬度可能会发生变化,因为纬度线的长度越远离赤道越远,因此这将是几何/三角函数。现在,根据我所知的球体三角学,cos(deg)*(pi * d)=圆的圆周,与球的赤道平面平行,以度为度,其中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米。
我也转换到每米度数而不是每度数米,但保留变量名称相同。