Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortatiana-kondakova <tatiana.kondakova@gmail.com>2018-01-30 18:16:06 +0300
committermpimenov <mpimenov@users.noreply.github.com>2018-02-02 17:57:31 +0300
commit863d766718e6ccb908e9c3060f81917b4eddbee6 (patch)
treee5d1042e20d4c84235f4c634826c6295c64f21fc /indexer/locality_index.hpp
parent467714d1d47915b445cad87eaf9c3e43a31d6dfe (diff)
Add LocalityIndex
Diffstat (limited to 'indexer/locality_index.hpp')
-rw-r--r--indexer/locality_index.hpp50
1 files changed, 50 insertions, 0 deletions
diff --git a/indexer/locality_index.hpp b/indexer/locality_index.hpp
new file mode 100644
index 0000000000..9acac6fcb3
--- /dev/null
+++ b/indexer/locality_index.hpp
@@ -0,0 +1,50 @@
+#pragma once
+
+#include "indexer/cell_id.hpp"
+#include "indexer/feature_covering.hpp"
+#include "indexer/interval_index.hpp"
+#include "indexer/locality_object.hpp"
+#include "indexer/scales.hpp"
+
+#include "geometry/rect2d.hpp"
+
+#include "base/osm_id.hpp"
+
+#include <functional>
+#include <memory>
+
+namespace indexer
+{
+// Geometry index which stores osm::Id as object identifier.
+// Used for geocoder server, stores only POIs and buildings which have address information.
+// Based on IntervalIndex.
+template <typename Reader>
+class LocalityIndex
+{
+public:
+ using ProcessObject = std::function<void(osm::Id const &)>;
+
+ explicit LocalityIndex(Reader const & reader)
+ {
+ m_intervalIndex = std::make_unique<IntervalIndex<Reader, uint64_t>>(reader);
+ }
+
+ void ForEachInRect(ProcessObject const & processObject, m2::RectD const & rect) const
+ {
+ covering::CoveringGetter cov(rect, covering::CoveringMode::ViewportWithLowLevels);
+ covering::Intervals const & intervals = cov.Get(scales::GetUpperScale());
+
+ for (auto const & i : intervals)
+ {
+ m_intervalIndex->ForEach(
+ [&processObject](uint64_t stored_id) {
+ processObject(LocalityObject::FromStoredId(stored_id));
+ },
+ i.first, i.second);
+ }
+ }
+
+private:
+ std::unique_ptr<IntervalIndex<Reader, uint64_t>> m_intervalIndex;
+};
+} // namespace indexer