gps-wizard

GPS Exchange Format (GPX) - GPSResults

Background

The GPX home page summarises the importance of GPX validation and best practices. It is quite straightforward to ensure the exports of GPSResults are compliant with the GPX 1.0 standard.

This document covers two main topics:

GPX Validation

There are numerous ways to check compliance and validate a GPX file against the XSD. Several approaches are described at the GPX home, but the simplest approach is to use an online validator such as the one at freeformatter.com.

This example has been fixed by hand to ensure compliance with the GPX 1.0 schema. Simply paste it into the XML Validator and press “Validate XML”.

<?xml version="1.0" encoding="UTF-8"?>
<gpx creator="GPSResults V6.187"
     version="1.0"
     xmlns="http://www.topografix.com/GPX/1/0"
     xmlns:gpss="http://www.gps-speed.com/gpx"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:schemaLocation="http://www.topografix.com/GPX/1/0
                         https://www.topografix.com/GPX/1/0/gpx.xsd
                         http://www.gps-speed.com/gpx
                         https://logiqx.github.io/gps-wizard/xmlschemas/logiqx/gpss/gpss.xsd">
  <trk>
    <name>exported tracks</name>
    <gpss:metadata>
      <gpss:link href="https://www.gps-speed.com">
        <gpss:text>GPS-Results</gpss:text>
      </gpss:link>
      <gpss:time>2023-01-14T08:45:08.200Z</gpss:time>
      <gpss:username>K888</gpss:username>
      <gpss:device>GT-31</gpss:device>
      <gpss:firmware>V1.3A0926B</gpss:firmware>
      <gpss:serialno>168603881</gpss:serialno>
    </gpss:metadata>
    <trkseg>
      <trkpt lat="51.537353200" lon="0.675161900">
        <ele>9.71</ele>
        <time>2023-01-14T08:45:08.200Z</time>
        <course>197.546</course>
        <speed>0.022</speed>
        <sat>21</sat>
        <hdop>0.60</hdop>
        <gpss:sdop>0.57</gpss:sdop>
        <gpss:cdop>46.18</gpss:cdop>
        <gpss:fix>43</gpss:fix>
      </trkpt>
    </trkseg>
  </trk>
</gpx>

Note: The link to https://logiqx.github.io should be replaced with a link to https://www.gps-speed.com once gpss.xsd is available on the gps-speed website.

GPX Writer

The above example was based on a GPX file generated by GPSResults, but a number of changes were required for GPX 1.0 compliance. None of them are particularly complicated but GPX compliance will ensure that exports can be loaded into other applications without issues.

XML Declaration

GPSResults includes the following declaration:

<?xml version="1.0" encoding="UTF-8" standalone="no" ?>

The standalone parameter is redundant since there is no DTD and can be removed:

<?xml version="1.0" encoding="UTF-8"?>

Note: No space is required after UTF-8 - reference is w3.org.

GPX Schema Location

The xsi:schemaLocation needs to specify the XSD location for the gps-speed extensions:

<gpx creator="GPSResults V6.187"
     version="1.0"
     xmlns="http://www.topografix.com/GPX/1/0"
     xmlns:gpss="http://www.gps-speed.com/gpx"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:schemaLocation="http://www.topografix.com/GPX/1/0
                         https://www.topografix.com/GPX/1/0/gpx.xsd
                         http://www.gps-speed.com/gpx
                         https://logiqx.github.io/gps-wizard/xmlschemas/logiqx/gpss/gpss.xsd">

Notes:

Metadata

GPX 1.0 does not support the <metadata> and <link> elements which are a feature of GPX 1.1:

<metadata>
  <link href="http://www.gps-speed.com">
    <text>GPS-Results</text>
  </link>
  <time>2023-01-14T08:45:08.200Z</time>
  <username>K888</username>
  <device>GT-31</device>
  <firmware>V1.3A0926B</firmware>
  <serialno>168603881</serialno>
</metadata>
<trk>
  <name>exported tracks</name>
  <trkseg>
    ...
  </trkseg>
</trk>

However, GPX 1.0 does allow for custom elements, so long as they use a different namespace.

Custom elements can appear immediately before the first <trkseg> element, or immediately after the final <trk> element:

<trk>
  <name>exported tracks</name>
  <gpss:metadata>
    <gpss:link href="http://www.gps-speed.com">
      <gpss:text>GPS-Results</gpss:text>
    </gpss:link>
    <gpss:time>2023-01-14T08:45:08.200Z</gpss:time>
    <gpss:username>K888</gpss:username>
    <gpss:device>GT-31</gpss:device>
    <gpss:firmware>V1.3A0926B</gpss:firmware>
    <gpss:serialno>168603881</gpss:serialno>
  </gpss:metadata>
  <trkseg>
    ...
  </trkseg>
