Skip to content

Commit

Permalink
addendum for right of way at internal junctions for intersecting left…
Browse files Browse the repository at this point in the history
… turns. refs #4252
  • Loading branch information
namdre committed Jun 27, 2018
1 parent 7647fcd commit 55d6627
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
7 changes: 6 additions & 1 deletion src/netbuild/NBEdge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1514,6 +1514,11 @@ NBEdge::buildInnerEdges(const NBNode& n, int noInternalNoSplits, int& linkIndex,
if ((n.forbids(*i2, (*k2).toEdge, this, con.toEdge, signalised) || rightTurnConflict) && (needsCont || dir == LINKDIR_TURN)) {
tmpFoeIncomingLanes.insert((*i2)->getID() + "_" + toString((*k2).fromLane));
}
if (bothPrio && oppositeLeftIntersect && getID() < (*i2)->getID()) {
//std::cout << " c1=" << con.getDescription(this) << " c2=" << (*k2).getDescription(*i2) << " bothPrio=" << bothPrio << " oppositeLeftIntersect=" << oppositeLeftIntersect << "\n";
// break symmetry using edge id
tmpFoeIncomingLanes.insert(innerID + "_" + toString(index) + "_0");
}
index++;
}
}
Expand Down Expand Up @@ -1600,7 +1605,7 @@ NBEdge::buildInnerEdges(const NBNode& n, int noInternalNoSplits, int& linkIndex,
if (crossingPositions.first >= 0) {
std::pair<PositionVector, PositionVector> split = shape.splitAt(crossingPositions.first);
con.shape = split.first;
con.foeIncomingLanes = joinToString(tmpFoeIncomingLanes, " ");
con.foeIncomingLanes = std::vector<std::string>(tmpFoeIncomingLanes.begin(), tmpFoeIncomingLanes.end());
con.foeInternalLinks = foeInternalLinks; // resolve link indices to lane ids later
con.viaID = innerID + "_" + toString(splitIndex + noInternalNoSplits);
++splitIndex;
Expand Down
2 changes: 1 addition & 1 deletion src/netbuild/NBEdge.h
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ class NBEdge : public Named, public Parameterised {
std::vector<int> foeInternalLinks;

/// @brief FOE Incomings lanes
std::string foeIncomingLanes;
std::vector<std::string> foeIncomingLanes;

/// @brief The lane index of this internal lane within the internal edge
int internalLaneIndex;
Expand Down
12 changes: 9 additions & 3 deletions src/netwrite/NWWriter_SUMO.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -538,11 +538,13 @@ NWWriter_SUMO::writeInternalNodes(OutputDevice& into, const NBNode& n) {
const std::vector<NBEdge*>& incoming = n.getIncomingEdges();
// build the list of internal lane ids
std::vector<std::string> internalLaneIDs;
std::map<std::string, std::string> viaIDs;
for (EdgeVector::const_iterator i = incoming.begin(); i != incoming.end(); i++) {
const std::vector<NBEdge::Connection>& elv = (*i)->getConnections();
for (std::vector<NBEdge::Connection>::const_iterator k = elv.begin(); k != elv.end(); ++k) {
if ((*k).toEdge != 0) {
internalLaneIDs.push_back((*k).getInternalLaneID());
viaIDs[(*k).getInternalLaneID()] = ((*k).viaID);
}
}
}
Expand All @@ -561,12 +563,16 @@ NWWriter_SUMO::writeInternalNodes(OutputDevice& into, const NBNode& n) {
into.writeAttr(SUMO_ATTR_TYPE, NODETYPE_INTERNAL);
NWFrame::writePositionLong(pos, into);
std::string incLanes = (*k).getInternalLaneID();
if ((*k).foeIncomingLanes.length() != 0) {
incLanes += " " + (*k).foeIncomingLanes;
std::vector<std::string> foeIDs;
for (std::string incLane : (*k).foeIncomingLanes) {
incLanes += " " + incLane;
if (incLane[0] == ':') {
// intersecting left turns
foeIDs.push_back(viaIDs[incLane] + "_0");
}
}
into.writeAttr(SUMO_ATTR_INCLANES, incLanes);
const std::vector<int>& foes = (*k).foeInternalLinks;
std::vector<std::string> foeIDs;
for (std::vector<int>::const_iterator it = foes.begin(); it != foes.end(); ++it) {
foeIDs.push_back(internalLaneIDs[*it]);
}
Expand Down

0 comments on commit 55d6627

Please sign in to comment.