How it works
This Coreflux LoT notebook bridges HSL’s public MQTT feed for Helsinki trams into local topics, then validates, digests, and geofences each vehicle position. It turns a live transport stream into per-tram state plus one-off downtown enter/leave events.
Key features
- MQTT bridge: Subscribes to
mqtt.hsl.fiand lands tram messages underdemo/trams/feed/raw/#. - Payload gate: Checks
VP.latbefore parsing and routes bad messages tofeed/fetch_error. - Per-vehicle digest: Writes line, latitude, longitude, speed, speed_kmh, and heading under
demo/trams/vehicle/<veh>/. - Collapsed position model: Publishes
TramPositionas a single position document for map consumers. - Downtown geofence: Detects rectangular enter/leave transitions for each tram.
What this template does
- Consumes the HFP v2 tram subset from HSL over MQTT.
- Normalizes valid vehicle positions into stable vehicle topics.
- Keeps geofence memory per vehicle with
KEEPstate. - Emits edge-triggered events only when a tram crosses the downtown box.
