diff --git a/generator/search_index_builder.cpp b/generator/search_index_builder.cpp index 47b6fb1657..c008e0537c 100644 --- a/generator/search_index_builder.cpp +++ b/generator/search_index_builder.cpp @@ -1,8 +1,10 @@ #include "search_index_builder.hpp" #include "search/reverse_geocoder.hpp" +#include "search/search_common.hpp" #include "search/search_index_values.hpp" #include "search/search_trie.hpp" +#include "search/types_skipper.hpp" #include "indexer/categories_holder.hpp" #include "indexer/classificator.hpp" @@ -16,9 +18,6 @@ #include "indexer/search_delimiters.hpp" #include "indexer/search_string_utils.hpp" #include "indexer/trie_builder.hpp" -#include "indexer/types_skipper.hpp" - -#include "search/search_common.hpp" #include "defines.hpp" diff --git a/indexer/indexer.pro b/indexer/indexer.pro index 66facc318a..b2b9fe13f7 100644 --- a/indexer/indexer.pro +++ b/indexer/indexer.pro @@ -54,7 +54,6 @@ SOURCES += \ search_delimiters.cpp \ # it's in indexer because of CategoriesHolder dependency. search_string_utils.cpp \ # it's in indexer because of CategoriesHolder dependency. types_mapping.cpp \ - types_skipper.cpp \ HEADERS += \ categories_holder.hpp \ @@ -117,7 +116,6 @@ HEADERS += \ trie_builder.hpp \ trie_reader.hpp \ types_mapping.hpp \ - types_skipper.hpp \ unique_index.hpp \ OTHER_FILES += drules_struct.proto diff --git a/search/search.pro b/search/search.pro index eafe41860a..1283337fa6 100644 --- a/search/search.pro +++ b/search/search.pro @@ -41,6 +41,7 @@ HEADERS += \ search_string_intersection.hpp \ search_trie.hpp \ suggest.hpp \ + types_skipper.hpp \ v2/cbv_ptr.hpp \ v2/features_filter.hpp \ v2/features_layer.hpp \ @@ -85,6 +86,7 @@ SOURCES += \ search_engine.cpp \ search_query.cpp \ search_query_params.cpp \ + types_skipper.cpp \ v2/cbv_ptr.cpp \ v2/features_filter.cpp \ v2/features_layer.cpp \ diff --git a/indexer/types_skipper.cpp b/search/types_skipper.cpp similarity index 86% rename from indexer/types_skipper.cpp rename to search/types_skipper.cpp index f9403bad38..2b6ccfdd51 100644 --- a/indexer/types_skipper.cpp +++ b/search/types_skipper.cpp @@ -1,4 +1,4 @@ -#include "indexer/types_skipper.hpp" +#include "types_skipper.hpp" #include "indexer/classificator.hpp" #include "indexer/feature_data.hpp" @@ -18,12 +18,11 @@ TypesSkipper::TypesSkipper() for (auto const & e : (StringIL[]){{"building", "address"}}) m_skipAlways[1].push_back(c.GetTypeByPath(e)); - for (auto const & e : (StringIL[]){{"highway", "bus_stop"}, {"highway", "speed_camera"}}) - m_dontSkipIfEmptyName.push_back(c.GetTypeByPath(e)); - - for (auto const & e : - (StringIL[]){{"building"}, {"highway"}, {"natural"}, {"waterway"}, {"landuse"}}) + for (auto const & e : (StringIL[]){{"building"}, {"highway"}, {"natural"}, + {"waterway"}, {"landuse"}}) + { m_skipIfEmptyName[0].push_back(c.GetTypeByPath(e)); + } for (auto const & e : (StringIL[]){{"place", "country"}, {"place", "state"}, @@ -62,10 +61,10 @@ void TypesSkipper::SkipEmptyNameTypes(feature::TypesHolder & types) const { auto shouldBeRemoved = [this](uint32_t type) { - ftype::TruncValue(type, 2); - if (HasType(m_dontSkipIfEmptyName, type)) + if (m_dontSkipIfEmptyName.Has(type)) return false; + ftype::TruncValue(type, 2); if (HasType(m_skipIfEmptyName[1], type)) return true; diff --git a/indexer/types_skipper.hpp b/search/types_skipper.hpp similarity index 91% rename from indexer/types_skipper.hpp rename to search/types_skipper.hpp index a4ae75a7a9..5dd51cf630 100644 --- a/indexer/types_skipper.hpp +++ b/search/types_skipper.hpp @@ -1,11 +1,8 @@ #pragma once -#include "base/buffer_vector.hpp" +#include "v2/search_model.hpp" -namespace feature -{ -class TypesHolder; -} +#include "base/buffer_vector.hpp" namespace search { @@ -34,7 +31,7 @@ private: // m_skipIfEmptyName and m_dontSkipIfEmptyName are used in the case 2 described above. TCont m_skipIfEmptyName[2]; - TCont m_dontSkipIfEmptyName; + v2::TwoLevelPOIChecker m_dontSkipIfEmptyName; uint32_t m_country, m_state; }; diff --git a/search/v2/search_model.cpp b/search/v2/search_model.cpp index 3b4eb7ca09..c0c79a35b2 100644 --- a/search/v2/search_model.cpp +++ b/search/v2/search_model.cpp @@ -2,7 +2,6 @@ #include "indexer/classificator.hpp" #include "indexer/feature.hpp" -#include "indexer/ftypes_matcher.hpp" #include "base/macros.hpp" @@ -12,7 +11,22 @@ namespace search { namespace v2 { -/// This checkers should be similar with ftypes::IsAddressObjectChecker, plus public transort. +TwoLevelPOIChecker::TwoLevelPOIChecker() : ftypes::BaseChecker(2 /* level */) +{ + Classificator const & c = classif(); + StringIL arr[] = { + {"highway", "bus_stop"}, + {"highway", "speed_camera"}, + {"waterway", "waterfall"}, + {"natural", "volcano"}, + {"natural", "cave_entrance"} + }; + + for (size_t i = 0; i < ARRAY_SIZE(arr); ++i) + m_types.push_back(c.GetTypeByPath(arr[i])); +} + +/// This checkers should be similar with ftypes::IsAddressObjectChecker, plus public transport. namespace { class OneLevelPOIChecker : public ftypes::BaseChecker @@ -28,16 +42,6 @@ public: } }; -class TwoLevelPOIChecker : public ftypes::BaseChecker -{ -public: - TwoLevelPOIChecker() : ftypes::BaseChecker(2 /* level */) - { - Classificator const & c = classif(); - m_types.push_back(c.GetTypeByPath({"highway", "bus_stop"})); - } -}; - class IsPoiChecker { public: diff --git a/search/v2/search_model.hpp b/search/v2/search_model.hpp index 394d6d1ba7..8ef802f7c3 100644 --- a/search/v2/search_model.hpp +++ b/search/v2/search_model.hpp @@ -1,5 +1,7 @@ #pragma once +#include "indexer/ftypes_matcher.hpp" + #include "std/string.hpp" #include "std/vector.hpp" @@ -7,15 +9,18 @@ class FeatureType; -namespace ftypes -{ -class BaseChecker; -} - namespace search { namespace v2 { + +class TwoLevelPOIChecker : public ftypes::BaseChecker +{ +public: + TwoLevelPOIChecker(); + bool Has(uint32_t type) const { return IsMatched(type); } +}; + // This class is used to map feature types to a restricted set of // different search classes (do not confuse these classes with search // categories - they are completely different things).