From 198ebaaf4c7701436df77cf464fcaedcbb3266fa Mon Sep 17 00:00:00 2001 From: tatiana-yan Date: Thu, 8 Nov 2018 11:24:15 +0300 Subject: [search][map] Use custom icons for cafe/bar/restaurant/.. in search. --- indexer/ftypes_matcher.cpp | 38 ++++++++++++++++++++++++++------------ indexer/ftypes_matcher.hpp | 20 +++++++++++++++++++- 2 files changed, 45 insertions(+), 13 deletions(-) (limited to 'indexer') diff --git a/indexer/ftypes_matcher.cpp b/indexer/ftypes_matcher.cpp index 4a82b7eb86..cc3206b5df 100644 --- a/indexer/ftypes_matcher.cpp +++ b/indexer/ftypes_matcher.cpp @@ -379,20 +379,34 @@ IsWifiChecker::IsWifiChecker() m_types.push_back(classif().GetTypeByPath({"internet_access", "wlan"})); } -IsEatChecker:: IsEatChecker() +IsEatChecker::IsEatChecker() { Classificator const & c = classif(); - char const * const paths[][2] = { - {"amenity", "cafe"}, - {"amenity", "bar"}, - {"amenity", "biergarden"}, - {"amenity", "pub"}, - {"amenity", "fast_food"}, - {"amenity", "restaurant"}, - {"shop", "bakery"} - }; - for (auto const & path : paths) - m_types.push_back(c.GetTypeByPath({path[0], path[1]})); + map> const descriptions = {{Type::Cafe, {"amenity", "cafe"}}, + {Type::Bakery, {"shop", "bakery"}}, + {Type::FastFood, {"amenity", "fast_food"}}, + {Type::Restaurant, {"amenity", "restaurant"}}, + {Type::Bar, {"amenity", "bar"}}, + {Type::Pub, {"amenity", "pub"}}, + {Type::Biergarten, {"amenity", "biergarten"}}}; + + for (auto const & desc : descriptions) + { + auto const type = c.GetTypeByPath(desc.second); + m_types.push_back(type); + m_sortedTypes[static_cast(desc.first)] = {type, desc.first}; + } +} + +IsEatChecker::Type IsEatChecker::GetType(uint32_t t) const +{ + for (auto type : m_sortedTypes) + { + if (type.first == t) + return type.second; + } + + return IsEatChecker::Type::Count; } IsCuisineChecker::IsCuisineChecker() : BaseChecker(1 /* level */) diff --git a/indexer/ftypes_matcher.hpp b/indexer/ftypes_matcher.hpp index 745abb9072..1f237eeaaa 100644 --- a/indexer/ftypes_matcher.hpp +++ b/indexer/ftypes_matcher.hpp @@ -216,11 +216,29 @@ public: class IsEatChecker : public BaseChecker { - IsEatChecker(); public: + enum class Type + { + Cafe, + Bakery, + FastFood, + Restaurant, + Bar, + Pub, + Biergarten, + + Count + }; + DECLARE_CHECKER_INSTANCE(IsEatChecker); std::vector const & GetTypes() const { return m_types; } + Type GetType(uint32_t t) const; + +private: + IsEatChecker(); + + std::array, base::Key(Type::Count)> m_sortedTypes; }; class IsCuisineChecker : public BaseChecker -- cgit v1.2.3