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
16
core/parse.c
16
core/parse.c
|
@ -22,7 +22,7 @@ struct parser_settings cur_settings;
|
|||
struct divecomputer *cur_dc = NULL;
|
||||
struct dive *cur_dive = NULL;
|
||||
struct dive_site *cur_dive_site = NULL;
|
||||
degrees_t cur_latitude, cur_longitude;
|
||||
location_t cur_location;
|
||||
dive_trip_t *cur_trip = NULL;
|
||||
struct sample *cur_sample = NULL;
|
||||
struct picture *cur_picture = NULL;
|
||||
|
@ -258,8 +258,8 @@ void dive_end(void)
|
|||
record_dive_to_table(cur_dive, target_table);
|
||||
cur_dive = NULL;
|
||||
cur_dc = NULL;
|
||||
cur_latitude.udeg = 0;
|
||||
cur_longitude.udeg = 0;
|
||||
cur_location.lat.udeg = 0;
|
||||
cur_location.lon.udeg = 0;
|
||||
cur_cylinder_index = 0;
|
||||
cur_ws_index = 0;
|
||||
}
|
||||
|
@ -442,19 +442,17 @@ void add_dive_site(char *ds_name, struct dive *dive)
|
|||
// but wait, we could have gotten this one based on GPS coords and could
|
||||
// have had two different names for the same site... so let's search the other
|
||||
// way around
|
||||
uint32_t exact_match_uuid = get_dive_site_uuid_by_gps_and_name(buffer, ds->latitude, ds->longitude);
|
||||
uint32_t exact_match_uuid = get_dive_site_uuid_by_gps_and_name(buffer, &ds->location);
|
||||
if (exact_match_uuid) {
|
||||
dive->dive_site_uuid = exact_match_uuid;
|
||||
} else {
|
||||
dive->dive_site_uuid = create_dive_site(buffer, dive->when);
|
||||
struct dive_site *newds = get_dive_site_by_uuid(dive->dive_site_uuid);
|
||||
if (cur_latitude.udeg || cur_longitude.udeg) {
|
||||
if (has_location(&cur_location)) {
|
||||
// we started this uuid with GPS data, so lets use those
|
||||
newds->latitude = cur_latitude;
|
||||
newds->longitude = cur_longitude;
|
||||
newds->location = cur_location;
|
||||
} else {
|
||||
newds->latitude = ds->latitude;
|
||||
newds->longitude = ds->longitude;
|
||||
newds->location = ds->location;
|
||||
}
|
||||
newds->notes = add_to_string(newds->notes, translate("gettextFromC", "additional name for site: %s\n"), ds->name);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue