UKHAS Wiki

UK High Altitude Society

User Tools

Site Tools


code:kml_live_update

KML near realtime update

Here are a couple of code files that provide a realtime update of balloon position on google earth etc.

The 1st KML file is the outer shell kml that you launch from google earth - it just tells google earth to read the 2nd file (every10.kml) once every 10 seconds.

The 2nd KML file (every10.kml) contains kml to draw a balloon track and the “launch” and “current position” placemarks. This whole file should be completly re-written every time the the balloon position needs updating. The google earth display will be updated upto 10 seconds later. Typically this file would be created and updated by code parsing GPS data being sent on a radio downlink.

<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://earth.google.com/kml/2.1">
<Document>
  <NetworkLink>
    <Link>
      <href>every10.kml</href>
      <refreshMode>onInterval</refreshMode>
	<refreshInterval>10</refreshInterval>
    </Link>
  </NetworkLink>
</Document>
</kml>

every10.kml - This defines a couple of suitable styles for placemarks and line strings, draws the launch placemark, draws the balloon track linestring (starting at the launch and ending at current position) and finally draws the current position placemark. This code based on the University of Wyoming trajectory calculator output (and uses their placemark gif)

<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://earth.google.com/kml/2.1">
<Document>
    <Style id="track">
      <LineStyle>
        <color>fff010c0</color>
      </LineStyle>
      <PolyStyle>
        <color>3fc00880</color>
      </PolyStyle>
    </Style>

    <Style id="place">
      <IconStyle>
        <scale>1</scale>
        <Icon>
          <href>http://weather.uwyo.edu/icons/purple.gif</href>
        </Icon>
      </IconStyle>
    </Style>

      <Placemark>
        <name>Launch</name>
        <styleUrl>#place</styleUrl>
        <description>Launch location was ... at ...</description>
        <Point>
          <altitudeMode>absolute</altitudeMode>
          <coordinates>-0.092096,52.250872,55</coordinates>
       </Point>
      </Placemark>

    <Placemark>
      <name>Flight Path</name>
      <styleUrl>#track</styleUrl>
      <LineString>
        <extrude>1</extrude>
        <altitudeMode>absolute</altitudeMode>
        <coordinates>
  -0.092096, 52.250872,   55
  -0.089721, 52.252995,  166
  -0.082192, 52.258184,  379
  -0.072153, 52.263721,  597
  -0.059924, 52.269104,  819
  -0.030587, 52.277540, 1279
   0.002241, 52.283403, 1761
   0.035656, 52.288259, 2269
   0.069353, 52.292391, 2803
   0.102276, 52.297056, 3368
   0.132938, 52.303864, 3970
        </coordinates> 
     </LineString>
    </Placemark>

      <Placemark>
        <name>Position Now</name>
        <styleUrl>#place</styleUrl>
        <description>Current Position is ... at ...</description>
        <Point>
          <altitudeMode>absolute</altitudeMode>
          <coordinates>   0.132938, 52.303864, 3970
          </coordinates>
        </Point>
      </Placemark>

  </Document>
</kml>
code/kml_live_update.txt · Last modified: 2008/07/19 23:33 by 127.0.0.1

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki