Support timedepth mode on UDCF import

Fixes #756

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Miika Turkia 2014-11-11 09:40:40 +08:00 committed by Dirk Hohndel
parent 01441ccb45
commit 116615857c

View file

@ -86,6 +86,43 @@
</cylinder>
</xsl:for-each>
<xsl:choose>
<!-- samples recorded at irregular internal, but storing time stamp -->
<xsl:when test="timedepthmode">
<!-- gas change -->
<xsl:for-each select="SAMPLES/SWITCH|samples/switch">
<event name="gaschange">
<xsl:variable name="timeSec" select="following-sibling::T|following-sibling::t"/>
<xsl:attribute name="time">
<xsl:value-of select="concat(floor($timeSec div 60), ':',
format-number(floor($timeSec mod 60), '00'), ' min')"/>
</xsl:attribute>
<xsl:attribute name="value">
<xsl:value-of select="ancestor::DIVE/GASES/MIX[MIXNAME=current()]/O2|ancestor::dive/gases/mix[mixname=current()]/o2 * 100" />
</xsl:attribute>
</event>
</xsl:for-each>
<!-- end gas change -->
<!-- samples -->
<xsl:for-each select="SAMPLES/D|samples/d">
<sample>
<xsl:variable name="timeSec" select="preceding-sibling::T[position()=1]|preceding-sibling::t[position()=1]"/>
<xsl:attribute name="time">
<xsl:value-of select="concat(floor($timeSec div 60), ':',
format-number(floor($timeSec mod 60), '00'), ' min')"/>
</xsl:attribute>
<xsl:attribute name="depth">
<xsl:value-of select="concat(., ' m')"/>
</xsl:attribute>
</sample>
</xsl:for-each>
<!-- end samples -->
</xsl:when>
<!-- sample recorded at even internals -->
<xsl:otherwise>
<xsl:variable name="delta" select="SAMPLES/DELTA|samples/delta"/>
<!-- gas change -->
@ -100,9 +137,11 @@
<xsl:value-of select="ancestor::DIVE/GASES/MIX[MIXNAME=current()]/O2|ancestor::dive/gases/mix[mixname=current()]/o2 * 100" />
</xsl:attribute>
</event>
</xsl:for-each>
<!-- end gas change -->
<!-- samples -->
<xsl:for-each select="SAMPLES/D|samples/d">
<sample>
<xsl:variable name="timeSec" select="(position() - 1) * $delta"/>
@ -115,6 +154,10 @@
</xsl:attribute>
</sample>
</xsl:for-each>
<!-- end samples -->
</xsl:otherwise>
</xsl:choose>
</dive>
</xsl:template>
</xsl:stylesheet>