A private project, built for fun

How this thing works

HSL vehicle · reports its position every second

Every bus, tram, metro, train and ferry in the Helsinki region broadcasts where it is. This site collects that, stores it, and works out how punctual each line really is.

Scroll

1 · The vehicle

On the road it reports its position, speed and predicted arrival at every remaining stop. HSL publishes all of it openly, as GTFS-RT feeds that anyone may read.

2 · The data

Vehicle position · delay GTFS-RT · protobuf Collector Python · every 20 s matches the timetable SQLite one file, on the server JSON Your browser draws the map

A small Python collector polls the feeds every 20 seconds, matches each running trip against the printed timetable, and works out the delay as predicted minus scheduled. HSL's feed carries no delay figure, so this is computed here.

3 · The project

steering wheel transitanalysis.ch live map delays cancellations every trip, every day, kept for good

The result is two views: a live map of everything moving right now, and analytics built from history the collector gathers day after day.

Built with

Small pieces, each doing one job

No framework, no build step, no paid service. Everything below runs on a single small server.

Python

Collector

Reads the GTFS-RT protobuf feeds, matches trips to the timetable and writes the delays. Runs as its own container, restarted automatically.

Python

Flask

Serves the pages and a small read-only JSON API. It never writes to the database, so a bug here cannot damage the history.

JavaScript

Map and pages

MapLibre GL draws the vehicles on a dark vector map. Everything else, including this page's scroll animation, is plain JavaScript.

SQL

SQLite

One file holds the timetable, the live snapshot and the permanent per-trip history. Write-ahead logging lets the site read while the collector writes.

Docker

Three containers

Collector, timetable loader and web app, from one image, sharing one volume.

Caddy

In front

Reverse proxy and automatic HTTPS, shared with the other sites on the same machine.

Interfaces

What is read, and what is offered

Read from HSL. Three real-time feeds and one timetable package, all open data under CC BY 4.0, no key required. Vehicle positions update every second and trip updates every 15 seconds; this site samples them every 20 seconds, which is plenty for delay statistics and keeps the load light.

The browser asks for vehicles every 10 seconds and holds no connection open, so the server stays cheap to run and the page recovers by itself after a dropout.

Batch work

What runs on a clock

Analytics need this patience. A weekday pattern needs weeks, and a seasonal one needs months, so the charts get more interesting the longer the collector runs.

This is a personal side project, made out of curiosity rather than for anyone's business. It is not affiliated with HSL. Transport data © HSL, used under CC BY 4.0. Map data © OpenStreetMap contributors.

Open the live map Analytics