mirror of
https://github.com/subsurface/subsurface.git
synced 2025-01-19 06:15:26 +00:00
Tune the dive joining surface event insert code
From 178a3f0d6d5112f76943fec5f8c1c1f3b173a7f4 Mon Sep 17 00:00:00 2001 From: Linus Torvalds <torvalds@linux-foundation.org> Date: Fri, 7 Dec 2012 09:34:18 -0800 Subject: [PATCH 2/2] Tune the dive joining surface event insert code So this makes us do surface events only if the samples are more than one minute apart, and are shallow enough (randomly selected at 5m). We can add more heuristics. Maybe we should compare the 1-minute sample time limit of the previous sample to the time to the sample before that: if some computer (or manually entered dive) has a long time between *all* samples, we'd make the cut-off time longer. Baby steps. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
59fc674e01
commit
3a7f3ba880
1 changed files with 9 additions and 2 deletions
11
dive.c
11
dive.c
|
@ -614,8 +614,15 @@ static void merge_one_sample(struct sample *sample, int time, struct divecompute
|
|||
int last = dc->samples-1;
|
||||
if (last >= 0) {
|
||||
static struct sample surface;
|
||||
int last_time = dc->sample[last].time.seconds;
|
||||
if (time > last_time + 60) {
|
||||
struct sample *prev = dc->sample + last;
|
||||
int last_time = prev->time.seconds;
|
||||
int last_depth = prev->depth.mm;
|
||||
|
||||
/*
|
||||
* Only do surface events if the samples are more than
|
||||
* a minute apart, and shallower than 5m
|
||||
*/
|
||||
if (time > last_time + 60 && last_depth < 5000) {
|
||||
add_sample(&surface, last_time+20, dc);
|
||||
add_sample(&surface, time - 20, dc);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue