<?xml version="1.0" encoding="UTF-8"?>
<essay xml:lang="en" version="5.0" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:dcterms="http://purl.org/dc/terms/" xmlns:gal="http://norman.walsh.name/rdf/gallery#" xmlns:foaf="http://xmlns.com/foaf/0.1/">
<info>
    
    
    
    
    
    
    
    
    
    
    
<title>Where am I?</title><biblioid class="uri">http://norman.walsh.name/2010/03/06/where</biblioid>
<volumenum>13</volumenum>
<issuenum>7</issuenum>
<pubdate>2010-03-06T16:57:48-05:00</pubdate>
<author>
      <personname>
<firstname>Norman</firstname>
	<surname>Walsh</surname>
</personname>
    </author>
<copyright>
      <year>2010</year>
      <holder>Norman Walsh</holder>
    </copyright>
<abstract>
<para>Or, perhaps more to the point, where was I? And where will I be?</para>
</abstract>
<dc:subject rdf:resource="http://norman.walsh.name/knows/taxonomy#SelfReference"/>
</info>

<para xml:id="p1">I've long been fascinated by geospatial data. I do
<wikipedia page="Geocaching">a
little geocaching</wikipedia>. I keep track of
<link xlink:href="http://norman.walsh.name/2009/10/05/dominicanrepublic">the
countries</link> I've been in. I use
services like
<link xlink:href="http://www.dopplr.com/">Dopplr</link> and
<link xlink:href="http://www.tripit.com/">TripIt</link>
to keep track of my itineraries. I
carry a GPS to
<wikipedia page="Geotagging">geotag photographs</wikipedia>. </para>

<para xml:id="p2">Carrying a mobile phone with a GPS allows me to explore the
features of
<wikipedia page="Geosocial_networking">geosocial applications</wikipedia>
like
<link xlink:href="http://www.brightkite.com/">BrightKite</link>,
<link xlink:href="http://www.gowalla.com/">Gowalla</link>, and
<link xlink:href="http://www.foursquare.com/">Foursquare</link>.
I allow Dopplr and Brightkite to update my
<link xlink:href="http://fireeagle.yahoo.com/">Fireeagle</link>
location.</para>

<para xml:id="p3">All very nice, but there were two obvious (to me) deficiencies
in this arrangement. First, and most obvious, <emphasis>my
data</emphasis> is spread all over <emphasis>someone else's</emphasis>
servers. I consider this unacceptable. Any one of these services could
get bought, go belly up, or
<link xlink:href="http://www.wired.com/epicenter/2009/01/magnolia-suffer/">carelessly</link> (or
<link xlink:href="http://help.yahoo.com/l/us/yahoo/geocities/close/close-03.html">maliciously</link>,
I suppose) discard all my data.</para>

<para xml:id="p4">The second point is less obvious: how do I tell when I'm home? I
don't actually think any of you reading this would have a hard time
working out where I live. I'm sure I've left enough digital
clues for anyone sufficiently interested to work it out. That said, I can't
actually convince myself that it's reasonable to “check in” to any of these
geolocation services when I'm home. I'm not sure
<link xlink:href="http://pleaserobme.com/">it's reasonable</link> to do when
I'm not home, either, but I do. I think I've set the services up so they only
reveal my location to friends anyway.</para>

