diff options
Diffstat (limited to 'storage')
-rw-r--r-- | storage/country_info.cpp | 13 | ||||
-rw-r--r-- | storage/country_info.hpp | 2 | ||||
-rw-r--r-- | storage/storage_tests/country_info_test.cpp | 6 |
3 files changed, 18 insertions, 3 deletions
diff --git a/storage/country_info.cpp b/storage/country_info.cpp index e55fc3ff12..74074f6b37 100644 --- a/storage/country_info.cpp +++ b/storage/country_info.cpp @@ -123,7 +123,7 @@ namespace storage { for (size_t i = 0; i < m_countries.size(); ++i) { - if (m_countries[i].m_name.find("USA_") != string::npos) + if (m_countries[i].m_name.find("USA_") == 0) { if (m_countries[i].m_name == "USA_Alaska") rects[1] = m_countries[i].m_rect; @@ -134,4 +134,15 @@ namespace storage } } } + + m2::RectD CountryInfoGetter::CalcLimitRect(string const & prefix) const + { + m2::RectD r; + for (size_t i = 0; i < m_countries.size(); ++i) + { + if (m_countries[i].m_name.find(prefix) == 0) + r.Add(m_countries[i].m_rect); + } + return r; + } } diff --git a/storage/country_info.hpp b/storage/country_info.hpp index 1231c43f70..119037aa72 100644 --- a/storage/country_info.hpp +++ b/storage/country_info.hpp @@ -51,5 +51,7 @@ namespace storage /// 1 - Alaska;\n /// 2 - Hawaii;\n void CalcUSALimitRect(m2::RectD rects[3]) const; + + m2::RectD CalcLimitRect(string const & prefix) const; }; } diff --git a/storage/storage_tests/country_info_test.cpp b/storage/storage_tests/country_info_test.cpp index c418bca091..e6c17fcc0f 100644 --- a/storage/storage_tests/country_info_test.cpp +++ b/storage/storage_tests/country_info_test.cpp @@ -62,14 +62,16 @@ UNIT_TEST(CountryInfo_ValidName_Smoke) TEST(IsEmptyName(id2info, "UK_Northern Ireland"), ()); } -UNIT_TEST(CountryInfo_USARect) +UNIT_TEST(CountryInfo_SomeRects) { scoped_ptr<CountryInfoT> getter(GetCountryInfo()); m2::RectD rects[3]; getter->CalcUSALimitRect(rects); - LOG(LINFO, ("Continental: ", rects[0])); + LOG(LINFO, ("USA Continental: ", rects[0])); LOG(LINFO, ("Alaska: ", rects[1])); LOG(LINFO, ("Hawaii: ", rects[2])); + + LOG(LINFO, ("Canada: ", getter->CalcLimitRect("Canada_"))); } |