]> git.tdb.fi Git - ext/subsurface.git/commitdiff
Remove redundant duplicate pressure samples
authorLinus Torvalds <torvalds@linux-foundation.org>
Thu, 17 Nov 2011 14:03:11 +0000 (12:03 -0200)
committerLinus Torvalds <torvalds@linux-foundation.org>
Thu, 17 Nov 2011 14:03:11 +0000 (12:03 -0200)
At least the Suunto pressure transmitter seems to be pretty
"quantisized", and it will send identical samples for a while until the
pressure changes enough.  Then subsurface gives this silly flat line
with a sudden jump downwards, which *could* be you suddenly taking a
deep breath after holding it for a while, but almost certainly it's a
sensor issue.

So just remove successive identical pressure readings.  They aren't
interesting, and subsurface will actually do a good job of interpolating
it according to SAC rate instead.  And they just make the XML look
worse.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
dive.c

diff --git a/dive.c b/dive.c
index dad0e237bc8726f0c983ef73fdfa1d47fd8540c4..cd797d27663f6578ea32ea4cc2ae31a63037bde6 100644 (file)
--- a/dive.c
+++ b/dive.c
@@ -239,16 +239,26 @@ struct dive *fixup_dive(struct dive *dive)
        int i;
        double depthtime = 0;
        int lasttime = 0;
+       int lastindex = -1;
        int start = -1, end = -1;
        int maxdepth = 0, mintemp = 0;
        int lastdepth = 0;
-       int lasttemp = 0;
+       int lasttemp = 0, lastpressure = 0;
 
        for (i = 0; i < dive->samples; i++) {
                struct sample *sample = dive->sample + i;
                int time = sample->time.seconds;
                int depth = sample->depth.mm;
                int temp = sample->temperature.mkelvin;
+               int pressure = sample->cylinderpressure.mbar;
+               int index = sample->cylinderindex;
+
+               /* Remove duplicate redundant pressure information */
+               if (pressure == lastpressure && index == lastindex)
+                       sample->cylinderpressure.mbar = 0;
+
+               lastindex = index;
+               lastpressure = pressure;
 
                if (lastdepth)
                        end = time;