-
Notifications
You must be signed in to change notification settings - Fork 2
/
gpxstats
executable file
·62 lines (51 loc) · 1.84 KB
/
gpxstats
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/usr/bin/env python
import argparse
import logging
import sys
import traceback
from datetime import timedelta
import gpxlib
def main():
parser = argparse.ArgumentParser()
parser.add_argument("--speedup", help="", type=int, default=1)
parser.add_argument("--maxspeed", help="", type=int, default=70)
parser.add_argument("-v", "--verbose", help="", action="store_true")
parser.add_argument("files", nargs="*")
args = parser.parse_args()
# go through GoPro extracted files
for f in args.files:
gpx_in, points = gpxlib.read(f)
start_time = points[0].time
prev_point = None
for idx, point in enumerate(points):
if not prev_point:
prev_point = point
continue
dist = gpxlib.dist(prev_point, point)
time_diff = point.time - prev_point.time
time_diff_in_secs = time_diff.total_seconds()
time_diff_in_secs_sped_up = time_diff_in_secs * args.speedup
actual_time = start_time + timedelta(
0, (point.time - start_time).total_seconds() * args.speedup
)
if time_diff_in_secs_sped_up:
speed = dist / time_diff_in_secs_sped_up * 3600
else:
speed = 0
print(
"%05d %s (%10.5f, %10.5f) -> (%10.5f, %10.5f): %4dm in %5.3fs @ %05.2f km/h"
% (
idx,
actual_time.strftime("%m/%d/%Y %H:%M:%S"),
prev_point.latitude,
prev_point.longitude,
point.latitude,
point.longitude,
dist * 1000,
time_diff_in_secs_sped_up,
speed,
)
)
prev_point = point
if __name__ == "__main__":
main()