From 212aa3468e34dafb79a8ed9f98682b8298e8a4dd Mon Sep 17 00:00:00 2001 From: Sebastian Pagel Date: Sat, 24 Jun 2023 10:18:34 +0200 Subject: [PATCH] add check if road id already exists --- src/OpenDriveMap.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/OpenDriveMap.cpp b/src/OpenDriveMap.cpp index d7885a7..d342fcb 100644 --- a/src/OpenDriveMap.cpp +++ b/src/OpenDriveMap.cpp @@ -147,8 +147,12 @@ OpenDriveMap::OpenDriveMap(const std::string& xodr_file, for (pugi::xml_node road_node : odr_node.children("road")) { /* make road */ - const std::string road_id = road_node.attribute("id").as_string(""); - std::string rule_str = std::string(road_node.attribute("rule").as_string("RHT")); + std::string road_id = road_node.attribute("id").as_string(""); + CHECK_AND_REPAIR(this->id_to_road.find(road_id) == this->id_to_road.end(), + (std::string("road::id already exists - ") + road_id).c_str(), + road_id = road_id + std::string("_dup")); + + std::string rule_str = std::string(road_node.attribute("rule").as_string("RHT")); std::transform(rule_str.begin(), rule_str.end(), rule_str.begin(), [](unsigned char c) { return std::tolower(c); }); const bool is_left_hand_traffic = (rule_str == "lht");