diff options
author | vng <viktor.govako@gmail.com> | 2012-01-31 14:01:06 +0400 |
---|---|---|
committer | Alex Zolotarev <alex@maps.me> | 2015-09-23 01:32:42 +0300 |
commit | 80bee1ab70f44911bfb36f0f2e44022e3849aed8 (patch) | |
tree | edfce863dbaaa89d48e5ad327632ecdd2dbb1a97 /storage | |
parent | 734df51bc1334176745a2a9e0099029505280c4d (diff) |
[search] Take into account Alaska and Hawaii for search rank.
Diffstat (limited to 'storage')
-rw-r--r-- | storage/country_info.cpp | 15 | ||||
-rw-r--r-- | storage/country_info.hpp | 6 | ||||
-rw-r--r-- | storage/storage_tests/country_info_test.cpp | 8 |
3 files changed, 20 insertions, 9 deletions
diff --git a/storage/country_info.cpp b/storage/country_info.cpp index db4f1588d1..e55fc3ff12 100644 --- a/storage/country_info.cpp +++ b/storage/country_info.cpp @@ -119,18 +119,19 @@ namespace storage } } - m2::RectD CountryInfoGetter::CalcUSALimitRect() const + void CountryInfoGetter::CalcUSALimitRect(m2::RectD rects[3]) const { - m2::RectD r; for (size_t i = 0; i < m_countries.size(); ++i) { - if ((m_countries[i].m_name.find("USA_") != string::npos) && - (m_countries[i].m_name != "USA_Alaska") && - (m_countries[i].m_name != "USA_Hawaii")) + if (m_countries[i].m_name.find("USA_") != string::npos) { - r.Add(m_countries[i].m_rect); + if (m_countries[i].m_name == "USA_Alaska") + rects[1] = m_countries[i].m_rect; + else if (m_countries[i].m_name == "USA_Hawaii") + rects[2] = m_countries[i].m_rect; + else + rects[0].Add(m_countries[i].m_rect); } } - return r; } } diff --git a/storage/country_info.hpp b/storage/country_info.hpp index 06ac1ffd93..1231c43f70 100644 --- a/storage/country_info.hpp +++ b/storage/country_info.hpp @@ -46,6 +46,10 @@ namespace storage void GetRegionInfo(m2::PointD const & pt, CountryInfo & info) const; void GetRegionInfo(string const & id, CountryInfo & info) const; - m2::RectD CalcUSALimitRect() const; + /// Return limit rects of USA:\n + /// 0 - continental part;\n + /// 1 - Alaska;\n + /// 2 - Hawaii;\n + void CalcUSALimitRect(m2::RectD rects[3]) const; }; } diff --git a/storage/storage_tests/country_info_test.cpp b/storage/storage_tests/country_info_test.cpp index d41070ccfe..c418bca091 100644 --- a/storage/storage_tests/country_info_test.cpp +++ b/storage/storage_tests/country_info_test.cpp @@ -65,5 +65,11 @@ UNIT_TEST(CountryInfo_ValidName_Smoke) UNIT_TEST(CountryInfo_USARect) { scoped_ptr<CountryInfoT> getter(GetCountryInfo()); - LOG(LINFO, (getter->CalcUSALimitRect())); + + m2::RectD rects[3]; + getter->CalcUSALimitRect(rects); + + LOG(LINFO, ("Continental: ", rects[0])); + LOG(LINFO, ("Alaska: ", rects[1])); + LOG(LINFO, ("Hawaii: ", rects[2])); } |