Skip to content

Commit

Permalink
fixed some missing connections. refs #4812
Browse files Browse the repository at this point in the history
  • Loading branch information
namdre committed Feb 10, 2019
1 parent c7c9726 commit 1a64e7e
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 4 deletions.
36 changes: 32 additions & 4 deletions src/netimport/NIImporter_OpenDrive.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@
//#define DEBUG_SPIRAL
//#define DEBUG_INTERNALSHAPES

#define DEBUG_COND(road) ((road)->id == "12")
#define DEBUG_COND2(edgeID) (StringUtils::startsWith((edgeID), "-12.0"))
#define DEBUG_COND3(roadID) (roadID == "12")
#define DEBUG_COND(road) ((road)->id == "175")
#define DEBUG_COND2(edgeID) (StringUtils::startsWith((edgeID), "disabled"))
#define DEBUG_COND3(roadID) (roadID == "175")

// ===========================================================================
// definitions
Expand Down Expand Up @@ -805,7 +805,7 @@ NIImporter_OpenDrive::buildConnectionsToOuter(const Connection& c, const std::ma
WRITE_WARNING("Circular connections in junction including roads '" + c.fromEdge + "' and '" + c.toEdge + "', loop size " + toString(seen.size()));
}
} else {
if ((*i).fromLane == c.toLane) {
if (laneSectionsConnected(dest, c.toLane, (*i).fromLane)) {
Connection cn = (*i);
cn.fromEdge = c.fromEdge;
cn.fromLane = c.fromLane;
Expand Down Expand Up @@ -896,6 +896,34 @@ NIImporter_OpenDrive::buildConnectionsToOuter(const Connection& c, const std::ma
}


bool
NIImporter_OpenDrive::laneSectionsConnected(OpenDriveEdge* edge, int in, int out) {
if (edge->laneSections.size() == 1) {
return in == out;
} else {
// there could be spacing lanes (type 'none') that lead to a shift in lane index
for (auto it = edge->laneSections.begin(); it + 1 < edge->laneSections.end(); it++) {
OpenDriveLaneSection& laneSection = *it;
if (laneSection.lanesByDir.find(OPENDRIVE_TAG_RIGHT) != laneSection.lanesByDir.end()) {
for (OpenDriveLane& lane : laneSection.lanesByDir.find(OPENDRIVE_TAG_RIGHT)->second) {
if (lane.id == in) {
in = lane.successor;
}
}
}
if (laneSection.lanesByDir.find(OPENDRIVE_TAG_LEFT) != laneSection.lanesByDir.end()) {
for (OpenDriveLane& lane : laneSection.lanesByDir.find(OPENDRIVE_TAG_LEFT)->second) {
if (lane.id == in) {
in = lane.successor;
}
}
}
}
return in == out;
}
}


void
NIImporter_OpenDrive::setEdgeLinks2(OpenDriveEdge& e, const std::map<std::string, OpenDriveEdge*>& edges) {
for (std::vector<OpenDriveLink>::iterator i = e.links.begin(); i != e.links.end(); ++i) {
Expand Down
1 change: 1 addition & 0 deletions src/netimport/NIImporter_OpenDrive.h
Original file line number Diff line number Diff line change
Expand Up @@ -565,6 +565,7 @@ class NIImporter_OpenDrive : public GenericSAXHandler {
void addGeometryShape(GeometryType type, const std::vector<double>& vals);
static void setEdgeLinks2(OpenDriveEdge& e, const std::map<std::string, OpenDriveEdge*>& edges);
static void buildConnectionsToOuter(const Connection& c, const std::map<std::string, OpenDriveEdge*>& innerEdges, std::vector<Connection>& into, std::set<Connection>& seen);
static bool laneSectionsConnected(OpenDriveEdge* edge, int in, int out);
friend bool operator<(const Connection& c1, const Connection& c2);
static std::string revertID(const std::string& id);
const NBTypeCont& myTypeContainer;
Expand Down

0 comments on commit 1a64e7e

Please sign in to comment.