ebrithiljonas / fittrackee-uploader

A companion application for FitTrackee to upload your workout files
GNU Affero General Public License v3.0
13 stars 4 forks source link

Extract sport field from GPX #9

Open slackline opened 4 months ago

slackline commented 4 months ago

Many GPX files will record the activity type directly in the metadata. For example OpenTracks records this in two places as both <type></type> and <opentracks:typeTranslated></opentracks:typeTranslated>...

<?xml version="1.0" encoding="UTF-8"?>
<gpx
version="1.1"
creator="OpenTracks"
xmlns="http://www.topografix.com/GPX/1/1"
xmlns:topografix="http://www.topografix.com/GPX/Private/TopoGrafix/0/1"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:opentracks="http://opentracksapp.com/xmlschemas/v1"
xmlns:gpxtpx="http://www.garmin.com/xmlschemas/TrackPointExtension/v2"
xmlns:gpxtrkx="http://www.garmin.com/xmlschemas/TrackStatsExtension/v1"
xmlns:cluetrust="http://www.cluetrust.com/Schemas/"
xmlns:pwr="http://www.garmin.com/xmlschemas/PowerExtension/v1"
xsi:schemaLocation="http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd http://www.topografix.com/GPX/Private/TopoGrafix/0/1 http://www.topografix.com/GPX/Private/TopoGrafix/0/1/topografix.xsd http://www.garmin.com/xmlschem
as/TrackPointExtension/v2 https://www8.garmin.com/xmlschemas/TrackPointExtensionv2.xsd http://www.garmin.com/xmlschemas/PowerExtension/v1 https://www8.garmin.com/xmlschemas/PowerExtensionv1.xsd http://www.garmin.com/xmlschemas/TrackStatsExtension/
v1 http://www.cluetrust.com/Schemas http://www.cluetrust.com/Schemas/gpxdata10.xsd http://opentracksapp.com/xmlschemas/v1 http://opentracksapp.com/xmlschemas/OpenTracks_v1.xsd">
<trk>
<name><![CDATA[2024-06-16T07:41+01]]></name>
<desc><![CDATA[]]></desc>
<type><![CDATA[biking]]></type>
<extensions>
<topografix:color>c0c0c0</topografix:color>
<opentracks:trackid>6d5bc681-400d-45ed-9d43-644c16270605</opentracks:trackid>
<opentracks:typeTranslated><![CDATA[biking]]></opentracks:typeTranslated>

It would be useful if these could be extracted when loading and mapped to the sport field which is required when uploading a track to [fittrackee]() as it would allow batches of GPX tracks to be uploaded automatically without the need to manually add the sport field when doing so as is currently required.