Refactor bus/coach loading and rendering to share code.
Extract `load_road_transport()` as a shared helper for bus and coach,
combining the near-identical route rendering blocks in `get_trip_routes`
and `Trip.elements()` into single `in ("coach", "bus")` branches.
Document transport type patterns in AGENTS.md.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
c87320415f
commit
53f4252b92
3 changed files with 59 additions and 92 deletions
17
AGENTS.md
17
AGENTS.md
|
|
@ -37,3 +37,20 @@ This is a personal agenda web application built with Flask that tracks various e
|
|||
- `travel_legs()` extracts airlines, airports, and stations from individual trip travel legs
|
||||
- `calculate_yearly_stats()` aggregates stats per year including flight/train counts, airlines, airports, stations
|
||||
- `calculate_overall_stats()` aggregates yearly stats into overall totals for the summary section
|
||||
|
||||
## Travel type patterns
|
||||
Transport types: `flight`, `train`, `ferry`, `coach`, `bus`.
|
||||
|
||||
**Road transport (bus and coach)** share a common loader `load_road_transport()` in `trip.py`. `load_coaches` and `load_buses` are thin wrappers that pass type name, YAML filenames, and CO2 factor (coach: 0.027 kg/km, bus: 0.1 kg/km). Both use `from_station`/`to_station` fields and support scalar or dict-keyed GeoJSON route filenames in the stop/station data.
|
||||
|
||||
**Ferry** is loaded separately: uses `from_terminal`/`to_terminal` fields and GeoJSON routes come from the terminal's `routes` dict (always a dict, not scalar).
|
||||
|
||||
**Route rendering** (`get_trip_routes`): bus and coach are handled in a single combined block (they use the same pattern — `from_station`/`to_station`, `{type}_routes/` folder). Ferry always has a geojson file and renders as type `"train"` for the map renderer.
|
||||
|
||||
**Trip elements** (`Trip.elements()` in `types.py`): bus and coach are handled in a single combined block using `item["type"] in ("coach", "bus")`. Ferry is separate because it uses `from_terminal`/`to_terminal` and always requires `arrive` (not optional).
|
||||
|
||||
**Location collection** (`get_locations`): bus → `bus_stop`, coach → `coach_station`, ferry → `ferry_terminal` (all separate map pin types).
|
||||
|
||||
**CO2 factors** (kg CO2e per passenger per km): train 0.037, coach 0.027, ferry 0.02254, bus 0.1.
|
||||
|
||||
**Schengen tracking**: ferry journeys are tracked for Schengen compliance; bus and coach are not.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue