Commit graph

9 commits

Author SHA1 Message Date
Berthold Stoeger
83c56bc34c cleanup: make taxonomy_index_for_category() local to taxonomy.c
This helper function is not used outside taxonomy.c anymore.
Let's hide this implementation detail.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-09-06 12:59:54 -07:00
Berthold Stoeger
1f1fd78f78 cleanup: create taxonomy_get_value() function
This is the counter-part to taxonomy_set_value(). Let taxonomy_get_country() be the
first user of the function. If a category doesn't exist, return NULL.

Small addition: make taxonomy_get_countr() take a const argument.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-09-06 12:59:54 -07:00
Berthold Stoeger
f93acdace7 cleanup: make alloc_taxonomy local to taxonomy.c
The alloc_taxonomy()/free_taxonomy() interface was exceedingly strange.
The former gave a "struct taxonomy", the latter took a "struct taxonomy_data".
To make things worse, is appears as if the names "taxonomy" and "taxonoma_data"
are reversed: the latter contains the former.

In any case, the alloc_taxonomy() call is not needed anymore from outside
taxonomy.c, as these memory-management details are now hidden in accessor
functions. Therefore, make the function local to taxonomy.c. Moreover,
rename it to "alloc_taxonomy_table()" and let it take a "taxonomy_data"
structure for symmetry with "free_taxonomy()".

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-09-06 12:59:54 -07:00
Berthold Stoeger
6da78a29c4 cleanup: add helper function to set taxonomy category
Setting a taxonomy category was cumbersome: the caller had to
make sure that the category-table was allocated. Introduce
a helper function to make that simpler.

Make taxonomy_set_country() the first caller of the new function,
since it is just a special case with category = TC_COUNTRY.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-09-06 12:59:54 -07:00
Michael Werle
d404aa767f [Bug #2934] Geo Lookup - support for remote dive sites
Some remote dive sites have no populated places (towns, cities)
nearby. For such sites, we now fall back to looking up
unpopulated place names, such as the reef or island name.

Also some code refactorisation:
the actual network access is now encapsulated in its own
function removing some duplicated code handling in the
reverseGeoLookup function and making it more readable.

Furthermore, reverseGeoLookup() was completely refactored as
most of its functionality was due to legacy requirements; the
current code-base only calls this function from a single
location and only with an empty taxonomy_data object. This
makes the function more focussed and much simpler and more
readable.

Finally, a resource leak in reverseGeocde introduced in
4f3b26f9b6 was fixed.

Signed-off-by: Michael Werle <micha@michaelwerle.com>
2020-09-05 17:34:15 +02:00
Berthold Stoeger
8815f77ea0 Dive site: use own copy of taxonomy in dive-site-edit widget
The dive-site-edit widget uses a copy of the to-be-edited site
to compare with old values. Generally, this seems overkill
(the original dive-site can be used for such a comparison).
But one place where it can't simply be removed is the taxonomy,
because the widget needs a place to store the unsaved data.

Change the code to use an explicit taxonomy structure instead
of the one provided in the copy. This should ultimately allow
removal of the latter.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-10-13 21:41:41 -04:00
Dirk Hohndel
9fd6b3eefb Add taxonomy helper functions
Right now we just want direct access to the country, I assume
we'll add more like this in the future.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-10-04 08:05:09 -07:00
Dirk Hohndel
b368ecd5aa Add SPDX header to remaining core files
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-04-29 13:32:55 -07:00
Dirk Hohndel
7be962bfc2 Move subsurface-core to core and qt-mobile to mobile-widgets
Having subsurface-core as a directory name really messes with
autocomplete and is obviously redundant. Simmilarly, qt-mobile caused an
autocomplete conflict and also was inconsistent with the desktop-widget
name for the directory containing the "other" UI.

And while cleaning up the resulting change in the path name for include
files, I decided to clean up those even more to make them consistent
overall.

This could have been handled in more commits, but since this requires a
make clean before the build, it seemed more sensible to do it all in one.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-04 22:33:58 -07:00
Renamed from subsurface-core/taxonomy.h (Browse further)