【发布时间】:2016-07-27 17:43:07
【问题描述】:
如果我有两个已知位置和一个已知速度,我如何计算距离 d(以公里为单位)的当前位置?
例如,给定:
ES4236 中的两个 gps 位置:
37.783333, -122.416667 # San Francisco
32.715, -117.1625 # San Diego
以1km/min直线行驶(忽略高度)
如何在一定距离找到gps坐标?类似的SO question使用geopy中的VincentyDistance根据方位和距离计算下一个点。
我猜,更具体地说:
如何使用
geopy计算两个gps 点之间的方位角?使用 VincentyDistance 通过方位和距离获取下一个 gps 点,我如何知道我是否已到达目的地,或者是否应该继续前进?它不需要完全在目的地上才能被视为到达。也许任何距离目的地 0.5 公里半径的点都被认为是“到达”。
即,
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))
【问题讨论】:
-
@James 啊,谢谢,但这计算的是向北 1 公里(按方位)而不是向第二点的距离。此外,我在 geopy 中找不到任何关于
VincentyDistance的文档,所以我很难确定它是否可以基于两点进行计算。
标签: python python-2.7 gps geolocation coordinate-systems