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
path: root/search
diff options
context:
space:
mode:
authorYuri Gorshenin <y@maps.me>2016-09-01 17:23:57 +0300
committerYuri Gorshenin <y@maps.me>2016-09-01 18:27:59 +0300
commit30ef25bfb34beab674320723f1bcc598a784fffe (patch)
treedf87e64e58605358d779142f389eca51bde4af1a /search
parenta43c309fc7adfbd853133debc712a86be3d149f9 (diff)
[indexer] Removed indexer dependency on search.
Diffstat (limited to 'search')
-rw-r--r--search/editor_delegate.cpp44
-rw-r--r--search/editor_delegate.hpp24
-rw-r--r--search/search.pro2
-rw-r--r--search/search_integration_tests/helpers.cpp3
4 files changed, 72 insertions, 1 deletions
diff --git a/search/editor_delegate.cpp b/search/editor_delegate.cpp
new file mode 100644
index 0000000000..aa982055df
--- /dev/null
+++ b/search/editor_delegate.cpp
@@ -0,0 +1,44 @@
+#include "search/editor_delegate.hpp"
+
+#include "search/reverse_geocoder.hpp"
+
+#include "indexer/feature_decl.hpp"
+#include "indexer/index.hpp"
+#include "indexer/index.hpp"
+#include "indexer/index_helpers.hpp"
+
+namespace search
+{
+EditorDelegate::EditorDelegate(Index const & index) : m_index(index) {}
+
+MwmSet::MwmId EditorDelegate::GetMwmIdByMapName(string const & name) const
+{
+ return m_index.GetMwmIdByCountryFile(platform::CountryFile(name));
+}
+
+unique_ptr<FeatureType> EditorDelegate::GetOriginalFeature(FeatureID const & fid) const
+{
+ auto feature = make_unique<FeatureType>();
+ Index::FeaturesLoaderGuard const guard(m_index, fid.m_mwmId);
+ if (!guard.GetOriginalFeatureByIndex(fid.m_index, *feature))
+ return unique_ptr<FeatureType>();
+ feature->ParseEverything();
+ return feature;
+}
+
+string EditorDelegate::GetOriginalFeatureStreet(FeatureType & ft) const
+{
+ search::ReverseGeocoder const coder(m_index);
+ auto const streets = coder.GetNearbyFeatureStreets(ft);
+ if (streets.second < streets.first.size())
+ return streets.first[streets.second].m_name;
+ return {};
+}
+
+void EditorDelegate::ForEachFeatureAtPoint(osm::Editor::TFeatureTypeFn && fn,
+ m2::PointD const & point) const
+{
+ auto const kToleranceMeters = 1e-2;
+ indexer::ForEachFeatureAtPoint(m_index, move(fn), point, kToleranceMeters);
+}
+} // namespace search
diff --git a/search/editor_delegate.hpp b/search/editor_delegate.hpp
new file mode 100644
index 0000000000..c523cf2372
--- /dev/null
+++ b/search/editor_delegate.hpp
@@ -0,0 +1,24 @@
+#pragma once
+
+#include "indexer/osm_editor.hpp"
+
+class Index;
+
+namespace search
+{
+class EditorDelegate : public osm::Editor::Delegate
+{
+public:
+ EditorDelegate(Index const & index);
+
+ // osm::Editor::Delegate overrides:
+ MwmSet::MwmId GetMwmIdByMapName(string const & name) const override;
+ unique_ptr<FeatureType> GetOriginalFeature(FeatureID const & fid) const override;
+ string GetOriginalFeatureStreet(FeatureType & ft) const override;
+ void ForEachFeatureAtPoint(osm::Editor::TFeatureTypeFn && fn,
+ m2::PointD const & point) const override;
+
+private:
+ Index const & m_index;
+};
+} // namespace search
diff --git a/search/search.pro b/search/search.pro
index da1ee701ea..dd1732c817 100644
--- a/search/search.pro
+++ b/search/search.pro
@@ -18,6 +18,7 @@ HEADERS += \
displayed_categories.hpp \
downloader_search_callback.hpp \
dummy_rank_table.hpp \
+ editor_delegate.hpp \
engine.hpp \
everywhere_search_params.hpp \
feature_offset_match.hpp \
@@ -83,6 +84,7 @@ SOURCES += \
displayed_categories.cpp \
downloader_search_callback.cpp \
dummy_rank_table.cpp \
+ editor_delegate.cpp \
engine.cpp \
features_filter.cpp \
features_layer.cpp \
diff --git a/search/search_integration_tests/helpers.cpp b/search/search_integration_tests/helpers.cpp
index 79768d0f2d..111d08718d 100644
--- a/search/search_integration_tests/helpers.cpp
+++ b/search/search_integration_tests/helpers.cpp
@@ -1,5 +1,6 @@
#include "search/search_integration_tests/helpers.hpp"
+#include "search/editor_delegate.hpp"
#include "search/processor_factory.hpp"
#include "search/search_tests_support/test_search_request.hpp"
@@ -27,7 +28,7 @@ SearchTest::SearchTest()
, m_engine(make_unique<storage::CountryInfoGetterForTesting>(), make_unique<ProcessorFactory>(),
Engine::Params())
{
- indexer::tests_support::SetUpEditorForTesting(m_engine);
+ indexer::tests_support::SetUpEditorForTesting(make_unique<EditorDelegate>(m_engine));
}
SearchTest::~SearchTest()