mirror of
https://github.com/subsurface/subsurface.git
synced 2024-12-01 06:30:26 +00:00
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>
This commit is contained in:
parent
1d0193c62e
commit
1d09ce2ce2
1 changed files with 10 additions and 1 deletions
11
dive.c
11
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, ×tamp);
|
||||
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);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue