Skip to content

Commit

Permalink
reflect comment
Browse files Browse the repository at this point in the history
Signed-off-by: Mamoru Sobue <[email protected]>
  • Loading branch information
soblin committed Nov 20, 2024
1 parent 5988d6b commit 5d8f6d3
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,7 @@ std::unique_ptr<lanelet::Projector> getProjector(
return nullptr;
}

std::pair<lanelet::LaneletMapPtr, std::vector<lanelet::validation::DetectedIssues>>
loadAndValidateMapLoad(
std::pair<lanelet::LaneletMapPtr, std::vector<lanelet::validation::DetectedIssues>> validateMapLoad(
const std::string & projector_type, const std::string & map_file,
const lanelet::validation::ValidationConfig & val_config)
{
Expand Down
10 changes: 6 additions & 4 deletions map/autoware_lanelet2_map_validator/src/common/validation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<lanelet::validation::DetectedIssues>()
: 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<lanelet::validation::DetectedIssues>();

// Add validation results to the json data
json & validator_json = find_validator_block(json_data, validator_name);
Expand Down Expand Up @@ -345,7 +347,7 @@ void process_requirements(
}
validator_json["issues"] = issues_json;
}
appendIssues(total_issues, std::vector<lanelet::validation::DetectedIssues>(issues));
appendIssues(total_issues, issues);
}

// Show results
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@
namespace lanelet::autoware::validation
{

std::pair<lanelet::LaneletMapPtr, std::vector<lanelet::validation::DetectedIssues>>
loadAndValidateMapLoad(
std::pair<lanelet::LaneletMapPtr, std::vector<lanelet::validation::DetectedIssues>> validateMapLoad(
const std::string & projector_type, const std::string & map_file,
const lanelet::validation::ValidationConfig & val_config);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include <lanelet2_validation/ValidatorFactory.h>

#include <string>
#include <type_traits>
#include <vector>

namespace lanelet
Expand All @@ -27,10 +28,16 @@ namespace autoware
{
namespace validation
{
template <typename T>
void appendIssues(std::vector<T> & to, std::vector<T> && from)
template <typename Container, typename T>
auto appendIssues(std::vector<T> & to, Container && from) ->
typename std::enable_if_t<std::is_same_v<T, typename std::decay_t<Container>::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<decltype(from)>::value) {
to.insert(to.end(), std::make_move_iterator(from.begin()), std::make_move_iterator(from.end()));
}
if constexpr (std::is_lvalue_reference<decltype(from)>::value) {
to.insert(to.end(), from.begin(), from.end());
}
}

template <typename T>
Expand Down
2 changes: 1 addition & 1 deletion map/autoware_lanelet2_map_validator/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit 5d8f6d3

Please sign in to comment.