summaryrefslogtreecommitdiffstats
path: root/core/parse.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/parse.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/parse.c')
-rw-r--r--core/parse.c16
1 files changed, 7 insertions, 9 deletions
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);
}