diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 9c1c865..2a3e18d 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -15,10 +15,10 @@ jobs: os: [windows-latest, macos-latest, ubuntu-latest] steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v2 + uses: actions/setup-python@v4 with: python-version: ${{ matrix.python-version }} cache: pip @@ -36,7 +36,7 @@ jobs: stravavis tests/gpx - name: Upload output images - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v3 with: name: images path: "*.png" diff --git a/src/stravavis/cli.py b/src/stravavis/cli.py index a07db1a..8cd2912 100644 --- a/src/stravavis/cli.py +++ b/src/stravavis/cli.py @@ -12,10 +12,29 @@ def main(): parser.add_argument( "-o", "--output_prefix", default="strava", help="Prefix for output PNG files" ) - parser.add_argument("--lon_min", default=None, help="Minimum longitude for plot_map (values less than this are removed from the data)") - parser.add_argument("--lon_max", default=None, help="Maximum longitude for plot_map (values greater than this are removed from the data)") - parser.add_argument("--lat_min", default=None, help="Minimum latitude for plot_map (values less than this are removed from the data)") - parser.add_argument("--lat_max", default=None, help="Maximum latitude for plot_map (values greater than this are removed from the data)") + parser.add_argument( + "--lon_min", + type=float, + help="Minimum longitude for plot_map (values less than this are removed from the data)", + ) + parser.add_argument( + "--lon_max", + type=float, + help="Maximum longitude for plot_map (values greater than this are removed from the data)", + ) + parser.add_argument( + "--lat_min", + type=float, + help="Minimum latitude for plot_map (values less than this are removed from the data)", + ) + parser.add_argument( + "--lat_max", + type=float, + help="Maximum latitude for plot_map (values greater than this are removed from the data)", + ) + parser.add_argument( + "--bbox", help="Shortcut for comma-separated LON_MIN,LAT_MIN,LON_MAX,LAT_MAX" + ) parser.add_argument("--alpha", default=0.4, help="Line transparency. 0 = Fully transparent, 1 = No transparency") parser.add_argument("--linewidth", default=0.4, help="Line width") parser.add_argument("--activities_path", help="Path to activities.csv from Strava bulk export zip") @@ -33,6 +52,12 @@ def main(): if os.path.isdir(args.path): args.path = os.path.join(args.path, "*") + if args.bbox: + # Convert comma-separated string into floats + args.lon_min, args.lat_min, args.lon_max, args.lat_max = ( + float(x) for x in args.bbox.split(",") + ) + if args.activities_path and os.path.isdir(args.activities_path): args.activities_path = os.path.join(args.activities_path, "activities.csv") @@ -62,7 +87,16 @@ def main(): print("Plotting map...") outfile = f"{args.output_prefix}-map.png" - plot_map(df, output_file=outfile) + plot_map( + df, + args.lon_min, + args.lon_max, + args.lat_min, + args.lat_max, + args.alpha, + args.linewidth, + outfile, + ) print(f"Saved to {outfile}") print("Plotting elevations...")