[PATCH] Guess imperial cylinder sizes on CSV import

Miika Turkia miika.turkia at gmail.com
Tue Dec 30 11:42:39 PST 2014


This patch uses pre-defined working pressures on cylinders to roughly
calculate the size in liters. Imperial selection is ignored here as we
can use the prefix to detect if the value seems like imperial unit (and
the type of cylinder varies based on location, not divers preference in
unit).

Signed-off-by: Miika Turkia <miika.turkia at gmail.com>
---
 xslt/subsurfacecsv.xslt | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)

diff --git a/xslt/subsurfacecsv.xslt b/xslt/subsurfacecsv.xslt
index 6820208..072dda2 100644
--- a/xslt/subsurfacecsv.xslt
+++ b/xslt/subsurfacecsv.xslt
@@ -218,9 +218,27 @@
             <xsl:with-param name="line" select="$line"/>
           </xsl:call-template>
         </xsl:variable>
+
+        <!--  ALxxx -> xxx cuft at 3000 psi
+              LPxxx -> xxx cuft at 2400 psi
+              HPxxx -> xxx cuft at 3440 psi -->
+
         <xsl:if test="$size != ''">
           <xsl:attribute name="size">
-            <xsl:value-of select="$size"/>
+            <xsl:choose>
+              <xsl:when test="substring($size, 1, 2) = 'AL'">
+                <xsl:value-of select="format-number((translate($size, translate($size, '0123456789', ''), '') * 14.7 div 3000) div 0.035315, '#.#')"/>
+              </xsl:when>
+              <xsl:when test="substring($size, 1, 2) = 'LP'">
+                <xsl:value-of select="format-number((translate($size, translate($size, '0123456789', ''), '') * 14.7 div 2400) div 0.035315, '#.#')"/>
+              </xsl:when>
+              <xsl:when test="substring($size, 1, 2) = 'HP'">
+                <xsl:value-of select="format-number((translate($size, translate($size, '0123456789', ''), '') * 14.7 div 3440) div 0.035315, '#.#')"/>
+              </xsl:when>
+              <xsl:otherwise>
+                <xsl:value-of select="$size"/>
+              </xsl:otherwise>
+            </xsl:choose>
           </xsl:attribute>
         </xsl:if>
         <xsl:if test="$start != ''">
-- 
1.9.1



More information about the subsurface mailing list