2014-08-27 99 views
3

我想完全理解方位角的概念,並遇到一些不一致(或者可能是我的錯誤)。赤道上的方位角是否等於不在赤道上的方位角?

我向你展示了一些不匹配的例子,希望有人能夠解釋我是如何工作的。

我在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度(不在赤道上)。

它是如何正確的?

感謝

+0

[如何計算PostGIS中兩點之間的方位角?](http://stackoverflow.com/questions/25526684/how-to-calculate-the-azimuth-between-two-points-in- postgis) – 2014-08-28 17:19:57

+0

這個問題似乎是題外話,因爲它不是關於編程(儘管它使用編程)。請參閱幫助中心的[我可以詢問哪些主題](http://stackoverflow.com/help/on-topic)。也許[Geography Stack Exchange](https://gis.stackexchange.com/)會是一個更好的地方。 – jww 2014-08-28 17:53:50

+0

@jww,謝謝。我知道GIS.StackExchange更好。我嘗試了兩種方法,而且這裏比較好。所以,非常感謝回答的人! :)我將來會更加小心。 – joaorodr84 2014-08-28 18:06:48

回答

2

在你的榜樣,你已經使用EPSG:900913,這是平面的,預計在米。這意味着公式使用將是ATAN2,這永遠是90時的緯度相同,與式爲:

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

而第二部分將始終爲0,得到的方位90.所以,使用平面座標,是的,對於相同緯度的座標對,方位角總是相同的,這就是爲什麼在使用EPS:900913時,Postgis總是給出相同的答案。

如果您切換到地理數據類型,並因此使用測地座標,則不再是這種情況。

例如:

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

給出80.1318065在PostGIS中,您鏈接計算器頁面上給出了80.139。

隨着x /經度越接近,對於給定的緯度,數值越接近90。例如,

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

現在給出POSTGIS 89.9131737和和89.333的在線計算器(稍微差異)。

所有這些都是由於公式現在說明了曲率的事實,所以兩個向量的投影之間的角度不會超過90度,除了在赤道上。

看看Wikipedia azimuth文章中有關球體版本的等式。這應該很容易在JavaScript中進行編碼,並且應該與Postgis的地理類型給出類似的答案。

+0

Hi @JohnBarça。我以錯誤的方式使用PostGIS。謝謝。正如你所看到的,我已經在使用[來自維基百科的功能](http://upload.wikimedia.org/math/2/3/8/238805bcce98ded92525289f49b3d6f9.png),稍作修改。或者你的意思是[第二個](http://upload.wikimedia.org/math/e/5/e/e5ecad955f1b1f7e2f84c3dd36eb4296.png)? – joaorodr84 2014-08-27 16:40:33

+0

我的意思是第二個,它代表了扁圓球體,從http://upload.wikimedia.org/math/7/6/e/76e90f1c786b852709ce30d9504cb19a.png開始。如果你使用它,你應該更接近你在Postgis中使用地理的值。 – 2014-08-27 16:43:55

+0

非常感謝。 :) – joaorodr84 2014-08-27 16:56:26

相關問題