Successfully reported this slideshow.
Your SlideShare is downloading. ×

The story behind SNCB alerts

Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Upcoming SlideShare
Jazz Hands Portfolio
Jazz Hands Portfolio
Loading in …3
×

Check these out next

1 of 55 Ad
Advertisement

More Related Content

Similar to The story behind SNCB alerts (20)

More from Open Knowledge Belgium (20)

Advertisement

Recently uploaded (20)

The story behind SNCB alerts

  1. 1. Open Belgium 2018 By Pol Dellaiera
  2. 2. Please raise your hand if...
  3. 3. Source: https://www.belate.be/
  4. 4. From door to door: ● In train: ~1h50 ● In car: ~1h15
  5. 5. 4h “lost” in public transportation
  6. 6. What to do ?
  7. 7. Sleeping
  8. 8. Reading
  9. 9. Listening to music/podcasts...
  10. 10. Working
  11. 11. Learning
  12. 12. In my case... I work.
  13. 13. How it began
  14. 14. Source: https://www.belate.be/
  15. 15. I had the idea to create a tool that would “alert” trains users of the delays.
  16. 16. SNCBAlerts (it just an ugly name) ● Open Source ● Using Symfony 4 ● Must rely on Git ● Must be pluggable
  17. 17. What is a delay ?
  18. 18. 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 delayed: The ballet performance began after a half-hour delay. Definition of “delay”
  19. 19. Where to get the data ?
  20. 20. Liveboard ● Destinations ● Departures ● Delays ● Cancellations ● Line number
  21. 21. The idea behind SNCBAlerts is to provide informations about delays and alerts in a standardized way.
  22. 22. https://irail.be
  23. 23. Data to provide ● Departure station 🆗 ● Destination station 🆗 ● Train line ❎ ● Delay (in minutes) 🆗
  24. 24. My first idea was to create a matrix of 600 columns on 600 rows… and to do it manually.
  25. 25. https://github.com/iRail/iRail/issues/334
  26. 26. After some talks with Pieter Colpaert from irail.be, he showed how I could use wikidata to complete train stations data.
  27. 27. So I started to manually edit the ~600 stations in Belgium...
  28. 28. Added informations ● Irail.be identifier ● Adjacent stations ● Connected lines ● Name normalization
  29. 29. I created a temporary tool to show me the percentage of completion of that work.
  30. 30. December 24th 2017
  31. 31. Today
  32. 32. Today
  33. 33. Today
  34. 34. A NodeJS library has been written as well, just to feed the map.
  35. 35. Neo4J, a graph database platform, was used to display the relationships in between stations.
  36. 36. https://bl.ocks.org/drupol/03813f30032b90cf11a0a33f66a79ed7
  37. 37. http://bl.ocks.org/drupol/930f851017c44e1176d3aa0a1212c369
  38. 38. The result
  39. 39. 3 gateways ● Twitter (delays >= 15 min) ● Telegram (public channel) ● Telegram Bot (custom alerts)(for now)
  40. 40. Twitter ● @sncbalerts ● 28k tweets
  41. 41. https://twitter.com/sncbalerts
  42. 42. https://twitter.com/sncbalerts
  43. 43. Telegram ● Public channel ● Bot
  44. 44. https://t.me/sncbalerts
  45. 45. https://t.me/sncbalerts_bot
  46. 46. https://t.me/sncbalerts_bot
  47. 47. ● Symfony 4 ● NodeJS ● Wikidata ● SparQL ● Heroku ● Neo4J What I learned ?
  48. 48. ● 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
  49. 49. The future
  50. 50. I’m taking my car to go to work.

Editor's Notes

  • 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 ?
  • What about the future ?

×