【发布时间】:2014-10-21 03:50:40
【问题描述】:
我正在尝试完全理解方位角的概念,但遇到了一些不一致(或者可能是我的错误)。
我向你展示了一些不匹配的例子,希望有人能解释一下这是如何工作的。
我使用我自己的 JavaScript 函数在 EPSG:900913、PostGIS 中显示坐标。
我的功能
/* 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 度。
如何正确?
谢谢
【问题讨论】:
-
这个问题似乎离题了,因为它与编程无关(尽管它使用编程)。请参阅帮助中心的What topics can I ask about here。也许Geography Stack Exchange 会是一个更好的提问地点。
-
@jww,谢谢。我知道 GIS.StackExchange 更好。我都试过了,这里的aswer更好。所以,非常感谢回答的人! :) 以后我会更加小心的。
-
@joaorodr84 - 太棒了;很高兴你得到了一个好的答案。 (请不要亲自结束。我不得不结束自己的问题(我真的在几年前问过这个问题吗?))。
-
没问题,@jww。 :) 我不认为这是个人的。你是绝对正确的。 ;)
标签: javascript postgis azimuth geodesic-sphere