Skip to content

Commit

Permalink
refactor(lanelet2_map_validator): move headers to include/
Browse files Browse the repository at this point in the history
Signed-off-by: Mamoru Sobue <[email protected]>
  • Loading branch information
soblin committed Nov 5, 2024
1 parent 3c33924 commit 369ac54
Show file tree
Hide file tree
Showing 19 changed files with 85 additions and 66 deletions.
3 changes: 2 additions & 1 deletion map/autoware_lanelet2_map_validator/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ ament_auto_find_build_dependencies()
find_package(nlohmann_json REQUIRED)

include_directories(
src
include
)

file(GLOB_RECURSE autoware_lanelet2_map_validator_lib_src
Expand All @@ -32,6 +32,7 @@ if(BUILD_TESTING)
${VALIDATION_NAME}_test
test/src/test_${VALIDATION_NAME}.cpp
)
target_include_directories(${VALIDATION_NAME}_test PUBLIC include)
target_link_libraries(
${VALIDATION_NAME}_test
autoware_lanelet2_map_validator_lib
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#ifndef COMMON__CLI_HPP_
#define COMMON__CLI_HPP_
#ifndef LANELET2_MAP_VALIDATOR__CLI_HPP_
#define LANELET2_MAP_VALIDATOR__CLI_HPP_

#include <boost/program_options.hpp>

Expand Down Expand Up @@ -42,4 +42,4 @@ MetaConfig parseCommandLine(int argc, const char * argv[]);
} // namespace autoware
} // namespace lanelet

#endif // COMMON__CLI_HPP_
#endif // LANELET2_MAP_VALIDATOR__CLI_HPP_
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#ifndef COMMON__UTILS_HPP_
#define COMMON__UTILS_HPP_
#ifndef LANELET2_MAP_VALIDATOR__UTILS_HPP_
#define LANELET2_MAP_VALIDATOR__UTILS_HPP_

#include <lanelet2_validation/Validation.h>
#include <lanelet2_validation/ValidatorFactory.h>
Expand Down Expand Up @@ -80,4 +80,4 @@ void checkPrimitivesType(
} // namespace autoware
} // namespace lanelet

#endif // COMMON__UTILS_HPP_
#endif // LANELET2_MAP_VALIDATOR__UTILS_HPP_
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#ifndef COMMON__VALIDATION_HPP_
#define COMMON__VALIDATION_HPP_
#ifndef LANELET2_MAP_VALIDATOR__VALIDATION_HPP_
#define LANELET2_MAP_VALIDATOR__VALIDATION_HPP_

#include "common/cli.hpp"
#include "common/utils.hpp"
#include "lanelet2_map_validator/cli.hpp"
#include "lanelet2_map_validator/utils.hpp"

#include <lanelet2_io/Io.h>
#include <lanelet2_projection/UTM.h>
Expand All @@ -25,6 +25,7 @@

#include <memory>
#include <regex>
#include <string>
#include <vector>

namespace
Expand All @@ -43,10 +44,13 @@ namespace autoware
{
namespace validation
{
std::unique_ptr<lanelet::Projector> getProjector(const MetaConfig & config);
std::vector<lanelet::validation::DetectedIssues> validateMap(const MetaConfig & config);
std::unique_ptr<lanelet::Projector> getProjector(
const std::string & projector_type, const lanelet::GPSPoint & origin);
std::vector<lanelet::validation::DetectedIssues> validateMap(
const std::string & projector_type, const std::string & map_file,
const lanelet::validation::ValidationConfig & val_config);
} // namespace validation
} // namespace autoware
} // namespace lanelet

#endif // COMMON__VALIDATION_HPP_
#endif // LANELET2_MAP_VALIDATOR__VALIDATION_HPP_
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#ifndef VALIDATORS__CROSSWALK__MISSING_REGULATORY_ELEMENTS_FOR_CROSSWALKS_HPP_
#define VALIDATORS__CROSSWALK__MISSING_REGULATORY_ELEMENTS_FOR_CROSSWALKS_HPP_
#ifndef LANELET2_MAP_VALIDATOR__VALIDATORS__CROSSWALK__MISSING_REGULATORY_ELEMENTS_FOR_CROSSWALKS_HPP_ // NOLINT
#define LANELET2_MAP_VALIDATOR__VALIDATORS__CROSSWALK__MISSING_REGULATORY_ELEMENTS_FOR_CROSSWALKS_HPP_ // NOLINT

#include <lanelet2_validation/Validation.h>
#include <lanelet2_validation/ValidatorFactory.h>
Expand All @@ -36,4 +36,6 @@ class MissingRegulatoryElementsForCrosswalksValidator : public lanelet::validati
} // namespace validation
} // namespace lanelet

