[search] Take into account Alaska and Hawaii for search rank.

This commit is contained in:
vng 2012-01-31 13:01:06 +03:00 committed by Alex Zolotarev
parent 734df51bc1
commit 80bee1ab70
4 changed files with 40 additions and 12 deletions

View file

@ -95,9 +95,26 @@ public:
population = max(population, static_cast<uint32_t>(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.

View file

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

View file

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

View file

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