Add Thurgau traffic visualizer and start page #1

Merged
clayschaad merged 3 commits from feature/traffic-visualizer into main 2026-11-06 20:17:26 +00:00
Owner

Summary

First version of OpenDataVisualizer: a start page with map tiles and an animated map of the canton of Thurgau's hourly traffic counts (opendata.swiss / data.tg.ch, CC0).

  • Backend (ASP.NET Core 10, Schaad.OpenData.*): refreshes the data from data.tg.ch every 6 h into a per-day JSON cache, so history grows beyond the source's two-week window; minimal API under /api/traffic/*; serves the built client.
  • Road geometry: each station's two directions are snapped to the real road using swisstopo swissTLM3D and oriented by geocoding the target town. Roundabout arms (… Kreisel …) run outward from the roundabout centre, which is derived from the sibling stations, and prefer the street named in the station address.
  • Map (React + Leaflet): vehicles drive as dots along the roads in both directions, with density by hourly count, colour by vehicle class and right-hand traffic. Play/pause, time slider, day selection and a swisstopo base map switcher (grey, colour, aerial).
  • Station panel: counts per vehicle class for the current hour, plus Chart.js charts for hourly values, weekday/weekend profile, daily totals and class mix.
  • Start page at / with one large tile per map (registry in client/src/maps.ts); the traffic map lives at /verkehr/thurgau.
  • Docker: multi-stage Dockerfile and docker-compose.yml with a data volume.

Test plan

  • dotnet test: 48 tests (mapping, cache, geometry, geocoding, analysis)
  • Ran locally: data import, geometry for all 64 stations, playback, station panel, base map switcher, start page navigation and deep links
  • Docker image builds and the container imports the data on first start (about 100 s)
  • One station path is still short: "Kreisel Wiler-/Dufourstrasse – Frauenfeld" (181 m)

🤖 Generated with Claude Code

## Summary First version of OpenDataVisualizer: a start page with map tiles and an animated map of the canton of Thurgau's hourly traffic counts (opendata.swiss / data.tg.ch, CC0). - **Backend** (ASP.NET Core 10, `Schaad.OpenData.*`): refreshes the data from data.tg.ch every 6 h into a per-day JSON cache, so history grows beyond the source's two-week window; minimal API under `/api/traffic/*`; serves the built client. - **Road geometry**: each station's two directions are snapped to the real road using swisstopo swissTLM3D and oriented by geocoding the target town. Roundabout arms (`… Kreisel …`) run outward from the roundabout centre, which is derived from the sibling stations, and prefer the street named in the station address. - **Map** (React + Leaflet): vehicles drive as dots along the roads in both directions, with density by hourly count, colour by vehicle class and right-hand traffic. Play/pause, time slider, day selection and a swisstopo base map switcher (grey, colour, aerial). - **Station panel**: counts per vehicle class for the current hour, plus Chart.js charts for hourly values, weekday/weekend profile, daily totals and class mix. - **Start page** at `/` with one large tile per map (registry in `client/src/maps.ts`); the traffic map lives at `/verkehr/thurgau`. - **Docker**: multi-stage `Dockerfile` and `docker-compose.yml` with a data volume. ## Test plan - [x] `dotnet test`: 48 tests (mapping, cache, geometry, geocoding, analysis) - [x] Ran locally: data import, geometry for all 64 stations, playback, station panel, base map switcher, start page navigation and deep links - [x] Docker image builds and the container imports the data on first start (about 100 s) - [ ] One station path is still short: "Kreisel Wiler-/Dufourstrasse – Frauenfeld" (181 m) 🤖 Generated with [Claude Code](https://claude.com/claude-code)
clayschaad added 3 commits 2026-11-06 20:15:17 +00:00
ASP.NET Core 10 API and React client that visualize the canton of
Thurgau's hourly traffic counts by vehicle class (data.tg.ch, CC0).

- Background refresh from data.tg.ch every 6 h into a per-day JSON
  cache, so history grows beyond the source's two-week window
- Road geometry per station direction from swisstopo swissTLM3D,
  oriented by geocoding the direction's target town; roundabout arms
  follow the road outward only
- Leaflet map with canvas animation: dots drive along the road in
  both directions, density by hourly count, colour by vehicle class,
  right-hand traffic; play/pause, time slider and day selection
- Station panel with per-class counts and Chart.js charts (hourly,
  weekday/weekend profile, daily totals, class mix)
- swisstopo base map switcher (grey, colour, aerial)
- Dockerfile and docker-compose with a data volume
- xUnit tests for mapping, cache, geometry, geocoding and analysis

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Stations like "WEINFELDEN Kreisel West - Umfahrung" have directions
such as "zur Umfahrung" or "von Egelseestrasse" that cannot be
geocoded, so their dots were drawn on a nearby side road or around
the roundabout ring.

- Derive the roundabout centre from all stations sharing the name
  before " - " and point each arm outward from it
- Prefer road segments named like the station's address when
  following an arm; reject arms that don't get away from the centre
- Parse "zur", "zum", "Richtung" and "vom" direction prefixes
- Treat only swissTLM3D object kinds 12-19 as non-roads; kind 20 is
  a regular road (e.g. Dunantstrasse in Weinfelden)
- Bump the geometry cache to v7 so all stations are rebuilt

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The app will show several maps and datasets, so it now opens on a
start page with one large tile per map instead of the traffic map.

- Routing with react-router-dom: "/" is the start page, the Thurgau
  traffic map moved to "/verkehr/thurgau" (pages/TrafficThurgauPage)
- Map registry in src/maps.ts drives the tiles (title, region,
  description, tags, source, preview image)
- SVG preview illustration for the traffic map tile
- Traffic map header links back to the start page; page titles set
  per page

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
clayschaad merged commit 7b65926aa2 into main 2026-11-06 20:17:26 +00:00
clayschaad deleted branch feature/traffic-visualizer 2026-11-06 20:17:26 +00:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: clayschaad/OpenDataVisualizer#1
No description provided.