#endif // VALIDATORS__CROSSWALK__MISSING_REGULATORY_ELEMENTS_FOR_CROSSWALKS_HPP_
// clang-format off
#endif // LANELET2_MAP_VALIDATOR__VALIDATORS__CROSSWALK__MISSING_REGULATORY_ELEMENTS_FOR_CROSSWALKS_HPP_ // NOLINT
// clang-format on
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#ifndef VALIDATORS__CROSSWALK__REGULATORY_ELEMENT_DETAILS_FOR_CROSSWALKS_HPP_
#define VALIDATORS__CROSSWALK__REGULATORY_ELEMENT_DETAILS_FOR_CROSSWALKS_HPP_
#ifndef LANELET2_MAP_VALIDATOR__VALIDATORS__CROSSWALK__REGULATORY_ELEMENT_DETAILS_FOR_CROSSWALKS_HPP_ // NOLINT
#define LANELET2_MAP_VALIDATOR__VALIDATORS__CROSSWALK__REGULATORY_ELEMENT_DETAILS_FOR_CROSSWALKS_HPP_ // NOLINT

#include <lanelet2_validation/Validation.h>
#include <lanelet2_validation/ValidatorFactory.h>
Expand All @@ -36,4 +36,6 @@ class RegulatoryElementsDetailsForCrosswalksValidator : public lanelet::validati
} // namespace validation
} // namespace lanelet

#endif // VALIDATORS__CROSSWALK__REGULATORY_ELEMENT_DETAILS_FOR_CROSSWALKS_HPP_
// clang-format off
#endif // LANELET2_MAP_VALIDATOR__VALIDATORS__CROSSWALK__REGULATORY_ELEMENT_DETAILS_FOR_CROSSWALKS_HPP_ // NOLINT
// clang-format on
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#ifndef VALIDATORS__STOP_LINE__MISSING_REGULATORY_ELEMENTS_FOR_STOP_LINES_HPP_
#define VALIDATORS__STOP_LINE__MISSING_REGULATORY_ELEMENTS_FOR_STOP_LINES_HPP_
#ifndef LANELET2_MAP_VALIDATOR__VALIDATORS__STOP_LINE__MISSING_REGULATORY_ELEMENTS_FOR_STOP_LINES_HPP_ // NOLINT
#define LANELET2_MAP_VALIDATOR__VALIDATORS__STOP_LINE__MISSING_REGULATORY_ELEMENTS_FOR_STOP_LINES_HPP_ // NOLINT

#include <lanelet2_validation/Validation.h>
#include <lanelet2_validation/ValidatorFactory.h>
Expand All @@ -36,4 +36,6 @@ class MissingRegulatoryElementsForStopLinesValidator : public lanelet::validatio
} // namespace validation
} // namespace lanelet

#endif // VALIDATORS__STOP_LINE__MISSING_REGULATORY_ELEMENTS_FOR_STOP_LINES_HPP_
// clang-format off
#endif // LANELET2_MAP_VALIDATOR__VALIDATORS__STOP_LINE__MISSING_REGULATORY_ELEMENTS_FOR_STOP_LINES_HPP_ // NOLINT
// clang-format on
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#ifndef VALIDATORS__TRAFFIC_LIGHT__MISSING_REGULATORY_ELEMENTS_FOR_TRAFFIC_LIGHTS_HPP_
#define VALIDATORS__TRAFFIC_LIGHT__MISSING_REGULATORY_ELEMENTS_FOR_TRAFFIC_LIGHTS_HPP_
#ifndef LANELET2_MAP_VALIDATOR__VALIDATORS__TRAFFIC_LIGHT__MISSING_REGULATORY_ELEMENTS_FOR_TRAFFIC_LIGHTS_HPP_ // NOLINT
#define LANELET2_MAP_VALIDATOR__VALIDATORS__TRAFFIC_LIGHT__MISSING_REGULATORY_ELEMENTS_FOR_TRAFFIC_LIGHTS_HPP_ // NOLINT

#include <lanelet2_validation/Validation.h>
#include <lanelet2_validation/ValidatorFactory.h>
Expand All @@ -39,4 +39,6 @@ class MissingRegulatoryElementsForTrafficLightsValidator : public lanelet::valid
} // namespace validation
} // namespace lanelet

