HSL departures heatmap

I created a a simple application using the HSL open data XML dump, the MapQuest Javascript API and the heatmap.js library. Here’s a screenshot:

HSL departures heatmap screenshot

HSL departures heatmap screenshot

The heatmap shows the number of departures from each stop in the HSL public transport system. It essentially answers the question “How easy is it to get away from here?”. Or, in other words, is the place “hyvien liikenneyhteyksien äärellä” (“next to good transport connections”, a common phrase in classified ads selling real estate).

The map is fully scrollable and zoomable, and there are a couple of settings available for tuning the heatmap output, accessible from the settings icon in the top right corner.

Some technical details

The application doesn’t take into account the dates when the departures are valid, it simply adds up every single departure from the XML dump. I was planning on adding a time-of-day filter as well, and maybe a selection for dates for more accurate data, but the MySQL backend unsurprisingly doesn’t excel in the kind of searches needed for this application.

The current version uses a table with pre-calculated totals, with one row for each station in the system, which gives us a row count of 7584. The full table with all the departures has 5336527 rows, and selecting from that based on the x and y coordinates just doesn’t work fast enough to be usable.

I might try switching to a MongoDB (or something similar) backend to get better performance, if I can find somewhere where I can host the data.

Should someone feel the need to develop this further, or to some other direction, here are the necessary files not downloadable off the web:

  • maps.sql – The table used by the current version
  • maps_full.sql – The full stop and station data (5M rows!)
  • ajax.php – The very simple PHP backend
This entry was posted in IT, Making stuff, Transport. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *