From def0f995e59c3d2bcaa40185b1d82a5049033eab Mon Sep 17 00:00:00 2001 From: typebrook Date: Tue, 10 Dec 2019 14:56:47 +0800 Subject: update --- scripts/gpx/check_gpx.py | 87 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100755 scripts/gpx/check_gpx.py (limited to 'scripts/gpx/check_gpx.py') diff --git a/scripts/gpx/check_gpx.py b/scripts/gpx/check_gpx.py new file mode 100755 index 0000000..f1e5c2f --- /dev/null +++ b/scripts/gpx/check_gpx.py @@ -0,0 +1,87 @@ +#!/usr/bin/env python3 + +import sys +import os +import argparse +import copy +import fileinput +from osgeo import ogr +import osr +import urllib.parse + +def rewrite_gpx(filename): + for line in fileinput.input(filename, inplace=True): + if fileinput.isfirstline() and "'" in line: + line = '' + if fileinput.filelineno() == 2 and "version" not in line: + line = line.replace('= threshold: + if not flag: + print(f'{filename} has problem, check with the folling urls:') + print() + flag = True + if add_prefix: + dir = os.path.dirname(filename) + if dir: + dir += '/' + os.rename(filename, f'{dir}invalid_{os.path.basename(filename)}') + + geojson = '{{"type": "LineString", "coordinates": [[{}, {}], [{}, {}]]}}'.format( + geom1.GetX(), geom1.GetY(), + geom2.GetX(), geom2.GetY() + ) + encoded = urllib.parse.quote(geojson) + print('http://geojson.io/#data=data:application/json,{}'.format(encoded)) + print() + else: + break + trkpt = nextTrkpt + +def main(argv): + parser = argparse.ArgumentParser() + parser.add_argument('file', help="you can add multiple gpx files at the same time", nargs='+') + parser.add_argument("-i", help="add prefix to invalid files", action="store_true") + parser.add_argument("-d", help="distance of tolerance(m), 100 by default", dest="distance", default=100) + args = parser.parse_args() + for file in args.file: + check_valid(file, args.distance, args.i) + + print(args.distance) + +if __name__ == '__main__': + main(sys.argv) -- cgit v1.2.3-70-g09d2