#endif // VALIDATORS__TRAFFIC_LIGHT__MISSING_REGULATORY_ELEMENTS_FOR_TRAFFIC_LIGHTS_HPP_
// clang-format off
#endif // LANELET2_MAP_VALIDATOR__VALIDATORS__TRAFFIC_LIGHT__MISSING_REGULATORY_ELEMENTS_FOR_TRAFFIC_LIGHTS_HPP_ // NOLINT
// clang-format on
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#ifndef VALIDATORS__TRAFFIC_LIGHT__REGULATORY_ELEMENT_DETAILS_FOR_TRAFFIC_LIGHTS_HPP_
#define VALIDATORS__TRAFFIC_LIGHT__REGULATORY_ELEMENT_DETAILS_FOR_TRAFFIC_LIGHTS_HPP_
#ifndef LANELET2_MAP_VALIDATOR__VALIDATORS__TRAFFIC_LIGHT__REGULATORY_ELEMENT_DETAILS_FOR_TRAFFIC_LIGHTS_HPP_ // NOLINT
#define LANELET2_MAP_VALIDATOR__VALIDATORS__TRAFFIC_LIGHT__REGULATORY_ELEMENT_DETAILS_FOR_TRAFFIC_LIGHTS_HPP_ // NOLINT

#include <lanelet2_validation/Validation.h>
#include <lanelet2_validation/ValidatorFactory.h>
Expand Down Expand Up @@ -43,4 +43,6 @@ class RegulatoryElementsDetailsForTrafficLightsValidator : public lanelet::valid
} // namespace validation
} // namespace lanelet

#endif // VALIDATORS__TRAFFIC_LIGHT__REGULATORY_ELEMENT_DETAILS_FOR_TRAFFIC_LIGHTS_HPP_
// clang-format off
#endif // LANELET2_MAP_VALIDATOR__VALIDATORS__TRAFFIC_LIGHT__REGULATORY_ELEMENT_DETAILS_FOR_TRAFFIC_LIGHTS_HPP_ // NOLINT
// clang-format on
2 changes: 1 addition & 1 deletion map/autoware_lanelet2_map_validator/src/common/cli.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#include "common/cli.hpp"
#include "lanelet2_map_validator/cli.hpp"

namespace po = boost::program_options;

Expand Down
29 changes: 14 additions & 15 deletions map/autoware_lanelet2_map_validator/src/common/validation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#include "common/validation.hpp"
#include "lanelet2_map_validator/validation.hpp"

