From 57aabff7af77e0ee6bf3ae2804733deb5aa29d4d Mon Sep 17 00:00:00 2001 From: Viktor Govako Date: Tue, 14 Nov 2023 22:01:47 -0300 Subject: [PATCH] [generator] Process barrier=* for Relation -> Way. Signed-off-by: Viktor Govako --- data/osm_test_data/fence_relation.osm | 75 +++++++++++++++++++ .../generator_tests/raw_generator_test.cpp | 21 ++++++ generator/relation_tags.cpp | 14 +++- 3 files changed, 106 insertions(+), 4 deletions(-) create mode 100644 data/osm_test_data/fence_relation.osm diff --git a/data/osm_test_data/fence_relation.osm b/data/osm_test_data/fence_relation.osm new file mode 100644 index 0000000000..4cbf04e5c9 --- /dev/null +++ b/data/osm_test_data/fence_relation.osm @@ -0,0 +1,75 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/generator/generator_tests/raw_generator_test.cpp b/generator/generator_tests/raw_generator_test.cpp index a68a7a491d..a4224d73f3 100644 --- a/generator/generator_tests/raw_generator_test.cpp +++ b/generator/generator_tests/raw_generator_test.cpp @@ -645,4 +645,25 @@ UNIT_CLASS_TEST(TestRawGenerator, Place_NoCityBoundaries) TEST(table.Load(), ()); TEST_EQUAL(table.GetSize(), 0, ()); } + +UNIT_CLASS_TEST(TestRawGenerator, Relation_Fence) +{ + std::string const mwmName = "Fences"; + + BuildFB("./data/osm_test_data/fence_relation.osm", mwmName); + + uint32_t const fenceType = classif().GetTypeByPath({"barrier", "fence"}); + + size_t count = 0; + ForEachFB(mwmName, [&](feature::FeatureBuilder const & fb) + { + if (fb.GetGeomType() == feature::GeomType::Line) + { + ++count; + TEST(fb.HasType(fenceType), ()); + } + }); + TEST_EQUAL(count, 2, ()); +} + } // namespace raw_generator_tests diff --git a/generator/relation_tags.cpp b/generator/relation_tags.cpp index bca232106b..0d6c6b8cab 100644 --- a/generator/relation_tags.cpp +++ b/generator/relation_tags.cpp @@ -51,8 +51,7 @@ void RelationTagsNode::Process(RelationElement const & e) // - used in routing information // - used in building addresses matching if (p.first == "network" || p.first == "operator" || p.first == "route" || - p.first == "maxspeed" || - strings::StartsWith(p.first, "addr:")) + p.first == "maxspeed" || strings::StartsWith(p.first, "addr:")) { if (!Base::IsKeyTagExists(p.first)) Base::AddCustomTag(p); @@ -79,12 +78,19 @@ bool RelationTagsWay::IsAcceptBoundary(RelationElement const & e) const void RelationTagsWay::Process(RelationElement const & e) { - /// @todo Review route relations in future. - /// Actually, now they give a lot of dummy tags. + // https://github.com/organicmaps/organicmaps/issues/4051 + /// @todo We skip useful Linear tags. Put workaround now and review *all* this logic in future! + /// Should parse classifier types for Relations separately and combine classifier types + /// with Nodes and Ways, according to the drule's geometry type. + auto const barrier = e.GetTagValue("barrier"); + if (!barrier.empty()) + Base::AddCustomTag({"barrier", std::string(barrier)}); + auto const type = e.GetType(); if (Base::IsSkipRelation(type)) return; + /// @todo Review route relations in future. Actually, now they give a lot of dummy tags. if (type == "route") { if (e.GetTagValue("route") == "road")