<para xml:id="p5">Not being able to solve the second of these problems made the data
sufficiently unreliable (I've been checked into Staples for eleven days?)
that the first problem hadn't crossed my “do something about it” threshold.</para>

<para xml:id="p6">All that changed a few days ago when
<personname>
      <firstname>Tom</firstname>
      <surname>Morris</surname>
    </personname>
happened to mention a clever solution in his Twitter stream. He later
documented it in
<link xlink:href="http://tommorris.org/blog/2010/02/22#When:19:34:55">a
thoughtful post</link>. The basic idea is this: if you always carry your
phone (or other device) on your person, then the presence of that device
in your house means your home.</para>

<para xml:id="p7">A <link xlink:href="http://gist.github.com/311495">little hack</link>
later and my server always knows when I'm home, give or take a few hours;
it can only ping the device when it's on and not in “standby” so there's some
latency. But not more than a few hours most days, I expect.</para>

<para xml:id="p8">Having solved the second problem, I turned my attention to the first.
A few hours of hacking later and the TripIt, Foursquare, Gowalla, Brightkite, and
Fireeagle APIs are giving me my data. The hardest part, honestly, was getting
over the authentication hurdles.
<wikipedia>OAuth</wikipedia> may be the right answer, but it's
not painless to setup a new application.</para>

<para xml:id="p9">I started out by pouring all this data into
<link xlink:href="http://www.marklogic.com/product/marklogic-server.html">MarkLogic Server</link>.
(Well,
I would, wouldn't I?). A little XQuery later and I had a normalized view of
all my locations. Cool.</para>

<para xml:id="p10">But wait, I thought, what about all those GPS tracks? Yes, those
belong in there as well! Easily done.</para>

<para xml:id="p11">The interesting thing about GPS tracks is that you can
(sometimes) interpolate data between points. I do this already when
I'm geotagging photographs. By adding “next point” to the normalized data
when appropriate, I could expose that in my system as well.</para>

<para xml:id="p12">Once that idea was in place, it was clear that an airline flight
or train ride (to a lesser extent) might be subject to interpolation as well.
A quick tweak to the scripts that normalize TripIt itinerary data took
care of that.</para>

<para xml:id="p13">At the end of the day, I have an interesting (to me) personal archive
of my geolocation over time. It's derived from GPS tracks, explicit checkins,
and itineraries. I'm also going to integrate the GPS data that comes from
photographs taken with my mobile phone. All very cool to me.</para>

<para xml:id="p14">I've also got a web service that I can use for geotagging photographs.
I can ask, for example, where was I this morning at 10:00a?</para>

<programlisting>&lt;point lat="42.360633" long="-72.543451"
       timestamp="2010-03-06T14:51:53Z"
       duration="PT8M7S" seconds="487"&gt;Staples&lt;/point&gt;</programlisting>

<para xml:id="p15">Apparently, I was at Staples and had been for 8 minutes. No wonder
I'm the mayor of Staples.</para>

<para xml:id="p16">If I ask where I was at 2006-07-15T13:28:00Z, the answer
comes from a GPS track:</para>

<programlisting>&lt;path start-lat="42.376713753" start-long="-72.516739368"
      end-lat="42.376821041" end-long="-72.516653538"
      timestamp="2006-07-15T18:27:58Z" end-timestamp="2006-07-15T18:28:03Z"
      total-distance="0.00842566695064306"
      total-duration="PT5S" total-seconds="5" velocity="6.06648020446301"
      duration="PT2S" seconds="2" distance="0.00337026678025723"
      lat="42.3768" long="-72.5167"/&gt;</programlisting>

<para xml:id="p17">That's a location interpolated over five seconds and about 44 feet.
Seems pretty reasonable.</para>

<para xml:id="p18">Interpolating over airline flights is a little less precise:</para>

<programlisting>&lt;path start-lat="42.363611" start-long="-71.006111"
      end-lat="18.3375" end-long="-64.969444"
      timestamp="2010-01-28T14:05:00Z" end-timestamp="2010-01-28T18:00:00Z"
      total-distance="1697.2841796875"
      total-duration="PT3H55M" total-seconds="14100" velocity="433.349152260638"
      duration="PT55M" seconds="3300" distance="397.236722905585"
      lat="36.7753" long="-69.2873"&gt;BOS&lt;/path&gt;</programlisting>

<para xml:id="p19">but it's still kind of cool. Also interesting is the fact that
itinerary data lets me look forward. Where will I be at
2010-03-12T08:25:00Z?</para>

<programlisting>&lt;point lat="50.1" long="14.266667"
       timestamp="2010-03-12T08:25:00Z"
       duration="P1DT1H55M" seconds="93300"&gt;PRG&lt;/point&gt;</programlisting>

<para xml:id="p20">Oh yes. I think I have
<link xlink:href="http://www.xmlprague.cz/2010/sessions.html#Automating-Document-Assembly-in-DocBook">an appointment</link> there. And it'll be more accurate after
I've actually checked in, taken photographs, and used my GPS. Sweet.</para>

</essay>

