summaryrefslogtreecommitdiffstats
path: root/core/dive.c
diff options
context:
space:
mode:
authorGravatar Linus Torvalds <torvalds@linux-foundation.org>2018-10-20 14:12:15 -0400
committerGravatar Lubomir I. Ivanov <neolit123@gmail.com>2018-10-21 19:55:09 +0300
commit28e3413ff66552f392fecee25068d634cdfe59fc (patch)
tree5fe303d1e7dc1c371e13b534b85c232e29aea884 /core/dive.c
parentc9869406301ff72f76b399097f0845fc1102ced1 (diff)
downloadsubsurface-28e3413ff66552f392fecee25068d634cdfe59fc.tar.gz
Add 'location_t' data structure
Instead of having people treat latitude and longitude as separate things, just add a 'location_t' data structure that contains both. Almost all cases want to always act on them together. This is really just prep-work for adding a few more locations that we track: I want to add a entry/exit location to each dive (independent of the dive site) because of how the Garmin Descent gives us the information (and hopefully, some day, other dive computers too). Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'core/dive.c')
-rw-r--r--core/dive.c12
1 files changed, 5 insertions, 7 deletions
diff --git a/core/dive.c b/core/dive.c
index 08ef5b6bd..e486d1a9a 100644
--- a/core/dive.c
+++ b/core/dive.c
@@ -4048,8 +4048,7 @@ void dive_create_picture(struct dive *dive, const char *filename, int shift_time
struct picture *picture = alloc_picture();
picture->filename = strdup(filename);
picture->offset.seconds = metadata.timestamp - dive->when + shift_time;
- picture->longitude = metadata.longitude;
- picture->latitude = metadata.latitude;
+ picture->location = metadata.location;
dive_add_picture(dive, picture);
dive_set_geodata_from_picture(dive, picture);
@@ -4078,12 +4077,11 @@ unsigned int dive_get_picture_count(struct dive *dive)
void dive_set_geodata_from_picture(struct dive *dive, struct picture *picture)
{
struct dive_site *ds = get_dive_site_by_uuid(dive->dive_site_uuid);
- if (!dive_site_has_gps_location(ds) && (picture->latitude.udeg || picture->longitude.udeg)) {
+ if (!dive_site_has_gps_location(ds) && has_location(&picture->location)) {
if (ds) {
- ds->latitude = picture->latitude;
- ds->longitude = picture->longitude;
+ ds->location = picture->location;
} else {
- dive->dive_site_uuid = create_dive_site_with_gps("", picture->latitude, picture->longitude, dive->when);
+ dive->dive_site_uuid = create_dive_site_with_gps("", &picture->location, dive->when);
invalidate_dive_cache(dive);
}
}
@@ -4428,7 +4426,7 @@ int get_idx_by_uniq_id(int id)
bool dive_site_has_gps_location(const struct dive_site *ds)
{
- return ds && (ds->latitude.udeg || ds->longitude.udeg);
+ return ds && has_location(&ds->location);
}
int dive_has_gps_location(const struct dive *dive)