Last updated 2019-12-22.
Kartalla displays in real-time the location of public transport vehicles in Finland based on the position, route and timetable information published by HSL and Finnish Transport and Communications Agency as open data. If measured vehicle positions are not available then positions are computed based on route and timetable information. Measured vehicle positions are available only for some HSL routes. Whether measured or computed positions are used the shown vehicle position may and is even likely to differ from the actual location.
The location is presented as an icon colored based on the type of the vehicle (bus, train, tram, metro, ferry or airplane). The visibility of the icons by type can be controlled by the buttons below the map. The form of the icon is a square for one minute before the departure time and a circle for one minute after the arrival time. In between the form of the icon is an array pointing into the direction the vehicle is moving to. Information like in the following example is shown when pointer is moved over an icon (computed vehicle position).
When measured vehicle positions are used the route name is shown inside a white circle in the vehicle icon. The longer the duration from the last position measurement the more transparent the icon is. The duration is also shown as Update in the route information.
Here are some maps displaying the location of public transport vehicles based on measured location.
Kartalla consists of two parts: gtfs2json and browser based graphical user interface. The former formats the route and timetable data published in GTFS format into compressed format more suitable for the latter to use. The source code of both parts is available at GitHub.
gtfs2json compresses GTFS files (calendar.txt, calendar_dates.txt, routes.txt, shapes.txt, stop_times.txt, stops.txt, trips.txt) into one JSON file. The size of HSL GTFS files is about 400-600 megabytes (40-60 megabytes in ZIP format) and the size of the JSON file is about 3 megabytes. The high compression ratio is achieved by skipping irrelevant parts in GTFS files and encoding the relevant parts in less verbose form. gtfs2json is implemented in Python programming language.
The browser based user interface downloads from a web server the JSON file created by gtfs2json. It then displays the locations of the public transport vehicles as icons on a map using either Leaflet library (using map data from Mapbox, OpenStreetMap or HSL) or Google Maps JavaScript API. The JSON file is downloaded as a compressed file if the browser supports HTTP compression. In that case size of the downloaded file is about 0.5 megabytes. The user interface is implemented in JavaScript programming language and it utilizes HTML, CSS and SVG technologies.
Measured vehicle positions are downloaded in JSON format from HSL's server using MQTT protocol.
Information like in the following example is shown when pointer is moved over the word Data below the map.
The user interface can be controlled with the following URL parameters.
Following are examples of the usage of the parameters.
Panu Ranta, panu.ranta@iki.fi