Introducing Commuter: Commute Times on the Command-Line
Driving in Toronto sucks.
There’s a distance of approximately 36 kilometers (22 miles) between my house and where I work, and without traffic its a breezy 25 minute drive. However, Toronto traffic and the 401 Highway being what they are, this drive rarely goes under 45 minutes and has gone as high as three hours during winter snow storms.
This leaves me with plenty of time to stew and rage while I sit in the middle of an unending line of cars all idling while they wait for the car in front to move. So, Google Maps and other similar apps are obviously helpful, especially with the ability to remember your frequent locations such as your home and work. What I wanted, however, is to be able to check how my commute is looking throughout the day so I can plan accordingly.
That’s where Commuter comes in. Commuter is a handy little application I wrote that uses the Google Maps API to calculate the travel time between two locations given current conditions. Where I find it particularly useful, however, is in adding aliases for frequent locations throughout the city, so I can see how long my drive home or to the gym is without leaving my terminal.
The first time you run commuter you’re prompted to enter a Google Maps API key and your default location, likely your home or work address:
$ commuter > Enter Google Maps API Key: (developers.google.com/console) 123APIKEY456 > Enter Your Default Location: (ex. 123 Main St. Toronto, Canada) 123 Main St. Toronto, Ontario
The API key and default location are then stored locally, and are never sent to any remote services aside from the official Google Maps API. The default location is then used by default when a
-to location is not provided.
Next, you’re able to request your commute time:
# From your default to a specific location: $ commuter -to "321 Maple Ave. Toronto, Ontario" > 32 Minutes # From a specific location to your default: $ commuter -from "Toronto, Ontario" > 20 Minutes
If you want a commute time beginning and ending somewhere other than your default location, you can use supply full locations for both the
$ commuter -from "123 Main St. Toronto, Ontario" -to "321 Maple Ave. Toronto, Ontario" > 32 Minutes
You can also add names for your frequent locations like so:
$ commuter add -name home -location "123 Main St. Toronto, Ontario" $ commuter add -name work -address "321 Maple Ave. Toronto, Ontario"
And use them as the
$ commuter -from home -to work > 32 Minutes
It’s a pretty simple application, but I find it very useful for my purposes. In the future I’m planning to add support for Geolocation, so you can use your current location without having to type it out or create an alias for it. I also want to support different transit methods (Walking, Biking, and Public Transit) in addition to the current support for driving.
In the long run, I want to monitor the commute throughout the day and attempt to train some machine learning algorithms that are highly specific to the Toronto area and my drive in particular. Google Maps does a great job of estimating what time you should leave to get somewhere on time, but I suspect that by taking into account all the highly specialized features you can’t use when training a globally applicable algorithm, that I might be able to get very accurate results.
If you’re at all interested in commuter, be sure to check it out at github.com/KyleBanks/commuter and as always contributions are very welcome!