在给定两个点的特定时间查找 gps 位置?

Finding a gps location at a certain time given two points?

如果我有两个已知位置和一个已知速度,我如何计算距离 d(以公里为单位)的当前位置?

例如,给定:

ES4236 中的两个 gps 位置:

37.783333, -122.416667   # San Francisco
32.715, -117.1625        # San Diego

1公里/分钟直线行驶(忽略高度)

如何找到一定距离的gps坐标?类似SO question使用geopy中的VincentyDistance根据方位计算下一个点和距离。

我想,更具体地说:

import geopy

POS1 = (37.783333, -122.416667)     # origin
POS2 = (32.715, -117.1625)          # dest

def get_current_position(d):
    # use geopy to calculate bearing between POS1 and POS2
    # then use VincentyDistance to get next coord

    return gps_coord_at_distance_d

# If current position is within .5 km of destination, consider it 'arrived'
def has_arrived(curr_pos):
    return True/False

d = 50     # 50 km
print get_current_position(d)
print has_arrived(get_current_position(d))

好吧,我想我会回到这个问题并尽我最大的努力,因为它还没有看到任何其他解决方案。不幸的是,我现在无法测试代码,但我相信可以使用 geopy 和 geographiclib 解决您的问题。开始了。

从终端(可能使用 sudo)

pip install geographiclib
pip install geopy

现在 Python

获取当前位置

import geographiclib
from geopy import geopy.distance

# Get the first azimuth, which should be the bearing
bearing = geographiclib.WGS84.Inverse(37.783333, -122.416667, 32.715, -117.1625)[2]


# Now we use geopy to calculate the distance over time
dist = geopy.distance.VincentyDistance(kilometers = 1)
san_fran = geopy.Point(37.783333, -122.416667)

print dist.destination(point=san_fran, bearing=bearing)

已经到达

def has_arrived(d):
    return geopy.distance.vincenty(curr_pos, (32.715, -117.1625)).kilometers < .5

就像我说的,遗憾的是我无法对此进行测试,但我相信这是正确的。轴承计算可能会有一些单位差异:it calculates bearing off of North as seen here。抱歉,如果这不完全正确,但就像我说的那样,因为这还没有收到回复,因为我想我也可以输入我所知道的。