diff options
author | Maxim Pimenov <m@maps.me> | 2016-07-01 14:09:31 +0300 |
---|---|---|
committer | Maxim Pimenov <m@maps.me> | 2016-07-07 12:08:32 +0300 |
commit | ad44499b38ba56ae87e788f1da3c3b54e58718b1 (patch) | |
tree | bb8c634c6e4e214db369972daa2dab4eea0185fb | |
parent | 092198b2f529ac96754c030c7e806998eddaabfa (diff) |
[search] Inverted a dependency: Ranker does not call PreRanker any longer.
Also, upgraded clang-format from 3.7.0 to 3.9.0 which resulted in a new
way of formatiing lambdas.
-rw-r--r-- | search/engine.cpp | 5 | ||||
-rw-r--r-- | search/geocoder.cpp | 68 | ||||
-rw-r--r-- | search/geocoder.hpp | 27 | ||||
-rw-r--r-- | search/pre_ranker.cpp | 65 | ||||
-rw-r--r-- | search/pre_ranker.hpp | 45 | ||||
-rw-r--r-- | search/processor.cpp | 46 | ||||
-rw-r--r-- | search/processor.hpp | 3 | ||||
-rw-r--r-- | search/ranker.cpp | 53 | ||||
-rw-r--r-- | search/ranker.hpp | 27 |
9 files changed, 185 insertions, 154 deletions
diff --git a/search/engine.cpp b/search/engine.cpp index 2046e09a2d..67cdbe08cd 100644 --- a/search/engine.cpp +++ b/search/engine.cpp @@ -309,11 +309,6 @@ void Engine::DoSearch(SearchParams const & params, m2::RectD const & viewport, processor.SetMode(params.GetMode()); processor.SetSuggestsEnabled(params.GetSuggestsEnabled()); - - // This flag is needed for consistency with old search algorithm - // only. It will be gone when we remove old search code. - processor.SetSearchInWorld(true); - processor.SetInputLocale(params.m_inputLocale); ASSERT(!params.m_query.empty(), ()); diff --git a/search/geocoder.cpp b/search/geocoder.cpp index 72027b827c..17805f84d2 100644 --- a/search/geocoder.cpp +++ b/search/geocoder.cpp @@ -403,23 +403,21 @@ void UniteCBVs(vector<CBV> & cbvs) } // namespace // Geocoder::Params -------------------------------------------------------------------------------- -Geocoder::Params::Params() : m_mode(Mode::Everywhere), m_accuratePivotCenter(0, 0) {} - +Geocoder::Params::Params() : m_mode(Mode::Everywhere) {} // Geocoder::Geocoder ------------------------------------------------------------------------------ Geocoder::Geocoder(Index const & index, storage::CountryInfoGetter const & infoGetter, - my::Cancellable const & cancellable) + PreRanker & preRanker, my::Cancellable const & cancellable) : m_index(index) , m_infoGetter(infoGetter) , m_cancellable(cancellable) , m_model(SearchModel::Instance()) , m_pivotRectsCache(kPivotRectsCacheSize, m_cancellable, Processor::kMaxViewportRadiusM) , m_localityRectsCache(kLocalityRectsCacheSize, m_cancellable) - , m_pivotFeatures(index) , m_filter(nullptr) , m_matcher(nullptr) , m_finder(m_cancellable) , m_lastMatchedRegion(nullptr) - , m_preRanker(nullptr) + , m_preRanker(preRanker) { } @@ -467,7 +465,7 @@ void Geocoder::SetParams(Params const & params) LOG(LDEBUG, ("Languages =", m_params.m_langs)); } -void Geocoder::GoEverywhere(PreRanker & preRanker) +void Geocoder::GoEverywhere() { // TODO (@y): remove following code as soon as Geocoder::Go() will // work fast for most cases (significantly less than 1 second). @@ -489,10 +487,10 @@ void Geocoder::GoEverywhere(PreRanker & preRanker) vector<shared_ptr<MwmInfo>> infos; m_index.GetMwmsInfo(infos); - GoImpl(preRanker, infos, false /* inViewport */); + GoImpl(infos, false /* inViewport */); } -void Geocoder::GoInViewport(PreRanker & preRanker) +void Geocoder::GoInViewport() { if (m_params.GetNumTokens() == 0) return; @@ -505,13 +503,11 @@ void Geocoder::GoInViewport(PreRanker & preRanker) return !m_params.m_pivot.IsIntersect(info->m_limitRect); }); - GoImpl(preRanker, infos, true /* inViewport */); + GoImpl(infos, true /* inViewport */); } -void Geocoder::GoImpl(PreRanker & preRanker, vector<shared_ptr<MwmInfo>> & infos, bool inViewport) +void Geocoder::GoImpl(vector<shared_ptr<MwmInfo>> & infos, bool inViewport) { - m_preRanker = &preRanker; - try { // Tries to find world and fill localities table. @@ -601,26 +597,24 @@ void Geocoder::GoImpl(PreRanker & preRanker, vector<shared_ptr<MwmInfo>> & infos m_lastMatchedRegion = nullptr; MatchRegions(ctx, REGION_TYPE_COUNTRY); - if (index < numIntersectingMaps || m_preRanker->IsEmpty()) + if (index < numIntersectingMaps || m_preRanker.IsEmpty()) MatchAroundPivot(ctx); }; // Iterates through all alive mwms and performs geocoding. ForEachCountry(infos, processCountry); + + m_preRanker.FinalizeResults(); } catch (CancelException & e) { } - - // Fill results ranks, as they were missed. - FillMissingFieldsInResults(); } void Geocoder::ClearCaches() { m_pivotRectsCache.Clear(); m_localityRectsCache.Clear(); - m_pivotFeatures.Clear(); m_matchersCache.clear(); m_streetsCache.clear(); @@ -974,7 +968,7 @@ void Geocoder::MatchCities(BaseContext & ctx) void Geocoder::MatchAroundPivot(BaseContext & ctx) { auto const features = RetrieveGeometryFeatures(*m_context, m_params.m_pivot, RECT_ID_PIVOT); - ViewportFilter filter(features, m_preRanker->Limit() /* threshold */); + ViewportFilter filter(features, m_preRanker.Limit() /* threshold */); LimitedSearch(ctx, filter); } @@ -1337,7 +1331,7 @@ void Geocoder::EmitResult(MwmSet::MwmId const & mwmId, uint32_t ftId, SearchMode info.m_startToken = startToken; info.m_endToken = endToken; - m_preRanker->Emplace(id, info); + m_preRanker.Emplace(id, info); } void Geocoder::EmitResult(Region const & region, size_t startToken, size_t endToken) @@ -1357,42 +1351,6 @@ void Geocoder::EmitResult(City const & city, size_t startToken, size_t endToken) EmitResult(city.m_countryId, city.m_featureId, city.m_type, startToken, endToken); } -void Geocoder::FillMissingFieldsInResults() -{ - MwmSet::MwmId mwmId; - MwmSet::MwmHandle mwmHandle; - unique_ptr<RankTable> rankTable = make_unique<DummyRankTable>(); - - m_preRanker->ForEachInfo([&](FeatureID const & id, PreRankingInfo & info) - { - if (id.m_mwmId != mwmId) - { - mwmId = id.m_mwmId; - mwmHandle = m_index.GetMwmHandleById(mwmId); - rankTable.reset(); - if (mwmHandle.IsAlive()) - { - rankTable = - RankTable::Load(mwmHandle.GetValue<MwmValue>()->m_cont); - } - if (!rankTable) - rankTable = make_unique<DummyRankTable>(); - } - - info.m_rank = rankTable->Get(id.m_index); - }); - - if (m_preRanker->Size() > m_preRanker->Limit()) - { - m_pivotFeatures.SetPosition(m_params.m_accuratePivotCenter, m_params.m_scale); - m_preRanker->ForEachInfo([&](FeatureID const & id, PreRankingInfo & info) - { - info.m_distanceToPivot = - m_pivotFeatures.GetDistanceToFeatureMeters(id); - }); - } -} - void Geocoder::MatchUnclassified(BaseContext & ctx, size_t curToken) { ASSERT(m_layers.empty(), ()); diff --git a/search/geocoder.hpp b/search/geocoder.hpp index 6347c03cf6..56f5cfcbde 100644 --- a/search/geocoder.hpp +++ b/search/geocoder.hpp @@ -75,16 +75,7 @@ public: Params(); Mode m_mode; - - // We need to pass both pivot and pivot center because pivot is - // usually a rectangle created by radius and center, and due to - // precision loss, |m_pivot|.Center() may differ from - // |m_accuratePivotCenter|. Therefore |m_pivot| should be used for - // fast filtering of features outside of the rectangle, while - // |m_accuratePivotCenter| should be used when it's needed to - // compute a distance from a feature to the pivot. m2::RectD m_pivot; - m2::PointD m_accuratePivotCenter; }; enum RegionType @@ -144,7 +135,7 @@ public: }; Geocoder(Index const & index, storage::CountryInfoGetter const & infoGetter, - my::Cancellable const & cancellable); + PreRanker & preRanker, my::Cancellable const & cancellable); ~Geocoder(); @@ -153,8 +144,8 @@ public: // Starts geocoding, retrieved features will be appended to // |results|. - void GoEverywhere(PreRanker & preRanker); - void GoInViewport(PreRanker & preRanker); + void GoEverywhere(); + void GoInViewport(); void ClearCaches(); @@ -180,7 +171,7 @@ private: CBV m_features; }; - void GoImpl(PreRanker & preRanker, vector<shared_ptr<MwmInfo>> & infos, bool inViewport); + void GoImpl(vector<shared_ptr<MwmInfo>> & infos, bool inViewport); template <typename TLocality> using TLocalitiesCache = map<pair<size_t, size_t>, vector<TLocality>>; @@ -260,9 +251,6 @@ private: void EmitResult(Region const & region, size_t startToken, size_t endToken); void EmitResult(City const & city, size_t startToken, size_t endToken); - // Computes missing fields for all results in |m_preRanker|. - void FillMissingFieldsInResults(); - // Tries to match unclassified objects from lower layers, like // parks, forests, lakes, rivers, etc. This method finds all // UNCLASSIFIED objects that match to all currently unused tokens. @@ -316,9 +304,6 @@ private: PivotRectsCache m_pivotRectsCache; LocalityRectsCache m_localityRectsCache; - // Cache of nested rects used to estimate distance from a feature to the pivot. - NestedRectsCache m_pivotFeatures; - // Cache of street ids in mwms. map<MwmSet::MwmId, CBV> m_streetsCache; @@ -344,10 +329,8 @@ private: // Stack of layers filled during geocoding. vector<FeaturesLayer> m_layers; - // Non-owning. - PreRanker * m_preRanker; + PreRanker & m_preRanker; }; string DebugPrint(Geocoder::Locality const & locality); - } // namespace search diff --git a/search/pre_ranker.cpp b/search/pre_ranker.cpp index f333b5efcd..3e298062e6 100644 --- a/search/pre_ranker.cpp +++ b/search/pre_ranker.cpp @@ -1,7 +1,11 @@ #include "search/pre_ranker.hpp" +#include "search/dummy_rank_table.hpp" #include "search/pre_ranking_info.hpp" +#include "indexer/mwm_set.hpp" +#include "indexer/rank_table.hpp" + #include "base/stl_helpers.hpp" #include "std/iterator.hpp" @@ -42,12 +46,52 @@ struct ComparePreResult1 }; } // namespace -PreRanker::PreRanker(size_t limit) : m_limit(limit) {} +PreRanker::PreRanker(Index const & index, Ranker & ranker, size_t limit) + : m_index(index), m_ranker(ranker), m_limit(limit), m_pivotFeatures(index) +{ +} + +void PreRanker::FillMissingFieldsInResults() +{ + MwmSet::MwmId mwmId; + MwmSet::MwmHandle mwmHandle; + unique_ptr<RankTable> rankTable = make_unique<DummyRankTable>(); + + ForEach([&](PreResult1 & r) { + FeatureID const & id = r.GetId(); + PreRankingInfo & info = r.GetInfo(); + if (id.m_mwmId != mwmId) + { + mwmId = id.m_mwmId; + mwmHandle = m_index.GetMwmHandleById(mwmId); + rankTable.reset(); + if (mwmHandle.IsAlive()) + { + rankTable = RankTable::Load(mwmHandle.GetValue<MwmValue>()->m_cont); + } + if (!rankTable) + rankTable = make_unique<DummyRankTable>(); + } + + info.m_rank = rankTable->Get(id.m_index); + }); + + if (Size() <= Limit()) + return; + + m_pivotFeatures.SetPosition(m_params.m_accuratePivotCenter, m_params.m_scale); + ForEach([&](PreResult1 & r) { + FeatureID const & id = r.GetId(); + PreRankingInfo & info = r.GetInfo(); + + info.m_distanceToPivot = m_pivotFeatures.GetDistanceToFeatureMeters(id); + }); +} void PreRanker::Filter(bool viewportSearch) { using TSet = set<PreResult1, LessFeatureID>; - TSet theSet; + TSet filtered; sort(m_results.begin(), m_results.end(), ComparePreResult1()); m_results.erase(unique(m_results.begin(), m_results.end(), my::EqualsBy(&PreResult1::GetId)), @@ -88,17 +132,26 @@ void PreRanker::Filter(bool viewportSearch) minstd_rand engine; shuffle(b, e, engine); } - theSet.insert(m_results.begin(), m_results.begin() + min(m_results.size(), m_limit)); + filtered.insert(m_results.begin(), m_results.begin() + min(m_results.size(), m_limit)); if (!viewportSearch) { size_t n = min(m_results.size(), m_limit); nth_element(m_results.begin(), m_results.begin() + n, m_results.end(), &PreResult1::LessRank); - theSet.insert(m_results.begin(), m_results.begin() + n); + filtered.insert(m_results.begin(), m_results.begin() + n); } - m_results.reserve(theSet.size()); + m_results.reserve(filtered.size()); m_results.clear(); - copy(theSet.begin(), theSet.end(), back_inserter(m_results)); + copy(filtered.begin(), filtered.end(), back_inserter(m_results)); } + +void PreRanker::FinalizeResults() +{ + FillMissingFieldsInResults(); + Filter(m_params.m_viewportSearch); + m_ranker.SetPreResults1(&m_results); +} + +void PreRanker::ClearCaches() { m_pivotFeatures.Clear(); } } // namespace search diff --git a/search/pre_ranker.hpp b/search/pre_ranker.hpp index 725c11d61f..ab24158190 100644 --- a/search/pre_ranker.hpp +++ b/search/pre_ranker.hpp @@ -1,6 +1,12 @@ #pragma once +#include "indexer/index.hpp" + #include "search/intermediate_result.hpp" +#include "search/nested_rects_cache.hpp" +#include "search/ranker.hpp" + +#include "geometry/point2d.hpp" #include "base/macros.hpp" @@ -15,16 +21,39 @@ namespace search class PreRanker { public: - explicit PreRanker(size_t limit); + struct Params + { + bool m_viewportSearch = false; + // This is different from geocoder's pivot because pivot is + // usually a rectangle created by radius and center and, due to + // precision loss, its center may differ from + // |m_accuratePivotCenter|. Therefore the pivot should be used for + // fast filtering of features outside of the rectangle, while + // |m_accuratePivotCenter| should be used when it's needed to + // compute the distance from a feature to the pivot. + m2::PointD m_accuratePivotCenter = m2::PointD(0, 0); + int m_scale = 0; + }; + + explicit PreRanker(Index const & index, Ranker & ranker, size_t limit); + + void Init(bool viewportSearch) { m_params.m_viewportSearch = viewportSearch; } template <typename... TArgs> void Emplace(TArgs &&... args) { m_results.emplace_back(forward<TArgs>(args)...); } + // Computes missing fields for all results. + void FillMissingFieldsInResults(); + void Filter(bool viewportSearch); + // This function is used in geocoder to indicate that + // no more results will be added. + void FinalizeResults(); + inline size_t Size() const { return m_results.size(); } inline size_t Limit() const { return m_limit; } inline bool IsEmpty() const { return Size() == 0; } @@ -36,16 +65,18 @@ public: for_each(m_results.begin(), m_results.end(), forward<TFn>(fn)); } - template <typename TFn> - void ForEachInfo(TFn && fn) - { - for (auto & result : m_results) - fn(result.GetId(), result.GetInfo()); - } + void SetParams(Params const & params) { m_params = params; } + void ClearCaches(); private: + Index const & m_index; + Ranker & m_ranker; vector<PreResult1> m_results; size_t const m_limit; + Params m_params; + + // Cache of nested rects used to estimate distance from a feature to the pivot. + NestedRectsCache m_pivotFeatures; DISALLOW_COPY_AND_MOVE(PreRanker); }; diff --git a/search/processor.cpp b/search/processor.cpp index 4262e6b372..712202bc61 100644 --- a/search/processor.cpp +++ b/search/processor.cpp @@ -110,12 +110,10 @@ Processor::Processor(Index const & index, CategoriesHolder const & categories, , m_infoGetter(infoGetter) , m_position(0, 0) , m_mode(Mode::Everywhere) - , m_worldSearch(true) , m_suggestsEnabled(true) - , m_preRanker(kPreResultsCount) - , m_ranker(m_preRanker, index, infoGetter, categories, suggests, - static_cast<my::Cancellable const &>(*this)) - , m_geocoder(index, infoGetter, static_cast<my::Cancellable const &>(*this)) + , m_preRanker(index, m_ranker, kPreResultsCount) + , m_ranker(index, infoGetter, categories, suggests, static_cast<my::Cancellable const &>(*this)) + , m_geocoder(index, infoGetter, m_preRanker, static_cast<my::Cancellable const &>(*this)) { // Initialize keywords scorer. // Note! This order should match the indexes arrays above. @@ -135,7 +133,7 @@ void Processor::Init(bool viewportSearch) m_tokens.clear(); m_prefix.clear(); m_preRanker.Clear(); - m_ranker.Init(viewportSearch); + m_preRanker.Init(viewportSearch); } void Processor::SetViewport(m2::RectD const & viewport, bool forceUpdate) @@ -347,29 +345,38 @@ void Processor::Search(Results & results, size_t limit) Geocoder::Params geocoderParams; InitGeocoderParams(geocoderParams); + PreRanker::Params preRankerParams; + InitPreRankerParams(preRankerParams); + Ranker::Params rankerParams; InitRankerParams(rankerParams); if (m_tokens.empty()) m_ranker.SuggestStrings(results); - m_geocoder.GoEverywhere(m_preRanker); + m_geocoder.GoEverywhere(); m_ranker.FlushResults(geocoderParams, results, limit); } void Processor::SearchViewportPoints(Results & results) { - Geocoder::Params params; + Geocoder::Params geocoderParams; + InitParams(geocoderParams); + geocoderParams.m_mode = m_mode; + geocoderParams.m_pivot = m_viewport[CURRENT_V]; - InitParams(params); - params.m_mode = m_mode; - params.m_pivot = m_viewport[CURRENT_V]; - params.m_accuratePivotCenter = params.m_pivot.Center(); - m_geocoder.SetParams(params); + m_geocoder.SetParams(geocoderParams); + + PreRanker::Params preRankerParams; + preRankerParams.m_accuratePivotCenter = geocoderParams.m_pivot.Center(); + m_preRanker.SetParams(preRankerParams); - m_geocoder.GoInViewport(m_preRanker); + Ranker::Params rankerParams; + rankerParams.m_accuratePivotCenter = geocoderParams.m_pivot.Center(); + m_ranker.SetParams(rankerParams); - m_ranker.FlushViewportResults(params, results); + m_geocoder.GoInViewport(); + m_ranker.FlushViewportResults(geocoderParams, results); } void Processor::SearchCoordinates(Results & res) const @@ -591,10 +598,15 @@ void Processor::InitGeocoderParams(Geocoder::Params & params) InitParams(params); params.m_mode = m_mode; params.m_pivot = GetPivotRect(); - params.m_accuratePivotCenter = GetPivotPoint(); m_geocoder.SetParams(params); } +void Processor::InitPreRankerParams(PreRanker::Params & params) +{ + params.m_accuratePivotCenter = GetPivotPoint(); + m_preRanker.SetParams(params); +} + void Processor::InitRankerParams(Ranker::Params & params) { params.m_currentLocaleCode = m_currentLocaleCode; @@ -608,6 +620,7 @@ void Processor::InitRankerParams(Ranker::Params & params) params.m_tokens = m_tokens; params.m_prefix = m_prefix; params.m_categoryLocales = GetCategoryLocales(); + params.m_accuratePivotCenter = GetPivotPoint(); m_ranker.SetParams(params); } @@ -617,6 +630,7 @@ void Processor::ClearCaches() ClearCache(i); m_geocoder.ClearCaches(); + m_preRanker.ClearCaches(); m_ranker.ClearCaches(); } diff --git a/search/processor.hpp b/search/processor.hpp index 7e77c72125..21db6bf34d 100644 --- a/search/processor.hpp +++ b/search/processor.hpp @@ -82,7 +82,6 @@ public: // TODO (@y): this function must be removed. void SetRankPivot(m2::PointD const & pivot); inline void SetMode(Mode mode) { m_mode = mode; } - inline void SetSearchInWorld(bool b) { m_worldSearch = b; } inline void SetSuggestsEnabled(bool enabled) { m_suggestsEnabled = enabled; } inline void SetPosition(m2::PointD const & position) { m_position = position; } @@ -105,6 +104,7 @@ public: void InitParams(QueryParams & params); void InitGeocoderParams(Geocoder::Params & params); + void InitPreRankerParams(PreRanker::Params & params); void InitRankerParams(Ranker::Params & params); void ClearCaches(); @@ -156,7 +156,6 @@ protected: m2::PointD m_pivot; m2::PointD m_position; Mode m_mode; - bool m_worldSearch; bool m_suggestsEnabled; /// @name Get ranking params. diff --git a/search/ranker.cpp b/search/ranker.cpp index c2c0d5b3ad..63f0d4782c 100644 --- a/search/ranker.cpp +++ b/search/ranker.cpp @@ -1,5 +1,4 @@ #include "search/ranker.hpp" -#include "search/pre_ranker.hpp" #include "search/string_intersection.hpp" #include "search/token_slice.hpp" #include "search/utils.hpp" @@ -9,6 +8,7 @@ #include "base/logging.hpp" #include "std/algorithm.hpp" +#include "std/unique_ptr.hpp" namespace search { @@ -165,7 +165,7 @@ class PreResult2Maker { auto const & preInfo = res.GetInfo(); - auto const & pivot = m_params.m_accuratePivotCenter; + auto const & pivot = m_ranker.m_params.m_accuratePivotCenter; info.m_distanceToPivot = MercatorBounds::DistanceOnEarth(center, pivot); info.m_rank = preInfo.m_rank; @@ -266,6 +266,21 @@ public: } }; +Ranker::Ranker(Index const & index, storage::CountryInfoGetter const & infoGetter, + CategoriesHolder const & categories, vector<Suggest> const & suggests, + my::Cancellable const & cancellable) + : m_reverseGeocoder(index) + , m_cancellable(cancellable) +#ifdef FIND_LOCALITY_TEST + , m_locality(&index) +#endif // FIND_LOCALITY_TEST + , m_index(index) + , m_infoGetter(infoGetter) + , m_categories(categories) + , m_suggests(suggests) +{ +} + bool Ranker::IsResultExists(PreResult2 const & p, vector<IndexedValue> const & values) { PreResult2::StrictEqualF equalCmp(p); @@ -279,27 +294,25 @@ bool Ranker::IsResultExists(PreResult2 const & p, vector<IndexedValue> const & v void Ranker::MakePreResult2(Geocoder::Params const & geocoderParams, vector<IndexedValue> & cont, vector<FeatureID> & streets) { - m_preRanker.Filter(m_params.m_viewportSearch); - - // Makes PreResult2 vector. + if (m_preResults1 == nullptr) + return; PreResult2Maker maker(*this, m_index, m_infoGetter, geocoderParams); - m_preRanker.ForEach( - [&](PreResult1 const & r) - { - auto p = maker(r); - if (!p) - return; + for (auto const & r : *m_preResults1) + { + auto p = maker(r); + if (!p) + return; - if (geocoderParams.m_mode == Mode::Viewport && - !geocoderParams.m_pivot.IsPointInside(p->GetCenter())) - return; + if (geocoderParams.m_mode == Mode::Viewport && + !geocoderParams.m_pivot.IsPointInside(p->GetCenter())) + return; - if (p->IsStreet()) - streets.push_back(p->GetID()); + if (p->IsStreet()) + streets.push_back(p->GetID()); - if (!IsResultExists(*p, cont)) - cont.push_back(IndexedValue(move(p))); - }); + if (!IsResultExists(*p, cont)) + cont.push_back(IndexedValue(move(p))); + }; } Result Ranker::MakeResult(PreResult2 const & r) const @@ -460,7 +473,6 @@ void Ranker::FlushResults(Geocoder::Params const & params, Results & res, size_t { vector<IndexedValue> values; vector<FeatureID> streets; - MakePreResult2(params, values, streets); RemoveDuplicatingLinear(values); if (values.empty()) @@ -488,7 +500,6 @@ void Ranker::FlushViewportResults(Geocoder::Params const & geocoderParams, Resul { vector<IndexedValue> values; vector<FeatureID> streets; - MakePreResult2(geocoderParams, values, streets); RemoveDuplicatingLinear(values); if (values.empty()) diff --git a/search/ranker.hpp b/search/ranker.hpp index b8ff40ea7c..0bf29fd8ef 100644 --- a/search/ranker.hpp +++ b/search/ranker.hpp @@ -46,8 +46,6 @@ public: { using TLocales = buffer_vector<int8_t, 3>; - bool m_viewportSearch = false; - int8_t m_currentLocaleCode = CategoriesHolder::kEnglishCode; m2::RectD m_viewport; m2::PointD m_position; @@ -61,26 +59,14 @@ public: // We need it here to make suggestions. strings::UniString m_prefix; + m2::PointD m_accuratePivotCenter = m2::PointD(0, 0); + TLocales m_categoryLocales; }; - Ranker(PreRanker & preRanker, Index const & index, storage::CountryInfoGetter const & infoGetter, + Ranker(Index const & index, storage::CountryInfoGetter const & infoGetter, CategoriesHolder const & categories, vector<Suggest> const & suggests, - my::Cancellable const & cancellable) - : m_reverseGeocoder(index) - , m_preRanker(preRanker) - , m_cancellable(cancellable) -#ifdef FIND_LOCALITY_TEST - , m_locality(&index) -#endif // FIND_LOCALITY_TEST - , m_index(index) - , m_infoGetter(infoGetter) - , m_categories(categories) - , m_suggests(suggests) - { - } - - inline void Init(bool viewportSearch) { m_params.m_viewportSearch = viewportSearch; } + my::Cancellable const & cancellable); bool IsResultExists(PreResult2 const & p, vector<IndexedValue> const & values); @@ -101,7 +87,7 @@ public: void FlushViewportResults(Geocoder::Params const & geocoderParams, Results & res); void SetParams(Params const & params) { m_params = params; } - + void SetPreResults1(vector<PreResult1> * preResults1) { m_preResults1 = preResults1; } void ClearCaches(); #ifdef FIND_LOCALITY_TEST @@ -136,7 +122,6 @@ private: Params m_params; ReverseGeocoder const m_reverseGeocoder; - PreRanker & m_preRanker; my::Cancellable const & m_cancellable; KeywordLangMatcher m_keywordsScorer; @@ -148,5 +133,7 @@ private: storage::CountryInfoGetter const & m_infoGetter; CategoriesHolder const & m_categories; vector<Suggest> const & m_suggests; + + vector<PreResult1> * m_preResults1 = nullptr; }; } // namespace search |