Skip to content

Commit

Permalink
fix #2174
Browse files Browse the repository at this point in the history
  • Loading branch information
namdre committed Mar 26, 2019
1 parent 5c7cf99 commit 14fa44f
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 14 deletions.
42 changes: 29 additions & 13 deletions src/netimport/NIXMLConnectionsHandler.cpp
Expand Up @@ -202,19 +202,6 @@ NIXMLConnectionsHandler::parseLaneBound(const SUMOSAXAttributes& attrs, NBEdge*
return;
}
bool ok = true;
const bool mayDefinitelyPass = attrs.getOpt<bool>(SUMO_ATTR_PASS, nullptr, ok, false);
const bool keepClear = attrs.getOpt<bool>(SUMO_ATTR_KEEP_CLEAR, nullptr, ok, true);
const double contPos = attrs.getOpt<double>(SUMO_ATTR_CONTPOS, nullptr, ok, NBEdge::UNSPECIFIED_CONTPOS);
const double visibility = attrs.getOpt<double>(SUMO_ATTR_VISIBILITY_DISTANCE, nullptr, ok, NBEdge::UNSPECIFIED_VISIBILITY_DISTANCE);
const double speed = attrs.getOpt<double>(SUMO_ATTR_SPEED, nullptr, ok, NBEdge::UNSPECIFIED_SPEED);
const bool uncontrolled = attrs.getOpt<bool>(SUMO_ATTR_UNCONTROLLED, nullptr, ok, false);
PositionVector customShape = attrs.getOpt<PositionVector>(SUMO_ATTR_SHAPE, nullptr, ok, PositionVector::EMPTY);
if (!NBNetBuilder::transformCoordinates(customShape)) {
WRITE_ERROR("Unable to project shape for connection from edge '" + from->getID() + "' to edge '" + to->getID() + "'.");
}
if (!ok) {
return;
}
// get the begin and the end lane
int fromLane;
int toLane;
Expand All @@ -237,6 +224,35 @@ NIXMLConnectionsHandler::parseLaneBound(const SUMOSAXAttributes& attrs, NBEdge*
if (from->hasConnectionTo(to, toLane) && from->getToNode()->getType() != NODETYPE_ZIPPER) {
WRITE_WARNING("Target lane '" + to->getLaneID(toLane) + "' is already connected from '" + from->getID() + "'.");
}

NBEdge::Connection defaultCon(fromLane, to, toLane);
if (from->getStep() == NBEdge::LANES2LANES_USER) {
// maybe we are patching an existing connection
std::vector<NBEdge::Connection> existing = from->getConnectionsFromLane(fromLane, to, toLane);
if (existing.size() > 0) {
assert(existing.size() == 1);
defaultCon = existing.front();
// remove the original so we can insert the replacement
from->removeFromConnections(defaultCon);
}
}
const bool mayDefinitelyPass = attrs.getOpt<bool>(SUMO_ATTR_PASS, nullptr, ok, defaultCon.mayDefinitelyPass);
const bool keepClear = attrs.getOpt<bool>(SUMO_ATTR_KEEP_CLEAR, nullptr, ok, defaultCon.keepClear);
const double contPos = attrs.getOpt<double>(SUMO_ATTR_CONTPOS, nullptr, ok, defaultCon.contPos);
const double visibility = attrs.getOpt<double>(SUMO_ATTR_VISIBILITY_DISTANCE, nullptr, ok, defaultCon.visibility);
const double speed = attrs.getOpt<double>(SUMO_ATTR_SPEED, nullptr, ok, defaultCon.speed);
const bool uncontrolled = attrs.getOpt<bool>(SUMO_ATTR_UNCONTROLLED, nullptr, ok, defaultCon.uncontrolled);
PositionVector customShape = attrs.getOpt<PositionVector>(SUMO_ATTR_SHAPE, nullptr, ok, defaultCon.customShape);
if (attrs.hasAttribute(SUMO_ATTR_SHAPE) && !NBNetBuilder::transformCoordinates(customShape)) {
WRITE_ERROR("Unable to project shape for connection from edge '" + from->getID() + "' to edge '" + to->getID() + "'.");
}
if (!ok) {
return;
}

if (from->getID() == "190083618#0" && to->getID() == "239335494" && fromLane==3) {
std::cout << "DEBUG\n";
}
if (!from->addLane2LaneConnection(fromLane, to, toLane, NBEdge::L2L_USER, true, mayDefinitelyPass,
keepClear, contPos, visibility, speed, customShape, uncontrolled)) {
if (OptionsCont::getOptions().getBool("show-errors.connections-first-try")) {
Expand Down
2 changes: 1 addition & 1 deletion src/netimport/NIXMLTrafficLightsHandler.cpp
Expand Up @@ -241,7 +241,7 @@ NIXMLTrafficLightsHandler::addTlConnection(const SUMOSAXAttributes& attrs) {
std::string tlID = attrs.getOpt<std::string>(SUMO_ATTR_TLID, nullptr, ok, "");
if (tlID == "") {
// we are updating an existing tl-controlled connection
tlID = c.tlID;
tlID = (*(from->getToNode()->getControllingTLS().begin()))->getID();
assert(tlID != "");
}
int tlIndex = attrs.getOpt<int>(SUMO_ATTR_TLLINKINDEX, nullptr, ok, -1);
Expand Down

0 comments on commit 14fa44f

Please sign in to comment.