If you want to catch a tram in Melbourne then you need a Myki, despite the fact you can’t buy one or top it up onboard the tram. In 2017 The Age highlighted the difficulty this can pose for intending tram passengers, in an article on myki “dead zones” - tram stops where the nearest place to top up your myki is at least a kilometre away. Coincidently I started work on an almost identical project years ago but never finished it, so what better time to polish it off?
Using the Public Transport Victoria API
Back in March 2014 Public Transport Victoria finally opened up the application program interface (API) which powers their mobile apps, so I decided to have a play around with it.
With the mobile landscape already littered with hundreds of different trip planning apps, I decided to build something slightly different - something to point out how the lack of ticket purchase options onboard trams was wasting the time of the intending passengers.
The API allows programmers to access all kinds of data - tram routes and Myki retailers being two of them, so I built an app that caters for two use cases:
- you're at home, work, or a friend's house - and you've discovered that you don't have a Myki on hand. Where is the nearest place to buy a new one, and how far will this detour take compared to purchasing a ticket onboard the tram?
- you've just stepped onto a tram and discovered that you don't have any credit left on your Myki. How far will you have to walk to top up, and then where can you get back on your way?
The end result is ‘walki’ - a small app that works on any device with a web browser.
The logic in the app is as follows:
- Show the user their current location,
- Calculate distance to nearest tram stop,
- Calculate distance to nearest Myki retailer,
- Calculate distance from Myki retailer back to nearest tram stop,
- Plot the walking routes on a map,
- Compare the distances for each,
- And finally, show the user much further they have to walk thanks to the lack of ticket sales onboard trams.
The app itself isn’t anything revolutionary from a technology standpoint.
The files are all hosted on my vanilla Apache web server, and you can find the source code on GitHub.