From 1a077ae44ecaa012463c51c325bfaea092892e3a Mon Sep 17 00:00:00 2001 From: TaikiYamada4 Date: Thu, 5 Dec 2024 10:17:45 +0900 Subject: [PATCH] Use findUsages in missing_referrers_for_traffic_lights Signed-off-by: TaikiYamada4 --- .../missing_referrers_for_traffic_lights.hpp | 11 ----------- .../missing_referrers_for_traffic_lights.cpp | 19 ++----------------- 2 files changed, 2 insertions(+), 28 deletions(-) diff --git a/map/autoware_lanelet2_map_validator/src/include/lanelet2_map_validator/validators/traffic_light/missing_referrers_for_traffic_lights.hpp b/map/autoware_lanelet2_map_validator/src/include/lanelet2_map_validator/validators/traffic_light/missing_referrers_for_traffic_lights.hpp index c7ebe527..0061e29a 100644 --- a/map/autoware_lanelet2_map_validator/src/include/lanelet2_map_validator/validators/traffic_light/missing_referrers_for_traffic_lights.hpp +++ b/map/autoware_lanelet2_map_validator/src/include/lanelet2_map_validator/validators/traffic_light/missing_referrers_for_traffic_lights.hpp @@ -36,17 +36,6 @@ class MissingReferrersForTrafficLightsValidator : public lanelet::validation::Ma */ lanelet::validation::Issues check_missing_referrers_for_traffic_lights( const lanelet::LaneletMap & map); - - /** - * @brief Returns lanelets that refers the regulatory element specified by the input id - * from the input lanelet map. - * - * @param map - * @param reg_elem_id - * @return lanelet::ConstLanelets - */ - lanelet::ConstLanelets collect_referring_lanelets( - const lanelet::LaneletMap & map, const lanelet::Id reg_elem_id); }; } // namespace lanelet::autoware::validation diff --git a/map/autoware_lanelet2_map_validator/src/validators/traffic_light/missing_referrers_for_traffic_lights.cpp b/map/autoware_lanelet2_map_validator/src/validators/traffic_light/missing_referrers_for_traffic_lights.cpp index 84281bb7..6245277e 100644 --- a/map/autoware_lanelet2_map_validator/src/validators/traffic_light/missing_referrers_for_traffic_lights.cpp +++ b/map/autoware_lanelet2_map_validator/src/validators/traffic_light/missing_referrers_for_traffic_lights.cpp @@ -51,8 +51,8 @@ MissingReferrersForTrafficLightsValidator::check_missing_referrers_for_traffic_l } // At least one lanelet should refer a traffic_light regulatory element - const lanelet::ConstLanelets referring_lanelets = - collect_referring_lanelets(map, reg_elem->id()); + const lanelet::ConstLanelets referring_lanelets = map.laneletLayer.findUsages(reg_elem); + if (referring_lanelets.size() == 0) { issues.emplace_back( lanelet::validation::Severity::Error, lanelet::validation::Primitive::RegulatoryElement, @@ -66,19 +66,4 @@ MissingReferrersForTrafficLightsValidator::check_missing_referrers_for_traffic_l return issues; } - -lanelet::ConstLanelets MissingReferrersForTrafficLightsValidator::collect_referring_lanelets( - const lanelet::LaneletMap & map, const lanelet::Id target_reg_elem_id) -{ - lanelet::ConstLanelets lanelet_group; - for (const lanelet::ConstLanelet & lanelet : map.laneletLayer) { - for (lanelet::RegulatoryElementConstPtr reg_elem : lanelet.regulatoryElements()) { - if (reg_elem->id() == target_reg_elem_id) { - lanelet_group.push_back(lanelet); - } - } - } - return lanelet_group; -} - } // namespace lanelet::autoware::validation