From 68ece84217fa2b94c28b13ea02186fdd15e9f4d5 Mon Sep 17 00:00:00 2001 From: vng Date: Fri, 3 Feb 2012 14:31:32 +0300 Subject: [PATCH] [search] High rank for Canada states. --- indexer/feature_utils.cpp | 5 ++++- storage/country_info.cpp | 13 ++++++++++++- storage/country_info.hpp | 2 ++ storage/storage_tests/country_info_test.cpp | 6 ++++-- 4 files changed, 22 insertions(+), 4 deletions(-) diff --git a/indexer/feature_utils.cpp b/indexer/feature_utils.cpp index 9440a41989..051bf2b33e 100644 --- a/indexer/feature_utils.cpp +++ b/indexer/feature_utils.cpp @@ -103,7 +103,10 @@ public: m2::RectD(-151.0, 63.0, -148.0, 66.0), // Hawaii m2::RectD(-179.3665041396082529, 17.740790096801504205, - -153.92127500280855656, 31.043358939740215874) + -153.92127500280855656, 31.043358939740215874), + // Canada + m2::RectD(-141.00315086636985029, 45.927730040557435132, + -48.663019303849921471, 162.92387487639103938) }; bool isUSA = false; 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 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_"))); }