Skip to content

Commit

Permalink
Merge pull request #18 from hugovk/map-args
Browse files Browse the repository at this point in the history
Add --bbox CLI param as a shortcut
  • Loading branch information
marcusvolz authored Sep 3, 2022
2 parents 314ed47 + 416f6a2 commit ebb5fa2
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 8 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"
44 changes: 39 additions & 5 deletions src/stravavis/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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")

Expand Down Expand Up @@ -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...")
Expand Down

0 comments on commit ebb5fa2

Please sign in to comment.