-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgpx2xtf.xsl
112 lines (106 loc) · 4.68 KB
/
gpx2xtf.xsl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
<?xml version="1.0"?>
<!--
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:gpx="http://www.topografix.com/GPX/1/0">
-->
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns="http://www.interlis.ch/INTERLIS2.3"
xmlns:gpx="http://www.topografix.com/GPX/1/1"
xmlns:gpxtpx="http://www.garmin.com/xmlschemas/TrackPointExtension/v1"
xmlns:uuid="java:java.util.UUID"
exclude-result-prefixes="gpx gpxtpx uuid">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes" />
<xsl:variable name="ilimodel" select="'GPX_GARMIN_EXTENSIONS'"/>
<xsl:param name="TRACK_CMT" select="0"/>
<xsl:template match="/">
<xsl:variable name="GPX_BID" select="uuid:randomUUID()"/>
<TRANSFER>
<HEADERSECTION SENDER="gpx2xtf XSLT processor" VERSION="2.3">
<MODELS>
<MODEL VERSION="2023-08-24" URI="http://www.garmin.com">
<xsl:attribute name="NAME">
<xsl:value-of select="$ilimodel"/>
</xsl:attribute>
</MODEL>
</MODELS>
</HEADERSECTION>
<DATASECTION>
<xsl:element name="{$ilimodel}.GPX">
<xsl:attribute name="BID">
<!--xsl:value-of select="1"/-->
<xsl:value-of select="uuid:randomUUID()"/>
</xsl:attribute>
<xsl:element name="{$ilimodel}.GPX.TRACK">
<xsl:attribute name="TID">
<!--xsl:value-of select="1"/-->
<xsl:value-of select="$GPX_BID"/>
</xsl:attribute>
<cmt>
<xsl:value-of select="$TRACK_CMT"/>
</cmt>
</xsl:element>
<xsl:apply-templates select="gpx:gpx/gpx:trk/gpx:trkseg">
<xsl:with-param name="BASKET_ID" select="$GPX_BID"/>
</xsl:apply-templates>
</xsl:element>
</DATASECTION>
</TRANSFER>
</xsl:template>
<xsl:template match="gpx:gpx/gpx:trk/gpx:trkseg">
<xsl:param name="BASKET_ID" select="0"></xsl:param>
<xsl:variable name="TRACKSEG_TID" select="uuid:randomUUID()"/>
<xsl:element name="{$ilimodel}.GPX.TRACKSEGMENT">
<xsl:attribute name="TID">
<xsl:value-of select="$TRACKSEG_TID"/>
</xsl:attribute>
<xsl:element name="TRACK">
<xsl:attribute name="REF">
<xsl:value-of select="$BASKET_ID"/>
</xsl:attribute>
</xsl:element>
</xsl:element>
<xsl:apply-templates select="gpx:trkpt">
<xsl:with-param name="TRACKSEG_TID" select="$TRACKSEG_TID"/>
</xsl:apply-templates>
</xsl:template>
<xsl:template match="gpx:trkpt">
<xsl:param name="TRACKSEG_TID" select="0"></xsl:param>
<xsl:element name="{$ilimodel}.GPX.TRACKPOINT">
<xsl:attribute name="TID">
<xsl:value-of select="uuid:randomUUID()"/>
</xsl:attribute>
<point>
<COORD>
<C1>
<xsl:value-of select="@lon"></xsl:value-of>
</C1>
<C2>
<xsl:value-of select="@lat"></xsl:value-of>
</C2>
<C3>
<xsl:value-of select="gpx:ele"></xsl:value-of>
</C3>
</COORD>
</point>
<time>
<xsl:value-of select="concat(substring-before(gpx:time, 'Z'),'.000')"/>
</time>
<atemp>
<xsl:value-of select="gpx:extensions/gpxtpx:TrackPointExtension/gpxtpx:atemp"/>
</atemp>
<cad>
<xsl:value-of select="gpx:extensions/gpxtpx:TrackPointExtension/gpxtpx:cad"/>
</cad>
<!-- Transform heartrate only if below 250 (see also INTERLIS model) -->
<xsl:if test="gpx:extensions/gpxtpx:TrackPointExtension/gpxtpx:hr < 250">
<hr>
<xsl:value-of select="gpx:extensions/gpxtpx:TrackPointExtension/gpxtpx:hr"/>
</hr>
</xsl:if>
<xsl:element name="TRACKSEGMENT">
<xsl:attribute name="REF">
<xsl:value-of select="$TRACKSEG_TID"/>
</xsl:attribute>
</xsl:element>
</xsl:element>
</xsl:template>
</xsl:stylesheet>