These patches allow one to import CSV file in imperial units. It is for the
pre-configured Subsurface style CSV. I am not sure how sensible this is,
but this format allows importing more fields than what we have in the
manual CSV import (and we got a request for this). Thus I thought it might
be useful.

Cylinder size is currently not supported in imperial format as it doesn't
really make sense without working pressure. And that I doubt anyone will
record on paper/excel logs. Of course, we could give rough estimates in the
form of 80 cuft -> 11L, 100 cuft -> 13L (or whatever they happen to
commonly be).

I was wondering if it would make sense to implement exporting the CSV files
in imperial units as well. Opinions?

miika
From fba2a78bb5d110b21065f4aa25a539e62ae83718 Mon Sep 17 00:00:00 2001
From: Miika Turkia <[email protected]>
Date: Tue, 30 Dec 2014 07:29:16 +0200
Subject: [PATCH 5/5] Allow unit selection on known CSV import

Signed-off-by: Miika Turkia <[email protected]>
---
 qt-ui/divelogimportdialog.cpp | 2 --
 1 file changed, 2 deletions(-)

diff --git a/qt-ui/divelogimportdialog.cpp b/qt-ui/divelogimportdialog.cpp
index 5c2a044..b79d33c 100644
--- a/qt-ui/divelogimportdialog.cpp
+++ b/qt-ui/divelogimportdialog.cpp
@@ -162,10 +162,8 @@ void DiveLogImportDialog::on_knownImports_currentIndexChanged(int index)
 {
 	if (specialCSV.contains(index)) {
 		ui->groupBox_3->setEnabled(false);
-		ui->CSVUnits->setEnabled(false);
 	} else {
 		ui->groupBox_3->setEnabled(true);
-		ui->CSVUnits->setEnabled(true);
 	}
 	if (index == 0)
 		return;
-- 
1.9.1

From 46ed9428b6d42e1ebe095456eeed529aab700884 Mon Sep 17 00:00:00 2001
From: Miika Turkia <[email protected]>
Date: Tue, 30 Dec 2014 07:27:15 +0200
Subject: [PATCH 4/5] Imperial weight for SSRF CSV import

Signed-off-by: Miika Turkia <[email protected]>
---
 xslt/subsurfacecsv.xslt | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/xslt/subsurfacecsv.xslt b/xslt/subsurfacecsv.xslt
index d8ecd97..6820208 100644
--- a/xslt/subsurfacecsv.xslt
+++ b/xslt/subsurfacecsv.xslt
@@ -339,7 +339,14 @@
       <xsl:if test="$weight != ''">
         <weightsystem description="unknown">
           <xsl:attribute name="weight">
-            <xsl:value-of select="$weight"/>
+            <xsl:choose>
+              <xsl:when test="$units = 0">
+                <xsl:value-of select="$weight"/>
+              </xsl:when>
+              <xsl:otherwise>
+                <xsl:value-of select="concat(format-number((substring-before($weight, ' ') * 0.453592), '#.##'), ' kg')"/>
+              </xsl:otherwise>
+            </xsl:choose>
           </xsl:attribute>
         </weightsystem>
       </xsl:if>
-- 
1.9.1

From dd20aff13d443dc696d8908b201bb960992bb949 Mon Sep 17 00:00:00 2001
From: Miika Turkia <[email protected]>
Date: Tue, 30 Dec 2014 07:11:51 +0200
Subject: [PATCH 3/5] Imperial support for pressure in Subsurface CSV import

Signed-off-by: Miika Turkia <[email protected]>
---
 xslt/subsurfacecsv.xslt | 18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)

diff --git a/xslt/subsurfacecsv.xslt b/xslt/subsurfacecsv.xslt
index f7751cd..d8ecd97 100644
--- a/xslt/subsurfacecsv.xslt
+++ b/xslt/subsurfacecsv.xslt
@@ -225,12 +225,26 @@
         </xsl:if>
         <xsl:if test="$start != ''">
           <xsl:attribute name="start">
-            <xsl:value-of select="$start"/>
+            <xsl:choose>
+              <xsl:when test="$units = 0">
+                <xsl:value-of select="$start"/>
+              </xsl:when>
+              <xsl:otherwise>
+                <xsl:value-of select="concat(format-number((substring-before($start, ' ') div 14.5037738007), '#'), ' bar')"/>
+              </xsl:otherwise>
+            </xsl:choose>
           </xsl:attribute>
         </xsl:if>
         <xsl:if test="$end != ''">
           <xsl:attribute name="end">
