diff --git a/map/address_finder.cpp b/map/address_finder.cpp index ae3e32cd40..0a922b019d 100644 --- a/map/address_finder.cpp +++ b/map/address_finder.cpp @@ -3,6 +3,8 @@ #include "../indexer/classificator.hpp" #include "../indexer/feature_visibility.hpp" +#include "../platform/preferred_languages.hpp" + namespace { @@ -305,8 +307,10 @@ namespace m_cont.clear(); } - void FillAddress(Framework::AddressInfo & info) + void FillAddress(search::Engine const * eng, Framework::AddressInfo & info) { + int8_t const lang = StringUtf8Multilang::GetLangIndex(languages::CurrentLanguage()); + SortResults(); for (size_t i = 0; i < m_cont.size(); ++i) @@ -322,7 +326,17 @@ namespace if (info.m_name.empty()) { if (m_cont[i].m_types.GetGeoType() != feature::GEOM_LINE) + { info.m_name = m_cont[i].m_name; + + // add types for POI + size_t const count = m_cont[i].m_types.Size(); + info.m_types.resize(count); + for (size_t j = 0; j < count; ++j) + { + eng->GetNameByType(m_cont[i].m_types[j], lang, info.m_types[j]); + } + } } if (!(info.m_street.empty() || info.m_name.empty())) @@ -374,7 +388,7 @@ void Framework::GetAddressInfo(m2::PointD const & pt, AddressInfo & info) const m_model.ForEachFeature( MercatorBounds::RectByCenterXYAndSizeInMeters(pt, addressR), getAddress, scale); - getAddress.FillAddress(info); + getAddress.FillAddress(GetSearchEngine(), info); } // now - get the locality diff --git a/map/framework.hpp b/map/framework.hpp index 86a0a6ed5c..fe83090cc1 100644 --- a/map/framework.hpp +++ b/map/framework.hpp @@ -219,6 +219,7 @@ public: struct AddressInfo { string m_country, m_city, m_street, m_house, m_name; + vector m_types; }; /// Get address information for point on map. diff --git a/map/map_tests/bookmarks_test.cpp b/map/map_tests/bookmarks_test.cpp index c07ebd489a..ce0e28af72 100644 --- a/map/map_tests/bookmarks_test.cpp +++ b/map/map_tests/bookmarks_test.cpp @@ -133,4 +133,8 @@ UNIT_TEST(Bookmarks_AddressInfo) TEST_EQUAL(info.m_street, "ул. Карла Маркса", ()); TEST_EQUAL(info.m_house, "10", ()); TEST_EQUAL(info.m_name, "Библос", ()); + TEST_EQUAL(info.m_types.size(), 1, ()); + + // assume that developers have English or Russian system language :) + TEST(info.m_types[0] == "cafe" || info.m_types[0] == "кафе", (info.m_types[0])); } diff --git a/search/search_engine.cpp b/search/search_engine.cpp index d9559cb305..3ae380792a 100644 --- a/search/search_engine.cpp +++ b/search/search_engine.cpp @@ -290,6 +290,11 @@ string Engine::GetCountryName(m2::PointD const & pt) return info.m_name; } +bool Engine::GetNameByType(uint32_t type, int8_t lang, string & name) const +{ + return m_pData->m_categories.GetNameByType(type, lang, name); +} + void Engine::ClearCaches() { /// @todo Add m_pData->m_infoGetter clearing routine. diff --git a/search/search_engine.hpp b/search/search_engine.hpp index a16f5d63e4..21097f996d 100644 --- a/search/search_engine.hpp +++ b/search/search_engine.hpp @@ -44,6 +44,8 @@ public: string GetCountryCode(m2::PointD const & pt); string GetCountryName(m2::PointD const & pt); + bool GetNameByType(uint32_t type, int8_t lang, string & name) const; + void ClearCaches(); private: