2011-02-05 36 views
8

尋找資源或算法來計算在導航應用程序中的以下內容:GPS/GIS計算:基於運動/ mph預測未來位置的算法?

如果我當前的GPS位置是(0,0),我以每小時15英里的速度前進32度,我怎麼才能計算出我的位置將在10秒內?

即:GPSCoordinate predictedCoord = GPSCoordinate.FromLatLong(0, 0).AddByMovement(32, 15, TimeSpan.FromSeconds(10));

編輯:基於下面的答案當前代碼:

public GPSCoordinate AddMovementMilesPerHour(double heading, double speedMph, TimeSpan duration) 
{ 
    double x = speedMph * System.Math.Sin(heading * pi/180) * duration.TotalSeconds/3600; 
    double y = speedMph * System.Math.Cos(heading * pi/180) * duration.TotalSeconds/3600; 

    double newLat = this.Latitude + 180/pi * y/earthRadius; 
    double newLong = this.Longitude + 180/pi/System.Math.Sin(this.Latitude * pi/180) * x/earthRadius; 

    return GPSCoordinate.FromLatLong(newLat, newLong); 
} 
+0

。如果汽車在行駛的街道上,你可能要遵循街道,而不是線性外推的半徑。 – CodesInChaos 2011-02-05 20:36:49

+0

@CodeInChaos在這種情況下,我確實想要線性;這並沒有採取接地路徑考慮(也許以後!) – Brandon 2011-02-05 21:23:55

回答

10

下面是完整的參數答案:

變量:

  • heading:標題(即。從方位角0°向後角度,單位爲度)
  • speed:速度(即,速度矢量的範數,以英里/小時)
  • lat0lon0:以度初始座標
  • dtime:從開始時間間隔位置,以秒
  • latlon:以度
  • 預測座標
  • pi:所述PI常數(3.14159 ...)
  • Rt:地球英里半徑(6378137.0米這使得3964.037911746英里)

在一個(東,北)本地幀,該時間間隔後的位置是:

x = speed * sin(heading*pi/180) * dtime/3600; 
y = speed * cos(heading*pi/180) * dtime/3600; 

(座標以英里爲單位)

從那裏你可以計算WGS84幀中的新位置(即經度和緯度):

lat = lat0 + 180/pi * y/Rt; 
lon = lon0 + 180/pi/sin(lat0*pi/180) * x/Rt; 

編輯:修正的最後一行:*罪(PHI)到/罪(PHI)

0

這裏有您需要的公式。

http://www.movable-type.co.uk/scripts/latlong.html

希望有所幫助。

鮑勃

[更新]下面是在JavaScript式(從源複製)

變種LAT2 = Math.asin(Math.sin(LAT1)* Math.cos(d/R)+ Math.cos(lat1)* Math.sin(d/R)* Math.cos(brng)); Math.cos(d/R)-Math.sin(lat1)* Math.cos(lat1), var lon2 = lon1 + Math.atan2(Math.sin(brng)* Math.sin(d/R)數學。罪(LAT2));

d =行駛距離=速度×時間 R =地球