diff --git a/python/gpxsimplify.py b/python/gpxsimplify.py new file mode 100644 index 0000000..344c283 --- /dev/null +++ b/python/gpxsimplify.py @@ -0,0 +1,30 @@ +#!/usr/bin/python3 + +import gpxpy +import gpxpy.gpx +import argparse + +# setup CLI parsing +parser = argparse.ArgumentParser( + prog='GPX simplifier', + description='Reduce number of points and / or remove data from GPX track to make it lighter', + epilog='') + +parser.add_argument('-f', '--filename') +parser.add_argument('-t', '--removetime', action=argparse.BooleanOptionalAction) +parser.add_argument('-d', '--maxdistance') +args = parser.parse_args() + +# parse gpx track +gpxfile = open(args.filename, 'r') + +gpx = gpxpy.parse(gpxfile) + +# drop time data +if args.removetime == True: + gpx.remove_time() + +# simplify +gpx.simplify(max_distance = float(args.maxdistance)) + +print(gpx.to_xml(prettyprint=False)) diff --git a/python/gpxsimplify.sh b/python/gpxsimplify.sh new file mode 100755 index 0000000..42666ce --- /dev/null +++ b/python/gpxsimplify.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) + +source ${DIR}/bin/activate +python3 ${DIR}/gpxsimplify.py $@ +deactivate diff --git a/python/requirements.txt b/python/requirements.txt new file mode 100644 index 0000000..4399149 --- /dev/null +++ b/python/requirements.txt @@ -0,0 +1,2 @@ +gpxpy +argparse