diff --git a/map/framework.cpp b/map/framework.cpp index dd40ebf78c..eaad02bf4e 100644 --- a/map/framework.cpp +++ b/map/framework.cpp @@ -875,6 +875,11 @@ string Framework::GetCountryName(m2::PointD const & pt) const return GetSearchEngine()->GetCountryName(pt); } +string Framework::GetCountryName(string const & id) const +{ + return GetSearchEngine()->GetCountryName(id); +} + void Framework::PrepareSearch(bool hasPt, double lat, double lon) { GetSearchEngine()->PrepareSearch(GetCurrentViewport(), hasPt, lat, lon); @@ -940,12 +945,14 @@ void Framework::SetRenderPolicy(RenderPolicy * renderPolicy) m_guiController->SetRenderParams(rp); - m_renderPolicy->SetCountryNameFn(bind(&Framework::GetCountryName, this, _1)); + string (Framework::*pFn)(m2::PointD const &) const = &Framework::GetCountryName; + m_renderPolicy->SetCountryNameFn(bind(pFn, this, _1)); + m_renderPolicy->SetRenderFn(DrawModelFn()); m_navigator.SetSupportRotation(m_renderPolicy->DoSupportRotation()); - if ((m_width != 0) && (m_height != 0)) + if (m_width != 0 && m_height != 0) OnSize(m_width, m_height); if (m_hasPendingInvalidate) diff --git a/map/framework.hpp b/map/framework.hpp index 3fcc72f38a..2cb0fe56c2 100644 --- a/map/framework.hpp +++ b/map/framework.hpp @@ -202,6 +202,8 @@ public: void ShowSearchResult(search::Result const & res); string GetCountryName(m2::PointD const & pt) const; + /// @param[in] id Country file name without an extension. + string GetCountryName(string const & id) const; /// @return country code in ISO 3166-1 alpha-2 format (two small letters) or empty string string GetCountryCodeByPosition(double lat, double lon) const; diff --git a/search/search_engine.cpp b/search/search_engine.cpp index e92593c3d0..5a57abcc76 100644 --- a/search/search_engine.cpp +++ b/search/search_engine.cpp @@ -305,15 +305,25 @@ string Engine::GetCountryCode(m2::PointD const & pt) return info.m_flag; } -string Engine::GetCountryName(m2::PointD const & pt) +template string Engine::GetCountryNameT(T const & t) { threads::MutexGuard searchGuard(m_searchMutex); storage::CountryInfo info; - m_pData->m_infoGetter.GetRegionInfo(pt, info); + m_pData->m_infoGetter.GetRegionInfo(t, info); return info.m_name; } +string Engine::GetCountryName(m2::PointD const & pt) +{ + return GetCountryNameT(pt); +} + +string Engine::GetCountryName(string const & id) +{ + return GetCountryNameT(id); +} + bool Engine::GetNameByType(uint32_t type, int8_t lang, string & name) const { return m_pData->m_categories.GetNameByType(type, lang, name); diff --git a/search/search_engine.hpp b/search/search_engine.hpp index 9357d5b838..e38a3a4290 100644 --- a/search/search_engine.hpp +++ b/search/search_engine.hpp @@ -42,7 +42,12 @@ public: string GetCountryFile(m2::PointD const & pt); string GetCountryCode(m2::PointD const & pt); + +private: + template string GetCountryNameT(T const & t); +public: string GetCountryName(m2::PointD const & pt); + string GetCountryName(string const & id); bool GetNameByType(uint32_t type, int8_t lang, string & name) const; diff --git a/storage/country_info.hpp b/storage/country_info.hpp index 119037aa72..2525f1c9d2 100644 --- a/storage/country_info.hpp +++ b/storage/country_info.hpp @@ -16,6 +16,7 @@ namespace storage FilesContainerR m_reader; vector m_countries; + /// ID - is a country file name without an extension. map m_id2info; mutable my::Cache > m_cache; @@ -43,7 +44,9 @@ namespace storage string GetRegionFile(m2::PointD const & pt) const; + /// @param[in] pt Point inside country. void GetRegionInfo(m2::PointD const & pt, CountryInfo & info) const; + /// @param[in] id Country file name without an extension. void GetRegionInfo(string const & id, CountryInfo & info) const; /// Return limit rects of USA:\n