</trk>

The gpss elements shown above are defined in the extension schema gpss.xsd which is based on the definitions in GPX 1.1

Making this change will also require a tweak to the GPX reader, so that it recognises <gpss:metadata> as well as <metadata>.

Sequencing

GPX mandates a strict sequencing of elements. The following example does not quite conform with GPX 1.0:

<trkpt lat="51.537353200" lon="0.675161900">
  <ele>9.71</ele>
  <time>2023-01-14T08:45:08.200Z</time>
  <sat>21</sat>
  <speed>0.022</speed>
  <cog>197.546</cog>
  <hdop>0.60</hdop>
</trkpt>

The correct sequencing of the elements is <course>, <speed>, <sat>:

<trkpt lat="51.537353200" lon="0.675161900">
  <ele>9.71</ele>
  <time>2023-01-14T08:45:08.200Z</time>
  <course>197.546</course>
  <speed>0.022</speed>
  <sat>21</sat>
  <hdop>0.60</hdop>
</trkpt>

This change will not affect the GPX reader in any way, but it does affect whether the file is GPX 1.0 compliant.

Course

The <course> element is currently called <cog> in GPSResults exports, which is not compliant with GPX 1.0.

The <course> element should also appear between the <time> and <speed> elements.

<trkpt lat="51.537353200" lon="0.675161900">
  <ele>9.71</ele>
  <time>2023-01-14T08:45:08.200Z</time>
  <course>197.546</course>
  <speed>0.022</speed>
  <sat>21</sat>
  <hdop>0.60</hdop>
</trkpt>

Making this change will also require a tweak to the GPX reader, so that it recognises <course> as well as <cog>.

Accuracy

The GPX exports of GPSResults include the following custom elements:

<sdop>0.57</sdop>
<vsdop>0.57</vsdop>
<cdop>46.18</cdop>
<fix>43</fix>

GPX 1.0 does allow for custom elements, so long as they use a different namespace:

<gpss:sdop>0.57</gpss:sdop>
<gpss:vsdop>0.57</gpss:vsdop>
<gpss:cdop>46.18</gpss:cdop>
<gpss:fix>43</gpss:fix>

The gpss elements shown above have been defined in the extension schema gpss.xsd

Making this change will require a tweak to the GPX reader, so that it recognises these fields with or without the gpss prefix.

Units

SDOP and VSDOP should use m/s as units but there appears to be a bug, multiplying the knots value by 1.852.

Exporting an SBP or OAO as GPX and reloading results in the +/- figures changing slightly, presumably rounding errors.

This can easily be fixed for the reading and writing of <gpss:sdop> and <gpss:vsdop>

GPX Reader

Metadata

The changes described earlier require a tweak to the GPX reader, so that it recognises <gpss:metadata> as well as <metadata>.

Speed

The GPX reader should be able to recognise the following variations of SOG.

The namespaces would be as follows:

xmlns:gpxdata="http://www.cluetrust.com/XML/GPXDATA/1/0"
xmlns:gpxtpx="http://www.garmin.com/xmlschemas/TrackPointExtension/v2"
xmlns:ns3="http://www.garmin.com/xmlschemas/TrackPointExtension/v2

Note: Technically speaking the namespace prefix (e.g. gpxdata, gpxtpx or ns3) can be chosen by the GPX creator.

Course

The GPX reader should be able to recognise the following variations of COG.

The namespaces would be as follows:

xmlns:gpxtpx="http://www.garmin.com/xmlschemas/TrackPointExtension/v2"
xmlns:ns3="http://www.garmin.com/xmlschemas/TrackPointExtension/v2

Note: Technically speaking the namespace prefix (e.g. gpxtpx or ns3) can be chosen by the GPX creator.

Timestamps

There is an issue with the GPX reader, relating to timestamps and timezones.

It should be noted that this doesn’t happen for all files. It happens for a test file on 22 Sep 2020, but not 14 Jan 2023. Perhaps it only affects files during the months with daylight saving?

Accuracy

It has been noted that <vsdop> and <cdop> do not appear to be loaded from GPX files.

When GPSResults reads a GPX file that contains <vsdop> or <cdop> they do not appear in a subsequent GPX export.

The GPX reader should support all four custom fields with <trkpt>, both with and without the gpss prefix:

Units

SDOP and VSDOP should use m/s as units but there appears to be a bug, multiplying the knots value by 1.852.

This can easily be fixed for the reading and writing of <gpss:sdop> and <gpss:vsdop>

Summary

Ensuring the exports of GPSResults are compliant with GPX 1.0 is pretty straightforward: