Add Framework::GetCountryCodeByPosition realization. Closed #622.

This commit is contained in:
vng 2012-02-15 17:50:39 +03:00 committed by Alex Zolotarev
parent f5a9b1007b
commit 507a99fa75
4 changed files with 12 additions and 4 deletions

View file

@ -891,8 +891,8 @@ void Framework::GetFeatureTypes(m2::PointD pt, vector<string> & 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)));
}

View file

@ -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();

View file

@ -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

View file

@ -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);