diff --git a/indexer/feature_utils.cpp b/indexer/feature_utils.cpp index 9cbfc28550..9440a41989 100644 --- a/indexer/feature_utils.cpp +++ b/indexer/feature_utils.cpp @@ -95,9 +95,26 @@ public: population = max(population, static_cast(10000)); else if (types[i] == m_TypeState) { - m2::RectD const usaRect(-125.73195962769162293, 25.168771674082393019, - -66.925073086214325713, 56.956377399113392812); - if (usaRect.IsPointInside(pt)) + m2::RectD usaRects[] = { + // Continental part of USA + m2::RectD(-125.73195962769162293, 25.168771674082393019, + -66.925073086214325713, 56.956377399113392812), + // Alaska + m2::RectD(-151.0, 63.0, -148.0, 66.0), + // Hawaii + m2::RectD(-179.3665041396082529, 17.740790096801504205, + -153.92127500280855656, 31.043358939740215874) + }; + + bool isUSA = false; + for (size_t i = 0; i < ARRAY_SIZE(usaRects); ++i) + if (usaRects[i].IsPointInside(pt)) + { + isUSA = true; + break; + } + + if (isUSA) { //LOG(LINFO, ("USA state population = ", population)); // Get rank equal to city for USA's states. 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 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])); }