Note: the video is very laggy due to some issues with screen recording. Please look at the screenshots, or just check out the online demo at http://firefly.nu:5000/ directly!

Inspiration

Sometimes it feels like you have to make a lot of transfers to reach your destination. But do you really? How far can you actually reach by train? Our goal was to visualize this!

What it does

Shows a map of Sweden, with train stations highlighted by dots. Interacting with the map allows you to show all routes passing through a given city, as well as routes that are one, two, etc changes away.

How we built it

We used the GTFS Sweden 2 dataset to find timetable and trip/route information for all of Sweden. Since this also has coordinates for all stops, we had all the data we needed to plot these routes on a map.

We then used Leaflet, powered by Openstreetmaps map tiles, to render the actual map. For convenience, we used React bindings for Leaflet, and built the frontend entirely in React.

Challenges we ran into

We ran into some performance issues when rendering the map data. These aren't fully solved yet, out of time limitations, but we managed to mitigate them somewhat by e.g. making fewer map elements interactive. It turns out that Leaflet defaults to making all map elements interactive.

For some reason the routes aren't rendered in the order we had hoped (from most to fewest hops, so that the lines representing closest routes are drawn last/on top). This is currently unresolved.

Another challenge was restricting the routes to only train routes. We restricted to routes with route_type in [100, 199], but somehow we ended up missing all trips between Duved and Storlien. This is also currently unresolved. Update: should be fixed now (15 min before deadline)! We had whitelisted train operators (for rendering performance reasons), which turned out to inadvertently exclude Norrtåg! We now include all train operators except SL, Västtrafik, Skånetrafiken & Arlanda Express.

Accomplishments that we're proud of

We managed to make something during our first hackathon!

We also managed to answer our initial question/problem, visualizing the number of transfers required to reach different destinations. This feels like a success to us! :)

What we learned

Wrapping our heads around the GTFS format was one of the main goals of this project. Additionally, learning about Leaflet and knowing how to throw elements onto an interactive map has been quite useful.

What's next for Destination Unknown

In the short run, it would be great to fix the route rendering order, performance issues, and perhaps make the map rendering slightly more palatable to the eye (colours, line thickness, markers, ...). We would also like to make sure all train routes in the dataset are actually included properly.

Another improvement that would be nice is drawing the train routes "geographically accurately". Currently, we just draw straight lines from stop to stop, rather than following the route (since the stop coordinates is what is available to us in the GTFS dataset).

Down the line, it would be very interesting to be able to switch between different parameters to visualize in a similar manner. Currently, we use colour to indicate number of train trips away/number of transfers. Maybe line thickness could be mapped to another parameter. Maybe the user could choose to map these (colour, thickness) to different parameters of their choice, from a selection. For instance: frequency of service, passenger density, cost, ...

Share this project:
×

Updates