mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Convert deco info from JDiveLog to Subsurface
This patch correctly converts the available deco data from JDiveLog files. In order for this to work correctly the next patch from Linus is needed as well. Acked-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Miika Turkia <miika.turkia@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
d8fd8b2099
commit
f6bd9d1a14
1 changed files with 77 additions and 49 deletions
|
@ -43,7 +43,7 @@
|
||||||
<xsl:if test="TEMPERATURE != ''">
|
<xsl:if test="TEMPERATURE != ''">
|
||||||
<xsl:choose>
|
<xsl:choose>
|
||||||
<xsl:when test="$units = 'si'">
|
<xsl:when test="$units = 'si'">
|
||||||
<temperature water="{concat(format-number(TEMPERATURE - 273.15, '00.0'), ' C')}"/>
|
<temperature water="{concat(format-number(TEMPERATURE - 273.15, '0.0'), ' C')}"/>
|
||||||
</xsl:when>
|
</xsl:when>
|
||||||
<xsl:otherwise>
|
<xsl:otherwise>
|
||||||
<temperature water="{concat(TEMPERATURE, ' C')}"/>
|
<temperature water="{concat(TEMPERATURE, ' C')}"/>
|
||||||
|
@ -240,61 +240,65 @@ Comment: <xsl:value-of select="Comment"/>
|
||||||
<!-- end gas change -->
|
<!-- end gas change -->
|
||||||
|
|
||||||
<!-- dive sample - all the depth and temp readings -->
|
<!-- dive sample - all the depth and temp readings -->
|
||||||
<xsl:choose>
|
<xsl:for-each select="DIVE/SAMPLES/D">
|
||||||
<xsl:when test="$delta != '0'">
|
<sample>
|
||||||
<xsl:for-each select="DIVE/SAMPLES/D">
|
<xsl:choose>
|
||||||
<xsl:variable name="timeSec" select="(position() - 1) * $delta"/>
|
<xsl:when test="$delta != '0'">
|
||||||
<xsl:variable name="time" select="concat(floor($timeSec div 60), ':',
|
<xsl:variable name="timeSec" select="(position() - 1) * $delta"/>
|
||||||
format-number(floor($timeSec mod 60), '00'), ' min')"/>
|
<xsl:attribute name="time">
|
||||||
<xsl:choose>
|
<xsl:value-of select="concat(floor($timeSec div 60), ':',
|
||||||
<xsl:when test="name(following-sibling::*[1]) = 'TEMPERATURE'">
|
format-number(floor($timeSec mod 60), '00'), ' min')"/>
|
||||||
<sample time="{$time}" depth="{concat(., ' m')}">
|
</xsl:attribute>
|
||||||
<xsl:attribute name="temp">
|
</xsl:when>
|
||||||
<xsl:choose>
|
<xsl:otherwise>
|
||||||
<xsl:when test="$units = 'si'">
|
|
||||||
<xsl:value-of select="concat(format-number(following-sibling::TEMPERATURE - 273.15, '00.0'), ' C')"/>
|
|
||||||
</xsl:when>
|
|
||||||
<xsl:otherwise>
|
|
||||||
<xsl:value-of select="concat(following-sibling::TEMPERATURE, ' C')"/>
|
|
||||||
</xsl:otherwise>
|
|
||||||
</xsl:choose>
|
|
||||||
</xsl:attribute>
|
|
||||||
</sample>
|
|
||||||
</xsl:when>
|
|
||||||
<xsl:otherwise>
|
|
||||||
<sample time="{$time}" depth="{concat(., ' m')}"/>
|
|
||||||
</xsl:otherwise>
|
|
||||||
</xsl:choose>
|
|
||||||
</xsl:for-each>
|
|
||||||
</xsl:when>
|
|
||||||
<xsl:otherwise>
|
|
||||||
<xsl:for-each select="DIVE/SAMPLES/D">
|
|
||||||
<sample>
|
|
||||||
<xsl:attribute name="time">
|
<xsl:attribute name="time">
|
||||||
<xsl:call-template name="timeConvert">
|
<xsl:call-template name="timeConvert">
|
||||||
<xsl:with-param name="timeSec" select="preceding-sibling::T[1]"/>
|
<xsl:with-param name="timeSec" select="preceding-sibling::T[1]"/>
|
||||||
<xsl:with-param name="units" select="$units"/>
|
<xsl:with-param name="units" select="$units"/>
|
||||||
</xsl:call-template>
|
</xsl:call-template>
|
||||||
</xsl:attribute>
|
</xsl:attribute>
|
||||||
<xsl:if test="name(following-sibling::*[1]) = 'TEMPERATURE'">
|
</xsl:otherwise>
|
||||||
<xsl:attribute name="temp">
|
</xsl:choose>
|
||||||
<xsl:choose>
|
<xsl:attribute name="depth">
|
||||||
<xsl:when test="$units = 'si'">
|
<xsl:value-of select="concat(., ' m')"/>
|
||||||
<xsl:value-of select="concat(format-number(following-sibling::TEMPERATURE - 273.15, '00.0'), ' C')"/>
|
</xsl:attribute>
|
||||||
</xsl:when>
|
<xsl:if test="name(following-sibling::*[1]) = 'TEMPERATURE'">
|
||||||
<xsl:otherwise>
|
<xsl:attribute name="temp">
|
||||||
<xsl:value-of select="concat(following-sibling::TEMPERATURE, ' C')"/>
|
<xsl:choose>
|
||||||
</xsl:otherwise>
|
<xsl:when test="$units = 'si'">
|
||||||
</xsl:choose>
|
<xsl:value-of select="concat(format-number(following-sibling::TEMPERATURE - 273.15, '0.0'), ' C')"/>
|
||||||
|
</xsl:when>
|
||||||
|
<xsl:otherwise>
|
||||||
|
<xsl:value-of select="concat(following-sibling::TEMPERATURE, ' C')"/>
|
||||||
|
</xsl:otherwise>
|
||||||
|
</xsl:choose>
|
||||||
|
</xsl:attribute>
|
||||||
|
</xsl:if>
|
||||||
|
<xsl:if test="(name(following-sibling::*[1]) = 'DECOINFO') or (name(following-sibling::*[2]) = 'DECOINFO')">
|
||||||
|
<xsl:choose>
|
||||||
|
<xsl:when test="following-sibling::DECOINFO[1] = '0.0'">
|
||||||
|
<xsl:attribute name="ndl">
|
||||||
|
<xsl:call-template name="timeConvertMin">
|
||||||
|
<xsl:with-param name="timeMin" select="following-sibling::DECOINFO[1]/@tfs"/>
|
||||||
|
<xsl:with-param name="units" select="$units"/>
|
||||||
|
</xsl:call-template>
|
||||||
</xsl:attribute>
|
</xsl:attribute>
|
||||||
</xsl:if>
|
</xsl:when>
|
||||||
<xsl:attribute name="depth">
|
<xsl:otherwise>
|
||||||
<xsl:value-of select="concat(., ' m')"/>
|
<xsl:attribute name="stoptime">
|
||||||
</xsl:attribute>
|
<xsl:call-template name="timeConvertMin">
|
||||||
</sample>
|
<xsl:with-param name="timeMin" select="following-sibling::DECOINFO[1]/@tfs"/>
|
||||||
</xsl:for-each>
|
<xsl:with-param name="units" select="$units"/>
|
||||||
</xsl:otherwise>
|
</xsl:call-template>
|
||||||
</xsl:choose>
|
</xsl:attribute>
|
||||||
|
<xsl:attribute name="stopdepth">
|
||||||
|
<xsl:value-of select="concat(following-sibling::DECOINFO[1], ' m')"/>
|
||||||
|
</xsl:attribute>
|
||||||
|
</xsl:otherwise>
|
||||||
|
</xsl:choose>
|
||||||
|
</xsl:if>
|
||||||
|
</sample>
|
||||||
|
</xsl:for-each>
|
||||||
<!-- dive sample -->
|
<!-- dive sample -->
|
||||||
|
|
||||||
</dive>
|
</dive>
|
||||||
|
@ -362,4 +366,28 @@ Comment: <xsl:value-of select="Comment"/>
|
||||||
</xsl:template>
|
</xsl:template>
|
||||||
<!-- end convert time -->
|
<!-- end convert time -->
|
||||||
|
|
||||||
|
<!-- convert time in minutes.decimal to minutes:seconds -->
|
||||||
|
<xsl:template name="timeConvertMin">
|
||||||
|
<xsl:param name="timeMin"/>
|
||||||
|
<xsl:param name="units"/>
|
||||||
|
|
||||||
|
<xsl:if test="$timeMin != ''">
|
||||||
|
<xsl:choose>
|
||||||
|
<xsl:when test="$units = 'si'">
|
||||||
|
<xsl:value-of select="concat(substring-before($timeMin, '.'), ':', format-number(substring-after($timeMin, '.'), '00'), ' min')"/>
|
||||||
|
</xsl:when>
|
||||||
|
<xsl:otherwise>
|
||||||
|
<xsl:choose>
|
||||||
|
<xsl:when test="substring-after($timeMin, '.') >= 60 or string-length(substring-after($timeMin, '.')) < 2">
|
||||||
|
<xsl:value-of select="concat(substring-before($timeMin, '.'), ':', format-number(round(substring-after(format-number($timeMin, '.00'), '.') * .6), '00'), ' min')"/>
|
||||||
|
</xsl:when>
|
||||||
|
<xsl:otherwise>
|
||||||
|
<xsl:value-of select="concat(substring-before($timeMin, '.'), ':', format-number(substring-after($timeMin, '.'), '00'), ' min')"/>
|
||||||
|
</xsl:otherwise>
|
||||||
|
</xsl:choose>
|
||||||
|
</xsl:otherwise>
|
||||||
|
</xsl:choose>
|
||||||
|
</xsl:if>
|
||||||
|
</xsl:template>
|
||||||
|
<!-- end convert time -->
|
||||||
</xsl:stylesheet>
|
</xsl:stylesheet>
|
||||||
|
|
Loading…
Add table
Reference in a new issue