diff --git a/generator/generator_tests_support/test_feature.cpp b/generator/generator_tests_support/test_feature.cpp index eaaebc0d46..bf645e3735 100644 --- a/generator/generator_tests_support/test_feature.cpp +++ b/generator/generator_tests_support/test_feature.cpp @@ -167,22 +167,21 @@ TestPOI::TestPOI(m2::PointD const & center, string const & name, string const & } // static -TestPOI TestPOI::AddWithEditor(osm::Editor & editor, MwmSet::MwmId const & mwmId, - string const & name, m2::PointD const & pt, FeatureID & tmp) +pair TestPOI::AddWithEditor(osm::Editor & editor, MwmSet::MwmId const & mwmId, + string const & enName, m2::PointD const & pt) { - TestPOI poi(pt, name, "en"); + TestPOI poi(pt, enName, "en"); osm::EditableMapObject emo; editor.CreatePoint(classif().GetTypeByPath({"shop", "bakery"}), pt, mwmId, emo); StringUtf8Multilang names; - names.AddString(StringUtf8Multilang::GetLangIndex("en"), name); + names.AddString(StringUtf8Multilang::GetLangIndex("en"), enName); emo.SetName(names); emo.SetTestId(poi.GetId()); editor.SaveEditedFeature(emo); - tmp = emo.GetID(); - return poi; + return {poi, emo.GetID()}; } void TestPOI::Serialize(FeatureBuilder1 & fb) const diff --git a/generator/generator_tests_support/test_feature.hpp b/generator/generator_tests_support/test_feature.hpp index b617c2e796..2c5af1e267 100644 --- a/generator/generator_tests_support/test_feature.hpp +++ b/generator/generator_tests_support/test_feature.hpp @@ -6,6 +6,7 @@ #include "geometry/point2d.hpp" #include "std/string.hpp" +#include "std/utility.hpp" #include "std/vector.hpp" class FeatureBuilder1; @@ -14,7 +15,7 @@ class FeatureType; namespace osm { class Editor; -} // namespace osm +} namespace generator { @@ -99,8 +100,8 @@ class TestPOI : public TestFeature public: TestPOI(m2::PointD const & center, string const & name, string const & lang); - static TestPOI AddWithEditor(osm::Editor & editor, MwmSet::MwmId const & mwmId, - string const & name, m2::PointD const & pt, FeatureID & tmp); + static pair AddWithEditor(osm::Editor & editor, MwmSet::MwmId const & mwmId, + string const & enName, m2::PointD const & pt); // TestFeature overrides: void Serialize(FeatureBuilder1 & fb) const override; diff --git a/indexer/editable_map_object.cpp b/indexer/editable_map_object.cpp index 0af0c72c95..800e8bb41c 100644 --- a/indexer/editable_map_object.cpp +++ b/indexer/editable_map_object.cpp @@ -293,6 +293,13 @@ uint64_t EditableMapObject::GetTestId() const return id; } +void EditableMapObject::SetTestId(uint64_t id) +{ + ostringstream oss; + oss << id; + m_metadata.Set(feature::Metadata::FMD_TEST_ID, oss.str()); +} + void EditableMapObject::SetEditableProperties(osm::EditableProperties const & props) { m_editableProperties = props; @@ -506,13 +513,6 @@ void EditableMapObject::SetOpeningHours(string const & openingHours) m_metadata.Set(feature::Metadata::FMD_OPEN_HOURS, openingHours); } -void EditableMapObject::SetTestId(uint64_t const & id) -{ - ostringstream oss; - oss << id; - m_metadata.Set(feature::Metadata::FMD_TEST_ID, oss.str()); -} - void EditableMapObject::SetPointType() { m_geomType = feature::EGeomType::GEOM_POINT; } diff --git a/indexer/editable_map_object.hpp b/indexer/editable_map_object.hpp index d003fa8894..feaefc4619 100644 --- a/indexer/editable_map_object.hpp +++ b/indexer/editable_map_object.hpp @@ -109,7 +109,10 @@ public: string const & GetHouseNumber() const; string GetPostcode() const; string GetWikipedia() const; + + // These two methods should only be used in tests. uint64_t GetTestId() const; + void SetTestId(uint64_t id); void SetEditableProperties(osm::EditableProperties const & props); // void SetFeatureID(FeatureID const & fid); @@ -143,8 +146,6 @@ public: void SetCuisines(vector const & cuisine); void SetOpeningHours(string const & openingHours); - void SetTestId(uint64_t const & id); - /// Special mark that it's a point feature, not area or line. void SetPointType(); /// Enables advanced mode with direct access to default name and disables any recalculations. diff --git a/indexer/indexer_tests/osm_editor_test.cpp b/indexer/indexer_tests/osm_editor_test.cpp index ea9b54685f..27534b0c51 100644 --- a/indexer/indexer_tests/osm_editor_test.cpp +++ b/indexer/indexer_tests/osm_editor_test.cpp @@ -167,7 +167,7 @@ void EditorTest::GetFeatureTypeInfoTest() auto const mwmId = ConstructTestMwm([](TestMwmBuilder & builder) { TestCafe cafe(m2::PointD(1.0, 1.0), "London Cafe", "en"); - builder.Add(cafe); + builder.Add(cafe); }); ForEachCafeAtPoint(m_index, m2::PointD(1.0, 1.0), [&editor, &mwmId](FeatureType & ft) diff --git a/indexer/osm_editor.cpp b/indexer/osm_editor.cpp index 64b650f894..1f2681caa8 100644 --- a/indexer/osm_editor.cpp +++ b/indexer/osm_editor.cpp @@ -1054,8 +1054,11 @@ FeatureID Editor::GenerateNewFeatureId(MwmSet::MwmId const & id) bool Editor::CreatePoint(uint32_t type, m2::PointD const & mercator, MwmSet::MwmId const & id, EditableMapObject & outFeature) { ASSERT(id.IsAlive(), ("Please check that feature is created in valid MWM file before calling this method.")); - CHECK(id.GetInfo()->m_limitRect.IsPointInside(mercator), - ("Attempt to create a feature outside of the MWM's bounding box.")); + if (!id.GetInfo()->m_limitRect.IsPointInside(mercator)) + { + LOG(LERROR, ("Attempt to create a feature outside of the MWM's bounding box.")); + return false; + } outFeature.SetMercator(mercator); outFeature.SetID(GenerateNewFeatureId(id)); outFeature.SetType(type); diff --git a/search/search_integration_tests/search_edited_features_test.cpp b/search/search_integration_tests/search_edited_features_test.cpp index a4f4014fa1..003ecb2c08 100644 --- a/search/search_integration_tests/search_edited_features_test.cpp +++ b/search/search_integration_tests/search_edited_features_test.cpp @@ -74,10 +74,16 @@ UNIT_CLASS_TEST(SearchEditedFeaturesTest, SearchInViewport) builder.Add(cornerPost); }); - FeatureID id1, id2, id3; - auto bakery1 = TestPOI::AddWithEditor(editor, countryId, "bakery1", {1.0, 1.0}, id1); - auto bakery2 = TestPOI::AddWithEditor(editor, countryId, "bakery2", {2.0, 2.0}, id2); - auto bakery3 = TestPOI::AddWithEditor(editor, countryId, "bakery3", {3.0, 3.0}, id3); + auto const tmp1 = TestPOI::AddWithEditor(editor, countryId, "bakery1", {1.0, 1.0}); + TestPOI const & bakery1 = tmp1.first; + FeatureID const & id1 = tmp1.second; + auto const tmp2 = TestPOI::AddWithEditor(editor, countryId, "bakery2", {2.0, 2.0}); + TestPOI const & bakery2 = tmp2.first; + FeatureID const & id2 = tmp2.second; + auto const tmp3 = TestPOI::AddWithEditor(editor, countryId, "bakery3", {3.0, 3.0}); + TestPOI const & bakery3 = tmp3.first; + FeatureID const & id3 = tmp3.second; + UNUSED_VALUE(id2); SetViewport(m2::RectD(-1.0, -1.0, 4.0, 4.0)); { diff --git a/search/search_tests_support/test_results_matching.cpp b/search/search_tests_support/test_results_matching.cpp index 34d8a3e1b9..ccbfa55b7f 100644 --- a/search/search_tests_support/test_results_matching.cpp +++ b/search/search_tests_support/test_results_matching.cpp @@ -13,7 +13,7 @@ namespace search { namespace tests_support { -ExactMatchingRule::ExactMatchingRule(MwmSet::MwmId const & mwmId, TestFeature & feature) +ExactMatchingRule::ExactMatchingRule(MwmSet::MwmId const & mwmId, TestFeature const & feature) : m_mwmId(mwmId), m_feature(feature) { } diff --git a/search/search_tests_support/test_results_matching.hpp b/search/search_tests_support/test_results_matching.hpp index 24505d369e..3a776d48ca 100644 --- a/search/search_tests_support/test_results_matching.hpp +++ b/search/search_tests_support/test_results_matching.hpp @@ -35,7 +35,8 @@ public: class ExactMatchingRule : public MatchingRule { public: - ExactMatchingRule(MwmSet::MwmId const & mwmId, generator::tests_support::TestFeature & feature); + ExactMatchingRule(MwmSet::MwmId const & mwmId, + generator::tests_support::TestFeature const & feature); // MatchingRule overrides: bool Matches(FeatureType const & feature) const override; @@ -43,7 +44,7 @@ public: private: MwmSet::MwmId m_mwmId; - generator::tests_support::TestFeature & m_feature; + generator::tests_support::TestFeature const & m_feature; }; class AlternativesMatchingRule : public MatchingRule