From 5d8f6d3e4cec36739c7406e9e2515abe1bad6d07 Mon Sep 17 00:00:00 2001 From: Mamoru Sobue Date: Wed, 20 Nov 2024 12:34:02 +0900 Subject: [PATCH] reflect comment Signed-off-by: Mamoru Sobue --- .../src/common/map_loader.cpp | 3 +-- .../src/common/validation.cpp | 10 ++++++---- .../include/lanelet2_map_validator/map_loader.hpp | 3 +-- .../src/include/lanelet2_map_validator/utils.hpp | 13 ++++++++++--- map/autoware_lanelet2_map_validator/src/main.cpp | 2 +- 5 files changed, 19 insertions(+), 12 deletions(-) diff --git a/map/autoware_lanelet2_map_validator/src/common/map_loader.cpp b/map/autoware_lanelet2_map_validator/src/common/map_loader.cpp index e7e9132c..018d9f32 100644 --- a/map/autoware_lanelet2_map_validator/src/common/map_loader.cpp +++ b/map/autoware_lanelet2_map_validator/src/common/map_loader.cpp @@ -47,8 +47,7 @@ std::unique_ptr getProjector( return nullptr; } -std::pair> -loadAndValidateMapLoad( +std::pair> validateMapLoad( const std::string & projector_type, const std::string & map_file, const lanelet::validation::ValidationConfig & val_config) { diff --git a/map/autoware_lanelet2_map_validator/src/common/validation.cpp b/map/autoware_lanelet2_map_validator/src/common/validation.cpp index 1ab2da0e..c728f4f0 100644 --- a/map/autoware_lanelet2_map_validator/src/common/validation.cpp +++ b/map/autoware_lanelet2_map_validator/src/common/validation.cpp @@ -306,13 +306,15 @@ void process_requirements( // Check prerequisites are OK const auto prerequisite_issues = check_prerequisite_completion(validators, validator_name); + appendIssues(total_issues, prerequisite_issues); + // NOTE: if prerequisite_issues is not empty, skip the content validation process const auto issues = prerequisite_issues.empty() - ? std::vector() - : apply_validation( + ? apply_validation( lanelet_map, replace_validator( - validator_config.command_line_config.validationConfig, validator_name)); + validator_config.command_line_config.validationConfig, validator_name)) + : std::vector(); // Add validation results to the json data json & validator_json = find_validator_block(json_data, validator_name); @@ -345,7 +347,7 @@ void process_requirements( } validator_json["issues"] = issues_json; } - appendIssues(total_issues, std::vector(issues)); + appendIssues(total_issues, issues); } // Show results diff --git a/map/autoware_lanelet2_map_validator/src/include/lanelet2_map_validator/map_loader.hpp b/map/autoware_lanelet2_map_validator/src/include/lanelet2_map_validator/map_loader.hpp index 3d70604d..9685d8c4 100644 --- a/map/autoware_lanelet2_map_validator/src/include/lanelet2_map_validator/map_loader.hpp +++ b/map/autoware_lanelet2_map_validator/src/include/lanelet2_map_validator/map_loader.hpp @@ -27,8 +27,7 @@ namespace lanelet::autoware::validation { -std::pair> -loadAndValidateMapLoad( +std::pair> validateMapLoad( const std::string & projector_type, const std::string & map_file, const lanelet::validation::ValidationConfig & val_config); diff --git a/map/autoware_lanelet2_map_validator/src/include/lanelet2_map_validator/utils.hpp b/map/autoware_lanelet2_map_validator/src/include/lanelet2_map_validator/utils.hpp index 775a9831..fb66a578 100644 --- a/map/autoware_lanelet2_map_validator/src/include/lanelet2_map_validator/utils.hpp +++ b/map/autoware_lanelet2_map_validator/src/include/lanelet2_map_validator/utils.hpp @@ -19,6 +19,7 @@ #include #include +#include #include namespace lanelet @@ -27,10 +28,16 @@ namespace autoware { namespace validation { -template -void appendIssues(std::vector & to, std::vector && from) +template +auto appendIssues(std::vector & to, Container && from) -> + typename std::enable_if_t::value_type>, void> { - to.insert(to.end(), std::make_move_iterator(from.begin()), std::make_move_iterator(from.end())); + if constexpr (std::is_rvalue_reference::value) { + to.insert(to.end(), std::make_move_iterator(from.begin()), std::make_move_iterator(from.end())); + } + if constexpr (std::is_lvalue_reference::value) { + to.insert(to.end(), from.begin(), from.end()); + } } template diff --git a/map/autoware_lanelet2_map_validator/src/main.cpp b/map/autoware_lanelet2_map_validator/src/main.cpp index 5f92c7c5..c5d3d724 100644 --- a/map/autoware_lanelet2_map_validator/src/main.cpp +++ b/map/autoware_lanelet2_map_validator/src/main.cpp @@ -58,7 +58,7 @@ int main(int argc, char * argv[]) if (!std::filesystem::is_regular_file(meta_config.command_line_config.mapFile)) { throw std::invalid_argument("Map file doesn't exist or is not a file!"); } - const auto [lanelet_map_ptr, map_issue] = lanelet::autoware::validation::loadAndValidateMapLoad( + const auto [lanelet_map_ptr, map_issue] = lanelet::autoware::validation::validateMapLoad( meta_config.projector_type, meta_config.command_line_config.mapFile, meta_config.command_line_config.validationConfig);