Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add --bbox CLI param as a shortcut #18

Merged
merged 3 commits into from
Sep 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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