diff --git a/js/gpx.js b/js/gpx.js index e797ef1..9770b9f 100644 --- a/js/gpx.js +++ b/js/gpx.js @@ -162,6 +162,7 @@ }).addTo(map) } +// TODO this list should be built server-side at startup const ta = [ this.addGPX(map, '../tracks/turin_09122022.gpx', 'red'), this.addGPX(map, '../tracks/biella_27122022.gpx', 'blue'), diff --git a/python/tracklist.py b/python/tracklist.py new file mode 100644 index 0000000..6408cd0 --- /dev/null +++ b/python/tracklist.py @@ -0,0 +1,24 @@ +#!/usr/bin/python3 + +# load GPX tracks from a provided directory and output a json file listing all of them + +import os +import glob +import json +import argparse + +# setup CLI parsing +parser = argparse.ArgumentParser( + prog='GPX track list builder', + description='load GPX tracks from a provided directory and output a json file listing all of them, paths are relative to the calling directory', + epilog='') + +parser.add_argument('-d', '--dir') +args = parser.parse_args() + +# list all files in args.dir +tracks = { + "tracklist": glob.glob(f"{args.dir}/*.gpx", recursive=True) + } + +print(json.dumps(tracks))