mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Dive pictures: use get_metadata() in dive_create_picture()
Thus, metadata has to be only read once and the picture_load_exif_data() function can be removed. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
9b2482aca9
commit
66b71c60a0
3 changed files with 6 additions and 14 deletions
10
core/dive.c
10
core/dive.c
|
@ -3780,16 +3780,18 @@ bool picture_check_valid(const char *filename, int shift_time)
|
|||
|
||||
void dive_create_picture(struct dive *dive, const char *filename, int shift_time, bool match_all)
|
||||
{
|
||||
timestamp_t timestamp = picture_get_timestamp(filename);
|
||||
struct metadata metadata;
|
||||
get_metadata(filename, &metadata);
|
||||
if (!new_picture_for_dive(dive, filename))
|
||||
return;
|
||||
if (!match_all && !dive_check_picture_time(dive, shift_time, timestamp))
|
||||
if (!match_all && !dive_check_picture_time(dive, shift_time, metadata.timestamp))
|
||||
return;
|
||||
|
||||
struct picture *picture = alloc_picture();
|
||||
picture->filename = strdup(filename);
|
||||
picture->offset.seconds = timestamp - dive->when + shift_time;
|
||||
picture_load_exif_data(picture);
|
||||
picture->offset.seconds = metadata.timestamp - dive->when + shift_time;
|
||||
picture->longitude = metadata.longitude;
|
||||
picture->latitude = metadata.latitude;
|
||||
|
||||
dive_add_picture(dive, picture);
|
||||
dive_set_geodata_from_picture(dive, picture);
|
||||
|
|
|
@ -98,12 +98,3 @@ extern "C" timestamp_t picture_get_timestamp(const char *filename)
|
|||
get_metadata(filename, &data);
|
||||
return data.timestamp;
|
||||
}
|
||||
|
||||
extern "C" void picture_load_exif_data(struct picture *p)
|
||||
{
|
||||
struct metadata data;
|
||||
if (get_metadata(p->filename, &data) == MEDIATYPE_IO_ERROR)
|
||||
return;
|
||||
p->longitude = data.longitude;
|
||||
p->latitude = data.latitude;
|
||||
}
|
||||
|
|
|
@ -22,7 +22,6 @@ extern "C" {
|
|||
|
||||
enum mediatype_t get_metadata(const char *filename, struct metadata *data);
|
||||
timestamp_t picture_get_timestamp(const char *filename);
|
||||
void picture_load_exif_data(struct picture *p);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue