diff options
author | Jonas Danielsson <jonas@threetimestwo.org> | 2014-01-13 12:21:48 +0100 |
---|---|---|
committer | Bastien Nocera <hadess@hadess.net> | 2019-11-06 16:46:32 +0100 |
commit | c40f7981a50d1d6cce655fa673208cec2c856463 (patch) | |
tree | 00ea1cf43ba42148b4c57b7a27e7bf8fde789902 | |
parent | d79678ecd28cc9543f90848a62174b84cead880c (diff) | |
download | geocode-glib-wip/issue-9.tar.gz |
forward: Equality for missing attributes in resultwip/issue-9
The function insert_place_into_tree creates a GNode
based tree that is built up by the search results attributes.
The idea is that if places share attributes they share a path
and we can later minimize what we include in the name.
This patch fixes a bug where missing attributes where inserted
as completly new nodes, creating subtrees that could never get
siblings.
https://bugzilla.gnome.org/show_bug.cgi?id=721340
Closes: #9
-rw-r--r-- | geocode-glib/geocode-nominatim.c | 31 |
1 files changed, 15 insertions, 16 deletions
diff --git a/geocode-glib/geocode-nominatim.c b/geocode-glib/geocode-nominatim.c index fc333dc..15c426a 100644 --- a/geocode-glib/geocode-nominatim.c +++ b/geocode-glib/geocode-nominatim.c @@ -510,23 +510,22 @@ insert_place_into_tree (GNode *place_tree, GHashTable *ht) GNode *child = NULL; attr_val = g_hash_table_lookup (ht, place_attributes[i]); - if (!attr_val) { - /* Add a dummy node if the attribute value is not - * available for the place */ - child = g_node_insert_data (start, -1, NULL); - } else { - /* If the attr value (eg for country United States) - * already exists, then keep on adding other attributes under that node. */ - child = g_node_first_child (start); - while (child && - child->data && - g_ascii_strcasecmp (child->data, attr_val) != 0) { - child = g_node_next_sibling (child); - } - if (!child) { - /* create a new node */ - child = g_node_insert_data (start, -1, g_strdup (attr_val)); + /* If the attr value (eg for country United States or missing completely) + * already exists, then keep on adding other attributes under that node. */ + child = g_node_first_child (start); + while (child) { + if (!attr_val) { + if (!child->data) + break; + } else if (child->data) { + if (g_ascii_strcasecmp (child->data, attr_val) == 0) + break; } + child = g_node_next_sibling (child); + } + if (!child) { + /* create a new node */ + child = g_node_insert_data (start, -1, g_strdup (attr_val)); } start = child; } |