-
-
Save tinrobot2000/8a95a79fd25f2887b2fb80ac403d1917 to your computer and use it in GitHub Desktop.
Create GPX from Wahoo Fitness WorkoutData.sqlite file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT | |
'<?xml version="1.0" encoding="UTF-8"?> | |
<gpx creator="tinrobot2000" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd http://www.garmin.com/xmlschemas/GpxExtensions/v3 http://www.garmin.com/xmlschemas/GpxExtensionsv3.xsd http://www.garmin.com/xmlschemas/TrackPointExtension/v1 http://www.garmin.com/xmlschemas/TrackPointExtensionv1.xsd" version="1.1" xmlns="http://www.topografix.com/GPX/1/1" xmlns:gpxtpx="http://www.garmin.com/xmlschemas/TrackPointExtension/v1" xmlns:gpxx="http://www.garmin.com/xmlschemas/GpxExtensions/v3"> | |
<metadata> | |
<time>' || STRFTIME( | |
'%Y-%m-%dT%H:%M:%fZ', | |
'now' | |
) || '</time> | |
</metadata> | |
<trk> | |
<name>' || ZWORKOUTTYPENAME || '</name> | |
<type>1</type> | |
<trkseg>' | |
FROM | |
ZWFWORKOUT | |
WHERE | |
Z_PK = :workout | |
UNION | |
ALL | |
SELECT | |
'<trkpt lat="' || LAT || '" lon="' || LON || '"> | |
<ele>' || ELE || '</ele> | |
<time>' || TMS || '</time>' || COALESCE( | |
'<extensions> | |
<gpxtpx:TrackPointExtension>' || | |
COALESCE('<gpxtpx:hr>' || HRT || '</gpxtpx:hr>', '') || | |
COALESCE('<gpxtpx:cad>' || CAD || '</gpxtpx:cad>', '') || | |
COALESCE('<gpxtpx:atemp>' || TMP || '</gpxtpx:atemp>', '') || | |
'</gpxtpx:TrackPointExtension> | |
</extensions>', | |
'' | |
) || '</trkpt>' | |
FROM | |
( | |
SELECT | |
L.ZLATITUDE AS LAT, | |
L.ZLONGITUDE AS LON, | |
ROUND(L.ZALTITUDE, 3) AS ELE, | |
STRFTIME( | |
'%Y-%m-%dT%H:%M:%fZ', | |
ZTIMESTAMP, | |
'unixepoch', | |
'+31 years' | |
) AS TMS, | |
( | |
SELECT | |
ZHEARTRATE | |
FROM | |
ZWFHEARTRATESAMPLE | |
WHERE | |
ZTIMESTAMP = ( | |
SELECT | |
MAX(ZTIMESTAMP) | |
FROM | |
ZWFHEARTRATESAMPLE | |
WHERE | |
ZTIMESTAMP <= L.ZTIMESTAMP | |
) | |
) AS HRT, | |
( | |
SELECT | |
CAST( | |
IFNULL( | |
60 * ( | |
ZCRANKREVOLUTIONS - LAG(ZCRANKREVOLUTIONS, 3, 0) OVER ( | |
ORDER BY | |
ZTIMESTAMP | |
) | |
) / ( | |
ZTIMESTAMP - LAG(ZTIMESTAMP, 3, ZTIMESTAMP) OVER ( | |
ORDER BY | |
ZTIMESTAMP | |
) | |
), | |
0 | |
) AS INT | |
) | |
FROM | |
ZWFBIKECADENCESAMPLE | |
WHERE | |
ZWORKOUTDATA = L.ZWORKOUTDATA | |
AND ZTIMESTAMP <= L.ZTIMESTAMP | |
ORDER BY | |
ZTIMESTAMP DESC | |
) AS CAD, | |
( | |
SELECT | |
ROUND(ZTEMPERATURE, 1) | |
FROM | |
ZWFATMOSPRESSURESAMPLE | |
WHERE | |
ZWORKOUTDATA = L.ZWORKOUTDATA | |
AND ZTIMESTAMP <= L.ZTIMESTAMP | |
ORDER BY | |
ZTIMESTAMP DESC | |
) AS TMP | |
FROM | |
ZWFLOCATIONSAMPLE AS L | |
WHERE | |
ZWORKOUTDATA IN ( | |
SELECT | |
DISTINCT ZWORKOUTDATA | |
FROM | |
ZWFWORKOUTSEGMENT | |
WHERE | |
ZWORKOUT IN (:workout) | |
) | |
AND ZISWORKOUTACTIVE | |
ORDER BY | |
ZTIMESTAMP, | |
Z_PK | |
LIMIT | |
:limit | |
) | |
UNION | |
ALL | |
SELECT | |
'</trkseg> | |
</trk> | |
</gpx>'; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment