GPX Utils is a C# class library that provides a number of methods useful in manipulating GPS Exchange Format (GPX) files and Training Center Database (TCX) files. It provides a menu (see below) that can be used in other applications such as GPX Viewer and Exercise Analyzer.
Currently only GPX 1.1 is supported. Extensions, such as Garmin's TrackPointExtensionv2, that give heart rate and cadence are supported.
Formats a TCX or GPX file in a form that is easily read by humans.
Formats any XML file, including TCX and GPX, in a form that is easily read by humans. The output for TCX and GPX files should be the same as above, but a different calculation method using XDocument is used.
Converts all the selected GPX files to TCX files. You will be prompted for where to save them.
Converts all the selected TCX files to GPX files. You will be prompted for where to save them.
Allows you to modify a TCX file using the latitude and longitude from a GPX patch file. It is a way to fix tracks that are in the wrong place owing to, say, inaccurate GPS or a GPS dropout. The trackpoints in the TCX file are modified to use the latitude and longitude from the GPX patch file. The result is that the times are retained, but the latitude and longitude values are interpolated from the GPX patch file proportional to the elapsed time in the interval used in the TCX file. This results in a constant speed for the processed points. This speed is the simple average speed = distance / time elapsed. This is hence a method of correcting trackpoints that will least affect the overall speed calculations.
You will have to find a GPX file that goes where you went with the TCX exercise. The time in the GPX file is not used. There is an application, Map Lines, that will allow you to draw a path that can be saved as a GPX. It requires having a calibrated map of the area so you can see where to draw.
Only the first Activity, Lap, and Track in the TCX file are processed.
There are two modes. In both modes you will have a dialog to chose a start and end time. The TCX file will only be corrected in this interval (including the start and end times). The start and end times need to be specified in UTC time, which is the time listed in the TCX and GPX file. The initial times are the start and end times of the TCX file. You can edit these. There are three decimal points to prevent round off if you are unsure. Only time values actually in the TCX file are used so that this relationship holds.
start <= actualStart < actualEnd <= end
There are two sub items
MatchLatLon Mode
Determines the actual interval by matching the latitude and longitude of the start and end points from the GPX file in the TCX file. If no match is found for the start (because the GPS was inaccurate at the start), it starts at the start time you specified. It will not go past the specified end time.
UseInterval
Uses the interval as specified.
Allows you to add or replace HR and cadence values in a GPX file, using the ones from a TCX file. This is a way to add missing HR or cadence information to a GPX file if there is a corresponding TCX file with HR and / or cadence values. GPX files from Polar tend to not have HR information, but the TCX ones do. It works even if the TCX file does not have latitude and longitude. Another way to do this is to convert the TCX file to a new GPX file (see above: Convert TCX to GPX). The latter method does not work, however, if there is no latitude and longitude information in the TCX file. (Note that a GPX file must have latitude and longitude information. A TCX file is not required to have it.)
The HR and cadence values are obtained from the TCX file as a function of time. That function is linearly interpolated to get the values for HR and cadence for each track point in the GPX file using the time for that track point.
All the tracks, segments, and track points in the GPX file and all the Activity, Lap, and Track elements in the TCX file are processed. There will likely be a problem if different Track elements in the TCX file are overlapping in time.
Deletes trackpoints from a TCX file. There is a dialog where you can choose the start and end times for the deletion. These are displayed in UTC time, the same as is used in the file. Only the first Activity, Lap, and Track in the TCX file are processed.
Recalculates the times for a TCX file. There is a dialog where you can choose the new start time, and it then adds the difference between the new and old start times to all the trackpoint times. The Activity Id, which is a string and may or may not be the old start time, is not changed. (For Polar Beat TCX files the Id is the start time, so it will not be consistent with the new times. It can be changed manually if desired. Use the Lap start time, which is just below.) It will default to saving the new file with the old file name with ".tcx" replaced by".timechange.tcx". If there is date and time information in the file name, be sure to change it before clicking "Save". Only the first Activity, Lap, and Track in the TCX file are processed.
This program was designed to handle TCX files from Polar Flow. These files have other information besides the latitude, longitude, and time for the trackpoints. This information includes StartTime, TotalTimeSeconds, DistanceMeters, AverageHeartRateBpm, MaximumHeartRateBpm, MaximumSpeed, and AvgSpeed for the Laps, and it includes DistanceMeters for the Trackpoints. These numbers change if the positions of the trackpoints change or if they are deleted. This option recalculates them from the trackpoints currently in the file.
What is actually contained in these elements is not specified in the TCX (TrainingCenterDatabasev2) specification. The recalculation uses values as used by Polar. The MaximumSpeed does not not agree with the Polar calculation. (It is not published how they do that calculation, but it probably involves low-pass filtering that is not done here.) Note that what is contained in these elements can be obtained from the trackpoints anyway. That is what the GPX / TCX Utilities do. If you do not use these data and do not care if they are consistent with the data, then you do not need to do this.
This step is automatically done at the end of the delete and interpolate calculations above.
Polar Access produces GPX files with the time given in the form 2020-04-13T13:29:18.002. It is the local time, not the UTC time as required by the GPX specification. The UTC time typically ends in a Z. The corrected version of this time would be 2020-04-13T17:29:18.002Z. To determine this it is necessary to determine the time zone corresponding to the incorrect time, otherwise there is no way to know the UTC offset. The GPX / TCX Utilities do this using the latitude and longitude to get the time zone. (In the example the actual time zone where the exercise occurred was EDT with a UTC offset of -4.)
This menu item will fix the local times to be UTC and will also add category and location elements to the metadata, if this can be determined by the name. The file is corrected in place and the modified time is retained. The corrected file will be formatted. If you are uncertain this procedure will work, you should back up your files somewhere else before running it.
In the event Polar Access fixes this issue, this menu item will only add the category and location if it can. If no changes are necessary, the file will not be modified, so it should be safe to run it on files that have already been fixed or that do not have the time issue.
Calculates which of a set of Points of Interest (POI) are within a specified distance of the tracks and/or routes in a GPX file. You will be prompted for the GPX file with the tracks/routes, then for the GPX file with waypoints representing the POI's, and then for the distance. (The POI file can be the same as the one with the tracks/routes.) The distance is specified as a number plus a space plus the units, which may be ft, mi, m, or km. (Example: 10 mi) It will find all the POI's that are within the given distance from any track or route point in the tracks/routes file. (Typically, however, there would only be one track or route, your choice.) The results are saved in a GPX file with the found POI's. It interpolates points along the track or route at a distance along the track or route of 1/3 the specified distance in case the track or route points are far apart. It only checks for POI's within a circle from those points, though, so some POI's along the outer limits could be missed if they lie where the circles do not overlap. All points within 89% of the specified distance should be within the overlapping circles.
Converts the TCX file to a CSV file (used on other programs by the same author). Each row has three columns:
Shows extensive information from the selected files. This information is shown in the log dialog.
If you are installing from a download, just unzip the files into a directory somewhere convenient. Then run it from there. If you are installing from a build, copy all the files and directories from the bin/Release directory into a directory somewhere convenient.
To uninstall, just delete these files.
To use in another project you neeed to add a Reference to GpsUtils.dll and add the required NuGet packages.
GPS Utils is available from GitHub at https://github.com/KennethEvans/VS-GpsUtils.
It uses the NuGet packages GeoTimeZone, LinqToXsd, Newtonsoft.Json, ObjectListView.Official, TimeZoneConverter, and TimeZoneNames.