-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupload-gpx
executable file
·30 lines (23 loc) · 895 Bytes
/
upload-gpx
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
#!/usr/bin/env python3
import argparse
import os
import subprocess
import sys
if __name__ == "__main__":
parser = argparse.ArgumentParser(description="Upload a GPX track file to a Garmin device via USB. Wrapper for gpsbabel.")
parser.add_argument("--track", help="GPX track file", type=str, required=True)
parser.add_argument("--downsample", help="Simplify track to less waypoints", type=int, default=100)
args = parser.parse_args()
command = ["gpsbabel",
"-s", "-r",
"-i", "gpx",
"-f", os.path.abspath(args.track),
"-x", "transform,rte=trk",
"-x", "simplify,count={}".format(args.downsample),
"-o", "garmin",
"-F", "usb:"]
try:
subprocess.run(command, check=True)
except subprocess.CalledProcessError as e:
sys.exit(1)
sys.exit(0)