-            <xsl:value-of select="$end"/>
+            <xsl:choose>
+              <xsl:when test="$units = 0">
+                <xsl:value-of select="$end"/>
+              </xsl:when>
+              <xsl:otherwise>
+                <xsl:value-of select="concat(format-number((substring-before($end, ' ') div 14.5037738007), '#'), ' bar')"/>
+              </xsl:otherwise>
+            </xsl:choose>
           </xsl:attribute>
         </xsl:if>
         <xsl:if test="$o2 != ''">
-- 
1.9.1

From 789f0e86a0499fedad1dab4ef684002d7f9574c2 Mon Sep 17 00:00:00 2001
From: Miika Turkia <[email protected]>
Date: Sat, 27 Dec 2014 06:35:19 +0200
Subject: [PATCH 2/5] Add imperial temperature support for Subsurface CSV
 import

Signed-off-by: Miika Turkia <[email protected]>
---
 xslt/subsurfacecsv.xslt | 18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)

diff --git a/xslt/subsurfacecsv.xslt b/xslt/subsurfacecsv.xslt
index fa98bdf..f7751cd 100644
--- a/xslt/subsurfacecsv.xslt
+++ b/xslt/subsurfacecsv.xslt
@@ -163,12 +163,26 @@
         </xsl:variable>
         <xsl:if test="$air != ''">
           <xsl:attribute name="air">
-            <xsl:value-of select="$air"/>
+            <xsl:choose>
+              <xsl:when test="$units = 0">
+                <xsl:value-of select="$air"/>
+              </xsl:when>
+              <xsl:otherwise>
+                <xsl:value-of select="concat(format-number((substring-before($air, ' ') - 32) * 5 div 9, '0.0'), ' C')"/>
+              </xsl:otherwise>
+            </xsl:choose>
           </xsl:attribute>
         </xsl:if>
         <xsl:if test="$water != ''">
           <xsl:attribute name="water">
-            <xsl:value-of select="$water"/>
+            <xsl:choose>
+              <xsl:when test="$units = 0">
+                <xsl:value-of select="$water"/>
+              </xsl:when>
+              <xsl:otherwise>
+                <xsl:value-of select="concat(format-number((substring-before($water, ' ') - 32) * 5 div 9, '0.0'), ' C')"/>
+              </xsl:otherwise>
+            </xsl:choose>
           </xsl:attribute>
         </xsl:if>
       </divetemperature>
-- 
1.9.1

From 2c289fadde4ccb203e18aceb780586ae6aad0fb3 Mon Sep 17 00:00:00 2001
From: Miika Turkia <[email protected]>
Date: Sat, 27 Dec 2014 06:34:49 +0200
Subject: [PATCH 1/5] Add imperial depth support for CSV import

Signed-off-by: Miika Turkia <[email protected]>
---
 xslt/subsurfacecsv.xslt | 18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)

diff --git a/xslt/subsurfacecsv.xslt b/xslt/subsurfacecsv.xslt
index ec6e871..fa98bdf 100644
--- a/xslt/subsurfacecsv.xslt
+++ b/xslt/subsurfacecsv.xslt
@@ -124,12 +124,26 @@
         </xsl:variable>
         <xsl:if test="$max != ''">
           <xsl:attribute name="max">
-            <xsl:value-of select="$max"/>
+            <xsl:choose>
+              <xsl:when test="$units = 0">
+                <xsl:value-of select="$max"/>
+              </xsl:when>
+              <xsl:otherwise>
+                <xsl:value-of select="concat(format-number((substring-before($max, ' ') * 0.3048), '#.##'), ' m')"/>
+              </xsl:otherwise>
+            </xsl:choose>
           </xsl:attribute>
         </xsl:if>
         <xsl:if test="$mean != ''">
           <xsl:attribute name="mean">
-            <xsl:value-of select="$mean"/>
+            <xsl:choose>
+              <xsl:when test="$units = 0">
+                <xsl:value-of select="$mean"/>
+              </xsl:when>
+              <xsl:otherwise>
+                <xsl:value-of select="concat(format-number((substring-before($mean, ' ') * 0.3048), '#.##'), ' m')"/>
+              </xsl:otherwise>
+            </xsl:choose>
           </xsl:attribute>
         </xsl:if>
       </depth>
-- 
1.9.1

_______________________________________________
subsurface mailing list
[email protected]
http://lists.subsurface-divelog.org/cgi-bin/mailman/listinfo/subsurface

Reply via email to