Using Virtual Earth to Write a Vista Gadget That Tracks the International Space Station
This is the second part of two articles about writing Vista Gadgets that use Virtual Earth. The first part ("Using Virtual Earth in a Vista Gadget") showed you how to write a Vista Gadget that showed a simple interactive map using Virtual Earth. This second part extends the gadget into something more useful: A Tracker for the International Space Station (ISS).
Download code for this article.
At start up, the gadget automatically downloads the latest orbital parameters from the AmSat website.
The map is updated every half second with the ISS’s latest position. The position is tracked with a
pushpin shaped like the ISS. The map automatically pans to keep the ISS centered in the map. The user
may zoom in or out using "+" and "-" buttons. A "Refresh" button allows the orbital parameters to be
refreshed from AmSat. These orbital parameters should only be refreshed every few days -- you do not
need to do this if you restart Vista (and hence the gadget) on a daily basis.
Instead of two files, the gadget now contains ten files. One of these
is an image: ISS_pin.gif stores the image of the ISS pushpin. The remaining extra files (global.js,
calculate the orbit of the ISS. These are based on the orbit calculation routines available from http://www.movingsatellites.com.
This gadget might seem quite a bit more complicated than the previous gadget. In reality it has the same overall structure. For example, here is our new manifest file:
The only change of consequence is that the main HTML source filename has been changed to "ISS_Tracker.html".
In turn, ISS_Tracker.html is based on the HTML file in our previous gadget. However, we need to add code to download the latest orbital data, make calls to the MovingSatellites.com code to calculate new positions, and to automatically update the map.
The gadget uses NORAD "TLE" (Two Line Element) Keplerian orbital parameters. This is a standard way of defining a satellite in Earth orbit in machine readable text form. A typical set of TLE parameters look like this:
1 25544U 98067A 07055.29853167 .00017324 00000-0 99505-4 0 7052
2 25544 051.6356 327.3797 0020641 244.1596 211.2169 15.78603656472945
The first line specifies the satellite name. The next two lines specify the parameters in a fixed format reminiscent of Fortran. These parameters can be obtained from a number of websites, including NORAD’s, but we shall get ours from the AmSat site. The URL for the file is: http://www.amsat.org/amsat/ftp/keps/current/nasa.all . We fetch this file using the ActiveX Microsoft.XMLHTTP object. Note that this is specific to Microsoft JScript. All Vista gadgets will use Jscript, but the ActiveX control will not necessarily be available in a traditional web browser environment (eg. Mozilla).
So let’s get to ISS_Tracker.html. Here is the beginning. As well as including the Virtual Earth control, we include the orbit calculation JScript files:
The body section of the gadget is very similar to the previous Virtual Earth example. The body tag itself defines a call-back to onPageLoad(). We also have the two zoom buttons, and an empty div tag to hold the Virtual Earth map. New additions are a third button (“Refresh”) and a span tag to display the ISS’s coordinate position as a line of text.
And that is it! A few simple steps make the Virtual Earth gadget into a useful little tracking tool.
The TLE Orbital Parameters: http://en.wikipedia.org/wiki/TLE
NASA’s ISS Homepage: http://www.nasa.gov/mission_pages/station/main/index.html
Developing Vista Gadgets: http://microsoftgadgets.com/Sidebar/DevelopmentOverview.aspx
Discuss this story in the forum.
Author: Richard Marsden
Richard Marsden is the proprietor of Winwaed Software Technology, LLC
which provides software consulting and development services,
specializing in both MapPoint and online mapping applications. He
operates the Mapping-Tools.com
Website for MapPoint Tools and Utilities, and recently launched
the GeoWeb Guru a community
website for developers of the geospatial web.
In 2008, Richard was awarded Virtual Earth MVP status by Microsoft.
Prior to Winwaed, Richard worked as a software developer working on
seismic processing algorithms for the oil exploration industry. He holds
geology and geophysics degrees from the University of Cambridge
(Churchill College), and the University of Durham; and an
interdisciplinary MBA from the University of Dallas.