core: include divesite table directly in divelog

Having this as a pointer is an artifact from the C/C++ split.
The divesitetable header is small enough so that we can
include it directly.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2024-06-08 16:30:24 +02:00 committed by bstoeger
parent 7792f54a73
commit 5af9d28291
29 changed files with 90 additions and 91 deletions

View file

@ -560,7 +560,7 @@ static void dive_site(const char *buffer, struct dive *d, struct parser_state *s
{
uint32_t uuid;
hex_value(buffer, &uuid);
state->log->sites->get_by_uuid(uuid)->add_dive(d);
state->log->sites.get_by_uuid(uuid)->add_dive(d);
}
static void get_notrip(const char *buffer, bool *notrip)
@ -977,9 +977,9 @@ static void divinglog_place(const char *place, struct dive *d, struct parser_sta
!state->city.empty() ? state->city.c_str() : "",
!state->country.empty() ? ", " : "",
!state->country.empty() ? state->country.c_str() : "");
ds = state->log->sites->get_by_name(buffer);
ds = state->log->sites.get_by_name(buffer);
if (!ds)
ds = state->log->sites->create(buffer);
ds = state->log->sites.create(buffer);
ds->add_dive(d);
// TODO: capture the country / city info in the taxonomy instead
@ -1147,7 +1147,7 @@ static void gps_lat(const char *buffer, struct dive *dive, struct parser_state *
location.lat = parse_degrees(buffer, &end);
if (!ds) {
state->log->sites->create(std::string(), location)->add_dive(dive);
state->log->sites.create(std::string(), location)->add_dive(dive);
} else {
if (ds->location.lat.udeg && ds->location.lat.udeg != location.lat.udeg)
report_info("Oops, changing the latitude of existing dive site id %8x name %s; not good", ds->uuid,
@ -1164,7 +1164,7 @@ static void gps_long(const char *buffer, struct dive *dive, struct parser_state
location.lon = parse_degrees(buffer, &end);
if (!ds) {
state->log->sites->create(std::string(), location)->add_dive(dive);
state->log->sites.create(std::string(), location)->add_dive(dive);
} else {
if (ds->location.lon.udeg && ds->location.lon.udeg != location.lon.udeg)
report_info("Oops, changing the longitude of existing dive site id %8x name %s; not good", ds->uuid,
@ -1195,14 +1195,14 @@ static void gps_in_dive(const char *buffer, struct dive *dive, struct parser_sta
parse_location(buffer, &location);
if (!ds) {
// check if we have a dive site within 20 meters of that gps fix
ds = state->log->sites->get_by_gps_proximity(location, 20);
ds = state->log->sites.get_by_gps_proximity(location, 20);
if (ds) {
// found a site nearby; in case it turns out this one had a different name let's
// remember the original coordinates so we can create the correct dive site later
state->cur_location = location;
} else {
ds = state->log->sites->create(std::string(), location);
ds = state->log->sites.create(std::string(), location);
}
ds->add_dive(dive);
} else {
@ -2226,7 +2226,7 @@ int parse_dlf_buffer(unsigned char *buffer, size_t size, struct divelog *log)
/* Measure GPS */
state.cur_location.lat.udeg = (int)((ptr[7] << 24) + (ptr[6] << 16) + (ptr[5] << 8) + (ptr[4] << 0));
state.cur_location.lon.udeg = (int)((ptr[11] << 24) + (ptr[10] << 16) + (ptr[9] << 8) + (ptr[8] << 0));
state.log->sites->create("DLF imported"s, state.cur_location)->add_dive(state.cur_dive.get());
state.log->sites.create("DLF imported"s, state.cur_location)->add_dive(state.cur_dive.get());
break;
default:
break;