mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
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>
This commit is contained in:
parent
c986940630
commit
28e3413ff6
40 changed files with 251 additions and 264 deletions
12
core/dive.c
12
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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue