且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

赤道上的方位角等于非赤道上的方位角吗?

更新时间:2023-02-09 19:51:35

在您的示例中,您使用了EPSG:900913,它是平面的,投影的并且以米为单位.这意味着所使用的公式将为atan2,当纬度相同时,它将始终为90,因为公式为:

In your example you have used EPSG:900913, which is planar, projected and in meters. This means that the formula used will be the atan2, which will always be 90 when the latitudes are the same, as the formula is:

azimuth = atan2(y1-y2, x1-x2)

第二部分将始终为0,方位角为90.因此,使用平面坐标,是的,对于纬度相同的坐标对,方位角将始终相同,这就是为什么Postgis始终给出相同答案的原因使用EPS:900913时.

And the 2nd part will always be 0, giving an azimuth of 90. So, using planar coordinates, yes, the azimuth will always be the same for pairs of coordinates with identical latitudes and this is why Postgis always gives the same answer when using EPS:900913.

如果切换到地理数据类型,因此使用大地坐标,则不再是这种情况.

If you switch to the geography datatype, and therefore use geodesic coordinates, this is no longer the case.

例如:

select degrees(   
  st_azimuth(
   st_makepoint(0, 10)::geography, 
   st_makepoint(90, 10)::geography));

在Postgis中给出80.1318065,并在您链接的计算器页面上给出80.139.

Gives 80.1318065 in Postgis and gives 80.139 on the calculator page you linked.

对于给定的纬度,随着x/经度越靠近,值越接近90.例如

As the x/longitudes get closer together, the closer the values get to 90, for a given latitude. For example,

select degrees(   
  st_azimuth(
   st_makepoint(0, 10)::geography, 
   st_makepoint(1, 10)::geography));

现在在Postgis中给出89.9131737,在在线计算器中给出89.333(略有差异).

Now gives 89.9131737 in Postgis and and 89.333 in the online calculator (slightly more discrepancy).

所有这些都是由于公式现在考虑了曲率,因此,除了在赤道上,两个具有相等纬度的向量的投影之间的夹角将不再是90度.

All of this is due to the fact that the formula now accounts for curvature, so the angle between the projections of the two vectors with equal latitude will no longer be 90, except on the equator.

请参见 Wikipedia方位角文章中的等式.这应该很容易用JavaScript编写代码,并且应该为具有地理类型的Postgis提供类似的答案.

Look at the equation in the Wikipedia azimuth article for the spheroid version. That should be easy enough to code up in JavaScript and that ought to give comparable answers to Postgis with the geography type.