aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2014-07-01 09:29:19 -0700
committerGravatar Dirk Hohndel <dirk@hohndel.org>2014-07-01 09:29:19 -0700
commit1d09ce2ce287b5e6b7fdc27e327eff8f2ac5fe90 (patch)
treee5c21ff94a4592bf69a42cb74e407fa97c2a214f
parent1d0193c62ed9af8161a389bb76e3fbac4c6cd4df (diff)
downloadsubsurface-1d09ce2ce287b5e6b7fdc27e327eff8f2ac5fe90.tar.gz
Picture loading: only add the pictures to "reasonable" dives
If the picture has a timestamp that was within 30 minutes of the start and finish of the dive, we take it. Otherwise we don't. If the timestamps of the images are off, the time shift dialog allows the user to fix this. And with this patch the user can select all the dives of a trip and all the pictures they took on the trip and the "right thing" will happen. Fixes #578 Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-rw-r--r--dive.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/dive.c b/dive.c
index c60f3c819..d6a2b9fd6 100644
--- a/dive.c
+++ b/dive.c
@@ -2261,6 +2261,9 @@ static bool new_picture_for_dive(struct dive *d, char *filename)
return true;
}
+// only add pictures that have timestamps between 30 minutes before the dive and
+// 30 minutes after the dive ends
+#define D30MIN (30 * 60)
void dive_create_picture(struct dive *d, char *filename, int shift_time)
{
timestamp_t timestamp;
@@ -2269,8 +2272,14 @@ void dive_create_picture(struct dive *d, char *filename, int shift_time)
struct picture *p = alloc_picture();
p->filename = filename;
picture_load_exif_data(p, &timestamp);
- if (timestamp)
+ if (timestamp) {
p->offset.seconds = timestamp - d->when + shift_time;
+ if (p->offset.seconds < -D30MIN || p->offset.seconds > d->duration.seconds + D30MIN) {
+ // this picture doesn't belong to this dive
+ free(p);
+ return;
+ }
+ }
dive_add_picture(d, p);
dive_set_geodata_from_picture(d, p);
}