diff options
author | Alex Zolotarev <deathbaba@gmail.com> | 2010-12-05 19:24:16 +0300 |
---|---|---|
committer | Alex Zolotarev <alex@maps.me> | 2015-09-22 22:33:57 +0300 |
commit | d6e12b7ce4bcbf0ccd1c07eb25de143422913c34 (patch) | |
tree | a7e910c330ce4da9b4f2d8be76067adece2561c4 /map/feature_vec_model.hpp |
One Month In Minsk. Made in Belarus.
Diffstat (limited to 'map/feature_vec_model.hpp')
-rw-r--r-- | map/feature_vec_model.hpp | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/map/feature_vec_model.hpp b/map/feature_vec_model.hpp new file mode 100644 index 0000000000..625eb64b54 --- /dev/null +++ b/map/feature_vec_model.hpp @@ -0,0 +1,76 @@ +#pragma once + +#include "../indexer/feature.hpp" +#include "../indexer/features_vector.hpp" +#include "../indexer/index.hpp" + +#include "../geometry/rect2d.hpp" +#include "../geometry/point2d.hpp" + +#include "../coding/file_reader.hpp" +#include "../coding/buffer_reader.hpp" + +#include "../base/start_mem_debug.hpp" + + +namespace model +{ + class FeatureVector + { + vector<FeatureBuilder> m_vec; + m2::RectD m_rect; + + public: + template <class TParam, class ToDo> + void ForEachFeature(TParam const &, ToDo & toDo) + { + std::for_each(m_vec.begin(), m_vec.end(), toDo); + } + + m2::RectD GetWorldRect() const { return m_rect; } + }; + +//#define USE_BUFFER_READER + + class FeaturesFetcher + { + m2::RectD m_rect; + +#ifdef USE_BUFFER_READER + typedef BufferReader reader_t; +#else + typedef FileReader reader_t; +#endif + + typedef Index<reader_t, reader_t>::Type index_t; + + index_t m_multiIndex; + + public: + void InitClassificator(); + + void AddMap(string const & dataPath, string const & indexPath); + void RemoveMap(string const & dataPath); + void Clean(); + + // process features by param type indices + template <class ToDo> + 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)); + } + + template <class ToDo> + void ForEachFeatureWithScale(m2::RectD const & rect, ToDo toDo, int scale) const + { + m_multiIndex.ForEachInRect(toDo, rect, scale); + } + + void AddWorldRect(m2::RectD const & r) { m_rect.Add(r); } + m2::RectD GetWorldRect() const { return m_rect; } + }; +} + +#include "../base/stop_mem_debug.hpp" |