Friday, February 23, 2007

The Blog based, RSS using, Yahoo pipe executed Carbon footprint calculator

I've had an idea for a while which started when I did the Geo ripping Wikipedia thing that created a web service. The idea was to have an easy way for me to calculate my carbon footprint, not the one for the house and those things but one that actually took into account how much I travel.

I also set myself another task and that was to achieve this end using communication technologies I hadn't used in that way before. So this ruled out using WS, and led me straight towards the world of POX... or is it REST, I'm not sure I can tell :)

Now taking my own advice and separating "Service" from invocation using a Facade to enable WS and REST on the same code base I quickly knocked up a servlet that takes in a place name (or a geo coord) and returns it as an RSS encoded entry. It also takes in a transport type (more of that later) which is basically to enable pass through. The Place search Pipe uses the same backend service as the WS service, with information ripped from Wikipedia.

Next up is to then have a source of information that will make this all useful. Welcome to Blogger as a data store: My trip blog is just test data (except the last destination for which I leave today). This gave me an input RSS feed that could then be consumed by another pipe, the next pipe is a bit more complex. Firstly it takes in a feed and then orders by date (the opposite way around to most feeds) and then it uses that information to call the first pipe to obtain a geo-tagged set of information. This Geotagging Pipe turns the blog feed into a set of points.

The final pipe in this stage is then one that is meant for cloning by other people if they want to do the same (thinking of the consumer's view) that one can be found here (NB you need to look at the RSS to get the real info).

Stage two of this exercise was then to have something that would take that RSS feed and do all the calculations. Again a quick bit of development followed by fronting using Rome and the next stage was ready. Using the JCoord library to do the distance calculations and taking the carbon numbers from The National Energy Foundation the next servlet was soon deployed. So back into Yahoo Pipes it was, this time taking the URI of the generated feed which is then passed to the new servlet which then returns its resuts as another RSS feed. The carbon calculation Pipe takes an input (as text because Yahoo pipes kept trying to be clever when I used a URL builder) of the Pipe generated RSS feed and then dumps it to the servlet. A Consumer focused (clonable) implementation for my feed is then available here.

Okay so there you have it a few hours of working and its all working, taking information geo ripped from Wikipedia, a blog feed and a bunch of servlets all done using RSS.

Now there is one slight issue here. I've got the carbon calculations for "train", "plane" and "car" but for some reason when you debug the feeds it shows the categories correctly but the deployed pipe is devoid of any category information, so at the moment this means all journeys are calculated based on flying. Other issues are that the database isn't complete (I need to update my regexp stuff to catch some more entries) and the search is currently "first" rather than "best" so London = London borough of Croydon.

Next step (obviously) is to take that feed and turn it into a GoogleMap.

Now one question I have is... did I "do" REST?

If I have time at the station I might lob up a picture of how it all works.

Technorati Tags: , ,


ovi said...

Steve - maybe you could implement your idea using

Anonymous said...


You know the whole 'earth warming caused by carbon' thing is b****ks, right?

-- SM

Anonymous said...

Its a very nice blog for...
architects in bangalore , architects in bangalore , interior designers in Bangalore , interior designers in Bangalore , architects in bangalore , architects in bangalore , interior designers in bangalore