Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/search
diff options
context:
space:
mode:
authorvng <viktor.govako@gmail.com>2015-06-03 16:11:08 +0300
committerAlex Zolotarev <alex@maps.me>2015-09-23 02:50:09 +0300
commit054b4dfdef54f5bb74e7845e25da6d0d78c9e3c4 (patch)
tree9225519e530934164f8c7e943c067696b2f18306 /search
parenta6794c03fa5960d00e67e37d01528ecf54d36b00 (diff)
Review fixes.
Diffstat (limited to 'search')
-rw-r--r--search/geometry_utils.cpp6
-rw-r--r--search/params.hpp2
-rw-r--r--search/search_common.hpp4
-rw-r--r--search/search_query.cpp16
-rw-r--r--search/search_query.hpp12
5 files changed, 28 insertions, 12 deletions
diff --git a/search/geometry_utils.cpp b/search/geometry_utils.cpp
index 7ba08759fe..a6ba235410 100644
--- a/search/geometry_utils.cpp
+++ b/search/geometry_utils.cpp
@@ -24,9 +24,11 @@ bool IsEqualMercator(m2::RectD const & r1, m2::RectD const & r2, double epsMeter
bool GetInflatedViewport(m2::RectD & viewport)
{
- double const level = scales::GetScaleLevelD(viewport);
+ double level = scales::GetScaleLevelD(viewport);
if (level < 11.5)
return false;
+ if (level > 16.5)
+ level = 16.5;
viewport = scales::GetRectForLevel(level - 1.5, viewport.Center());
return true;
@@ -37,4 +39,4 @@ int GetQueryIndexScale(m2::RectD const & viewport)
return scales::GetScaleLevel(viewport) + 7;
}
-}
+} // namespace search
diff --git a/search/params.hpp b/search/params.hpp
index 09fa48c5bd..344e4ea88f 100644
--- a/search/params.hpp
+++ b/search/params.hpp
@@ -44,7 +44,7 @@ namespace search
return (m_searchRadiusM > 0 && IsValidPosition());
}
- void SetSearchRadius(double radiusM) { m_searchRadiusM = radiusM; }
+ void SetSearchRadiusMeters(double radiusM) { m_searchRadiusM = radiusM; }
bool GetSearchRect(m2::RectD & rect) const;
/// @param[in] locale can be "fr", "en-US", "ru_RU" etc.
diff --git a/search/search_common.hpp b/search/search_common.hpp
index 4cf47b93dd..1901e42c95 100644
--- a/search/search_common.hpp
+++ b/search/search_common.hpp
@@ -4,8 +4,8 @@ namespace search
{
/// Upper bound for max count of tokens for indexing and scoring.
-constexpr int MAX_TOKENS = 32;
-constexpr int MAX_SUGGESTS_COUNT = 5;
+int constexpr MAX_TOKENS = 32;
+int constexpr MAX_SUGGESTS_COUNT = 5;
template <typename IterT1, typename IterT2>
bool StartsWith(IterT1 beg, IterT1 end, IterT2 begPrefix, IterT2 endPrefix)
diff --git a/search/search_query.cpp b/search/search_query.cpp
index 2791951675..0de1fe25a1 100644
--- a/search/search_query.cpp
+++ b/search/search_query.cpp
@@ -147,17 +147,22 @@ void Query::SetViewportByIndex(MWMVectorT const & mwmsInfo, m2::RectD const & vi
// Check if we can skip this cache query.
if (m_viewport[idx].IsValid())
{
+ // Threshold to compare for equal or inner rects.
+ // It doesn't influence on result cached features because it's smaller
+ // than minimal cell size in geometry index (i'm almost sure :)).
+ double constexpr epsMeters = 10.0;
+
if (forceUpdate)
{
- // skip if rects are equal with 10 meters tolerance
- if (IsEqualMercator(m_viewport[idx], viewport, 10.0))
+ // skip if rects are equal
+ if (IsEqualMercator(m_viewport[idx], viewport, epsMeters))
return;
}
else
{
- // skip if new viewport is inside the old one
+ // skip if the new viewport is inside the old one (no need to recache)
m2::RectD r(m_viewport[idx]);
- constexpr long double eps = 5.0 * MercatorBounds::degreeInMetres;
+ double constexpr eps = epsMeters * MercatorBounds::degreeInMetres;
r.Inflate(eps, eps);
if (r.IsRectInside(viewport))
@@ -325,7 +330,8 @@ void Query::Init(bool viewportSearch)
else
{
m_queuesCount = QUEUES_COUNT;
- m_results[0] = QueueT(PRE_RESULTS_COUNT, QueueCompareT(g_arrCompare1[0]));
+ m_results[DISTANCE_TO_PIVOT] =
+ QueueT(PRE_RESULTS_COUNT, QueueCompareT(g_arrCompare1[DISTANCE_TO_PIVOT]));
}
}
diff --git a/search/search_query.hpp b/search/search_query.hpp
index 939ee90b54..de0fa915c8 100644
--- a/search/search_query.hpp
+++ b/search/search_query.hpp
@@ -274,13 +274,21 @@ private:
typedef CompareT<impl::PreResult1> QueueCompareT;
typedef my::limited_priority_queue<impl::PreResult1, QueueCompareT> QueueT;
+ /// @name Intermediate result queues sorted by different criterias.
+ //@{
public:
enum { QUEUES_COUNT = 2 };
private:
- // 0 - LessDistance
- // 1 - LessRank
+ // The values order should be the same as in
+ // g_arrCompare1, g_arrCompare2 function arrays.
+ enum
+ {
+ DISTANCE_TO_PIVOT, // LessDistance
+ FEATURE_RANK // LessRank
+ };
QueueT m_results[QUEUES_COUNT];
size_t m_queuesCount;
+ //@}
};
} // namespace search