From 28e3413ff66552f392fecee25068d634cdfe59fc Mon Sep 17 00:00:00 2001 From: Linus Torvalds Date: Sat, 20 Oct 2018 14:12:15 -0400 Subject: 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 --- core/parse.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) (limited to 'core/parse.c') diff --git a/core/parse.c b/core/parse.c index 067008970..76b66733f 100644 --- a/core/parse.c +++ b/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); } -- cgit v1.2.3-70-g09d2