diff options
author | vng <viktor.govako@gmail.com> | 2012-09-21 03:31:52 +0400 |
---|---|---|
committer | Alex Zolotarev <alex@maps.me> | 2015-09-23 01:43:37 +0300 |
commit | d03e167bc0484fcf9837da2a84ff2bc220ad0203 (patch) | |
tree | 568ba7847b0287e787ab2d1afdd63cf6f05475f9 /indexer | |
parent | 94fa7d216cffdffe1fbfd58923fe2e6f13523b3a (diff) |
Framework::GetVisiblePOI is working for symbols now.
Diffstat (limited to 'indexer')
-rw-r--r-- | indexer/feature.hpp | 13 | ||||
-rw-r--r-- | indexer/index.cpp | 12 | ||||
-rw-r--r-- | indexer/index.hpp | 24 |
3 files changed, 46 insertions, 3 deletions
diff --git a/indexer/feature.hpp b/indexer/feature.hpp index 31faeb29b2..a9c3a3b761 100644 --- a/indexer/feature.hpp +++ b/indexer/feature.hpp @@ -148,9 +148,22 @@ class FeatureType : public FeatureBase { typedef FeatureBase base_type; + /// @name This params define unique id for feature. + //@{ + size_t m_mwmID; + uint32_t m_offset; + //@} + public: void Deserialize(feature::LoaderBase * pLoader, BufferT buffer); + inline void SetID(size_t mwmID, uint32_t offset) + { + m_mwmID = mwmID; + m_offset = offset; + } + inline pair<size_t, uint32_t> GetID() const { return make_pair(m_mwmID, m_offset); } + /// @name Parse functions. Do simple dispatching to m_pLoader. //@{ void ParseHeader2() const; diff --git a/indexer/index.cpp b/indexer/index.cpp index 69de20d718..cd6989798d 100644 --- a/indexer/index.cpp +++ b/indexer/index.cpp @@ -120,3 +120,15 @@ void Index::UpdateMwmInfo(MwmId id) break; } } + +Index::FeaturesLoaderGuard::FeaturesLoaderGuard(Index const & parent, MwmId id) + : m_lock(parent, id), + /// @note This guard is suitable when mwm is loaded + m_vector(m_lock.GetValue()->m_cont, m_lock.GetValue()->GetHeader()) +{ +} + +void Index::FeaturesLoaderGuard::GetFeature(uint32_t offset, FeatureType & ft) +{ + m_vector.Get(offset, ft); +} diff --git a/indexer/index.hpp b/indexer/index.hpp index ff3afbd85f..669624f6e9 100644 --- a/indexer/index.hpp +++ b/indexer/index.hpp @@ -77,6 +77,16 @@ public: ForEachInIntervals(f, 2, m2::RectD::GetInfiniteRect(), scale); } + /// Guard for loading features from particular MWM by demand. + class FeaturesLoaderGuard + { + MwmLock m_lock; + FeaturesVector m_vector; + public: + FeaturesLoaderGuard(Index const & parent, MwmId id); + void GetFeature(uint32_t offset, FeatureType & ft); + }; + private: template <typename F> @@ -85,16 +95,24 @@ private: FeaturesVector const & m_V; F & m_F; unordered_set<uint32_t> & m_offsets; + MwmId m_mwmID; public: - ReadFeatureFunctor(FeaturesVector const & v, F & f, unordered_set<uint32_t> & offsets) - : m_V(v), m_F(f), m_offsets(offsets) {} + ReadFeatureFunctor(FeaturesVector const & v, F & f, + unordered_set<uint32_t> & offsets, MwmId mwmID) + : m_V(v), m_F(f), m_offsets(offsets), m_mwmID(mwmID) + { + } + void operator() (uint32_t offset) const { if (m_offsets.insert(offset).second) { FeatureType feature; + m_V.Get(offset, feature); + feature.SetID(m_mwmID, offset); + m_F(feature); } } @@ -125,7 +143,7 @@ private: // iterate through intervals unordered_set<uint32_t> offsets; - ReadFeatureFunctor<F> f1(fv, f, offsets); + ReadFeatureFunctor<F> f1(fv, f, offsets, id); for (size_t i = 0; i < interval.size(); ++i) { index.ForEachInIntervalAndScale(f1, interval[i].first, interval[i].second, scale); |