forked from organicmaps/organicmaps
Review fixes.
This commit is contained in:
parent
cbc4eeec92
commit
f4a4c4f721
4 changed files with 17 additions and 12 deletions
|
@ -323,8 +323,10 @@ uint32_t PreResult2::GetBestType(set<uint32_t> const * pPrefferedTypes) const
|
|||
if (pPrefferedTypes)
|
||||
{
|
||||
for (uint32_t type : m_types)
|
||||
{
|
||||
if (pPrefferedTypes->count(type) > 0)
|
||||
return type;
|
||||
}
|
||||
}
|
||||
|
||||
// Do type truncate (2-level is enough for search results) only for
|
||||
|
|
|
@ -94,7 +94,6 @@ private:
|
|||
LocalityItem::LocalityItem(m2::RectD const & rect, uint32_t population, ID id, string const & name)
|
||||
: m_rect(rect), m_name(name), m_population(population), m_id(id)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
LocalityFinder::LocalityFinder(Index const * pIndex)
|
||||
|
@ -149,19 +148,22 @@ void LocalityFinder::RecreateCache(Cache & cache, m2::RectD rect) const
|
|||
}
|
||||
}
|
||||
|
||||
void LocalityFinder::SetViewportByIndex(m2::RectD const & rect, size_t idx)
|
||||
void LocalityFinder::SetViewportByIndex(m2::RectD const & viewport, size_t idx)
|
||||
{
|
||||
ASSERT_LESS(idx, (size_t)MAX_VIEWPORT_COUNT, ());
|
||||
RecreateCache(m_cache[idx], rect);
|
||||
RecreateCache(m_cache[idx], viewport);
|
||||
}
|
||||
|
||||
void LocalityFinder::SetViewportSafe(m2::RectD const & rect)
|
||||
void LocalityFinder::SetReservedViewportIfNeeded(m2::RectD const & viewport)
|
||||
{
|
||||
size_t constexpr kSafeIndex = 2;
|
||||
if (m_cache[kSafeIndex].m_rect.IsValid() && m_cache[kSafeIndex].m_rect.IsRectInside(rect))
|
||||
size_t constexpr kReservedIndex = 2;
|
||||
if (m_cache[kReservedIndex].m_rect.IsValid() &&
|
||||
m_cache[kReservedIndex].m_rect.IsRectInside(viewport))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
SetViewportByIndex(rect, kSafeIndex);
|
||||
SetViewportByIndex(viewport, kReservedIndex);
|
||||
}
|
||||
|
||||
void LocalityFinder::GetLocalityInViewport(m2::PointD const & pt, string & name) const
|
||||
|
|
|
@ -55,12 +55,13 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
void SetViewportByIndex(m2::RectD const & rect, size_t idx);
|
||||
void SetViewportSafe(m2::RectD const & rect);
|
||||
void SetViewportByIndex(m2::RectD const & viewport, size_t idx);
|
||||
/// Set new viewport for the reserved slot only if it's no a part of the previous one.
|
||||
void SetReservedViewportIfNeeded(m2::RectD const & viewport);
|
||||
|
||||
/// Check for localities in pre-cached viewports only.
|
||||
void GetLocalityInViewport(m2::PointD const & pt, string & name) const;
|
||||
/// Checl for localities in all Index and make new cache if needed.
|
||||
/// Check for localities in all Index and make new cache if needed.
|
||||
void GetLocalityCreateCache(m2::PointD const & pt, string & name);
|
||||
|
||||
void ClearCacheAll();
|
||||
|
@ -81,4 +82,4 @@ private:
|
|||
int8_t m_lang;
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace search
|
||||
|
|
|
@ -1974,7 +1974,7 @@ void Query::SearchAdditional(Results & res, size_t resCount)
|
|||
|
||||
// Hack with 90.0 is important for the countries divided by 180 meridian.
|
||||
if (rect.IsValid() && (rect.maxX() - rect.minX()) <= 90.0)
|
||||
m_locality.SetViewportSafe(rect);
|
||||
m_locality.SetReservedViewportIfNeeded(rect);
|
||||
#endif
|
||||
|
||||
FlushResults(res, true, resCount);
|
||||
|
|
Loading…
Add table
Reference in a new issue