GPS / GIS计算:基于运动/英里/小时预测未来位置的算法?
寻找资源或算法来计算导航应用中的以下内容:
如果我当前的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); }
这是完整的参数化答案:
变量:
-
heading
:航向(即从方位角0°向后倾斜,以度为单位) -
speed
:速度(即速度矢量的范数,以英里/小时为单位) -
lat0
,lon0
:以度为单位的初始坐标 -
dtime
:从起始位置开始的时间间隔,以秒为单位 -
lat
,lon
:以度为单位的预测坐标 -
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;
编辑:更正了最后一行:* sin(phi)to / sin(phi)
以下是您需要的公式。
http://www.movable-type.co.uk/scripts/latlong.html
希望有所帮助。
短发
[更新]以下是JavaScript中的公式(从源代码复制)
var lat2 = Math.asin(Math.sin(lat1)* Math.cos(d / R)+ Math.cos(lat1)* Math.sin(d / R)* Math.cos(brng)); var lon2 = lon1 + Math.atan2(Math.sin(brng)* Math.sin(d / R)* Math.cos(lat1),Math.cos(d / R)-Math.sin(lat1)* Math。罪(LAT2));
d =行进距离=速度x时间R =地球半径