diff --git a/indexer/indexer.pro b/indexer/indexer.pro index 2dfa56dbc6..6e3620ea7a 100644 --- a/indexer/indexer.pro +++ b/indexer/indexer.pro @@ -134,6 +134,7 @@ HEADERS += \ trie_reader.hpp \ types_mapping.hpp \ unique_index.hpp \ + wheelchair.hpp \ OTHER_FILES += drules_struct.proto diff --git a/indexer/map_object.cpp b/indexer/map_object.cpp index 8ab26b6dea..3db6a7e40c 100644 --- a/indexer/map_object.cpp +++ b/indexer/map_object.cpp @@ -198,6 +198,11 @@ string MapObject::GetBuildingLevels() const return m_metadata.Get(feature::Metadata::FMD_BUILDING_LEVELS); } +wheelchair::Type MapObject::GetWheelchairType() const +{ + return wheelchair::Matcher::GetType(m_types); +} + feature::Metadata const & MapObject::GetMetadata() const { return m_metadata; } bool MapObject::IsPointType() const { return m_geomType == feature::EGeomType::GEOM_POINT; } bool MapObject::IsBuilding() const { return ftypes::IsBuildingChecker::Instance()(m_types); } diff --git a/indexer/map_object.hpp b/indexer/map_object.hpp index 23c408b6ab..b144baa8b2 100644 --- a/indexer/map_object.hpp +++ b/indexer/map_object.hpp @@ -3,6 +3,7 @@ #include "indexer/feature_data.hpp" #include "indexer/feature_decl.hpp" #include "indexer/feature_meta.hpp" +#include "indexer/wheelchair.hpp" #include "geometry/latlon.hpp" #include "geometry/mercator.hpp" @@ -88,6 +89,7 @@ public: string GetWikipediaLink() const; string GetFlats() const; string GetBuildingLevels() const; + wheelchair::Type GetWheelchairType() const; // TODO(Vlad, yunikkk): Use Props enum + getters instead of direct metadata access. // TODO: Remove this method. diff --git a/indexer/wheelchair.hpp b/indexer/wheelchair.hpp new file mode 100644 index 0000000000..a1029fca59 --- /dev/null +++ b/indexer/wheelchair.hpp @@ -0,0 +1,53 @@ +#pragma once + +#include "indexer/feature.hpp" +#include "indexer/ftypes_mapping.hpp" + +#include + +namespace wheelchair +{ +enum class Type +{ + No, + Yes, + Limited +}; + +inline string DebugPrint(Type wheelchair) +{ + switch (wheelchair) + { + case Type::No: return "No"; + case Type::Yes: return "Yes"; + case Type::Limited: return "Limited"; + } + return {}; +} + +class Matcher +{ +public: + static Type GetType(feature::TypesHolder const & types) + { + static Matcher instance; + auto const it = instance.m_matcher.Find(types); + if (!instance.m_matcher.IsValid(it)) + return Type::No; + + return it->second; + } + +private: + using TypesInitializer = std::initializer_list>; + + Matcher() + { + m_matcher.Append({{"wheelchair", "no"}}, Type::No); + m_matcher.Append({{"wheelchair", "yes"}}, Type::Yes); + m_matcher.Append({{"wheelchair", "limited"}}, Type::Limited); + } + + ftypes::HashMapMatcher m_matcher; +}; +} // namespace wheelchair