2017-06-24 37 views
1

我在地圖[x1,y1]中有一個給定的中心。從那個中心我畫了一個半徑1英里的圓圈。我需要在圓周上生成8個點,單個點到中心的距離應爲1英里,因此它們位於圓圈邊界上。我知道得到x2,y2的公式,但問題是它不適用於地球的地圖,因爲它不是一個完美的球體。從中心生成給定距離,角度的座標

我試過使用this,但沒有運氣。

任何人都可以指向我的某處或者我得到了這個錯誤?

編輯:解決!

所以仔細閱讀整個Movable Type的腳本,我發現這個(稍微修改爲我所用):

let getPoint = (distance, bearing, center) => { 

    let δ = Number(distance)/6371e3; 
    let θ = Number(bearing).toRadians(); 

    let φ1 = center[0].toRadians(); 
    let λ1 = center[1].toRadians(); 

    let sinφ1 = Math.sin(φ1), cosφ1 = Math.cos(φ1); 
    let sinδ = Math.sin(δ), cosδ = Math.cos(δ); 
    let sinθ = Math.sin(θ), cosθ = Math.cos(θ); 

    let sinφ2 = sinφ1*cosδ + cosφ1*sinδ*cosθ; 
    let φ2 = Math.asin(sinφ2); 
    let y = sinθ * sinδ * cosφ1; 
    let x = cosδ - sinφ1 * sinφ2; 
    let λ2 = λ1 + Math.atan2(y, x); 

    return [φ2.toDegrees(), (λ2.toDegrees()+540)%360-180]; 
}; 

它沒有解決我的問題。

+0

但是,如果您忽略地球的實際拓撲結構,則您沒有指定最大允許誤差,但是在1英里的範圍內,誤差可以忽略不計 –

回答

2

您正試圖解決所謂的first (or direct) geodetic problem。知道這個名字會讓你的研究更容易。

正如所指出的答案,「How to draw polyline perpendicular to another polyline using Leaflet」和「Find destination coordinates given starting coodinates, bearing, and distance」,你的主要選項,以解決這個問題在javascript是cheap-ruler爲小(ISH)區和greographiclib爲大的距離。

cheap-ruler往往是非常快但不準確,而且geographiclib往往會更慢但非常準確。

你可能會發現其他的實現,每個實現都有自己的折衷。大地測量很難,所以there is no "one true way"來計算距離或方位角。

相關問題