diff --git a/search/geocoder.cpp b/search/geocoder.cpp index 2df77ca9cc..72e56e7847 100644 --- a/search/geocoder.cpp +++ b/search/geocoder.cpp @@ -1168,8 +1168,16 @@ void Geocoder::CreateStreetsLayerAndMatchLowerLayers(BaseContext & ctx, vector sortedFeatures; sortedFeatures.reserve(base::checked_cast(prediction.m_features.PopCount())); - prediction.m_features.ForEach([&sortedFeatures](uint64_t bit) { - sortedFeatures.push_back(base::asserted_cast(bit)); + prediction.m_features.ForEach([&](uint64_t bit) { + auto const fid = base::asserted_cast(bit); + m2::PointD streetCenter; + if (m_context->GetCenter(fid, streetCenter) && + any_of(centers.begin(), centers.end(), [&](auto const & center) { + return mercator::DistanceOnEarth(center, streetCenter) <= m_params.m_streetSearchRadiusM; + })) + { + sortedFeatures.push_back(base::asserted_cast(bit)); + } }); layer.m_sortedFeatures = &sortedFeatures; diff --git a/search/geocoder.hpp b/search/geocoder.hpp index c4c646d997..5e4aff22ec 100644 --- a/search/geocoder.hpp +++ b/search/geocoder.hpp @@ -92,6 +92,7 @@ public: std::vector m_cuisineTypes; std::vector m_preferredTypes; std::shared_ptr m_tracer; + double m_streetSearchRadiusM = 0.0; }; Geocoder(DataSource const & dataSource, storage::CountryInfoGetter const & infoGetter, diff --git a/search/processor.cpp b/search/processor.cpp index 197c380dc5..00727abb85 100644 --- a/search/processor.cpp +++ b/search/processor.cpp @@ -729,6 +729,7 @@ void Processor::InitGeocoder(Geocoder::Params & geocoderParams, SearchParams con geocoderParams.m_cuisineTypes = m_cuisineTypes; geocoderParams.m_preferredTypes = m_preferredTypes; geocoderParams.m_tracer = searchParams.m_tracer; + geocoderParams.m_streetSearchRadiusM = searchParams.m_streetSearchRadiusM; m_geocoder.SetParams(geocoderParams); } diff --git a/search/search_params.hpp b/search/search_params.hpp index a542e3c506..59ad59408b 100644 --- a/search/search_params.hpp +++ b/search/search_params.hpp @@ -27,6 +27,7 @@ struct SearchParams inline static size_t const kDefaultNumResultsEverywhere = 30; inline static size_t const kDefaultNumResultsInViewport = 200; inline static size_t const kPreResultsCount = 200; + inline static double const kDefaultStreetSearchRadiusM = 80000; inline static std::chrono::steady_clock::duration const kDefaultTimeout = std::chrono::seconds(3); inline static std::chrono::steady_clock::duration const kDefaultDesktopTimeout = @@ -73,6 +74,9 @@ struct SearchParams // pre-ranking of viewport search results. double m_minDistanceOnMapBetweenResults = 0.0; + // Street search radius from pivot or matched city center for everywhere search mode. + double m_streetSearchRadiusM = kDefaultStreetSearchRadiusM; + Mode m_mode = Mode::Everywhere; // Needed to generate search suggests. diff --git a/search/search_tests_support/helpers.cpp b/search/search_tests_support/helpers.cpp index 73d6942896..b67f51ca2e 100644 --- a/search/search_tests_support/helpers.cpp +++ b/search/search_tests_support/helpers.cpp @@ -88,6 +88,7 @@ unique_ptr SearchTest::MakeRequest( params.m_mode = Mode::Everywhere; params.m_needAddress = true; params.m_suggestsEnabled = false; + params.m_streetSearchRadiusM = tests_support::TestSearchRequest::kDefaultTestStreetSearchRadiusM; auto request = make_unique(m_engine, params); request->Run(); diff --git a/search/search_tests_support/test_search_request.cpp b/search/search_tests_support/test_search_request.cpp index 75b2666b3c..31a9100d8f 100644 --- a/search/search_tests_support/test_search_request.cpp +++ b/search/search_tests_support/test_search_request.cpp @@ -25,6 +25,7 @@ TestSearchRequest::TestSearchRequest(TestSearchEngine & engine, string const & q m_params.m_inputLocale = locale; m_params.m_viewport = viewport; m_params.m_mode = mode; + m_params.m_streetSearchRadiusM = kDefaultTestStreetSearchRadiusM; SetUpCallbacks(); SetUpResultParams(); } @@ -47,6 +48,7 @@ TestSearchRequest::TestSearchRequest(TestSearchEngine & engine, string const & q m_params.m_mode = mode; m_params.m_onStarted = onStarted; m_params.m_onResults = onResults; + m_params.m_streetSearchRadiusM = kDefaultTestStreetSearchRadiusM; SetUpResultParams(); } diff --git a/search/search_tests_support/test_search_request.hpp b/search/search_tests_support/test_search_request.hpp index 82423cf0a7..bd6310f0bb 100644 --- a/search/search_tests_support/test_search_request.hpp +++ b/search/search_tests_support/test_search_request.hpp @@ -25,6 +25,8 @@ class TestSearchEngine; class TestSearchRequest { public: + inline static double const kDefaultTestStreetSearchRadiusM = 2e7; + TestSearchRequest(TestSearchEngine & engine, std::string const & query, std::string const & locale, Mode mode, m2::RectD const & viewport); TestSearchRequest(TestSearchEngine & engine, SearchParams const & params);