我想完全理解方位角的概念,並遇到一些不一致(或者可能是我的錯誤)。赤道上的方位角是否等於不在赤道上的方位角?
我向你展示了一些不匹配的例子,希望有人能夠解釋我是如何工作的。
我在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