Skip to content

Commit

Permalink
fix #14702 (not pretty)
Browse files Browse the repository at this point in the history
  • Loading branch information
namdre committed Apr 11, 2024
1 parent eaa7841 commit 9fc0a98
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 5 deletions.
16 changes: 15 additions & 1 deletion src/netbuild/NBNode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3505,7 +3505,7 @@ NBNode::buildWalkingAreas(int cornerDetail, double joinMinDist) {
Crossing& prev = **it;
Crossing& next = (it != validCrossings.begin() ? **(it - 1) :** (validCrossings.end() - 1));
if (gDebugFlag1) {
std::cout << " checkIntermediate: prev=" << prev.id << " next=" << next.id << " prev.nextWA=" << prev.nextWalkingArea << "\n";
std::cout << " checkIntermediate: prev=" << prev.id << " next=" << next.id << " prev.nextWA=" << prev.nextWalkingArea << " next.prevWA=" << next.prevWalkingArea << "\n";
}
if (prev.nextWalkingArea == "") {
if (next.prevWalkingArea != "" || &prev == &next) {
Expand Down Expand Up @@ -3874,6 +3874,20 @@ NBNode::getWalkingArea(const std::string& id) {
return walkingArea;
}
}
// not found, maybe we need to rebuild
updateSurroundingGeometry();
sortEdges(true);
buildCrossingsAndWalkingAreas();
for (auto& walkingArea : myWalkingAreas) {
if (walkingArea.id == id) {
return walkingArea;
}
}
if (myWalkingAreas.size() > 0) {
// don't crash
WRITE_WARNINGF("Could not retrieve walkingarea '%' (edge ordering changed after recompute).", id);
return myWalkingAreas.front();
}
throw ProcessError(TLF("Request for unknown walkingarea '%'.", id));
}

Expand Down
40 changes: 36 additions & 4 deletions src/netedit/changes/GNEChange_Crossing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,14 @@ void GNEChange_Crossing::undo() {
WRITE_DEBUG("removing " + toString(SUMO_TAG_CROSSING) + " from " + myJunctionParent->getTagStr() + " '" + myJunctionParent->getID() + "'");
// unselect if mySelectedElement is enabled
if (mySelectedElement) {
myJunctionParent->retrieveGNECrossing(myJunctionParent->getNBNode()->getCrossing(myEdges), false)->unselectAttributeCarrier();
GNECrossing* crossing = myJunctionParent->retrieveGNECrossing(myJunctionParent->getNBNode()->getCrossing(myEdges), false);
if (crossing) {
crossing->unselectAttributeCarrier();
} else {
#ifdef _DEBUG
WRITE_WARNINGF("Unable to deselect crossing at junction '%' after undo", myJunctionParent->getID());
#endif
}
}
// remove crossing of NBNode
myJunctionParent->getNBNode()->removeCrossing(myEdges);
Expand Down Expand Up @@ -103,7 +110,16 @@ void GNEChange_Crossing::undo() {
myJunctionParent->clearWalkingAreas();
// select if mySelectedElement is enabled
if (mySelectedElement) {
myJunctionParent->retrieveGNECrossing(c, false)->selectAttributeCarrier();
if (mySelectedElement) {
GNECrossing* crossing = myJunctionParent->retrieveGNECrossing(c, false);
if (crossing) {
crossing->selectAttributeCarrier();
} else {
#ifdef _DEBUG
WRITE_WARNINGF("Unable to select crossing at junction '%' after undo", myJunctionParent->getID());
#endif
}
}
}
}
// enable save networkElements
Expand All @@ -129,14 +145,30 @@ void GNEChange_Crossing::redo() {
myJunctionParent->clearWalkingAreas();
// select if mySelectedElement is enabled
if (mySelectedElement) {
myJunctionParent->retrieveGNECrossing(c, false)->selectAttributeCarrier();
if (mySelectedElement) {
GNECrossing* crossing = myJunctionParent->retrieveGNECrossing(c, false);
if (crossing) {
crossing->selectAttributeCarrier();
} else {
#ifdef _DEBUG
WRITE_WARNINGF("Unable to select crossing at junction '%' after undo", myJunctionParent->getID());
#endif
}
}
}
} else {
// show extra information for tests
WRITE_DEBUG("Removing " + toString(SUMO_TAG_CROSSING) + " from " + myJunctionParent->getTagStr() + " '" + myJunctionParent->getID() + "'");
// unselect if mySelectedElement is enabled
if (mySelectedElement) {
myJunctionParent->retrieveGNECrossing(myJunctionParent->getNBNode()->getCrossing(myEdges), false)->unselectAttributeCarrier();
GNECrossing* crossing = myJunctionParent->retrieveGNECrossing(myJunctionParent->getNBNode()->getCrossing(myEdges), false);
if (crossing) {
crossing->unselectAttributeCarrier();
} else {
#ifdef _DEBUG
WRITE_WARNINGF("Unable to deselect crossing at junction '%' after undo", myJunctionParent->getID());
#endif
}
}
// remove crossing of NBNode and update geometry
myJunctionParent->getNBNode()->removeCrossing(myEdges);
Expand Down

0 comments on commit 9fc0a98

Please sign in to comment.