【问题标题】:gps coordinates + metersGPS坐标+米
【发布时间】:2011-09-27 01:00:24
【问题描述】:

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

纬度:45.815005 长:15.978501

可能是近似的

谢谢

【问题讨论】:

  • 如果您使用的是 MySQL 数据库,那么上面喜欢的 SO Question 可能会有所帮助。如果您单独使用 PHP,请搜索“大圆计算器” - 它可以让您根据方位和距离计算纬度/经度坐标,反之亦然。
  • 谢谢,这正是我需要的

标签: php gps coordinates


【解决方案1】:

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

找到北/南应该很容易算术,因为每条经线的长度总是相同的,因此距离和度数应该联系起来,因此可以通过计算以米为单位的两极周围的地球周长来完成通过 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 米。

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

【讨论】:

  • 这个答案对我非常有用。我试图做的是在 KML 中为谷歌地球绘制圆圈。所以我使用 $deg_diff_long 和 $deg_diff_lat 作为两个半径。但是那样半径太大了,如果我用 2*M_PI 划分它们,它们就会变得完美(他们同意我的项目在 Heremap 上绘制的圆圈)。如果你知道为什么,请赐教。
猜你喜欢
  • 2014-05-06
  • 2018-08-28
  • 2017-12-06
  • 1970-01-01
  • 2023-03-21
  • 1970-01-01
  • 2012-03-21
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多