From 98eedc2ac86bc8d6cacc6ef81678a7853d0d696e Mon Sep 17 00:00:00 2001 From: Jochen Topf Date: Thu, 21 Aug 2025 14:42:58 +0200 Subject: [PATCH] Remove unused DomainMatcher class Leftover from gazetteer code --- src/domain-matcher.hpp | 50 --------------- tests/CMakeLists.txt | 1 - tests/test-domain-matcher.cpp | 116 ---------------------------------- 3 files changed, 167 deletions(-) delete mode 100644 src/domain-matcher.hpp delete mode 100644 tests/test-domain-matcher.cpp diff --git a/src/domain-matcher.hpp b/src/domain-matcher.hpp deleted file mode 100644 index 726230627..000000000 --- a/src/domain-matcher.hpp +++ /dev/null @@ -1,50 +0,0 @@ -#ifndef OSM2PGSQL_DOMAIN_MATCHER_HPP -#define OSM2PGSQL_DOMAIN_MATCHER_HPP - -/** - * SPDX-License-Identifier: GPL-2.0-or-later - * - * This file is part of osm2pgsql (https://osm2pgsql.org/). - * - * Copyright (C) 2006-2025 by the osm2pgsql developer community. - * For a full list of authors see the git log. - */ - -#include - -#include - -/** - * Returns the tag specific name, if applicable. - * - * OSM tags may contain name tags that refer to one of the other tags - * in the tag set. For example, the name of a bridge is tagged as - * bridge:name=Foo to not confuse it with the name of the highway - * going over the bridge. This matcher checks if a tag is such a name tag - * for the given tag key and returns the name key without the prefix - * if it matches. - */ -class DomainMatcher -{ -public: - explicit DomainMatcher(char const *cls) noexcept - : m_domain(cls), m_len(std::strlen(cls)) - {} - - char const *operator()(osmium::Tag const &t) const noexcept - { - if (std::strncmp(t.key(), m_domain, m_len) == 0 && - std::strncmp(t.key() + m_len, ":name", 5) == 0 && - (t.key()[m_len + 5] == '\0' || t.key()[m_len + 5] == ':')) { - return t.key() + m_len + 1; - } - - return nullptr; - } - -private: - char const *m_domain; - size_t m_len; -}; - -#endif // OSM2PGSQL_DOMAIN_MATCHER_HPP diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 4b946be34..14f312cd2 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -41,7 +41,6 @@ target_compile_features(catch_main_lib PUBLIC cxx_std_17) set_test(test-check-input LABELS NoDB) set_test(test-db-copy-mgr) set_test(test-db-copy-thread) -set_test(test-domain-matcher LABELS NoDB) set_test(test-expire-from-geometry LABELS NoDB) set_test(test-expire-tiles LABELS NoDB) set_test(test-flex-indexes LABELS NoDB) diff --git a/tests/test-domain-matcher.cpp b/tests/test-domain-matcher.cpp deleted file mode 100644 index f6356c5e3..000000000 --- a/tests/test-domain-matcher.cpp +++ /dev/null @@ -1,116 +0,0 @@ -/** - * SPDX-License-Identifier: GPL-2.0-or-later - * - * This file is part of osm2pgsql (https://osm2pgsql.org/). - * - * Copyright (C) 2006-2025 by the osm2pgsql developer community. - * For a full list of authors see the git log. - */ - -#include - -#include "domain-matcher.hpp" - -#include -#include -#include - -#include - -namespace { - -osmium::Tag &fill_buffer(osmium::memory::Buffer *buffer, char const *key, - char const *value) -{ - { - osmium::builder::TagListBuilder builder{*buffer}; - builder.add_tag(key, value); - } - buffer->commit(); - - return *buffer->get(0).begin(); -} - -} // anonymous namespace - -TEST_CASE("DomainMatcher: name", "[NoDB]") -{ - osmium::memory::Buffer buffer{1024}; - DomainMatcher const matcher{"bridge"}; - - auto const &tag = fill_buffer(&buffer, "bridge:name", "Golden Gate Bridge"); - char const *result = matcher(tag); - - REQUIRE(result); - REQUIRE(std::strcmp(result, "name") == 0); -} - -TEST_CASE("DomainMatcher: name with language", "[NoDB]") -{ - osmium::memory::Buffer buffer{1024}; - DomainMatcher const matcher{"bridge"}; - - auto const &tag = - fill_buffer(&buffer, "bridge:name:en", "The Bridge on the River Kwai"); - char const *result = matcher(tag); - - REQUIRE(result); - REQUIRE(std::strcmp(result, "name:en") == 0); -} - -TEST_CASE("DomainMatcher: no :name", "[NoDB]") -{ - osmium::memory::Buffer buffer{1024}; - DomainMatcher const matcher{"bridge"}; - - auto const &tag = fill_buffer(&buffer, "bridge_name", "A Bridge Too Far"); - char const *result = matcher(tag); - - REQUIRE_FALSE(result); -} - -TEST_CASE("DomainMatcher: empty matcher", "[NoDB]") -{ - osmium::memory::Buffer buffer{1024}; - DomainMatcher const matcher{""}; - - auto const &tag = - fill_buffer(&buffer, "bridge:name", "Tacoma Narrows Bridge"); - char const *result = matcher(tag); - - REQUIRE_FALSE(result); -} - -TEST_CASE("DomainMatcher: names", "[NoDB]") -{ - osmium::memory::Buffer buffer{1024}; - DomainMatcher const matcher{"bridge"}; - - auto const &tag = - fill_buffer(&buffer, "bridge:names", "Seven Bridges of Königsberg"); - char const *result = matcher(tag); - - REQUIRE_FALSE(result); -} - -TEST_CASE("DomainMatcher: not matching", "[NoDB]") -{ - osmium::memory::Buffer buffer{1024}; - DomainMatcher const matcher{"bridge"}; - - auto const &tag = fill_buffer(&buffer, "the_bridge_tag", "Pont du Gard"); - char const *result = matcher(tag); - - REQUIRE_FALSE(result); -} - -TEST_CASE("DomainMatcher: empty tag", "[NoDB]") -{ - osmium::memory::Buffer buffer{1024}; - DomainMatcher const matcher{"bridge"}; - - auto const &tag = fill_buffer(&buffer, "", "London Bridge"); - char const *result = matcher(tag); - - REQUIRE_FALSE(result); -}