Add to Technorati Favorites .................................. - All posts tagged 'gps'
..................................
the blog@spencerwilliams.net

Innards of KML files - gross (seriously)

January 13, 2008 12:27 by Spencer

Compared with GPX files, KML files are ugly - at least when they are saved by Google Earth.

Look at this file:  GPX File

and compare it to this:  KML File

The KML file is XML, but when it comes to coordinates it just craps them out in one HUGE coordinates tag.  Take a close look,

-97.82383400000001,30.275435,267.383911

The 3rd number in the comma-delimited string (I thought that went away with XML?) is the elevation.  Not very pretty.  Compared with the GPX format:

- <trkpt lat="30.266583" lon="-97.823150">
  <ele>182.691</ele>
  <time>2007-12-20T21:46:55Z</time>
</trkpt>
Very pretty.  Unfortunately the schema of GPX files doesn't lend itself to doing much more than recording tracks and waypoints.  It's a file format made for GPS units only.  So instead of crafting a more difficult regExpression to remove the elevation data out of the KML file, I just regEx(^ *<ele>.*<\/ele>) to remove the elevation data from the GPX file before editing it in Google Earth and saving it as a KML file.

Problems with KML and Virtual Earth

January 12, 2008 10:53 by Spencer

I have been importing different KML files into the webpage I have been working with.  I first tried the 2D setting on the map control.  This works very well.  It wasn't until I played with the 3D capabilities of the VE control that I noticed some issues.  The following is excerpted from my post on the MSDN Virtual Earth Map Control Forum:

 When adding a KML overlay using ImportShapeLayerData the VEDataType.ImportXML type in a 2D rendering of the map works wonderfully.  Hybrid, road, even birds eye - they all work.  However, change the map to 3D style and the KML overlay is skewed and does not appear to be overlayed correctly on the map. 

<script type="text/javascript">

var map = null;
var layerid=1;

function GetMap()
{
map = new VEMap('myMap');
map.LoadMap(null,null,'h',null,null,null,null);
var l = new VEShapeLayer();
var veLayerSpec = new VEShapeSourceSpecification(VEDataType.ImportXML, "
http://www.spencerwilliams.net/kml/kmltest2.xml", l);
map.ImportShapeLayerData(veLayerSpec, onFeedLoad, 1);
}

function AddMyLayer(type)
{
var l = new VEShapeLayer();
var veLayerSpec = new VEShapeSourceSpecification(type, txtSource.value, null);
map.ImportShapeLayerData(veLayerSpec, onFeedLoad, 1);
}

function onFeedLoad(feed)
{

}

 

When you look at the map in 2D, zoom into the area where 3 trails meet by clicking the "Go To Position" button on the right side of the map (Click here for this map). 

This is a hiking trail where 3 trails come together.  This placement is correct.  Now change it to 3D view and you will see that the triangle section is nowhere near the previous spot.  I would assume that this has something to do with a 2D KML overlay being placed on a 3D contoured shape, like a paper cutout that doesnt fit around an object.  I thought about this for a while and then looked at the KML.

 

UPDATE - 7-18-2008 : this appears to be fixed as long as you don't zoom in past 20yds in 3d - I'll have to research if there were changes to the rendering of 3D overlays by the virtual earth team


The new VEDataType - ImportXML

January 11, 2008 10:34 by Spencer

There's a new addition to an enumeration folks, VEDataType.ImportXML .  Here's an easy example of how collections are added to a map:
 


function MapLoad()
        {
            map = new VEMap('myMap');
            map.onLoadMap = fnLoadCollection;
            map.LoadMap();
        }

        function fnLoadCollection()
        {
            var l = new VEShapeLayer();
            var veLayerSpec = new VEShapeSourceSpecification(VEDataType.VECollection, "C63B5D9B400AD5!122", l);
            map.ImportShapeLayerData(veLayerSpec, null, true);
        }

Collections are cool,  but they aren't my style.  My style is to own my own data.  Collections are assigned an ID on maps.live.com (after you sign in to save them), and granted you can import XML files (GPX, KML, LOC) but you can't import -> modify -> then export the files to a format that you use.  They go into the black hole that is known as a hosted service.  I like to keep tabs on my data and own it myself.  That being said, I did try this out here.  This shows my collection that is stored on maps.live.com - a geocaching trip my wife and I took to the Greenbelt and Barton Creek.  I DID have to edit the KML file that I imported - more on that later.

The coolest thing about this example?  Mouse-over the waypoint labeled 4-way and click the picture.  Now note where the camera was to take the picture - I was North/Northeast of the trail intersection.  Got that? OK, now click the birds-eye view in the upper-left of the Map Control.  Zoom into that waypoint and see how accurate that is.  I thought it was pretty impressive.


GPS Tracks - editing/manipulation

January 10, 2008 08:15 by Spencer

I love looking at where I've been.  I love not having to recreate where I've been on a map after I have traveled.  If only there was a way to record where I've been, and then somehow be able to put that on a map that people could see......I recently bought a GPS, and whaddya know, it can do that! 

Now comes the fun part, showing a trail map that is "exact" or as exact as my Garmin eTrex Vista HCx can gather from civilian satellites on a map - online - for the world to see (or at least my friends).  GPX files are the export format of choice for GPS receivers.  You can view the schema of GPX files here, the documentation for that schema here and a general overview here and here

I usually get home from a bike ride or a hike/geocaching expedition and grab the file off of my GPS.  Now, because the GPS has to be on when I retrieve the files and waypoints (I guess I could pull the card out, but that's a bit more time consuming considering my bike mount), the track file normally gets updated with some more information than I would like - the location of my house.  Normally, when I load the GPX file into Google Earth, I see a nice trail track of where I was, and then a long line drawn from the parking lot or ending point, to my house.  The GPS takes the last point it had when it was on - the parking lot, and adds to it the next point it gets when I turn it on in my house - usually a few miles away at the least.  I understand that I could tell it to stop recording the tracks when I'm done hiking/biking/etc, but I forget.

Either way, the file needs to be edited in a easy-to-use program like Google Earth so that I can add names that are more than a few characters to waypoints, add descriptions, choose better icons to mark my places, etc.  I usually edit the track XML in a text editor using the time element as a guide, and then import the GPX into Google Earth.


Tags:
Categories: Geocaching | GPS Hacks
Actions: E-mail | Permalink | Comments (0) | Comment RSSRSS comment feed

Virtual Earth KML - Take One - Waypoints

January 9, 2008 07:55 by Spencer

So I tried adding KML to the map - first glance, it looks great.  Pretty simple code too:

var map = null;

function MapLoad()
         {
            map = new VEMap('myMap');
            map.LoadMap(null,null,'h',null,VEMapMode.Mode3D,null,null);
            var l = new VEShapeLayer();
            
            var veLayerSpec = new VEShapeSourceSpecification(VEDataType.ImportXML, "
http://www.spencerwilliams.net/kml/kmlmainmap1.xml", 1);
            map.ImportShapeLayerData(veLayerSpec, onFeedLoad, 1);
          }

 function onFeedLoad(feed)
              {
                 
                 
              }

See the example here: http://spencerwilliams.net/trailmaps/default.aspx

I liked how Virtual Earth automatically zoomed the map in to see the two waypoints at the lowest zoom level that they would fit in.  I tried unsuccessfully to change the default pushpin icon.  More on that later.


 
Blog Information Profile for williasp