Skip to content

Commit

Permalink
fix #4998
Browse files Browse the repository at this point in the history
  • Loading branch information
namdre committed Jan 4, 2019
1 parent 9975a57 commit 4bd8684
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions src/netedit/GNENet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1656,6 +1656,15 @@ GNENet::splitJunction(GNEJunction* junction, GNEUndoList* undoList) {
}
// start operation
undoList->p_begin("Split junction");
// record connections
std::map<GNEEdge*, std::vector<NBEdge::Connection>> straightConnections;
for (GNEEdge* e : junction->getGNEIncomingEdges()) {
for (const auto& c : e->getNBEdge()->getConnections()) {
if (c.fromLane >= 0 && junction->getNBNode()->getDirection(e->getNBEdge(), c.toEdge) == LINKDIR_STRAIGHT) {
straightConnections[e].push_back(c);
}
};
}
//std::cout << "split junction at endpoints: " << toString(endpoints) << "\n";
junction->setLogicValid(false, undoList);
for (Position pos : endpoints) {
Expand Down Expand Up @@ -1683,6 +1692,30 @@ GNENet::splitJunction(GNEJunction* junction, GNEUndoList* undoList) {
}
}
}
// recreate edges from straightConnections
for (const auto& item : straightConnections) {
GNEEdge* in = item.first;
std::map<NBEdge*, GNEEdge*> newEdges;
for (auto& c : item.second) {
GNEEdge* out = retrieveEdge(c.toEdge->getID());
GNEEdge* newEdge = nullptr;
if (in->getGNEJunctionDestiny() == out->getGNEJunctionSource()) {
continue;
}
if (newEdges.count(c.toEdge) == 0) {
newEdge = createEdge(in->getGNEJunctionDestiny(), out->getGNEJunctionSource(), in, undoList);
newEdges[c.toEdge] = newEdge;
newEdge->setAttribute(SUMO_ATTR_NUMLANES, "1", undoList);
} else {
newEdge = newEdges[c.toEdge];
duplicateLane(newEdge->getLanes().back(), undoList, true);
}
// copy permissions
newEdge->getLanes().back()->setAttribute(SUMO_ATTR_ALLOW,
in->getLanes()[c.fromLane]-> getAttribute(SUMO_ATTR_ALLOW), undoList);
}
}

deleteJunction(junction, undoList);
// finish operation
undoList->p_end();
Expand Down

0 comments on commit 4bd8684

Please sign in to comment.