Geocaching the Google Earth 2

More fun tricks for combining geocaching with Google Earth!

I snooped around and discovered that Google Earth keeps track of place markers in XML format, under the .kml extension.  That’s pretty cool, since you can download waypoints from Geocaching.com in XML format too, under the .loc extension. For a long time it was my day job to define a language (XSL Transformations) for transforming one form of XML to the other.  So I wrote a short XSLT (so short, I’ll reproduce it here in it’s entirety).

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
  <kml xmlns="http://earth.google.com/kml/2.0">
   <Folder>
    <name>Downloaded caches</name>
    <open>1</open>
    <xsl:apply-templates select="loc/waypoint[last()]"/>
   </Folder>
  </kml>
</xsl:template>
<xsl:template match="waypoint">
  <Placemark xmlns="http://earth.google.com/kml/2.0">
   <name>
    <xsl:value-of select="name"/>
   </name>
   <description>
    <xsl:value-of select="link"/>
   </description>
   <LookAt>
    <longitude>
     <xsl:value-of select="coord/@lon"/>
    </longitude>
    <latitude>
     <xsl:value-of select="coord/@lat"/>
    </latitude>
    <range>999.9999999999999</range>
    <tilt>0</tilt>
    <heading>0</heading>
   </LookAt>
   <styleUrl>root://styles#default+icon=0×307</styleUrl>
   <Point>
    <coordinates>
     <xsl:value-of select="coord/@lon"/>,<xsl:value-of select="coord/@lat"/>,0</coordinates>
   </Point>
  </Placemark>
  <xsl:apply-templates select="preceding-sibling::waypoint[1]"/>
</xsl:template>
</xsl:stylesheet>

All this does is reverse the list of waypoints, and copy the latitude and longitude from one format to the other.  Simple, but effective - you load the result (appropriately named .kml) into Google Earth and you can take a tour of the caches you’ve downloaded.

My sample was the last 20 caches I’ve visited.  It’s a pretty fun sample, as it jumps between California, Washington, Berlin, and Melbourne Australia.  (Pathetic though that I’ve only done 20 caches since last December…)  Try it out here, or get the XSLT above here.

Leave a Reply

 

 

 

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Spam Protection by WP-SpamFree Plugin