From 4bd8684ceaa5e606015bfafbc754ec8b9fb327d5 Mon Sep 17 00:00:00 2001 From: namdre Date: Fri, 4 Jan 2019 13:28:20 +0100 Subject: [PATCH] fix #4998 --- src/netedit/GNENet.cpp | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/src/netedit/GNENet.cpp b/src/netedit/GNENet.cpp index 5477d66170c..9c92a7d41fa 100644 --- a/src/netedit/GNENet.cpp +++ b/src/netedit/GNENet.cpp @@ -1656,6 +1656,15 @@ GNENet::splitJunction(GNEJunction* junction, GNEUndoList* undoList) { } // start operation undoList->p_begin("Split junction"); + // record connections + std::map> 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) { @@ -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 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();