Skip to content

Commit

Permalink
now using lane-to-lane data for right-of-way mode. fix #4637, refs #3850
Browse files Browse the repository at this point in the history
  • Loading branch information
namdre committed Oct 1, 2018
1 parent f6c273d commit 49b7325
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 4 deletions.
20 changes: 20 additions & 0 deletions src/netbuild/NBNode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -883,6 +883,26 @@ NBNode::writeLogic(OutputDevice& into) const {
}


const std::string
NBNode::getFoes(int linkIndex) const {
if (myRequest == nullptr) {
return "";
} else {
return myRequest->getFoes(linkIndex);
}
}


const std::string
NBNode::getResponse(int linkIndex) const {
if (myRequest == nullptr) {
return "";
} else {
return myRequest->getResponse(linkIndex);
}
}


void
NBNode::computeNodeShape(double mismatchThreshold) {
if (myHaveCustomPoly) {
Expand Down
3 changes: 3 additions & 0 deletions src/netbuild/NBNode.h
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,9 @@ class NBNode : public Named, public Parameterised {
/// @brief writes the XML-representation of the logic as a bitset-logic XML representation
bool writeLogic(OutputDevice& into) const;

const std::string getFoes(int linkIndex) const;
const std::string getResponse(int linkIndex) const;

/// @brief Returns something like the most unused direction Should only be used to add source or sink nodes
Position getEmptyDir() const;

Expand Down
15 changes: 15 additions & 0 deletions src/netbuild/NBRequest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,21 @@ NBRequest::distanceCounterClockwise(NBEdge* from, NBEdge* to) {
return ret;
}

const std::string&
NBRequest::getFoes(int linkIndex) const {
assert(linkIndex >= 0);
assert(linkIndex < (int)myFoes.size());
return myFoes[linkIndex];
}


const std::string&
NBRequest::getResponse(int linkIndex) const {
assert(linkIndex >= 0);
assert(linkIndex < (int)myResponse.size());
return myResponse[linkIndex];
}


void
NBRequest::writeLogic(OutputDevice& into) const {
Expand Down
3 changes: 3 additions & 0 deletions src/netbuild/NBRequest.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,9 @@ class NBRequest {

void writeLogic(OutputDevice& into) const;

const std::string& getFoes(int linkIndex) const;
const std::string& getResponse(int linkIndex) const;

/// @brief prints the request
friend std::ostream& operator<<(std::ostream& os, const NBRequest& r);

Expand Down
16 changes: 12 additions & 4 deletions src/netedit/frames/GNEProhibitionFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,15 +179,23 @@ GNEProhibitionFrame::buildProhibition(GNEConnection* conn, bool /* mayDefinitely
NBEdge* currentConnFrom = myCurrentConn->getEdgeFrom()->getNBEdge();
NBEdge* currentConnTo = myCurrentConn->getEdgeTo()->getNBEdge();

const int currentLinkIndex = node->getConnectionIndex(currentConnFrom, myCurrentConn->getNBEdgeConnection());
std::string currentFoesString = node->getFoes(currentLinkIndex);
std::string currentResponseString = node->getResponse(currentLinkIndex);
std::reverse(currentFoesString.begin(), currentFoesString.end());
std::reverse(currentResponseString.begin(), currentResponseString.end());

for (auto i : allConns) {
if (i != myCurrentConn) {
NBEdge* otherConnFrom = i->getEdgeFrom()->getNBEdge();
NBEdge* otherConnTo = i->getEdgeTo()->getNBEdge();

const int linkIndex = node->getConnectionIndex(otherConnFrom, i->getNBEdgeConnection());
std::string responseString = node->getResponse(linkIndex);
std::reverse(responseString.begin(), responseString.end());
// determine the prohibition status
bool foes = node->foes(currentConnFrom, currentConnTo, otherConnFrom, otherConnTo);
bool forbids = node->forbids(currentConnFrom, currentConnTo, otherConnFrom, otherConnTo, true);
bool forbidden = node->forbids(otherConnFrom, otherConnTo, currentConnFrom, currentConnTo, true);
bool foes = currentFoesString.size() > linkIndex && currentFoesString[linkIndex] == '1';
bool forbids = responseString.size() > currentLinkIndex && responseString[currentLinkIndex] == '1';
bool forbidden = currentResponseString.size() > linkIndex && currentResponseString[linkIndex] == '1';

myConcernedConns.insert(i);

Expand Down

0 comments on commit 49b7325

Please sign in to comment.