Skip to content

feat: add --gpx flag for travel route overlay#224

Open
tmchow wants to merge 5 commits intooriginalankur:mainfrom
tmchow:feat/gpx-travel-route-overlay
Open

feat: add --gpx flag for travel route overlay#224
tmchow wants to merge 5 commits intooriginalankur:mainfrom
tmchow:feat/gpx-travel-route-overlay

Conversation

@tmchow
Copy link
Copy Markdown

@tmchow tmchow commented Apr 3, 2026

Summary

Adds a --gpx flag that accepts a GPX file path and renders the GPS track as a colored line overlay on the poster. Uses stdlib xml.etree.ElementTree for parsing and pyproj (already installed via osmnx) for coordinate transformation.

Why this matters

The JS variant (dimartarmizi/map-to-poster) has travel path plotting built in. Paid services like MixPlaces sell route map posters as a core product. The Python CLI had no route visualization.

GPX is the standard format exported by Strava, Garmin, Apple Watch, and every GPS app, so this covers the most common use case for commemorating a hike, run, or bike ride on a poster.

Changes

  • parse_gpx(gpx_path) (new function): parses GPX files using stdlib XML, extracts <trkpt> lat/lon pairs. Handles the GPX 1.1 namespace. Returns empty list with error message on malformed files.
  • --gpx CLI argument: optional path to a GPX file
  • Route rendering in create_poster(): transforms lat/lon to the projected CRS via pyproj, draws the route with ax.plot() between the road layer and gradient fades (zorder 8). Line width scales with poster dimensions.
  • route_color theme field (new, optional): each of the 17 built-in themes gets a hand-picked accent color chosen to contrast with both the background and road network. Warm themes get cool complements (teal, plum), cool themes get warm accents (orange, coral). Custom themes fall back to the text color.
  • README: documents route_color as an optional theme field

Usage

python create_map_poster.py --city Paris --country France --theme terracotta --gpx my_walk.gpx

All themes with route overlay

image

Testing

  • Syntax check passes (python -m compileall)
  • flake8 passes (max-line-length=160, matching CI config)
  • Tested with a 16-trackpoint GPX route across all 17 themes
  • Route visible on both light themes (terracotta, autumn) and dark themes (midnight_blue, noir, neon_cyberpunk)

This contribution was developed with AI assistance (Codex).

tmchow added 5 commits April 3, 2026 11:27
Parse GPX files with stdlib xml.etree.ElementTree and render the
GPS track as a colored line on the map poster. The route is drawn
after roads but before gradient fades, using pyproj (already
installed via osmnx) for coordinate transformation.

Route color defaults to the theme's road_motorway color. Themes
can override it with an optional route_color field.
Default route color changed from road_motorway (blends in) to
#E74C3C (bright red). Line width increased from 3.0 to 5.0 scale
units. zorder raised to 8 so the route draws above roads and water.
Route color now falls back to the theme's text color instead of a
hardcoded red. The text color is always chosen by each theme to
contrast with its background, so the route is visible on both
light and dark themes. Themes can still override with route_color.
Each theme gets a deliberately chosen route accent color that
contrasts with both the background and road network. Warm themes
get cool complements (teal, plum), cool themes get warm accents
(orange, coral). The route_color field is optional for custom
themes and falls back to the text color.
@mvanhorn
Copy link
Copy Markdown

mvanhorn commented Apr 3, 2026

that image looks so pretty

@tmchow
Copy link
Copy Markdown
Author

tmchow commented Apr 7, 2026

that image looks so pretty

Ha, thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants