On Tue, Aug 12, 2014 at 2:41 PM, Niclas Öhman <ni...@headdown.net> wrote:

> Hi,
>
> First: Thanks for Subsurface! love it.
>
>
> I usually dive with 2x12 tanks.
> When i upload my dives to divelogs.de i get a single tank of 24 liters
> instead of a 2x12.
> It would be nice to get that right.
>

The attached patch will add support for exporting the double tank info to
divelogs.de. It has its limitations as the cylinder description must use
form D<size>. There is also a sanity check so that <size> in description
must be half of the reported cylinder size for the dive to be marked as
double tank dive. Of course this is true for the predefined double
cylinders but I have no idea how imperial people would mark their
cylinders...

miika
From 451422ef40ca9ebccd63389cd9720128fff7b3d9 Mon Sep 17 00:00:00 2001
From: Miika Turkia <miika.tur...@gmail.com>
Date: Sat, 16 Aug 2014 10:00:14 +0300
Subject: [PATCH] Hack double tank support for export to divelogs

If the cylinder description starts with D%d we test if the size in
description matches the cylinder size. If the cylinder size is double
compared to size in description, we mark the dive as double tank dive to
divelogs.de.

Signed-off-by: Miika Turkia <miika.tur...@gmail.com>
---
 xslt/divelogs-export.xslt | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/xslt/divelogs-export.xslt b/xslt/divelogs-export.xslt
index 3de8c60..ec39ba2 100644
--- a/xslt/divelogs-export.xslt
+++ b/xslt/divelogs-export.xslt
@@ -69,8 +69,22 @@
     <CYLINDERDESCRIPTION>
       <xsl:value-of select="cylinder[position() = $cylinder]/@description"/>
     </CYLINDERDESCRIPTION>
+
+    <xsl:variable name="double">
+      <xsl:choose>
+        <xsl:when test="substring(cylinder[position() = $cylinder]/@description, 1, 1) = 'D' and substring-before(substring(cylinder[position() = $cylinder]/@description, 2), ' ') * 2 = substring-before(cylinder[position() = $cylinder]/@size, ' ')">
+          <xsl:value-of select="'2'"/>
+        </xsl:when>
+        <xsl:otherwise>
+          <xsl:value-of select="'1'"/>
+        </xsl:otherwise>
+      </xsl:choose>
+    </xsl:variable>
+    <DBLTANK>
+      <xsl:value-of select="$double - 1"/>
+    </DBLTANK>
     <CYLINDERSIZE>
-      <xsl:value-of select="substring-before(cylinder[position() = $cylinder]/@size, ' ')"/>
+      <xsl:value-of select="substring-before(cylinder[position() = $cylinder]/@size, ' ') div $double"/>
     </CYLINDERSIZE>
     <CYLINDERSTARTPRESSURE>
       <xsl:choose>
-- 
1.9.1

_______________________________________________
subsurface mailing list
subsurface@hohndel.org
http://lists.hohndel.org/cgi-bin/mailman/listinfo/subsurface

Reply via email to