From 507a99fa7586e523e2e313997a5af63e2ab8b486 Mon Sep 17 00:00:00 2001 From: vng Date: Wed, 15 Feb 2012 17:50:39 +0300 Subject: [PATCH] Add Framework::GetCountryCodeByPosition realization. Closed #622. --- map/framework.cpp | 6 +++--- map/framework.hpp | 2 +- search/search_engine.cpp | 7 +++++++ search/search_engine.hpp | 1 + 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/map/framework.cpp b/map/framework.cpp index 4916b39408..c32f402075 100644 --- a/map/framework.cpp +++ b/map/framework.cpp @@ -891,8 +891,8 @@ void Framework::GetFeatureTypes(m2::PointD pt, vector & types) const getTypes.GetFeatureTypes(5, types); } -string Framework::GetCountryCodeByPosition(double lat, double lon) const +string Framework::GetCountryCodeByPosition(double lat, double lon) { - // @TODO add valid implementation - return "by"; + return GetSearchEngine()->GetCountryCode(m2::PointD( + MercatorBounds::LonToX(lon), MercatorBounds::LatToY(lat))); } diff --git a/map/framework.hpp b/map/framework.hpp index dba690a43b..1fe56138aa 100644 --- a/map/framework.hpp +++ b/map/framework.hpp @@ -147,7 +147,7 @@ public: bool GetCurrentPosition(double & lat, double & lon); /// @return country code in ISO 3166-1 alpha-2 format (two small letters) or empty string - string GetCountryCodeByPosition(double lat, double lon) const; + string GetCountryCodeByPosition(double lat, double lon); void SetMaxWorldRect(); diff --git a/search/search_engine.cpp b/search/search_engine.cpp index 47f70ac5bb..66ea48d6d9 100644 --- a/search/search_engine.cpp +++ b/search/search_engine.cpp @@ -209,4 +209,11 @@ string Engine::GetCountryFile(m2::PointD const & pt) const return m_pData->m_infoGetter.GetRegionFile(pt); } +string Engine::GetCountryCode(m2::PointD const & pt) const +{ + storage::CountryInfo info; + m_pData->m_infoGetter.GetRegionInfo(pt, info); + return info.m_flag; +} + } // namespace search diff --git a/search/search_engine.hpp b/search/search_engine.hpp index 8c0abc0357..3111c84aad 100644 --- a/search/search_engine.hpp +++ b/search/search_engine.hpp @@ -41,6 +41,7 @@ public: void Search(SearchParams const & params, m2::RectD const & viewport); string GetCountryFile(m2::PointD const & pt) const; + string GetCountryCode(m2::PointD const & pt) const; private: void SetViewportAsync(m2::RectD const & viewport, m2::RectD const & nearby);