0

Alpertopia

Transit hacking – polylines

After attending the King County Metro developers conference earlier in October, they awarded each of us with a CD of the current dataset and also a GTFS copy of the data.  I had been having troubles trying to figure out metro’s shape data (apparently it was some form of GIS awesomeness), so I was sooo happy to find out that Google’s format has shapes defined by a list of lat/long points.

After adding all the data to a sql server instance, I hacked together a C# program to extract the lat/long points for each shape and encode Google Maps polylines, with the help of an implementation Mark Rambow did in java.  That put info back into the database, so I exported it into mysql and put it up on Alpertopia.

gmapshapeex

It seems to work pretty well!  There’s a wacky issue with some routes completely screwing up the map though; so if a route doesn’t display, you’ll have to reload the page.  I haven’t pinned down the bug yet.. One of the coolest things here is jQuery, which everyone on the internet says is awesome.  I really didn’t like the syntax at first, but my then-roommate Chris was using it in his research and was extoling the virtues of it.  Looking at the code of my hacking above, I’ve gotta admit that it’s pretty nice 🙂

Those shape IDs correspond to individual trips that the buses take, so that a  bus can have more than just two trips (allows for express, weekend, snow routes).  That’s the next step, hopefully.

If there’s any interest in the code behind it to generate the polylines, I’d be happy to make it available.

Leave a Reply