我想完全理解方位角的概念,并遇到一些不一致(或者可能是我的错误)。赤道上的方位角是否等于不在赤道上的方位角?
我向你展示了一些不匹配的例子,希望有人能够解释我是如何工作的。
我在EPSG中显示坐标:900913,在PostGIS中使用我自己的JavaScript函数。
MY FUNCTION
/* Difference between the two longitudes */
var dLon = lon2 - lon1;
/* Y value */
var y = Math.sin(dLon) * Math.cos(lat2);
/* X value */
var x = Math.cos(lat1) * Math.sin(lat2) - Math.sin(lat1) * Math.cos(lat2) * Math.cos(dLon);
/* Calculates the azimuth between the two points and converts it to degrees */
var angle = Math.atan2(y, x)/Math.PI * 180;
实施例
/* Same Y, not on the equator */
Point A: (-81328.998084106, 7474929.8690234)
Point B: (4125765.0381464, 7474929.8690234)
Result in PostGIS: 90 degrees
Result in my JS function: 74.232 degrees
/* Same Y, on the equator */
Point A: (-81328.998084106, 0)
Point B: (4125765.0381464, 0)
Result in PostGIS: 90 degrees
Result in my JS function: 90 degrees
我明白,在赤道上,方位角是90(或270),用于一条水平线。认为如果你画一条水平线稍微偏向赤道北(或南),那么方位角不再是90度。但是... PostGIS告诉我,当我们有相同的Y时,总是90度。
此外,这个calculator还显示,当Y!= 0时,水平线的方位角不是90度(不在赤道上)。
它是如何正确的?
感谢
[如何计算PostGIS中两点之间的方位角?](http://stackoverflow.com/questions/25526684/how-to-calculate-the-azimuth-between-two-points-in- postgis) – 2014-08-28 17:19:57
这个问题似乎是题外话,因为它不是关于编程(尽管它使用编程)。请参阅帮助中心的[我可以询问哪些主题](http://stackoverflow.com/help/on-topic)。也许[Geography Stack Exchange](https://gis.stackexchange.com/)会是一个更好的地方。 – jww 2014-08-28 17:53:50
@jww,谢谢。我知道GIS.StackExchange更好。我尝试了两种方法,而且这里比较好。所以,非常感谢回答的人! :)我将来会更加小心。 – joaorodr84 2014-08-28 18:06:48