diff options
author | tatiana-yan <tatiana.kondakova@gmail.com> | 2018-06-28 12:30:40 +0300 |
---|---|---|
committer | Sergey Yershov <syershov@maps.me> | 2018-06-28 16:58:20 +0300 |
commit | 29be9091cad51749cf521924c98a3751b89b6016 (patch) | |
tree | 10cf6c2b542bd167008dd41b9bcdb482d6b433fd /editor | |
parent | 0f012f1bc7cb09fd78d902579a36f5deff50c8d3 (diff) |
[indexer] DataSource refactoring: ReadMWMFunctor is not template anymore
Diffstat (limited to 'editor')
-rw-r--r-- | editor/editable_feature_source.cpp | 11 | ||||
-rw-r--r-- | editor/editable_feature_source.hpp | 4 | ||||
-rw-r--r-- | editor/editor_tests/osm_editor_test.cpp | 17 | ||||
-rw-r--r-- | editor/osm_editor.cpp | 25 | ||||
-rw-r--r-- | editor/osm_editor.hpp | 13 |
5 files changed, 13 insertions, 57 deletions
diff --git a/editor/editable_feature_source.cpp b/editor/editable_feature_source.cpp index 308324dc37..b341e9935b 100644 --- a/editor/editable_feature_source.cpp +++ b/editor/editable_feature_source.cpp @@ -14,15 +14,8 @@ bool EditableFeatureSource::GetModifiedFeature(uint32_t index, FeatureType & fea return editor.GetEditedFeature(m_handle.GetId(), index, feature); } -void EditableFeatureSource::ForEachInRectAndScale( - m2::RectD const & rect, int scale, std::function<void(FeatureID const &)> const & fn) const -{ - osm::Editor & editor = osm::Editor::Instance(); - editor.ForEachFeatureInMwmRectAndScale(m_handle.GetId(), fn, rect, scale); -} - -void EditableFeatureSource::ForEachInRectAndScale( - m2::RectD const & rect, int scale, std::function<void(FeatureType &)> const & fn) const +void EditableFeatureSource::ForEachInRectAndScale(m2::RectD const & rect, int scale, + std::function<void(uint32_t)> const & fn) const { osm::Editor & editor = osm::Editor::Instance(); editor.ForEachFeatureInMwmRectAndScale(m_handle.GetId(), fn, rect, scale); diff --git a/editor/editable_feature_source.hpp b/editor/editable_feature_source.hpp index 3dadf59801..e9265b48b4 100644 --- a/editor/editable_feature_source.hpp +++ b/editor/editable_feature_source.hpp @@ -19,9 +19,7 @@ public: FeatureStatus GetFeatureStatus(uint32_t index) const override; bool GetModifiedFeature(uint32_t index, FeatureType & feature) const override; void ForEachInRectAndScale(m2::RectD const & rect, int scale, - std::function<void(FeatureID const &)> const & fn) const override; - void ForEachInRectAndScale(m2::RectD const & rect, int scale, - std::function<void(FeatureType &)> const & fn) const override; + std::function<void(uint32_t)> const & fn) const override; }; class EditableFeatureSourceFactory : public FeatureSourceFactory diff --git a/editor/editor_tests/osm_editor_test.cpp b/editor/editor_tests/osm_editor_test.cpp index a28b417af1..b90d892d9c 100644 --- a/editor/editor_tests/osm_editor_test.cpp +++ b/editor/editor_tests/osm_editor_test.cpp @@ -117,16 +117,13 @@ void GenerateUploadedFeature(MwmSet::MwmId const & mwmId, xf.AttachToParentNode(created); } -template <typename T> uint32_t CountFeaturesInRect(MwmSet::MwmId const & mwmId, m2::RectD const & rect) { auto & editor = osm::Editor::Instance(); int unused = 0; uint32_t counter = 0; - editor.ForEachFeatureInMwmRectAndScale(mwmId, [&counter](T const & ft) - { - ++counter; - }, rect, unused); + editor.ForEachFeatureInMwmRectAndScale(mwmId, [&counter](uint32_t index) { ++counter; }, rect, + unused); return counter; } @@ -769,13 +766,9 @@ void EditorTest::ForEachFeatureInMwmRectAndScaleTest() CreateCafeAtPoint({22.0, 22.0}, mwmId, emo); } - TEST_EQUAL(CountFeaturesInRect<FeatureType>(mwmId, {0.0, 0.0, 2.0, 2.0}), 0, ()); - TEST_EQUAL(CountFeaturesInRect<FeatureType>(mwmId, {9.0, 9.0, 21.0, 21.0}), 2, ()); - TEST_EQUAL(CountFeaturesInRect<FeatureType>(mwmId, {9.0, 9.0, 23.0, 23.0}), 3, ()); - - TEST_EQUAL(CountFeaturesInRect<FeatureID>(mwmId, {0.0, 0.0, 2.0, 2.0}), 0, ()); - TEST_EQUAL(CountFeaturesInRect<FeatureID>(mwmId, {9.0, 9.0, 21.0, 21.0}), 2, ()); - TEST_EQUAL(CountFeaturesInRect<FeatureID>(mwmId, {9.0, 9.0, 23.0, 23.0}), 3, ()); + TEST_EQUAL(CountFeaturesInRect(mwmId, {0.0, 0.0, 2.0, 2.0}), 0, ()); + TEST_EQUAL(CountFeaturesInRect(mwmId, {9.0, 9.0, 21.0, 21.0}), 2, ()); + TEST_EQUAL(CountFeaturesInRect(mwmId, {9.0, 9.0, 23.0, 23.0}), 3, ()); } void EditorTest::CreateNoteTest() diff --git a/editor/osm_editor.cpp b/editor/osm_editor.cpp index 9aa56222cf..4bfa77f5c7 100644 --- a/editor/osm_editor.cpp +++ b/editor/osm_editor.cpp @@ -486,8 +486,7 @@ bool Editor::RollBackChanges(FeatureID const & fid) } void Editor::ForEachFeatureInMwmRectAndScale(MwmSet::MwmId const & id, - TFeatureIDFunctor const & f, - m2::RectD const & rect, + TFeatureIndexFunctor const & f, m2::RectD const & rect, int /*scale*/) { auto const mwmFound = m_features.find(id); @@ -501,27 +500,7 @@ void Editor::ForEachFeatureInMwmRectAndScale(MwmSet::MwmId const & id, FeatureTypeInfo const & ftInfo = index.second; if (ftInfo.m_status == FeatureStatus::Created && rect.IsPointInside(ftInfo.m_feature.GetCenter())) - f(FeatureID(id, index.first)); - } -} - -void Editor::ForEachFeatureInMwmRectAndScale(MwmSet::MwmId const & id, - TFeatureTypeFunctor const & f, - m2::RectD const & rect, - int /*scale*/) -{ - auto mwmFound = m_features.find(id); - if (mwmFound == m_features.end()) - return; - - // TODO(AlexZ): Check that features are visible at this scale. - // Process only new (created) features. - for (auto & index : mwmFound->second) - { - FeatureTypeInfo & ftInfo = index.second; - if (ftInfo.m_status == FeatureStatus::Created && - rect.IsPointInside(ftInfo.m_feature.GetCenter())) - f(ftInfo.m_feature); + f(index.first); } } diff --git a/editor/osm_editor.hpp b/editor/osm_editor.hpp index da215aa9d2..51236cdaee 100644 --- a/editor/osm_editor.hpp +++ b/editor/osm_editor.hpp @@ -92,16 +92,9 @@ public: void OnMapDeregistered(platform::LocalCountryFile const & localFile) override; - using TFeatureIDFunctor = function<void(FeatureID const &)>; - void ForEachFeatureInMwmRectAndScale(MwmSet::MwmId const & id, - TFeatureIDFunctor const & f, - m2::RectD const & rect, - int scale); - using TFeatureTypeFunctor = function<void(FeatureType &)>; - void ForEachFeatureInMwmRectAndScale(MwmSet::MwmId const & id, - TFeatureTypeFunctor const & f, - m2::RectD const & rect, - int scale); + using TFeatureIndexFunctor = function<void(uint32_t)>; + void ForEachFeatureInMwmRectAndScale(MwmSet::MwmId const & id, TFeatureIndexFunctor const & f, + m2::RectD const & rect, int scale); // TODO(mgsergio): Unify feature functions signatures. |