diff --git a/map/autoware_lanelet2_map_validator/autoware_requirement_set.json b/map/autoware_lanelet2_map_validator/autoware_requirement_set.json index 74185b48..4b8566f7 100644 --- a/map/autoware_lanelet2_map_validator/autoware_requirement_set.json +++ b/map/autoware_lanelet2_map_validator/autoware_requirement_set.json @@ -8,6 +8,14 @@ } ] }, + { + "id": "vm-03-01", + "validators": [ + { + "name": "mapping.intersection.intersection_area_dangling_reference" + } + ] + }, { "id": "vm-03-08", "validators": [ diff --git a/map/autoware_lanelet2_map_validator/src/validators/intersection/intersection_area_dangling_reference.cpp b/map/autoware_lanelet2_map_validator/src/validators/intersection/intersection_area_dangling_reference.cpp index 6fb9f45f..a3cbeb19 100644 --- a/map/autoware_lanelet2_map_validator/src/validators/intersection/intersection_area_dangling_reference.cpp +++ b/map/autoware_lanelet2_map_validator/src/validators/intersection/intersection_area_dangling_reference.cpp @@ -61,13 +61,6 @@ IntersectionAreaDanglingReferenceValidator::check_intersection_area_dangling_ref return id; }; - std::vector> intersection_with_area_lanelets; - for (const auto & lanelet : map.laneletLayer) { - if (const auto id_opt = is_intersection_with_area(lanelet); id_opt) { - intersection_with_area_lanelets.emplace_back(lanelet, id_opt.value()); - } - } - std::unordered_set intersection_area_ids; for (const auto & area : map.polygonLayer) { if ( @@ -77,15 +70,18 @@ IntersectionAreaDanglingReferenceValidator::check_intersection_area_dangling_ref } lanelet::validation::Issues issues; - for (const auto & [lanelet, intersection_area_id] : intersection_with_area_lanelets) { - if (intersection_area_ids.find(intersection_area_id) == intersection_area_ids.end()) { - issues.emplace_back( - lanelet::validation::Severity::Error, lanelet::validation::Primitive::Lanelet, lanelet.id(), - append_issue_code_prefix( - this->name(), 1, - "Lanelet of ID " + std::to_string(lanelet.id()) + - " has dangling reference to non-existing intersection area of ID " + - std::to_string(intersection_area_id))); + for (const auto & lanelet : map.laneletLayer) { + if (const auto id_opt = is_intersection_with_area(lanelet); id_opt) { + const auto id = id_opt.value(); + if (intersection_area_ids.find(id) == intersection_area_ids.end()) { + issues.emplace_back( + lanelet::validation::Severity::Error, lanelet::validation::Primitive::Lanelet, + lanelet.id(), + append_issue_code_prefix( + this->name(), 1, + "Dangling reference to non-existing intersection area of ID " + std::to_string(id) + + " is detected")); + } } } diff --git a/map/autoware_lanelet2_map_validator/test/src/test_intersection_area_dangling_reference.cpp b/map/autoware_lanelet2_map_validator/test/src/test_intersection_area_dangling_reference.cpp index 9103c90e..eafbe191 100644 --- a/map/autoware_lanelet2_map_validator/test/src/test_intersection_area_dangling_reference.cpp +++ b/map/autoware_lanelet2_map_validator/test/src/test_intersection_area_dangling_reference.cpp @@ -70,8 +70,8 @@ TEST_F(TestIntersectionAreaDanglingReferenceError, ValidateDanglingReference) / EXPECT_EQ(issues[0].primitive, lanelet::validation::Primitive::Lanelet); EXPECT_EQ( issues[0].message, - "[Intersection.IntersectionAreaDanglingReference-001] Lanelet of ID 53 has dangling " - "reference to non-existing intersection area of ID 777"); + "[Intersection.IntersectionAreaDanglingReference-001] Dangling " + "reference to non-existing intersection area of ID 777 is detected"); } TEST_F(TestIntersectionAreaDanglingReferenceOK, ValidIntersectionArea) // NOLINT for gtest