summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2017-10-02 23:03:44 -0700
committerGravatar Dirk Hohndel <dirk@hohndel.org>2017-10-04 08:05:09 -0700
commit21d78121ade941adf9eaad399e6b8146298b421f (patch)
tree56cc4109f116d7b667163e960fcc7936fdf4c6aa /core
parentde10fd4021f7fa7e203782df29456c09e07165e8 (diff)
downloadsubsurface-21d78121ade941adf9eaad399e6b8146298b421f.tar.gz
Don't add separate country field, use taxonomy
The more I looked at the code that added the country to the dive site, the more it seemed redundant given what we have with the taxonomy. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'core')
-rw-r--r--core/dive.h9
-rw-r--r--core/divesite.c4
-rw-r--r--core/divesite.h1
-rw-r--r--core/load-git.c5
-rw-r--r--core/parse-xml.c3
-rw-r--r--core/save-git.c1
-rw-r--r--core/save-xml.c1
7 files changed, 8 insertions, 16 deletions
diff --git a/core/dive.h b/core/dive.h
index a638cfd0c..51524500f 100644
--- a/core/dive.h
+++ b/core/dive.h
@@ -570,11 +570,14 @@ static inline struct dive_site *get_dive_site_for_dive(struct dive *dive)
return NULL;
}
-static inline char *get_dive_country(struct dive *dive)
+static inline const char *get_dive_country(struct dive *dive)
{
struct dive_site *ds = get_dive_site_by_uuid(dive->dive_site_uuid);
- if (ds && ds->country)
- return ds->country;
+ if (ds) {
+ int idx = taxonomy_index_for_category(&ds->taxonomy, TC_COUNTRY);
+ if (idx >= 0)
+ return ds->taxonomy.category[idx].value;
+ }
return NULL;
}
diff --git a/core/divesite.c b/core/divesite.c
index 159ac4d40..fd25bb965 100644
--- a/core/divesite.c
+++ b/core/divesite.c
@@ -205,7 +205,6 @@ uint32_t create_dive_site(const char *name, timestamp_t divetime)
uint32_t uuid = create_divesite_uuid(name, divetime);
struct dive_site *ds = alloc_or_get_dive_site(uuid);
ds->name = copy_string(name);
- ds->country = NULL;
return uuid;
}
@@ -240,7 +239,6 @@ bool dive_site_is_empty(struct dive_site *ds)
return same_string(ds->name, "") &&
same_string(ds->description, "") &&
same_string(ds->notes, "") &&
- same_string(ds->country, "") &&
ds->latitude.udeg == 0 &&
ds->longitude.udeg == 0;
}
@@ -304,7 +302,6 @@ void merge_dive_site(struct dive_site *a, struct dive_site *b)
merge_string(&a->name, &b->name);
merge_string(&a->notes, &b->notes);
merge_string(&a->description, &b->description);
- merge_string(&a->country, &b->country);
if (!a->taxonomy.category) {
a->taxonomy = b->taxonomy;
@@ -325,7 +322,6 @@ void clear_dive_site(struct dive_site *ds)
ds->longitude.udeg = 0;
ds->uuid = 0;
ds->taxonomy.nr = 0;
- ds->country = 0;
free_taxonomy(&ds->taxonomy);
}
diff --git a/core/divesite.h b/core/divesite.h
index 452a27927..b44e34a31 100644
--- a/core/divesite.h
+++ b/core/divesite.h
@@ -17,7 +17,6 @@ struct dive_site
{
uint32_t uuid;
char *name;
- char *country;
degrees_t latitude, longitude;
char *description;
char *notes;
diff --git a/core/load-git.c b/core/load-git.c
index c77d4c05d..e7732a69f 100644
--- a/core/load-git.c
+++ b/core/load-git.c
@@ -293,9 +293,6 @@ static void parse_dive_notrip(char *line, struct membuffer *str, void *_dive)
struct dive *dive = _dive; dive->tripflag = NO_TRIP;
}
-static void parse_site_country(char *line, struct membuffer *str, void *_ds)
-{ (void) line; struct dive_site *ds = _ds; ds->country = strdup(mb_cstring(str)); }
-
static void parse_site_description(char *line, struct membuffer *str, void *_ds)
{ (void) line; struct dive_site *ds = _ds; ds->description = strdup(mb_cstring(str)); }
@@ -997,7 +994,7 @@ static void dive_parser(char *line, struct membuffer *str, void *_dive)
struct keyword_action site_action[] = {
#undef D
#define D(x) { #x, parse_site_ ## x }
- D(country), D(description), D(geo), D(gps), D(name), D(notes)
+ D(description), D(geo), D(gps), D(name), D(notes)
};
static void site_parser(char *line, struct membuffer *str, void *_ds)
diff --git a/core/parse-xml.c b/core/parse-xml.c
index 27b7b484f..ece85022b 100644
--- a/core/parse-xml.c
+++ b/core/parse-xml.c
@@ -1057,6 +1057,7 @@ static void divinglog_place(char *place, uint32_t *uuid)
if (*uuid == 0)
*uuid = create_dive_site(buffer, cur_dive->when);
+ // TODO: capture the country / city info in the taxonomy instead
city = NULL;
country = NULL;
}
@@ -1506,8 +1507,6 @@ static void try_to_fill_dive_site(struct dive_site **ds_p, const char *name, cha
return;
if (MATCH("name", utf8_string, &ds->name))
return;
- if (MATCH("country", utf8_string, &ds->country))
- return;
if (MATCH("description", utf8_string, &ds->description))
return;
if (MATCH("notes", utf8_string, &ds->notes))
diff --git a/core/save-git.c b/core/save-git.c
index be0d3920b..548664239 100644
--- a/core/save-git.c
+++ b/core/save-git.c
@@ -961,7 +961,6 @@ static void save_divesites(git_repository *repo, struct dir *tree)
}
struct membuffer site_file_name = { 0 };
put_format(&site_file_name, "Site-%08x", ds->uuid);
- show_utf8(&b, "country ", ds->country, "\n");
show_utf8(&b, "name ", ds->name, "\n");
show_utf8(&b, "description ", ds->description, "\n");
show_utf8(&b, "notes ", ds->notes, "\n");
diff --git a/core/save-xml.c b/core/save-xml.c
index 0410975dc..d3b9e6c8d 100644
--- a/core/save-xml.c
+++ b/core/save-xml.c
@@ -598,7 +598,6 @@ void save_dives_buffer(struct membuffer *b, const bool select_only)
put_format(b, "<site uuid='%8x'", ds->uuid);
show_utf8(b, ds->name, " name='", "'", 1);
- show_utf8(b, ds->country, " country='", "'", 1);
if (ds->latitude.udeg || ds->longitude.udeg) {
put_degrees(b, ds->latitude, " gps='", " ");
put_degrees(b, ds->longitude, "", "'");