gpt4 book ai didi

python - 如何从一组 GPS 点中获取 "fastest miles"的列表

转载 作者:塔克拉玛干 更新时间:2023-11-03 03:02:10 25 4
gpt4 key购买 nike

我正在尝试解决一个奇怪的问题。也许你们知道一些算法可以解决这个问题。

我有 cargo 卡车的数据,想提取一些数据。假设我有一个从 GPS 获得的排序点列表。那是那辆卡车的路线:

[
{
"lng": "-111.5373066",
"lat": "40.7231711",
"time": "1970-01-01T00:00:04Z",
"elev": "1942.1789265256325"
},
{
"lng": "-111.5372056",
"lat": "40.7228762",
"time": "1970-01-01T00:00:07Z",
"elev": "1942.109892409177"
}
]

现在,我想要得到的是“最快里程”列表。我举个例子:

鉴于积分:

A, B, C, D, E, F

A点到B点的距离为1英里, cargo 用时10:32分钟。从 B 点到 D 点我还有一英里, cargo 需要 10 分钟,等等。所以,我需要一个按时间排序的列表。类似于:

B -> D: 10
A -> B: 10:32
D -> F: 11:02

你知道有什么有效的算法可以让我计算吗?

谢谢大家

PS:我使用的是 Python。

编辑:

我知道距离了。我知道如何计算它,并且有很多帖子可以做到这一点。我需要的是一种算法,可以按英里标记并从中获得速度。具有距离功能还不够有用:

results = {}
for point in points:
aux_points = points.takeWhile(point>n) #This doesn't exist, just trying to be simple
for aux_point in aux_points:
d = distance(point, aux_point)
if d == 1_MILE:
time_elapsed = time(point, aux_point)
results[time_elapsed] = (point, aux_point)

我仍在做一些非常低效的计算。

最佳答案

如果您有获取位置数据时的位置和时间戳,您可以简单地执行以下操作:

def CalculateSpeeds(list_of_points_in_time_order):
"""Calculate a list of (average) speeds for a list of geographic points."""

points = list_of_points_in_time_order
segment_start = points[0]
speed_list = []

for segment_end in points[1:]:
dt = ElapsedTime(segment_start, segment_end)
# If you're looking at skipping points, with a slight risk of degraded data
# you could do something like "if dt < MIN_ELAPSED_TIME:" and indent
# the rest of the loop. However, you'd need to then check if the last point
# has been accounted for, as it might've been too close to the last considered
# point.
d = Distance(segment_start, segment_end)
speed_list.append(d/dt)
segment_start = segment_end
return speed_list

您已经说过(在评论中)您可以对单个对执行此操作,因此您需要做的就是对所有连续的对执行此操作。

关于python - 如何从一组 GPS 点中获取 "fastest miles"的列表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11325694/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com