How toget a list of "fastest miles" from a set of GPS Points
Posted
by
santiagobasulto
on Stack Overflow
See other posts from Stack Overflow
or by santiagobasulto
Published on 2012-07-04T08:55:55Z
Indexed on
2012/07/04
9:16 UTC
Read the original article
Hit count: 279
I'm trying to solve a weird problem. Maybe you guys know of some algorithm that takes care of this.
I have data for a cargo freight truck and want to extract some data. Suppose I've got a list of sorted points that I get from the GPS. That's the route for that truck:
[
{
"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"
}
]
Now, what I want to get is a list of the "fastest miles". I'll do an example:
Given the points:
A, B, C, D, E, F
the distance from point A to point B is 1 mile, and the cargo took 10:32 minutes. From point B to point D i've got other mile, and the cargo took 10 minutes, etc. So, i need a list sorted by time. Similar to:
B -> D: 10
A -> B: 10:32
D -> F: 11:02
Do you know any efficient algorithm that let me calculate that?
Thank you all.
PS: I'm using Python.
EDIT:
I've got the distance. I know how to calculate it and there are plenty of posts to do that. What I need is an algorithm to tokenize by mile and get speed from that. Having a distance function is not helpful enough:
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)
I'm still doing some pretty inefficient calculations.
© Stack Overflow or respective owner