Add web frontend and refactor core to use OsmError

- Refactor core.py: replace sys.exit() calls with OsmError exceptions
  so the library is safe to use from Flask and other callers
- Add fetch_sibling_routes and fetch_route_master_routes to core.py
- Add Flask web frontend (web/app.py, templates, static assets):
  - Map view with Leaflet; full route drawn in grey on load
  - Sidebar stop list; active-slot UX for From/To selection
  - Segment preview and download (full route or selected segment)
  - Include-stops toggle applied client-side
  - Bookmarkable URLs: GET /<relation_id>
  - Clear selection button
  - Other directions panel (sibling routes from same route_master)
  - route_master handling: draws all member routes in colour on map
    with links to each individual direction
- Add SVG favicon
- Add py.typed marker; add .gitignore

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Edward Betts 2026-02-27 18:18:12 +00:00
parent d3e6d7ac42
commit e0ade9e5ab
13 changed files with 1049 additions and 20 deletions

View file

@ -8,6 +8,7 @@ from click.testing import CliRunner
from osm_geojson.pt import core
from osm_geojson.pt.cli import cli, output_geojson
from osm_geojson.pt.core import OsmError
FIXTURES = Path(__file__).parent / "fixtures"
FULL_URL = "https://www.openstreetmap.org/api/0.6/relation/15083963/full.json"
@ -57,8 +58,8 @@ def test_parse_elements_tags(parsed: tuple) -> None:
def test_parse_elements_unknown_relation(full_data: dict) -> None:
"""Requesting a relation ID not present in the response exits with an error."""
with pytest.raises(SystemExit):
"""Requesting a relation ID not present in the response raises OsmError."""
with pytest.raises(OsmError):
core.parse_elements(full_data, 9999999)