Three weeks ago I bought my main mode of transportation... a Trek 7100 bicycle. It’s a hybrid style bike, which means it has skinny tires like a street bike but has the shape and feel of a mountain bike. At $320, I thought it was reasonably priced and I’ve been VERY happy with it. Since that Thursday three weeks ago, I’ve ridden over 120 miles! I thought it might be fun to track all of my trips, so I spent some quality hours in the last week creating a webpage to enter and display my bike trips. I am quite excited about it, so unfortunately for you I am now going to describe it.
First off, here’s the webpage for displaying my trips (or here’s a version with more features, but it’s a beta version since I don’t like how it opens new windows). I’ve also added a permanent link to the ride log page on the right sidebar. Anyway, the very cool thing about that page is it’s generated on the fly from info in a MySQL database. The database contains a few tables that track rides (dates, routes, miles), places (place names, addresses or coordinates) and distances (a list of two locations and distances between them).
The pages are all written in Perl from scratch and access the database using the Perl Database Interface (DBI). I had never used the DBI before, so this was all new to me (in fact, I’ve not used Perl much since college, so this was quite a learning experience). So, you’ve seen the display page, but let me show a bit of the slick input pages. Here’s the initial page where I can put in trip data.

The date field is auto-filled with the current date using a nice piece of Javascript code that I found on a tutorial page. And here’s the same page with a sample trip put into it.

Routes are described using the pattern above, which was convenient for parsing while also making a decent amount of sense. Once the ‘Submit’ button is pressed, the first Perl script is run. First task on the list is to make sure all of the places entered are recognized. In this example, I had already entered trips that included ‘Home’ and ‘Bike shop’ previously, so their addresses are already in the database. Here is a screenshot before I have typed anything into the fields.

Since Safeway is a new location, I can type in the address and then the address will be remembered for any trip in the future that includes Safeway. Hitting ‘Continue’ brings me to the next page which deals with the trip distances for each leg of the trip.

A previous trip contained the ‘Bike shop to Home’ leg, so the distance for that portion of the trip is already known. For the other two legs of the trip, I need to look up the distances and enter them into the webpage. Fortunately for me, I was kind enough to automate the looking up of distances. Because the addresses are known for these places, I was able to automatically create driving direction links to local.live.com for each of these legs. For example, the ‘Home to Safeway’ link in the screenshot above would take me to this page. So, all I need to do is click these links and enter the mileage in the appropriate boxes.

With a click of the ‘Finish’ button, the mileage for the new trip legs are saved for future reference and the actual ride data is saved as well. I never have to touch messy URLs, the links to waypoint maps on the display page are generated using the place addresses or even latitude/longitude coordinates!
The only thing I haven’t spent much time on yet is the look and feel of the pages. I would prefer the ride log page to look a little nicer than just plain old HTML tables, but I’ll save that work for some other day. The important thing is that I can easily enter in ride data right now and it’ll instantly show up on the log page!
this is cool! have you seen http://www.motionbased.com/? it's like this but with gps data, and it costs money. and you don't have the pleasure of building it yourself. but other than that, it's pretty much the same thing. or vaguely similar.
I hadn't heard of that before but that does sound cool. I'll have to integrate GPS data into my system! ;)
Phase 2: Combine a GPS receiver and a simple microsystem into your bike to automatically track your progress. It can have a simple display to tell your speed and distance travelled in real time. When you get home it will automatically upload the data through your wireless network to your web site. Your life will finally be fully transparent to us.
Not FULLY transparent until I install a webcam in my shower... Phase 3!!
Very cool. I noticed your ride log page a few days ago, but I didn't realize how automated it was. That's awesome that you have been able to ride so much. I used to do quite a bit of bike riding until my bike got stolen in Seattle like 4 or 5 years ago. :( I need to get a new one, but just haven't made it a priority yet.
Web database programming is pretty fun... I have never used Perl, but I've been using PHP with MySQL for a while now and it's pretty neat. It's cool to be able to just enter in the data and have the pages sort of create themselves. Fun stuff (for nerds like me, I guess).
so, by the time I come to visit you I'll know and have seen more about you than in the last however many years we've been friends?!
Once again, Jake's laziness is his primary motivation. :)
I just wanted to comment from my new phone. It is really cool. I can connect to the web and surf away. I like it. Did you buy your bike new or used?
I bought the bike new for $320 including 2 years of service from the bike shop (South Maui Bicycles).
I would like to point out a few things.
First, did you know you're publishing your home and work addresses on the web? Searching for "Jake home" on google gets your page.
Second, you should put the bike log on its own RSS feed. That would be geek-tastic.
Third, as Tony mentioned in your next post, your comment window is too small.