From 56acda1a2a5cebae21b97c40a812e5469de167a5 Mon Sep 17 00:00:00 2001 From: tatiana-yan Date: Fri, 18 May 2018 13:25:53 +0300 Subject: [PATCH] [search] Separate PreRanker::Params::m_minDistanceOnMapBetweenResults and Ranker::Params::m_minDistanceBetweenResultsM --- search/pre_ranker.hpp | 2 +- search/processor.cpp | 8 -------- search/processor.hpp | 2 -- search/ranker.cpp | 2 +- search/ranker.hpp | 4 ++-- .../interactive_search_test.cpp | 16 +++++++--------- search/search_params.hpp | 2 +- 7 files changed, 12 insertions(+), 24 deletions(-) diff --git a/search/pre_ranker.hpp b/search/pre_ranker.hpp index 4734e62a0b..4d5f951b3f 100644 --- a/search/pre_ranker.hpp +++ b/search/pre_ranker.hpp @@ -28,7 +28,7 @@ public: { m2::RectD m_viewport; - // A minimum distance between search results in meters, needed for + // Minimal distance between search results in mercators, needed for // filtering of viewport search results. double m_minDistanceOnMapBetweenResults = 0.0; diff --git a/search/processor.cpp b/search/processor.cpp index 751c8e2dab..f4223fd93c 100644 --- a/search/processor.cpp +++ b/search/processor.cpp @@ -140,7 +140,6 @@ void RemoveStopWordsIfNeeded(QueryTokens & tokens, strings::UniString & prefix) size_t const Processor::kPreResultsCount = 200; double const Processor::kMinViewportRadiusM = 5.0 * 1000; double const Processor::kMaxViewportRadiusM = 50.0 * 1000; -double const Processor::kMinDistanceOnMapBetweenResultsM = 100.0; Processor::Processor(Index const & index, CategoriesHolder const & categories, vector const & suggests, @@ -580,14 +579,7 @@ void Processor::InitRanker(Geocoder::Params const & geocoderParams, params.m_currentLocaleCode = m_currentLocaleCode; if (viewportSearch) - { params.m_viewport = GetViewport(); - params.m_minDistanceOnMapBetweenResults = searchParams.m_minDistanceOnMapBetweenResults; - } - else - { - params.m_minDistanceOnMapBetweenResults = kMinDistanceOnMapBetweenResultsM; - } params.m_limit = searchParams.m_maxNumResults; params.m_position = GetPosition(); diff --git a/search/processor.hpp b/search/processor.hpp index 27966c4f86..632bb8a75b 100644 --- a/search/processor.hpp +++ b/search/processor.hpp @@ -63,8 +63,6 @@ public: static double const kMinViewportRadiusM; static double const kMaxViewportRadiusM; - static double const kMinDistanceOnMapBetweenResultsM; - Processor(Index const & index, CategoriesHolder const & categories, std::vector const & suggests, storage::CountryInfoGetter const & infoGetter); diff --git a/search/ranker.cpp b/search/ranker.cpp index df133c36f9..64326f4ba3 100644 --- a/search/ranker.cpp +++ b/search/ranker.cpp @@ -552,7 +552,7 @@ void Ranker::MakeRankerResults(Geocoder::Params const & geocoderParams, continue; } - if (!ResultExists(*p, results, m_params.m_minDistanceOnMapBetweenResults)) + if (!ResultExists(*p, results, m_params.m_minDistanceBetweenResultsM)) results.push_back(move(*p)); }; } diff --git a/search/ranker.hpp b/search/ranker.hpp index 01f93c8c89..abe7784bee 100644 --- a/search/ranker.hpp +++ b/search/ranker.hpp @@ -66,9 +66,9 @@ public: m2::PointD m_accuratePivotCenter = m2::PointD(0, 0); - // A minimum distance between search results in meters, needed for + // Minimal distance between search results in meters, needed for // filtering of identical search results. - double m_minDistanceOnMapBetweenResults = 0.0; + double m_minDistanceBetweenResultsM = 100.0; Locales m_categoryLocales; diff --git a/search/search_integration_tests/interactive_search_test.cpp b/search/search_integration_tests/interactive_search_test.cpp index c2bdeb392d..e2d49987b6 100644 --- a/search/search_integration_tests/interactive_search_test.cpp +++ b/search/search_integration_tests/interactive_search_test.cpp @@ -126,17 +126,15 @@ UNIT_CLASS_TEST(InteractiveSearchTest, Smoke) UNIT_CLASS_TEST(InteractiveSearchTest, NearbyFeaturesInViewport) { - double const kEps = 1e-5; + double const kEps = 0.1; TestCafe cafe1(m2::PointD(0.0, 0.0)); TestCafe cafe2(m2::PointD(0.0, kEps)); - TestCafe cafe3(m2::PointD(kEps, kEps)); - TestCafe cafe4(m2::PointD(kEps, 0.0)); + TestCafe cafe3(m2::PointD(0.0, 2 * kEps)); auto const id = BuildCountry("Wonderland", [&](TestMwmBuilder & builder) { builder.Add(cafe1); builder.Add(cafe2); builder.Add(cafe3); - builder.Add(cafe4); }); SearchParams params; @@ -144,20 +142,20 @@ UNIT_CLASS_TEST(InteractiveSearchTest, NearbyFeaturesInViewport) params.m_inputLocale = "en"; params.m_viewport = m2::RectD(m2::PointD(-0.5, -0.5), m2::PointD(0.5, 0.5)); params.m_mode = Mode::Viewport; - params.m_minDistanceOnMapBetweenResults = 0.5; + params.m_minDistanceOnMapBetweenResults = kEps * 0.9; params.m_suggestsEnabled = false; { TestSearchRequest request(m_engine, params); request.Run(); - TEST(MatchResults(m_index, TRules{ExactMatch(id, cafe1), ExactMatch(id, cafe2), - ExactMatch(id, cafe3), ExactMatch(id, cafe4)}, + TEST(MatchResults(m_index, + TRules{ExactMatch(id, cafe1), ExactMatch(id, cafe2), ExactMatch(id, cafe3)}, request.Results()), ()); } - params.m_minDistanceOnMapBetweenResults = 1.0; + params.m_minDistanceOnMapBetweenResults = kEps * 1.1; { TestSearchRequest request(m_engine, params); @@ -166,7 +164,7 @@ UNIT_CLASS_TEST(InteractiveSearchTest, NearbyFeaturesInViewport) auto const & results = request.Results(); TEST(MatchResults(m_index, TRules{ExactMatch(id, cafe1), ExactMatch(id, cafe3)}, results) || - MatchResults(m_index, TRules{ExactMatch(id, cafe2), ExactMatch(id, cafe4)}, results), + MatchResults(m_index, TRules{ExactMatch(id, cafe2)}, results), ()); } } diff --git a/search/search_params.hpp b/search/search_params.hpp index e7e7c31573..6e6e361008 100644 --- a/search/search_params.hpp +++ b/search/search_params.hpp @@ -42,7 +42,7 @@ struct SearchParams size_t m_maxNumResults = kDefaultNumResultsEverywhere; - // A minimum distance between search results in meters, needed for + // Minimal distance between search results in mercators, needed for // pre-ranking of viewport search results. double m_minDistanceOnMapBetweenResults = 0.0;