mirror of
https://github.com/subsurface/subsurface.git
synced 2025-01-31 21:03:23 +00:00
Fix Suunto FIT file import dive duration mis-calculation
The Suunto FIT files end up creating a sample every second, but a lot of those samples with no depth information, marked as "depth.mm" being negative. That doesn't end up being a problem for subsurface, _except_ that it really confuses our "dc_fixup_duration()" logic, and the dive duration ends up being completely nonsensical (generally roughly by a factor of five: every tenth sample has a depth, and we only count samples that "begin or end under water" as being relevant for the dive duration, so two out of the ten samples will count towards the dive time). Saving the dive will then not save these invalid depths, so saving and reloading the dive ends up fixing the dive duration calculation. The fix is trivial - we just ignore samples with negative depth in dc_fixup_duration(). The FIT file parser should probably be taught to not even bother sending empty samples to subsurface, but that's a separate cleanup. This fixes the actual bad behavior. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
parent
069f8a5d18
commit
914cdb102b
1 changed files with 4 additions and 0 deletions
|
@ -272,6 +272,10 @@ void fixup_dc_duration(struct divecomputer &dc)
|
|||
int time = sample.time.seconds;
|
||||
int depth = sample.depth.mm;
|
||||
|
||||
/* Do we *have* a depth? */
|
||||
if (depth < 0)
|
||||
continue;
|
||||
|
||||
/* We ignore segments at the surface */
|
||||
if (depth > SURFACE_THRESHOLD || lastdepth > SURFACE_THRESHOLD) {
|
||||
duration += time - lasttime;
|
||||
|
|
Loading…
Add table
Reference in a new issue