Where in the world: a year in travel

Volume 14, Issue 51; 16 Dec 2011

MarkLogic Server + XQuery + Google Maps = Fast, fun app.

Years ago, and on a totally different semi-automated system, I built a map showing all my travels for a year.

Today's semi-automated system is the same as the old one in some respects: it's still all XML, and different in others: it now runs on MarkLogic Server. Naturally.

The MarkLogic 5 Query Console feature makes it really easy to bang out a quick query to get all my flights:

declare namespace pim = "http://nwalsh.com/xmlns/pim";
declare namespace p = "http://nwalsh.com/rdf/pim#";
declare namespace it = "http://nwalsh.com/rdf/itinerary#";

string-join(
  for $flight in /pim:cards/pim:event[p:class='flight' and starts-with(pim:dtstart,'2011-')]
  return
    concat($flight/it:depart,"-",$flight/it:arrive),
  ",")

Ok, that's not the prettiest bit of code ever, but it gets the job done. One of the best things about MarkLogic Server is how easily it supports ad hoc data exploration. The query above gives me a big long list of flights: BDL-ORD,ORD-SFO,SFO-IAD,… Now all I need is a way to turn that into a map like this one:

I grabbed the airport data from OurAirports, loaded that into MarkLogic, added Google Maps, and sprinkled with JavaScript. Easy peasy. Now there's a travel map app if you want to play along at home.

The bits are on github if you're curious.

Please don't ask (or tell me!) about the carbon footprint of of 46 flights.