#include <autoware_lanelet2_extension/projection/mgrs_projector.hpp>
#include <autoware_lanelet2_extension/projection/transverse_mercator_projector.hpp>
Expand All @@ -27,31 +27,30 @@ namespace autoware
namespace validation
{

std::unique_ptr<lanelet::Projector> getProjector(const MetaConfig & config)
std::unique_ptr<lanelet::Projector> getProjector(
const std::string & projector_type, const lanelet::GPSPoint & origin)
{
const auto & val_config = config.command_line_config.validationConfig;
if (config.projector_type == projector_names::mgrs) {
if (projector_type == projector_names::mgrs) {
return std::make_unique<lanelet::projection::MGRSProjector>();
} else if (config.projector_type == projector_names::transverse_mercator) {
} else if (projector_type == projector_names::transverse_mercator) {
return std::make_unique<lanelet::projection::TransverseMercatorProjector>(
lanelet::Origin{val_config.origin});
} else if (config.projector_type == projector_names::utm) {
return std::make_unique<lanelet::projection::UtmProjector>(lanelet::Origin{val_config.origin});
lanelet::Origin{origin});
} else if (projector_type == projector_names::utm) {
return std::make_unique<lanelet::projection::UtmProjector>(lanelet::Origin{origin});
}
return std::make_unique<lanelet::projection::MGRSProjector>();
return nullptr;
}

std::vector<lanelet::validation::DetectedIssues> validateMap(const MetaConfig & config)
std::vector<lanelet::validation::DetectedIssues> validateMap(
const std::string & projector_type, const std::string & map_file,
const lanelet::validation::ValidationConfig & val_config)
{
const auto & cm_config = config.command_line_config;
const auto & val_config = config.command_line_config.validationConfig;

std::vector<lanelet::validation::DetectedIssues> issues;
lanelet::LaneletMapPtr map;
lanelet::validation::Strings errors;
try {
const auto & projector = getProjector(config);
map = lanelet::load(cm_config.mapFile, *projector, &errors);
const auto & projector = getProjector(projector_type, val_config.origin);
map = lanelet::load(map_file, *projector, &errors);
if (!errors.empty()) {
issues.emplace_back("general", utils::transform(errors, [](auto & error) {
return lanelet::validation::Issue(
Expand Down
17 changes: 11 additions & 6 deletions map/autoware_lanelet2_map_validator/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,14 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#include "common/cli.hpp"
#include "common/utils.hpp"
#include "common/validation.hpp"
#include "lanelet2_validation/Validation.h"
#include "lanelet2_map_validator/cli.hpp"
#include "lanelet2_map_validator/utils.hpp"
#include "lanelet2_map_validator/validation.hpp"

#include <nlohmann/json.hpp>

#include <lanelet2_validation/Validation.h>

#include <filesystem>
#include <fstream>
#include <iomanip>
Expand Down Expand Up @@ -54,7 +55,9 @@ void process_requirements(
temp_validator_config.command_line_config.validationConfig.checksFilter = validator_name;

std::vector<lanelet::validation::DetectedIssues> temp_issues =
lanelet::autoware::validation::validateMap(temp_validator_config);
lanelet::autoware::validation::validateMap(
validator_config.projector_type, validator_config.command_line_config.mapFile,
validator_config.command_line_config.validationConfig);

if (temp_issues.empty()) {
// Validator passed
Expand Down Expand Up @@ -176,7 +179,9 @@ int main(int argc, char * argv[])
input_file >> json_config;
process_requirements(json_config, meta_config);
} else {
auto issues = lanelet::autoware::validation::validateMap(meta_config);
auto issues = lanelet::autoware::validation::validateMap(
meta_config.projector_type, meta_config.command_line_config.mapFile,
meta_config.command_line_config.validationConfig);
lanelet::validation::printAllIssues(issues);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#include "common/utils.hpp"
#include "validators/crosswalk/missing_regulatory_elements_for_crosswalks.hpp"
#include "lanelet2_map_validator/utils.hpp"
#include "lanelet2_map_validator/validators/crosswalk/missing_regulatory_elements_for_crosswalks.hpp"

#include <range/v3/view/filter.hpp>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#include "validators/crosswalk/regulatory_element_details_for_crosswalks.hpp"
#include "lanelet2_map_validator/validators/crosswalk/regulatory_element_details_for_crosswalks.hpp"

#include "common/utils.hpp"
#include "lanelet2_map_validator/utils.hpp"

#include <autoware_lanelet2_extension/regulatory_elements/crosswalk.hpp>
#include <range/v3/view/filter.hpp>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#include "validators/stop_line/missing_regulatory_elements_for_stop_lines.hpp"
#include "lanelet2_map_validator/validators/stop_line/missing_regulatory_elements_for_stop_lines.hpp"

#include "common/utils.hpp"
#include "lanelet2_map_validator/utils.hpp"

#include <range/v3/view/filter.hpp>
#include <range/v3/view/transform.hpp>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#include "validators/traffic_light/missing_regulatory_elements_for_traffic_lights.hpp"
#include "lanelet2_map_validator/validators/traffic_light/missing_regulatory_elements_for_traffic_lights.hpp"

#include "common/utils.hpp"
#include "lanelet2_map_validator/utils.hpp"

#include <range/v3/view/filter.hpp>
#include <range/v3/view/transform.hpp>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#include "validators/traffic_light/regulatory_element_details_for_traffic_lights.hpp"
#include "lanelet2_map_validator/validators/traffic_light/regulatory_element_details_for_traffic_lights.hpp"

#include "common/utils.hpp"
#include "lanelet2_map_validator/utils.hpp"

#include <range/v3/view/filter.hpp>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#include "validators/crosswalk/missing_regulatory_elements_for_crosswalks.hpp"
#include "validators/stop_line/missing_regulatory_elements_for_stop_lines.hpp"
#include "validators/traffic_light/missing_regulatory_elements_for_traffic_lights.hpp"
#include "lanelet2_map_validator/validators/crosswalk/missing_regulatory_elements_for_crosswalks.hpp"
#include "lanelet2_map_validator/validators/stop_line/missing_regulatory_elements_for_stop_lines.hpp"
#include "lanelet2_map_validator/validators/traffic_light/missing_regulatory_elements_for_traffic_lights.hpp"

#include <autoware_lanelet2_extension/regulatory_elements/autoware_traffic_light.hpp>
#include <autoware_lanelet2_extension/regulatory_elements/crosswalk.hpp>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#include "validators/crosswalk/regulatory_element_details_for_crosswalks.hpp"
#include "validators/traffic_light/regulatory_element_details_for_traffic_lights.hpp"
#include "lanelet2_map_validator/validators/crosswalk/regulatory_element_details_for_crosswalks.hpp"
#include "lanelet2_map_validator/validators/traffic_light/regulatory_element_details_for_traffic_lights.hpp"

#include <autoware_lanelet2_extension/regulatory_elements/autoware_traffic_light.hpp>
#include <autoware_lanelet2_extension/regulatory_elements/crosswalk.hpp>
Expand Down

0 comments on commit 369ac54

Please sign in to comment.