Click here to Skip to main content
Click here to Skip to main content

Bernie’s Trackviewer

, 8 Sep 2013
Rate this:
Please Sign up or sign in to vote.
View and edit your GPS track records on a nice GUI with online maps and aerial views.

The current (updated) version 1.4 of the executables and the source code can be downloaded from http://berniestrackviewer.codeplex.com/ [^].

Introduction

There are many tools available for viewing tracks recorded with GPS devices. They can often do lots of things, but editing is quite uncommon. There are many good reasons for editing, e.g., you might want to publish just a part of your track, need to correct some misplaced points, or want to remove the short deviation into the bushes when you provided a tree with liquid fertilizer... If you want to add data to OpenStreetMap [^], it could be advisable to record one point per second in order to get bends nicely, and then remove unnecessary points from straight sections of the road.

Hence I decided to write my own software for analysing and editing GPX files. Here I wish to present some steps of the development and a small sample program.

The GPX format 

This format was developed by TopoGrafix, and they publish the XML schema for it (see http://www.topografix.com/GPX/1/1/gpx.xsd [^]). It shows a hierarchical structure:

Structure of GPX data

The WayPoints in the GPX proper are some kind of "points of interest" which you explicitly save on your device. The RoutePoints and TrackPoints are of the same type, but they belong to Routes and Tracks, resp. The tracks use an extra layer, the "TrackSegment". The documentation says, that where GPS reception was lost, or the GPS receiver was turned off, a new TrackSegment is to be started for each continuous span of track data. There are some discussions whether this is still useful.

Now we need a means to get C# classes.xsd.exe is included with Visual Studio (it is located in Program Files\Microsoft Visual Studio <Version>\SDK\v<Version>\Bin). Let us save the schema from the browser into a local file and then call xsd:

xsd.exe D:\Temp\gpx.xsd /classes /out:D:\Temp /language:CS

And voilà, there is one big C# code file with all the classes required for a GPX file.

Several property names look quite ugly - e.g., public decimal ele. I would prefer to use a well readable name here: Elevation. When we rename it, serialization / deserialization will become incompatible. But there is a trick - XmlElementAttribute. We can thus tell the serializer how the properties are mapped to the XML elements:

[System.Xml.Serialization.XmlElementAttribute("ele")]
public decimal Elevation

And let's add the documentation found at TopoGrafix's website as code comments. Further editing pertains to cryptic names of classes (e.g., wptType -> WayPoint), and generic lists are better for the purpose of editing than arrays.

Now we have nice classes which are just data containers - they have no inherent functionality. Let's add some, e.g., for reading and writing GPX files:

public static GPXType FromFile(string fileName)
public void ToFile(string fileName)

When we want to add further properties to a waypoint, e.g., the speed, we must consider that the XML serializer will write such a value to the file - which might render it unreadable for other devices. We can use two tricks:

  • Use a function instead of a property, e.g., double GetSpeed() instead of double Speed (the private member variable _Speed is ignored by the serializer).
  • Use the XmlIgnoreAttribute attribute.

I hope the automatically generated classes could thus become more intelligible and more useful.

Elevation quirks

The determination of the elevation from the satellite is not good. Modern GPS receivers also have a barometric altimeter. They typically use the values from the barometric altimeter, but from time to time calibrate it with the satellite values. Since no information on that calibration is recorded, you cannot know when it happened and by how much the elevation values were changed from then on. The elevation plot can be totally useless.

I decided to switch the automatic calibration off, and then found systematic deviations from the expected values. E.g., my brother's home's location was 10m higher than expected. After a lot of search through the web, I found the major reason: air temperature (see also "Grundlagen - Luft + Luftdruck"; link removed, original page is no more available and redirection points to spam). The altimeter uses a conversion factor for air pressure to elevation, about 12 hectopascal per 100 m - that's valid for 15 C or 288 K (degrees Kelvin). With the cold temperature of some -10C at that time, the elevation difference from my home to my brother's home stretched from 100m to 110 m = 100m * 288K / 263K.

Another issue is that there are minor oscillations by typically less than one meter. When calculating total ascent/descent, these oscillations could sum up to several meters and severely distort the results for tracks in the plains. Here, a threshold value is used to ignore the oscillations.

Timestamp issues

The Global Positioning System actually relies on extremely exact time values. Hence we should think that the timestamps of our way points are perfect. But they are not. I discovered two cases where a later waypoint has an earlier timestamp than its predecessor - I published one of these cases in the Lounge (Proof of Time Travel[^]).

This could be caused by a clock issue of my Garmin Oregon, but I did not find any related information on the web. Another cause could be a willful distortion by the US armed forces who are the owner of the GPS, but "Selective Availability" is said to have been switched off.

Sample application 

The sample application requires .NET Framework 2. For maps and aerial photographs, a high speed internet connection is required.

Just download the files and unpack the archive into a folder. Then edit the configuration file (BerniesTrackViewer.exe.config) - you should enter valid data for the folder for caching aerial photographs and maps and the file name of the image shown.

Now double click the executable and drag a GPX file into it, select the track and track segment to be edited, and go to Edit-Track to display the track in various forms. Edit a point by double clicking it, dragging it (right mouse click) to a different location, correct the elevation of all points, etc., and finally save your work from the main page.

Further development

The base classes work quite nice, hence the development will be focused on the "sample application".

  • The algorithm for total ascent/descent needs improvement
  • Display/edit more than one track segment at a time
  • Loading the map tiles sometimes seems to hang on single-core computers (i.e., one or two tiles are loaded, and for the next minute nothing happens, then suddenly further tiles show up)
  • Many settings are actually user settings, but nonetheless stored in the application config file - some differentiation will be required here
  • Undo/redo functionality
  • Add an installation package (because of configuration)
  • Make the application fool proof... 

I do not know when I will find the time to do that... 

Acknowledgements / License

This sample application uses code from several authors published on CodeProject:

For those parts, their licensing schemes may apply. For that part which is my work, the CodeProject Open License(^) applies.

History

Version 1.1: 15 Sep 2010

Added mapping of photographs.

Version 1.2: 9 Jan 2011

New design of the user interface of main page.
Also displays waypoints which are not part of a track.
Can convert a route into a track.
Maximum age of cached maps can be set.

Version 1.3: 13 Feb 2011

Compressing a track segment by removal of unnecessary points.
Further enhancement of user interface.

Version 1.4: 8 Sep 2013

Added Garmin extensions for heartrate etc.
Improved usablitiy: automatically open first track segment with a map / aerial images as background (configurable).

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Bernhard Hiller
Software Developer (Senior)
Germany Germany
No Biography provided

Comments and Discussions

 
GeneralMy vote of 5 PinprofessionalPrasad Khandekar10-Sep-13 3:08 
GeneralMy vote of 5 Pinmembermanoj kumar choubey16-Feb-12 1:43 
GeneralMy vote of 5 PinmemberSledgeHammer0116-Feb-11 19:26 
GeneralMy vote of 4 PinmemberJustJimBean20-Sep-10 18:36 
GeneralTime travel PinmemberSilic0re0915-Sep-10 9:09 
I'm a bit of a GPS expert and can lend some insight to your "time travel" problem...
 
Selective Availability (SA) is indeed turned off, and technically can't be turned back on for short bursts (single or double readings) as you experienced. SA screws with the clocks, but this would only have presented you with a large (up to 100 meter) error in your position, not a change on the time clock. SA has been permanently removed from future GPS satellites as the military has found methods to deny certain area's of GPS use and leave other area's alone.
 
There are a number of explanations of what may be happening to you, the first is simply the error in positioning accuracy, known as the DOP. Certain atmospheric and other conditions (such as terrain, which includes buildings) can increase your DOP. The higher the DOP, the less sure about your real position the GPS receiver is. What probably happened is that you got an erroneous reading which projected your position behind or in front of a previous position. Depending on how fast you are traveling when recording, this can look like the new point appears behind a previous one. The magic number is somewhere around 22mph (36km/h), since un-corrected GPS has a rough position error of +/- 10 meters.
 
The way to mitigate these effects is either use a corrected GPS signal (WAAS or DGPS), or do some white noise filtering and position prediction (aka Kalman Filter). You could make it a little simpler and just do linear predictions and if the new position is outside the allowable error, reject it then insert an interpolated point between the last good reading and the next one.
GeneralRe: Time travel Pinmemberbhiller16-Sep-10 21:40 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Mobile
Web01 | 2.8.140814.1 | Last Updated 8 Sep 2013
Article Copyright 2010 by Bernhard Hiller
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid