Flickr Badge

Tuesday, December 25, 2007

My hack at PipesCamp HackDay

One of the coolest parts of PipesCamp on Sunday was the HackDay part of it. Okay, it wasn't a whole day, more like about three hours, but it was still fun. You can find my pipe here: MTC Mashup.

You can type a bus number in the input box on the top and it displays (or tries to display :P) the places visited by the bus on a map.

Check it out!

The raw data comes from the Chennai MTC website (Yes, they have a website). There is a section that gives the stages visited for the bus number that you enter in a form. However, the output is quite a messy bit of HTML, quite a pain to parse through. Luckily, Rabin Vincent has taken this data and put out a much cleaner bus query interface over it.

So, Rabin's site provides the raw data for the pipe. Given a bus number, we construct an appropriate URL and query Rabin's site for the bus route, then parse the HTML to extract out a list of stages that the bus goes through.

Now that we have the list of stages, the next step is to figure out the latitude and longitude of these places. For that, we used Yahoo's Geocode service. This service takes a string address and returns the latitude and longitude of the place. Once we have the lat/long coordinates of each of the stages, we send it out on a yahoo map.

Now for the hiccups:

The biggest by far is ambiguity while searching. For example, the MTC site refers to the Central Station stop simply as "Central" which when passed to the Geocoding API gets confused because a lot of things match this. At the other extreme, a bus stop like "P. Orr & Sons" does not get any hits on the Geocoding API. So, sometimes the lat/long positions can be all over the map depending on whether the Geocoding API returned the right place or not.

An obvious solution is to create a small web service that takes the names as specified on the MTC site and return the correct lat/long for that stop. So we know that Central refers to central station, and we can return the position of that stop accurately.

The other thing that I could not figure out was how to get the data on other maps. By default Y! Pipes uses Y! Maps (Worldwide) which does not have good resolution for Indian cities. However, there is a India specific Y! Maps, which has good detail for Indian cities. How do I get Pipes to output to the Y! India maps instead of the global Y! Maps? I couldn't figure that one out.

Right at the end, labsji took my mashup, downloaded the KML data and imported it into Google Earth, so that the whole route was superimposed on Google Earth and it automatically ran an animated tour between the stops.

In the end it was a fun experiment, and something I would not have done without PipesCamp. When I first started this hack, I though it would be impossible, but Y! Pipes allowed me to create the whole mashup in a few hours as a total newbie. That's pretty cool if you ask me.


Unknown said...

Neato.. would like to get it done for Bangalore help.Should contact Rabin too.

shivku said...

It is not possible just as yet to mash up for India using maps and pipes. But, on the other hand, it is possible to hack with India maps. Much like how these guys
and have done with a combination of and

Unknown said...

I think the Yahoo Pipes are the first step to web 3.0.
If you want to see some pipes in actions check my MacrosReader

Ravages/CC said...

Um, I get a 500 error on Rabin's site, which probably explains why the Pipe does not compute.

Can you, ahem, sort it out. This kind of stuff needs to be made available to every person in Chennai.

Anonymous said...

Ravages: It seems to be working..

Praveen said...

Great. Robin's and your site seems to be great. I was wondering if we can develop a site similar to But you both are on track to achieve that. Keep it up.