在特定时间给出两点的GPS定位? [英] Finding a gps location at a certain time given two points?

查看:179
本文介绍了在特定时间给出两点的GPS定位?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

ES4236中的两个gps位置:

  37.783333,-122.416667#旧金山
32.715,-117.1625#圣地亚哥

1km / min 在一条直线上(忽略高度)

如何在一定距离找到GPS坐标?类似的 SO问题 geopy 中使用VincentyDistance来计算下一个点基于方位和距离。



我想,更具体地说:


  • 我该如何计算使用 geopy


  • 使用VincentyDistance通过轴承获取下一个gps点和距离,我怎么知道我是否已经抵达我的目的地,或者我是否应该继续前进?它不需要完全在目的地被认为是到达目的地。也许任何半径为0.5公里的目的地被认为是到达。




即, p>

 导入地理区域

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

def get_current_position(d):
#使用geopy计算POS1和POS2之间的方位
#然后使用VincentyDistance得到下一个坐标

return gps_coord_at_distance_d

#如果当前位置在目的地的0.5公里范围内,则认为它已经到达
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



获取当前位置



 从geopy导入geographiclib 
导入geopy.distance

#获取第一个方位角,这应该是方位
bearing = geographiclib.WGS84.Inverse(37.783333,-122.416667,32.715,-117.1625)[2]


#现在我们使用geopy来计算一段时间内的距离
dist = geopy.distance.VincentyDistance(千米= 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

就像我说过的,我不幸无法测试这个,但我相信这是正确的。这可能会与方位计算有一些单位差异:它计算轴承的北方面积这里。对不起,如果这不完全正确,但正如我所说,因为我没有收到回应,因为我想我可能会抛出我所知道的。


If I have two known locations and a known speed, how can I calculate the current position at distance d (in km)?

For example, given:

Two gps locations in ES4236:

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

Traveling at 1km/min in a straight line (ignoring altitude)

How can I find the gps coordinate at a certain distance? A similar SO question uses VincentyDistance in geopy to calculate the next point based on bearing and distance.

I guess, more specifically:

  • How can I calculate the bearing between two gps points using geopy?

  • Using VincentyDistance to get the next gps point by bearing and distance, how do I know if I have arrived at my destination, or if I should keep going? It doesn't need to be exactly on the destination to be considered being arrived. Maybe any point with a radius of .5 km of the destination is considered 'arrived'.

ie,

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))

解决方案

Ok, figured I'd come back to this question and give it my best shot given that it hasn't seen any other solutions. Unfortunately I can't test code right now, but I believe there is a solution to your problem using both geopy and geographiclib. Here goes.

From the terminal (possibly with sudo)

pip install geographiclib
pip install geopy

Now with Python

Get Current Position

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)

Has Arrived

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

Like I said, I unfortunately can't test this, but I believe this is correct. It's possible there will be some unit differences with the bearing calculation: it calculates bearing off of North as seen here. Sorry if this isn't exactly correct, but like I said since this hasn't received a response since I figured I may as well throw in what I know.

这篇关于在特定时间给出两点的GPS定位?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