1. the act of delaying; procrastination; loitering.
2. an instance of being delayed: there were many delays
during the train trip.
3. the period or amount of time during which something is
The ballet performance began after a half-hour delay.
Definition of “delay”
● Symfony 4
What I learned ?
● A Twitter account spamming its subscribers with trains
delays greater than 15 minutes.
● A Telegram channel spamming subscribers with delays
greater than 1 minute
● A Telegram bot that subscribers are able to customize to
receive their delays and alerts in “real time”.
What I give back
Hello everyone, welcome to this session. First I’d like to thanks to the organizers for letting me present a small project I’ve been working on the past 3 months.
Before going deep into the subject, I would like to start by asking a question to everyone here… Who’s relying on public transportation to go to work ?
If some of you are using the trains in Belgium, I guess, sadly, that you are used to this kind of liveboard… If not, let me tell you about my own experience.
I used to live in Mons for 36 years and as you can see, and since a couple of days ago, I was living in the worst part of Belgium when it comes to punctuality of trains.
It used to take me almost 2 hours per day to go to work with trains… and 1h15 by car if I leave home early in the morning around 6h00.
If you do the math, it’s 4 hours lost in public transportation.
If some of you are like me and hate wasting time doing nothing, then the question that I’d like to ask is… What to do when you waste 4h every day to go to work ?
Some of you might say: Sleeping. Which is a very good idea, I love sleeping. But in my train, it’s most of the time, impossible. The line 97/96 which is the one I was using are equipped with old trains, without automatic doors and not well isolated agains all kind of noises.
The second choice is reading. Either to learn stuff or to just relax.
The third option is to listen to music or podcasts. Of course with a reasonable volume to not disturb your neighbors. Trust me, this never happend.
The fourth option is to work, this is my favorite option, because it allows you to focus on something else quickly.
The last option is to learn stuff by reading.
In my case, my favorite activity in the train besides sleeping when it’s not too noisy, is working on my personal projects.
Being a long time contributor to the Drupal OpenSource community, I usually maintain and develop my personal modules. Drupal is a framework/cms written in PHP and created by Dries Buytaert a fellow belgian.
So, how the story of my project began ?
Just because of this. I was tired to not have a practical way to check if my trains were late or not. Tired of the lack of consistency in these data. We are at the edge of 2020 and we still do not have a way to check if a train will be late or not in a consistent way.
So, I had the idea to create a tool that would send users the trains delays and alerts.
So I created SNCBAlerts which is a platform that gather delays and alerts of belgian trains, then this send those data to different gateways. SNCBAlerts is OpenSource, using Symfony 4, relies on Git for many things, and is pluggable.
Before going further, the main question that everyone should ask himself is, “what, in the end, is a delay” ?
According to the internet, this is the definition of a delay. But in our case, my case, a train delay is when the train doesn’t leave at the right time. According to SNCB, a delay is when your train has more than 15 minutes of late. Which is completely unfair, but it’s not the main subject of the presentation.
Where to get those delays ? Are they available somewhere ?
Of course, you can find them on the liveboard of each stations in Belgium.
A liveboard provides information about destinations, departures, delays, cancellations… and unfortunately, it doesn’t provides the train line.
But… the idea of SNCBAlerts is to provide informations about delays and alerts in a standardized way.
This is why it relies on irail.be from Pieter Colpaert to get its data.
Irail.be provides information about the departure, the destination, the delays, the cancellations, but not the train line. So, the first version of SNCBAlerts was not having those train line information.
In order to get these information, as I didn’t find it anywhere on the internet, was to create a matrix of ~600 columns on ~600 rows, which makes about ~36000 cells and to complete that grid manually. Of course, if you think about it, it would only require the half of the cells because the train line from a station A to B is the same as from B to A. But still … 18000 cells.
To be honest, I started the document on Google Docs… and it was completely unmaintainable. I had to find another way to do this.
So, I created an issue on the irail project on Github to have some feedback.
And after a talk with Pieter Colpaert, I deleted the Google Doc I was creating to use Wikidata. A tool that I didn’t even know it existed.
So, I started to edit the ~600 stations in Belgium on Wikidata… even if it’s a lot, it much better than filling 18000 cells in a spreadsheet.
The added informations on Wikidata are the following… As each station on irail.be has an identifier, I filled a property on each station on wikidata with the station identifier from irail. I also added adjacent stations, connected lines and also normalized some stations names.
I had no way to have the big picture of what is done and what is left to do… so I created a small map with informations from irail and wikidata. The map is showing belgian stations on a map. Based on the state of completion, the markers were red meaning that most of the informations were missing. Yellow, meaning that there were missing informations, and green meaning that everything was ok.
This is a screenshot of the tool… as you can see, most of the stations were already done.
Today the map looks like this. Most of the belgian stations are green, some of them are still in yellow. In this case, it doesn’t means that there are missing information, it just means that they only have one adjacent station, they are the last stations on a line.
Here’s a glimpse of the information that you can get when you click on a station with a yellow marker. As you can see, there is only one adjacent station.
If you click on a green marker, you can see that all the information are there.
In order to display this live map, I wrote a nodejs library just to feed the map. This library has been extended since and can be used to query irail.be and cross those data with wikidata quite easily.
The nodejs/npm package is Opensource and available for everyone, the name is irail-api.
The tools you’ve seen were great, but it was not enough to visually check the consistency of the “adjacent stations” property.
What you see here is a map showing belgian railway stations and their link in between each others. To draw the map, Neo4J and D3 were used.
I really enjoyed doing that part, it’s actually the part I liked the most. I liked it so much that I did the same for the metro stations in London. It’s not possible to do it for the Brussels metro, a lot of informations are missing on Wikidata.
So, enough talking, what’s the result of all of this ?
3 gateways or plugins are available and Open Source: The twitter account, the Telegram channel and a Telegram bot.
The twitter account SNCBAlerts is up since the 6 of December and now has more than 28 thousands tweets so far.
Here’s a message from @sncbalerts on Twitter when it was the first version.
And thanks to the data on Wikidata, we can now get the line information in the message.
The telegram gateway provides a public channel that everyone can join and see “real time” alerts and delays. This is very hard to follow what is going on there because there’s so much information that it’s unusable. This is why I created a bot that users can customize at will.
Here’s a screenshot of the Telegram web application and the SNCB Alerts public channel.
And here’s a screenshot of the Telegram web application and the SNCB Alerts bot. As you can see, you can query it inline.
If you’re using Telegram, you can use the bot today by following the url that you can find on the Twitter bio.
What are the things that I learned by doing this ?