diff --git a/indexer/index.hpp b/indexer/index.hpp index 811fd532e6..236d18c164 100644 --- a/indexer/index.hpp +++ b/indexer/index.hpp @@ -4,7 +4,6 @@ #include "data_factory.hpp" #include "features_vector.hpp" #include "scale_index.hpp" -#include "scales.hpp" #include "search_trie.hpp" #include "../../defines.hpp" @@ -33,7 +32,7 @@ template class IndexForEachAdapter : public BaseT { private: template - void CallForIntervals(F const & f, covering::IntervalsT const & intervals, + void CallForIntervals(F & f, covering::IntervalsT const & intervals, m2::RectD const & rect, uint32_t scale) const { for (size_t i = 0; i < intervals.size(); ++i) @@ -45,13 +44,13 @@ private: public: template - void ForEachInRect(F const & f, m2::RectD const & rect, uint32_t scale) const + void ForEachInRect(F & f, m2::RectD const & rect, uint32_t scale) const { CallForIntervals(f, covering::CoverViewportAndAppendLowerLevels(rect), rect, scale); } template - void ForEachInRect_TileDrawing(F const & f, m2::RectD const & rect, uint32_t scale) const + void ForEachInRect_TileDrawing(F & f, m2::RectD const & rect, uint32_t scale) const { using namespace covering; @@ -62,15 +61,8 @@ public: } public: - template - void ForEachInViewport(F const & f, m2::RectD const & viewport) const - { - ForEachInRect(f, viewport, scales::GetScaleLevel(viewport)); - } - - template - void ForEachInScale(F const & f, uint32_t scale) const + void ForEachInScale(F & f, uint32_t scale) const { int64_t const rootId = RectId("").ToInt64(); BaseT::ForEachInIntervalAndScale(f, rootId, rootId + RectId("").SubTreeSize(), scale, @@ -101,7 +93,7 @@ public: } template - void ForEachInIntervalAndScale(F const & f, int64_t beg, int64_t end, uint32_t scale, + void ForEachInIntervalAndScale(F & f, int64_t beg, int64_t end, uint32_t scale, m2::RectD const & occlusionRect) const { for (size_t iIndex = 0; true;) @@ -400,7 +392,7 @@ public: } template - void ForEachInIntervalAndScale(F const & f, int64_t beg, int64_t end, uint32_t scale) const + void ForEachInIntervalAndScale(F & f, int64_t beg, int64_t end, uint32_t scale) const { OffsetToFeatureReplacer offsetToFeatureReplacer(m_FeatureVector, f); BaseT::ForEachInIntervalAndScale(offsetToFeatureReplacer, beg, end, scale); @@ -413,10 +405,10 @@ private: class OffsetToFeatureReplacer { FeatureVectorT const & m_V; - F const & m_F; + F & m_F; public: - OffsetToFeatureReplacer(FeatureVectorT const & v, F const & f) : m_V(v), m_F(f) {} + OffsetToFeatureReplacer(FeatureVectorT const & v, F & f) : m_V(v), m_F(f) {} void operator() (uint32_t offset) const { FeatureType feature; @@ -436,7 +428,7 @@ public: UniqueOffsetAdapter(T1 const & t1, T2 & t2) : BaseT(t1, t2) {} template - void ForEachInIntervalAndScale(F const & f, int64_t beg, int64_t end, uint32_t scale) const + void ForEachInIntervalAndScale(F & f, int64_t beg, int64_t end, uint32_t scale) const { unordered_set offsets; UniqueOffsetFunctorAdapter uniqueOffsetFunctorAdapter(offsets, f); @@ -447,7 +439,7 @@ private: template struct UniqueOffsetFunctorAdapter { - UniqueOffsetFunctorAdapter(unordered_set & offsets, F const & f) + UniqueOffsetFunctorAdapter(unordered_set & offsets, F & f) : m_Offsets(offsets), m_F(f) {} void operator() (uint32_t offset) const @@ -457,7 +449,7 @@ private: } unordered_set & m_Offsets; - F const & m_F; + F & m_F; }; }; diff --git a/indexer/indexer_tests/index_builder_test.cpp b/indexer/indexer_tests/index_builder_test.cpp index a54b115715..0ee762b6cc 100644 --- a/indexer/indexer_tests/index_builder_test.cpp +++ b/indexer/indexer_tests/index_builder_test.cpp @@ -61,7 +61,8 @@ UNIT_TEST(BuildIndexTest) index.Add(fileName); // Make sure that index is actually parsed. - index.ForEachInScale(NoopFunctor(), 15); + NoopFunctor fn; + index.ForEachInScale(fn, 15); } // Clean after the test. diff --git a/indexer/indexer_tests/index_test.cpp b/indexer/indexer_tests/index_test.cpp index 2c37c029c3..9694979bf6 100644 --- a/indexer/indexer_tests/index_test.cpp +++ b/indexer/indexer_tests/index_test.cpp @@ -13,5 +13,6 @@ UNIT_TEST(IndexParseTest) index.Add("minsk-pass" DATA_FILE_EXTENSION); // Make sure that index is actually parsed. - index.ForEachInScale(NoopFunctor(), 15); + NoopFunctor fn; + index.ForEachInScale(fn, 15); } diff --git a/map/feature_vec_model.hpp b/map/feature_vec_model.hpp index b29c49898c..89560f50e0 100644 --- a/map/feature_vec_model.hpp +++ b/map/feature_vec_model.hpp @@ -1,6 +1,7 @@ #pragma once #include "../indexer/index.hpp" +#include "../indexer/scales.hpp" #include "../geometry/rect2d.hpp" #include "../geometry/point2d.hpp" @@ -39,20 +40,26 @@ namespace model void Clean(); void ClearCaches(); - // process features by param type indices + /// @name Features enumeration. + //@{ template - void ForEachFeature(m2::RectD const & rect, ToDo toDo) const + void ForEachFeature(m2::RectD const & rect, ToDo & toDo) const { - m_multiIndex.ForEachInViewport(toDo, rect); - // Uncomment to traverse all features (SLOW!!): - // m_multiIndex.ForEachInScale(toDo, GetScaleLevel(rect)); + ForEachFeature(rect, toDo, scales::GetScaleLevel(rect)); } template - void ForEachFeature_TileDrawing(m2::RectD const & rect, ToDo const & toDo, int scale) const + void ForEachFeature(m2::RectD const & rect, ToDo & toDo, int scale) const + { + m_multiIndex.ForEachInRect(toDo, rect, scale); + } + + template + void ForEachFeature_TileDrawing(m2::RectD const & rect, ToDo & toDo, int scale) const { m_multiIndex.ForEachInRect_TileDrawing(toDo, rect, scale); } + //@} index_t const & GetIndex() const { return m_multiIndex; } diff --git a/search/query.cpp b/search/query.cpp index d23b51171a..d0bbffe149 100644 --- a/search/query.cpp +++ b/search/query.cpp @@ -6,6 +6,7 @@ #include "../indexer/feature_visibility.hpp" #include "../indexer/string_search_utils.hpp" +#include "../indexer/scales.hpp" #include "../base/exception.hpp" #include "../base/stl_add.hpp"