From 7bcb13bea222e8a99fb2fd14527cddac0a0e0f3a Mon Sep 17 00:00:00 2001 From: vng Date: Mon, 19 Mar 2012 18:33:18 +0300 Subject: [PATCH] [search] Fix search rects routine. --- search/search_engine.cpp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/search/search_engine.cpp b/search/search_engine.cpp index a1b84b4b4b..03e28ffb7e 100644 --- a/search/search_engine.cpp +++ b/search/search_engine.cpp @@ -109,10 +109,15 @@ namespace enum { VIEWPORT_RECT = 0, NEARME_RECT = 1 }; /// Check rects for optimal search (avoid duplicating). - void AnalizeRects(m2::RectD arrRects[2]) + void AnalyzeRects(m2::RectD arrRects[2]) { - if (arrRects[NEARME_RECT].IsRectInside(arrRects[VIEWPORT_RECT])) + static double const eps = 100.0 * MercatorBounds::degreeInMetres; + + if (arrRects[NEARME_RECT].IsRectInside(arrRects[VIEWPORT_RECT]) && + arrRects[NEARME_RECT].Center().EqualDxDy(arrRects[VIEWPORT_RECT].Center(), eps)) + { arrRects[VIEWPORT_RECT].MakeEmpty(); + } else { if (arrRects[VIEWPORT_RECT].IsRectInside(arrRects[NEARME_RECT]) && @@ -155,7 +160,7 @@ void Engine::SetViewportAsync(m2::RectD const & viewport, m2::RectD const & near threads::MutexGuard searchGuard(m_searchMutex); m2::RectD arrRects[] = { viewport, nearby }; - AnalizeRects(arrRects); + AnalyzeRects(arrRects); m_pQuery->SetViewport(arrRects, ARRAY_SIZE(arrRects)); } @@ -205,10 +210,8 @@ void Engine::SearchAsync() worldSearch = false; arrRects[VIEWPORT_RECT].MakeEmpty(); } -// Commented out to always get mixed viewport/my position results, -// even when you're looking close to my position -// else -// AnalizeRects(arrRects); + else + AnalyzeRects(arrRects); } else m_pQuery->NullPosition();