summaryrefslogtreecommitdiffstats
path: root/xslt/MacDive.xslt
diff options
context:
space:
mode:
authorGravatar Miika Turkia <miika.turkia@gmail.com>2013-02-27 07:01:22 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2013-02-27 06:44:34 -0800
commitecdb4cd52230faca2b3637ca4f2a0c5caa36a7ce (patch)
tree1026d866ab1b71026e369e365e93812540668e2d /xslt/MacDive.xslt
parent4b0d7ac72f632383763a37ba1f989b5a06aea5b1 (diff)
downloadsubsurface-ecdb4cd52230faca2b3637ca4f2a0c5caa36a7ce.tar.gz
Fix MacDive import to convert Imperial temperature
MacDive import needs to convert temperatures to Celcius. However, it seems that MacDive reports no reading as 32F (and probably 0C when using Metric). There is no way of knowing whether we have no reading or the temperature is actually zero, so we use the given temperature currently as 0C is a valid temperature... Signed-off-by: Miika Turkia <miika.turkia@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'xslt/MacDive.xslt')
-rw-r--r--xslt/MacDive.xslt41
1 files changed, 36 insertions, 5 deletions
diff --git a/xslt/MacDive.xslt b/xslt/MacDive.xslt
index c7c406521..35a5a783d 100644
--- a/xslt/MacDive.xslt
+++ b/xslt/MacDive.xslt
@@ -208,22 +208,34 @@
<temperature>
<xsl:if test="tempAir != ''">
<xsl:attribute name="air">
- <xsl:value-of select="concat(tempAir, ' C')"/>
+ <xsl:call-template name="tempConvert">
+ <xsl:with-param name="temp" select="tempAir"/>
+ <xsl:with-param name="units" select="$units"/>
+ </xsl:call-template>
</xsl:attribute>
</xsl:if>
<xsl:if test="tempLow != ''">
<xsl:attribute name="water">
- <xsl:value-of select="concat(tempLow, ' C')"/>
+ <xsl:call-template name="tempConvert">
+ <xsl:with-param name="temp" select="tempLow"/>
+ <xsl:with-param name="units" select="$units"/>
+ </xsl:call-template>
</xsl:attribute>
</xsl:if>
<xsl:if test="tempair != ''">
<xsl:attribute name="air">
- <xsl:value-of select="concat(tempair, ' C')"/>
+ <xsl:call-template name="tempConvert">
+ <xsl:with-param name="temp" select="tempair"/>
+ <xsl:with-param name="units" select="$units"/>
+ </xsl:call-template>
</xsl:attribute>
</xsl:if>
<xsl:if test="templow != ''">
<xsl:attribute name="water">
- <xsl:value-of select="concat(templow, ' C')"/>
+ <xsl:call-template name="tempConvert">
+ <xsl:with-param name="temp" select="temlow"/>
+ <xsl:with-param name="units" select="$units"/>
+ </xsl:call-template>
</xsl:attribute>
</xsl:if>
</temperature>
@@ -288,7 +300,10 @@
</xsl:if>
<xsl:if test="temperature != ''">
<xsl:attribute name="temp">
- <xsl:value-of select="concat(temperature, ' C')"/>
+ <xsl:call-template name="tempConvert">
+ <xsl:with-param name="temp" select="temperature"/>
+ <xsl:with-param name="units" select="$units"/>
+ </xsl:call-template>
</xsl:attribute>
</xsl:if>
</sample>
@@ -378,6 +393,22 @@
</xsl:template>
<!-- end convert pressure -->
+ <!-- convert temperature to C -->
+ <xsl:template name="tempConvert">
+ <xsl:param name="temp"/>
+ <xsl:param name="units"/>
+
+ <xsl:choose>
+ <xsl:when test="$units = 'Imperial'">
+ <xsl:value-of select="concat(format-number(($temp - 32) * 5 div 9, '0.0'), ' C')"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="concat($temp, ' C')"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+ <!-- end convert temperature -->
+
<!-- convert time in seconds to minutes:seconds -->
<xsl:template name="timeConvert">
<xsl:param name="timeSec"/>