2.5 KiB
Untitled Realtime Train Map
we should probably work out a name lol
Overview
The project is to create a map that shows the real-time locations of selected trains on the Network Rail network in the UK.
For a given train it should display the current interpolated location of the train, any stations that it will call at and the approximate route that it'll take.
Aspirationally, it should be able to track multiple trains at any one time, with the option to show all trains on the network.
Data sources
The Project will source data from multiple Network Rail Open Data Feeds:
- Train Movements will be used to retrieve the real-time location of trains on the Network Rail network.
- SCHEDULE will be used to retrieve train scheduling information.
Additionally, the project will make use of the OpenStreeMap Overpass API to source data about track layout. It may also be used to find station locations.
Architecture
In addition to a Redis database, there are three main components to the project:
- A data processing application that consumes the real-time feeds supplied by Network Rail
- A Python API server that powers the frontend application
- The frontend JavaScript application
Redis Database
The Redis database will store:
- Real-time train location by train ID
- Schedule information
- TIPLOC information (see below)
Data sources
SCHEDULE
Authoritatitve scheduling information can be retrieved from Network Rail by downloading a single file. This will be parsed and loaded into the Redis database.
The downloads contain information about schedules and TIPLOCs, where a TIPLOC is an identifier for a physical location on the rail network. Every schedule contains timings for when a given service will pass through a given set of TIPLOCs.
Each schedule is identified with a so-called "headcode".
Train Movements
The Train Movements (herein referred to as TM) feed provides real-time updates as to where a train is. It emits messages of different types, documented below:
Activation
messages link a train ID to a headcode. No other messages types do this, so if the activation message is missed we will be unable to adequately understand any other messages relating to that train.
TIPLOC Information
TIPLOCs can be mapped to real-world Northings and Eastings and hence then used as