ltog/osmi-addresses

Handling empty values

Opened this issue · 3 comments

ltog commented

Can empty values occur in OSM tags, e.g. for name=?

There is an inconsistency in the code:

return std::string("");
returns an empty std::string if a key doesn't exist. However, in
if (addrstreet && has_entry_in_name2highways(street)) {
and others const char* addrstreet = street.c_str() will never return a nullptr, making the test obsolete.

Maybe usage of AltTagList can completely be avoided and osmium::TagList can be used instead?

ltog commented

Starting at

m_addr_interpolation_node_map.set(node.id(), alt_tag_list);
I tried to insert the following line:

osmium::TagList mytaglist = node.tags();

That led to the following clang++ error:

In file included from main.cpp:31:
./SecondHandler.hpp:71:20: error: call to implicitly-deleted copy constructor of 'osmium::TagList'
                        osmium::TagList mytaglist = node.tags();
                                        ^           ~~~~~~~~~~~
/usr/local/include/osmium/osm/tag.hpp:105:21: note: copy constructor of 'TagList' is implicitly deleted because base class 'osmium::memory::Collection<Tag, osmium::item_type::tag_list>'
      has a deleted copy constructor
    class TagList : public osmium::memory::Collection<Tag, osmium::item_type::tag_list> {
                    ^
/usr/local/include/osmium/memory/collection.hpp:105:28: note: copy constructor of 'Collection<osmium::Tag, 17>' is implicitly deleted because base class 'osmium::memory::Item' has a
      deleted copy constructor
        class Collection : public Item {
                           ^
/usr/local/include/osmium/memory/item.hpp:127:13: note: 'Item' has been explicitly marked deleted here
            Item(const Item&) = delete;
            ^
1 error generated.

IIRC there have been some topics about empty tags in OSM data and whether the OSM API should reject them, or whether that is a task of the editors to do some validation before uploading.

But I have no concrete link to any topic or discussion about that ... needs some research.

Are you interested in those topics?

ltog commented

@stephan75 : As far as I understood the issue, tags can have empty values but editors usually prevent it. See e.g. https://lists.openstreetmap.org/pipermail/talk/2013-September/068158.html

Currently I'm only in so far interested as I would like osmi-addresses to still work correctly in the presence of such empty tags. As described in #73 (comment) I guess I slightly misimplemented things but currently I'm unsure about the impact of this.