Learning a new technology is much more fun when you actually have a mission. So I decided to make a little web app that can show the departure times of streetcars in Toronto.
You can see the end result in the screenshot below, or try the app yourself on my test server. (If it is down, clone the code from Github, it is very simple to run the web app)
Many thanks to Sean Martell for his superhero CSS skills to make it look so good.
There is a good chunk of XML parsing in the app using clj-xpath and I also implemented a very basic geo-spatial database that currently has a naive
find-objects function, but is plenty fast. (Less than a millisecond to find stops in a database with more than 10000 entries. Yay for JVM speed.)
The app has two modes of operation:
- Location based - where it will ask your browser for your current location and then show departure times for streetcars and buses within a 250 meter radius. This is the default. See Demo (Only finds stops if you are in Toronto)
- Preconfigured stops - this uses a list of stops that you can provide. The current app has two, one for where I work and one for where I sometimes play. You can change the list of stops in
index.jsand reference a configuration by putting it's name in the location hash. See Demo
The project is open source and you can find the code at https://github.com/st3fan/departures-board