Since Realtime Trains launched a couple of weeks ago, I’ve been pondering on how to fix what I call the black hole of the Chilterns.
Chiltern Railways has a small network that operates out of London Marylebone. The lines it operates split at Neasden operating up towards High Wycombe and Princes Risborough with the other line heading up towards Harrow, Amersham and Aylesbury – and this is the black hole.
Chiltern Railways services operate on London Underground rails between Harrow South Jn. and Mantles Wood (north of Amersham). Between these two locations, the trains go as good as missing.
TRUST gives us some data at Harrow-on-the-Hill and Amersham, in both directions, by applying an offset to the moves made on the train describers. Other than that, TRUST provides no information at intermediate locations and the Train Describer (TD) feeds just step up in quick succession to act as an effective ‘first in first out’ queue.
As such, we need a secondary data source. Fortunately, London Underground have a system called Trackernet and this is published as a processed open data set by TfL. Emil at Citymapper gave a helpful suggestion earlier this week and I was able to do a bit more work and crack the puzzle.
The problem of following trains through Trackernet was the initial puzzle, although it turns out to be quite easy! Within the feed there is an ‘LCID’ identifier (supposedly Leading Car IDentifier), and it was quite straight forward to just follow around with that.
Then came the problem of matching a Trackernet train up to a train on the national railway network. Not easy, as it turns out. Here’s an extract from the output of a Chiltern Railways service moving through the area (from TD):
2012-12-17 20:47:40: [box ME] 0021 -> 00232012-12-17 20:48:10: [box ME] 0023 -> 00252012-12-17 20:48:46: [box ME] 0025 -> 00272012-12-17 20:49:49: [box ME] 0027 -> RJB12012-12-17 20:49:49: [box ME] intr -> XJB12012-12-17 20:51:34: [box ME] RJB1 -> 0JB12012-12-17 20:52:45: [box ME] 0JB1 -> 09132012-12-17 20:52:45: [box ME] 0913 -> 09112012-12-17 20:52:45: [box ME] XJB1 -> cancel2012-12-17 20:52:45: [box ME] 0911 -> 09092012-12-17 20:52:45: [box ME] 0909 -> 09072012-12-17 20:52:46: [box ME] 0907 -> 09052012-12-17 20:53:24: [box ME] 0905 -> 09032012-12-17 21:20:07: [box ME] 0903 -> 09012012-12-17 21:22:31: [box ME] 0901 -> 03752012-12-17 21:23:27: [box ME] 0375 -> 0379
My emphasis (where the train is on London Underground metal) is in bold. Trackernet will give you a hint of train direction by the platform the train is expected to be on, but I elected not to use this (I’m crazy – but I’m also lazy). You can see the train arriving into Harrow (RJB1, etc) and then stepping through the queues in quick succession (0913 -> 0903) and then leaving Amersham with the move from 0903 to 0901.
In order to fetch a train identity for Trackernet usage, I simply, upon arrival at either Harrow or Amersham – depending on the direction of travel, alert Trackernet of an oncoming train. The next train that pops up in either direction then will fetch that identity and it will track along separately to that in the TD feed.
Once the train is tracking in Trackernet, all I do then is have a match-up table of TrackCode to TIPLOC (what Realtime Trains uses for locations) and an time offset. We don’t know departure times – so they’re guessed but RTT assumes a train can’t leave early.
That’s a pretty vast simplification of how it works – but it does the trick. Oh, and that train I pasted above – it reported through Trackernet (rollover the times, a tooltip will come up):