KML Tracker for the Pocket PC

Sometimes the simplest portable apps can be the most useful. Tracking routes using a GPS connected to a Pocket PC is very simple, and being able to view the tracks in Google Maps (on a pocket or desktop PC) or Google Earth (on a desktop PC) can be very useful indeed for many applications. Therefore, KML Tracker was written using NS Basic on a Microsoft Windows Mobile based Pocket PC, as an example of how easy it is to write some code that does both of these things through logging of GPS data in Keyhole Markup Language (KML) files. The resulting program is shown in Figure 1, and an example of viewing a track in Google Maps on the Pocket PC is shown in Figure 2.

The KML Tracker main window.

Figure 1. The KML Tracker window.

Viewing a track in Google Maps.

Figure 2. Viewing a track in Google Maps.

Fortunately, NS Basic provides a relatively rapid way of creating Pocket PC apps, which are largely code compatible with their other development software such as for PC's and Symbian phones. It was particularly useful for this project as it allows development both on a desktop PC and the Pocket PC itself, which is very useful if the code needs alteration when out and about with a GPS. The interface is relatively straightforward: to log you first need to connect to a Bluetooth GPS in the wireless manager and then run the app. The only really technical knowledge that you need is the port number (e.g. COM6) and speed (e.g. 57600) of your Bluetooth serial connection, which you should find in your wireless manager software and GPS manuals. In fact, for Bluetooth it probably won't matter what speed you set in KML Tracker, although it is important if you are connecting to a GPS built into your Pocket PC or Windows Mobile SmartPhone. If all of that is done, you should be able to click the connect button and, after a short time, your location should be displayed (if not, please check that your GPS has a fix).

Of course, the fun bit is to track your position. To do that, you enter a name for the track in the box at the top, select the frequency for log entries in seconds at the bottom left of the screen, and click the big green start button. You will then be asked for a file name and location for the track, after which the start button changes to a stop button and the pause button is activated to let you pause the logging (e.g. if you've stopped and don't want lots of logs at the same place). When you are done, you just need to press the red stop button to finish logging, and click the disconnect button when you want the app to stop updating your position. After closing the app, you should find a file in the place you specified that you can tap in your file manager to open in Google Maps on your Pocket PC (assuming you have it installed). You can also copy the file to your desktop PC for viewing in Google Earth, as shown in Figure 3.

Viewing a track in Google Earth.

Figure 3. Viewing a track in Google Earth on a PC.

To use KML Tracker on a Pocket PC, you first need to install the correct NS Basic runtime files for your device, which you can get by clicking here. Then, download the file below onto your Pocket PC and run it:

Click here to download KML Tracker for the Pocket PC.

As you may already know, NS Basic apps are encrypted, so that only people who have a copy of NS Basic can read the code. However, KML Tracker is open-source (GPL) and so a text version is provided here for you to view in a text editor (relevant license codes removed).

For the technically curious, KML Tracker opens a serial port to read NMEA sentences from a GPS device, either over Bluetooth, or from a built in GPS. It monitors incoming text (the NMEA sentences are simple ASCII text) and each time it gets to the end of a line it checks to see if the line starts with $GPGGA. That's one of a number of types of GPS sentences which we could use, but is particularly useful for us as it contains the latitude, longitude and altitude (most others do not include the altitude). Only using GGA lines shouldn't be a problem, as most GPS devices output them quite often, sometimes even more than once a second. Each time a GGA line is found it is split up into the individual parameters which are used to update the NS Basic position variables and the location display. During logging, a timer is activated at the frequency selected (in seconds) which saves the latest location data to the log file. Basically that's the operation in a nutshell, but if you want to know more please feel free to read the text version of the code in the link above, and maybe visit NS Basic for more info on their programming language and how it works.

And now the obligatory warning: Using a GPS or Pocket PC can be hazardous especially when walking, driving, or cycling, both to yourself and to others around you. Please do not use KML Tracker unless you are sure that you can do so safely and without contravening any relevant laws. Basically, don't kill, injure or otherwise hurt anybody, or annoy any law enforcement agencies, using this software as that would be just plain stupid (e.g. it is not for use by terrorists or for guiding ballistic missiles). Also, while using KML Tracker please don't hurt any animals, or trample any defenceless plants or insects to death, as we wouldn't approve of such callous acts. That's the end of the warning, so all that needs saying is that KML Tracker is GPL licensed open-source software, so you are free to use the code as a basis for your own GPS programs, with no financial cost to purchase or license, as long as you abide by the license terms.