mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-27 20:58:47 +00:00
Export: Fix Cylinder Pressures in CSV Export.
Fix the cylinder pressures in the CSV summary export. Only show pressures derived from `pressure` attributes in samples for the first cylinder. Add support for showing pressures derived from `pressure0` ... `pressureX` attributes. Also cleaned up unit conversions, and changed tabs to spaces. From discussion in https://github.com/subsurface/subsurface/pull/3906#issuecomment-1575980882. Signed-off-by: Michael Keller <github@ike.ch>
This commit is contained in:
parent
5d708c0d92
commit
e260780c9d
1 changed files with 124 additions and 128 deletions
|
@ -177,100 +177,84 @@
|
||||||
</xsl:choose>
|
</xsl:choose>
|
||||||
<xsl:value-of select="$fs"/>
|
<xsl:value-of select="$fs"/>
|
||||||
|
|
||||||
|
<!-- Cylinders -->
|
||||||
<xsl:for-each select="cylinder">
|
<xsl:for-each select="cylinder">
|
||||||
<xsl:choose>
|
<xsl:call-template name="CsvEscape">
|
||||||
<xsl:when test="position() <= $cylinders">
|
<xsl:with-param name="value">
|
||||||
<xsl:call-template name="CsvEscape">
|
<xsl:choose>
|
||||||
<xsl:with-param name="value">
|
<xsl:when test="$units = 1">
|
||||||
<xsl:choose>
|
<xsl:value-of select="concat(format-number((substring-before(@size, ' ') div 14.7 * 3000) * 0.035315, '#.#'), '')"/>
|
||||||
<xsl:when test="$units = 1">
|
</xsl:when>
|
||||||
<xsl:value-of select="concat(format-number((substring-before(@size, ' ') div 14.7 * 3000) * 0.035315, '#.#'), '')"/>
|
<xsl:otherwise>
|
||||||
</xsl:when>
|
<xsl:value-of select="substring-before(@size, ' ')"/>
|
||||||
<xsl:otherwise>
|
</xsl:otherwise>
|
||||||
<xsl:value-of select="substring-before(@size, ' ')"/>
|
</xsl:choose>
|
||||||
</xsl:otherwise>
|
</xsl:with-param>
|
||||||
</xsl:choose>
|
</xsl:call-template>
|
||||||
</xsl:with-param>
|
<xsl:value-of select="$fs"/>
|
||||||
</xsl:call-template>
|
|
||||||
<xsl:value-of select="$fs"/>
|
<xsl:variable name="pressureAttribute" select="concat('pressure', position() - 1)"/>
|
||||||
<xsl:call-template name="CsvEscape">
|
<xsl:call-template name="CsvEscape">
|
||||||
<xsl:with-param name="value">
|
<xsl:with-param name="value">
|
||||||
<xsl:choose>
|
<xsl:choose>
|
||||||
<xsl:when test="@start|@end != ''">
|
<xsl:when test="@start != ''">
|
||||||
<xsl:choose>
|
<xsl:call-template name="ConvertPressure">
|
||||||
<xsl:when test="$units = 1">
|
<xsl:with-param name="pressureBar" select="@start"/>
|
||||||
<xsl:value-of select="concat(format-number((substring-before(@start, ' ') * 14.5037738007), '#'), '')"/>
|
</xsl:call-template>
|
||||||
</xsl:when>
|
</xsl:when>
|
||||||
<xsl:otherwise>
|
<xsl:when test="substring-before(../divecomputer[1]/sample/@*[name() = $pressureAttribute], ' ') > 0">
|
||||||
<xsl:value-of select="substring-before(@start, ' ')"/>
|
<xsl:call-template name="ConvertPressure">
|
||||||
</xsl:otherwise>
|
<xsl:with-param name="pressureBar" select="../divecomputer[1]/sample/@*[name() = $pressureAttribute]"/>
|
||||||
</xsl:choose>
|
</xsl:call-template>
|
||||||
</xsl:when>
|
</xsl:when>
|
||||||
<xsl:otherwise>
|
<xsl:when test="(position() = 1) and (substring-before(../divecomputer[1]/sample/@pressure, ' ') > 0)">
|
||||||
<xsl:choose>
|
<xsl:call-template name="ConvertPressure">
|
||||||
<xsl:when test="$units = 1">
|
<xsl:with-param name="pressureBar" select="../divecomputer[1]/sample/@pressure"/>
|
||||||
<xsl:choose>
|
</xsl:call-template>
|
||||||
<xsl:when test="substring-before(../divecomputer[1]/sample[@pressure]/@pressure, ' ') > 0">
|
</xsl:when>
|
||||||
<xsl:value-of select="concat(format-number((substring-before(../divecomputer[1]/sample[@pressure]/@pressure, ' ') * 14.5037738007), '#'), '')"/>
|
<xsl:otherwise>
|
||||||
</xsl:when>
|
<xsl:value-of select="''"/>
|
||||||
<xsl:otherwise>
|
</xsl:otherwise>
|
||||||
<xsl:value-of select="''"/>
|
</xsl:choose>
|
||||||
</xsl:otherwise>
|
</xsl:with-param>
|
||||||
</xsl:choose>
|
</xsl:call-template>
|
||||||
</xsl:when>
|
<xsl:value-of select="$fs"/>
|
||||||
<xsl:otherwise>
|
|
||||||
<xsl:value-of select="substring-before(../divecomputer[1]/sample[@pressure]/@pressure, ' ')"/>
|
<xsl:call-template name="CsvEscape">
|
||||||
</xsl:otherwise>
|
<xsl:with-param name="value">
|
||||||
</xsl:choose>
|
<xsl:choose>
|
||||||
</xsl:otherwise>
|
<xsl:when test="@end != ''">
|
||||||
</xsl:choose>
|
<xsl:call-template name="ConvertPressure">
|
||||||
</xsl:with-param>
|
<xsl:with-param name="pressureBar" select="@end"/>
|
||||||
</xsl:call-template>
|
</xsl:call-template>
|
||||||
<xsl:value-of select="$fs"/>
|
</xsl:when>
|
||||||
<xsl:call-template name="CsvEscape">
|
<xsl:when test="substring-before(../divecomputer[1]/sample[@*[name() = $pressureAttribute]][last()]/@*[name() = $pressureAttribute], ' ') > 0">
|
||||||
<xsl:with-param name="value">
|
<xsl:call-template name="ConvertPressure">
|
||||||
<xsl:choose>
|
<xsl:with-param name="pressureBar" select="../divecomputer[1]/sample[@*[name() = $pressureAttribute]][last()]/@*[name() = $pressureAttribute]"/>
|
||||||
<xsl:when test="@start|@end != ''">
|
</xsl:call-template>
|
||||||
<xsl:choose>
|
</xsl:when>
|
||||||
<xsl:when test="$units = 1">
|
<xsl:when test="(position() = 1) and (substring-before(../divecomputer[1]/sample[@pressure][last()]/@pressure, ' ') > 0)">
|
||||||
<xsl:value-of select="concat(format-number((substring-before(@end, ' ') * 14.5037738007), '#'), '')"/>
|
<xsl:call-template name="ConvertPressure">
|
||||||
</xsl:when>
|
<xsl:with-param name="pressureBar" select="../divecomputer[1]/sample[@pressure][last()]/@pressure"/>
|
||||||
<xsl:otherwise>
|
</xsl:call-template>
|
||||||
<xsl:value-of select="substring-before(@end, ' ')"/>
|
</xsl:when>
|
||||||
</xsl:otherwise>
|
<xsl:otherwise>
|
||||||
</xsl:choose>
|
<xsl:value-of select="''"/>
|
||||||
</xsl:when>
|
</xsl:otherwise>
|
||||||
<xsl:otherwise>
|
</xsl:choose>
|
||||||
<xsl:choose>
|
</xsl:with-param>
|
||||||
<xsl:when test="$units = 1">
|
</xsl:call-template>
|
||||||
<xsl:choose>
|
<xsl:value-of select="$fs"/>
|
||||||
<xsl:when test="substring-before(../divecomputer[1]/sample[@pressure][last()]/@pressure, ' ') > 0">
|
|
||||||
<xsl:value-of select="concat(format-number((substring-before(../divecomputer[1]/sample[@pressure][last()]/@pressure, ' ') * 14.5037738007), '#'), '')"/>
|
<xsl:call-template name="CsvEscape">
|
||||||
</xsl:when>
|
<xsl:with-param name="value" select="substring-before(@o2, '%')"/>
|
||||||
<xsl:otherwise>
|
</xsl:call-template>
|
||||||
<xsl:value-of select="''"/>
|
<xsl:value-of select="$fs"/>
|
||||||
</xsl:otherwise>
|
|
||||||
</xsl:choose>
|
<xsl:call-template name="CsvEscape">
|
||||||
</xsl:when>
|
<xsl:with-param name="value" select="substring-before(@he, '%')"/>
|
||||||
<xsl:otherwise>
|
</xsl:call-template>
|
||||||
<xsl:value-of select="substring-before(../divecomputer[1]/sample[@pressure][last()]/@pressure, ' ')"/>
|
<xsl:value-of select="$fs"/>
|
||||||
</xsl:otherwise>
|
|
||||||
</xsl:choose>
|
|
||||||
</xsl:otherwise>
|
|
||||||
</xsl:choose>
|
|
||||||
</xsl:with-param>
|
|
||||||
</xsl:call-template>
|
|
||||||
<xsl:value-of select="$fs"/>
|
|
||||||
<xsl:call-template name="CsvEscape">
|
|
||||||
<xsl:with-param name="value" select="substring-before(@o2, '%')"/>
|
|
||||||
</xsl:call-template>
|
|
||||||
<xsl:value-of select="$fs"/>
|
|
||||||
<xsl:call-template name="CsvEscape">
|
|
||||||
<xsl:with-param name="value" select="substring-before(@he, '%')"/>
|
|
||||||
</xsl:call-template>
|
|
||||||
<xsl:value-of select="$fs"/>
|
|
||||||
</xsl:when>
|
|
||||||
</xsl:choose>
|
|
||||||
</xsl:for-each>
|
</xsl:for-each>
|
||||||
|
|
||||||
<xsl:if test="count(cylinder) < $cylinders">
|
<xsl:if test="count(cylinder) < $cylinders">
|
||||||
|
@ -291,25 +275,21 @@
|
||||||
<xsl:otherwise>
|
<xsl:otherwise>
|
||||||
<xsl:call-template name="CsvEscape">
|
<xsl:call-template name="CsvEscape">
|
||||||
<xsl:with-param name="value">
|
<xsl:with-param name="value">
|
||||||
<xsl:if test="string-length(@divesiteid) > 0">
|
<xsl:if test="string-length(@divesiteid) > 0">
|
||||||
<xsl:variable name="uuid">
|
<xsl:variable name="uuid" select="@divesiteid"/>
|
||||||
<xsl:value-of select="@divesiteid" />
|
|
||||||
</xsl:variable>
|
|
||||||
<xsl:value-of select="//divesites/site[@uuid = $uuid]/@name"/>
|
<xsl:value-of select="//divesites/site[@uuid = $uuid]/@name"/>
|
||||||
</xsl:if>
|
</xsl:if>
|
||||||
</xsl:with-param>
|
</xsl:with-param>
|
||||||
</xsl:call-template>
|
</xsl:call-template>
|
||||||
<xsl:value-of select="$fs"/>
|
<xsl:value-of select="$fs"/>
|
||||||
<xsl:call-template name="CsvEscape">
|
<xsl:call-template name="CsvEscape">
|
||||||
<xsl:with-param name="value">
|
<xsl:with-param name="value">
|
||||||
<xsl:if test="string-length(@divesiteid) > 0">
|
<xsl:if test="string-length(@divesiteid) > 0">
|
||||||
<xsl:variable name="uuid">
|
<xsl:variable name="uuid" select="@divesiteid"/>
|
||||||
<xsl:value-of select="@divesiteid" />
|
|
||||||
</xsl:variable>
|
|
||||||
<xsl:value-of select="//divesites/site[@uuid = $uuid]/@gps"/>
|
<xsl:value-of select="//divesites/site[@uuid = $uuid]/@gps"/>
|
||||||
</xsl:if>
|
</xsl:if>
|
||||||
</xsl:with-param>
|
</xsl:with-param>
|
||||||
</xsl:call-template>
|
</xsl:call-template>
|
||||||
</xsl:otherwise>
|
</xsl:otherwise>
|
||||||
</xsl:choose>
|
</xsl:choose>
|
||||||
<xsl:value-of select="$fs"/>
|
<xsl:value-of select="$fs"/>
|
||||||
|
@ -367,6 +347,32 @@
|
||||||
<xsl:value-of select="$lf"/>
|
<xsl:value-of select="$lf"/>
|
||||||
</xsl:template>
|
</xsl:template>
|
||||||
|
|
||||||
|
<!-- Convert pressure values to the correct units -->
|
||||||
|
<xsl:template name="ConvertPressure">
|
||||||
|
<xsl:param name="pressureBar"/>
|
||||||
|
<xsl:choose>
|
||||||
|
<xsl:when test="$units = 1">
|
||||||
|
<xsl:value-of select="concat(format-number((substring-before($pressureBar, ' ') * 14.5037738007), '#'), '')"/>
|
||||||
|
</xsl:when>
|
||||||
|
<xsl:otherwise>
|
||||||
|
<xsl:value-of select="substring-before($pressureBar, ' ')"/>
|
||||||
|
</xsl:otherwise>
|
||||||
|
</xsl:choose>
|
||||||
|
</xsl:template>
|
||||||
|
|
||||||
|
<!-- Convert distance values to the correct units -->
|
||||||
|
<xsl:template name="ConvertDistance">
|
||||||
|
<xsl:param name="distanceM"/>
|
||||||
|
<xsl:choose>
|
||||||
|
<xsl:when test="$units = 1">
|
||||||
|
<xsl:value-of select="concat(format-number((substring-before($distanceM, ' ') div 0.3048), '#.##'), '')"/>
|
||||||
|
</xsl:when>
|
||||||
|
<xsl:otherwise>
|
||||||
|
<xsl:value-of select="format-number(substring-before($distanceM, ' '), '#.##')"/>
|
||||||
|
</xsl:otherwise>
|
||||||
|
</xsl:choose>
|
||||||
|
</xsl:template>
|
||||||
|
|
||||||
<!-- Print the header -->
|
<!-- Print the header -->
|
||||||
<xsl:template name="printHeaders">
|
<xsl:template name="printHeaders">
|
||||||
<xsl:param name="cylinders"/>
|
<xsl:param name="cylinders"/>
|
||||||
|
@ -393,11 +399,11 @@
|
||||||
</xsl:call-template>
|
</xsl:call-template>
|
||||||
<xsl:value-of select="$fs"/>
|
<xsl:value-of select="$fs"/>
|
||||||
<xsl:call-template name="CsvEscape">
|
<xsl:call-template name="CsvEscape">
|
||||||
<xsl:with-param name="value" select="concat('sac [', $volumeUnits, '/min]')"/>
|
<xsl:with-param name="value" select="concat('sac [', $volumeUnits, '/min]')"/>
|
||||||
</xsl:call-template>
|
</xsl:call-template>
|
||||||
<xsl:value-of select="$fs"/>
|
<xsl:value-of select="$fs"/>
|
||||||
<xsl:call-template name="CsvEscape">
|
<xsl:call-template name="CsvEscape">
|
||||||
<xsl:with-param name="value" select="concat('maxdepth [', $distanceUnits, ']')"/>
|
<xsl:with-param name="value" select="concat('maxdepth [', $distanceUnits, ']')"/>
|
||||||
</xsl:call-template>
|
</xsl:call-template>
|
||||||
<xsl:value-of select="$fs"/>
|
<xsl:value-of select="$fs"/>
|
||||||
<xsl:call-template name="CsvEscape">
|
<xsl:call-template name="CsvEscape">
|
||||||
|
@ -477,23 +483,23 @@
|
||||||
|
|
||||||
<xsl:if test="$index <= $count">
|
<xsl:if test="$index <= $count">
|
||||||
<xsl:call-template name="CsvEscape">
|
<xsl:call-template name="CsvEscape">
|
||||||
<xsl:with-param name="value" select="concat('cylinder size (', $index, ') [', $volumeUnits, ']')"/>
|
<xsl:with-param name="value" select="concat('cylinder size (', $index, ') [', $volumeUnits, ']')"/>
|
||||||
</xsl:call-template>
|
</xsl:call-template>
|
||||||
<xsl:value-of select="$fs"/>
|
<xsl:value-of select="$fs"/>
|
||||||
<xsl:call-template name="CsvEscape">
|
<xsl:call-template name="CsvEscape">
|
||||||
<xsl:with-param name="value" select="concat('startpressure (', $index, ') [', $pressureUnits, ']')"/>
|
<xsl:with-param name="value" select="concat('startpressure (', $index, ') [', $pressureUnits, ']')"/>
|
||||||
</xsl:call-template>
|
</xsl:call-template>
|
||||||
<xsl:value-of select="$fs"/>
|
<xsl:value-of select="$fs"/>
|
||||||
<xsl:call-template name="CsvEscape">
|
<xsl:call-template name="CsvEscape">
|
||||||
<xsl:with-param name="value" select="concat('endpressure (', $index, ') [', $pressureUnits, ']')"/>
|
<xsl:with-param name="value" select="concat('endpressure (', $index, ') [', $pressureUnits, ']')"/>
|
||||||
</xsl:call-template>
|
</xsl:call-template>
|
||||||
<xsl:value-of select="$fs"/>
|
<xsl:value-of select="$fs"/>
|
||||||
<xsl:call-template name="CsvEscape">
|
<xsl:call-template name="CsvEscape">
|
||||||
<xsl:with-param name="value" select="concat('o2 (', $index, ') [%]')"/>
|
<xsl:with-param name="value" select="concat('o2 (', $index, ') [%]')"/>
|
||||||
</xsl:call-template>
|
</xsl:call-template>
|
||||||
<xsl:value-of select="$fs"/>
|
<xsl:value-of select="$fs"/>
|
||||||
<xsl:call-template name="CsvEscape">
|
<xsl:call-template name="CsvEscape">
|
||||||
<xsl:with-param name="value" select="concat('he (', $index, ') [%]')"/>
|
<xsl:with-param name="value" select="concat('he (', $index, ') [%]')"/>
|
||||||
</xsl:call-template>
|
</xsl:call-template>
|
||||||
<xsl:value-of select="$fs"/>
|
<xsl:value-of select="$fs"/>
|
||||||
|
|
||||||
|
@ -510,27 +516,17 @@
|
||||||
<xsl:template match="divecomputer/depth">
|
<xsl:template match="divecomputer/depth">
|
||||||
<xsl:call-template name="CsvEscape">
|
<xsl:call-template name="CsvEscape">
|
||||||
<xsl:with-param name="value">
|
<xsl:with-param name="value">
|
||||||
<xsl:choose>
|
<xsl:call-template name="ConvertDistance">
|
||||||
<xsl:when test="$units = 1">
|
<xsl:with-param name="distanceM" select="@max"/>
|
||||||
<xsl:value-of select="concat(format-number((substring-before(@max, ' ') div 0.3048), '#.##'), '')"/>
|
</xsl:call-template>
|
||||||
</xsl:when>
|
|
||||||
<xsl:otherwise>
|
|
||||||
<xsl:value-of select="substring-before(@max, ' ')"/>
|
|
||||||
</xsl:otherwise>
|
|
||||||
</xsl:choose>
|
|
||||||
</xsl:with-param>
|
</xsl:with-param>
|
||||||
</xsl:call-template>
|
</xsl:call-template>
|
||||||
<xsl:value-of select="$fs"/>
|
<xsl:value-of select="$fs"/>
|
||||||
<xsl:call-template name="CsvEscape">
|
<xsl:call-template name="CsvEscape">
|
||||||
<xsl:with-param name="value">
|
<xsl:with-param name="value">
|
||||||
<xsl:choose>
|
<xsl:call-template name="ConvertDistance">
|
||||||
<xsl:when test="$units = 1">
|
<xsl:with-param name="distanceM" select="@mean"/>
|
||||||
<xsl:value-of select="concat(format-number((substring-before(@mean, ' ') div 0.3048), '#.##'), '')"/>
|
</xsl:call-template>
|
||||||
</xsl:when>
|
|
||||||
<xsl:otherwise>
|
|
||||||
<xsl:value-of select="format-number(substring-before(@mean, ' '), '#.##')"/>
|
|
||||||
</xsl:otherwise>
|
|
||||||
</xsl:choose>
|
|
||||||
</xsl:with-param>
|
</xsl:with-param>
|
||||||
</xsl:call-template>
|
</xsl:call-template>
|
||||||
</xsl:template>
|
</xsl:template>
|
||||||
|
@ -543,7 +539,7 @@
|
||||||
<xsl:with-param name="value">
|
<xsl:with-param name="value">
|
||||||
<xsl:choose>
|
<xsl:choose>
|
||||||
<xsl:when test="$units = 1">
|
<xsl:when test="$units = 1">
|
||||||
<xsl:if test="substring-before($temp, ' ') > 0">
|
<xsl:if test="substring-before($temp, ' ') > 0">
|
||||||
<xsl:value-of select="concat(format-number((substring-before($temp, ' ') * 1.8) + 32, '0.0'), '')"/>
|
<xsl:value-of select="concat(format-number((substring-before($temp, ' ') * 1.8) + 32, '0.0'), '')"/>
|
||||||
</xsl:if>
|
</xsl:if>
|
||||||
</xsl:when>
|
</xsl:when>
|
||||||
|
@ -558,7 +554,7 @@
|
||||||
<!-- Fill in non-existent cylinder info -->
|
<!-- Fill in non-existent cylinder info -->
|
||||||
<xsl:template name="printEmptyCylinders">
|
<xsl:template name="printEmptyCylinders">
|
||||||
<xsl:param name="count"/>
|
<xsl:param name="count"/>
|
||||||
<xsl:if test="$count > 0">
|
<xsl:if test="$count > 0">
|
||||||
<xsl:value-of select="$fs"/>
|
<xsl:value-of select="$fs"/>
|
||||||
<xsl:value-of select="$fs"/>
|
<xsl:value-of select="$fs"/>
|
||||||
<xsl:value-of select="$fs"/>
|
<xsl:value-of select="$fs"/>
|
||||||
|
|
Loading…
Reference in a new issue