Skip to content

Commit

Permalink
add check if road id already exists
Browse files Browse the repository at this point in the history
  • Loading branch information
pageldev committed Jun 24, 2023
1 parent 385f95b commit 212aa34
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/OpenDriveMap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");

Expand Down

0 comments on commit 212aa34

Please sign in to comment.