On Tue, Jul 22, 2014 at 3:42 PM, Davide DB <[email protected]> wrote:

> In my endless tries to import SmartTrak logs I found a bug but I don't
> know if it's a problem of DL or Subsurface 4.1.
>
> Imported a .slg file containing 379 dives to diving log 5.0.
> Exported fromm DL in xml format (as Subsurface manual suggest)
> Exported from DL in uddf format as well.
>
> xml import: dives seems ok except for some of them with incorrect profiles.
> uddf import: everything ok.
>
> The DL exported xml file contains correct depth points but somehow the
> profile is completely different (see screenshot). Dive stats indicate
> correct values
>

It seems that Diving Log has recorded the maximum depth to be a bit less
than the maximum sample depth. And the Imperial vs. metric unit test was a
simple comparison, if maximum sample depth is greater than the value of
maximum depth, then it was considered to be imperial units. Attached patch
doubles the maximum depth value of this comparison, so the difference must
be quite significant for this test to fail in the future.

miika
From 417ce39ed6d69a4d491abbbfab2e03fd9504e984 Mon Sep 17 00:00:00 2001
From: Miika Turkia <[email protected]>
Date: Tue, 22 Jul 2014 17:58:19 +0300
Subject: [PATCH] Tune the unit test on DivingLog import

At least in some cases the maximum sample depth can be more than
recorded maximum depth on DivingLog XML export. Thus the maximum depth
is doubled for unit detection.

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

diff --git a/xslt/DivingLog.xslt b/xslt/DivingLog.xslt
index 49f617c..15ad651 100644
--- a/xslt/DivingLog.xslt
+++ b/xslt/DivingLog.xslt
@@ -157,7 +157,10 @@
       <!-- Trying to detect if depth samples are in Imperial or Metric
            units. This is based on an assumption that maximum depth of
            a dive is recorded in metric and if samples contain bigger
-           values, they must be imperial.
+	   values, they must be imperial. However, we double the depth
+	   for the test in some cases the maximum sample depth might be
+	   a bit more than what is recorded as maximum depth for the
+	   dive.
            -->
 
       <xsl:variable name="max">
@@ -169,7 +172,7 @@
 
       <xsl:variable name="depthUnit">
         <xsl:choose>
-          <xsl:when test="$max &gt; Depth + 1">
+          <xsl:when test="$max &gt; Depth * 2 + 1">
             <xsl:value-of select="'imperial'"/>
           </xsl:when>
           <xsl:otherwise>
-- 
1.9.1

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

Reply via email to