60 #define DEBUGCOND (getID() == "disabled") 61 #define DEBUGCOND2(obj) ((obj != 0 && (obj)->getID() == "disabled")) 107 NBEdge::Connection::Connection(
int fromLane_,
NBEdge* toEdge_,
int toLane_,
bool mayDefinitelyPass_,
bool keepClear_,
double contPos_,
double visibility_,
bool haveVia_,
bool uncontrolled_) :
129 connectionsDone(false) {
139 assert((
int)myTransitions.size() > virtEdge);
141 NBEdge* succEdge = myTransitions[virtEdge];
142 std::vector<int> lanes;
146 std::map<NBEdge*, std::vector<int> >::iterator i =
myConnections.find(succEdge);
154 std::vector<int>::iterator j = find(lanes.begin(), lanes.end(), lane);
155 if (j == lanes.end()) {
157 lanes.push_back(lane);
170 if (outgoing.size() == 0) {
174 assert(outgoing.size() > 0);
176 #ifdef DEBUG_CONNECTION_GUESSING 178 std::cout <<
" MainDirections edge=" << parent->
getID() <<
" straightest=" << outgoing[indexOfStraightest]->getID() <<
" dir=" <<
toString(straightestDir) <<
"\n";
190 if (outgoing.back()->getJunctionPriority(to) == 1) {
196 if (outgoing.back()->getPriority() > tmp[0]->getPriority()) {
199 if (outgoing.back()->getNumLanes() > tmp[0]->getNumLanes()) {
208 NBEdge* edge = *(tmp.begin());
221 return myDirs.empty();
227 return find(myDirs.begin(), myDirs.end(), d) != myDirs.end();
247 std::string type,
double speed,
int nolanes,
248 int priority,
double laneWidth,
double offset,
249 const std::string& streetName,
265 init(nolanes,
false,
id);
270 std::string type,
double speed,
int nolanes,
271 int priority,
double laneWidth,
double offset,
273 const std::string& streetName,
274 const std::string& origID,
290 init(nolanes, tryIgnoreNodePositions, origID);
320 if (to == tpl->
myTo) {
329 double speed,
int nolanes,
int priority,
331 const std::string& streetName,
333 bool tryIgnoreNodePositions) {
355 const std::vector<Lane> oldLanes =
myLanes;
356 init(nolanes, tryIgnoreNodePositions, oldLanes.empty() ?
"" : oldLanes[0].origID);
357 for (
int i = 0; i < (int)nolanes; ++i) {
359 myLanes[i] = oldLanes[
MIN2(i, (
int)oldLanes.size() - 1)];
378 if (from == 0 || to == 0) {
379 throw ProcessError(
"At least one of edge's '" +
myID +
"' nodes is not known.");
396 NBEdge::init(
int noLanes,
bool tryIgnoreNodePositions,
const std::string& origID) {
401 throw ProcessError(
"At least one of edge's '" +
myID +
"' nodes is not known.");
407 if (!tryIgnoreNodePositions ||
myGeom.size() < 2) {
422 WRITE_ERROR(
"Edge's '" +
myID +
"' from- and to-node are at the same position.");
430 assert(
myGeom.size() >= 2);
431 if ((
int)
myLanes.size() > noLanes) {
433 for (
int lane = noLanes; lane < (int)
myLanes.size(); ++lane) {
438 for (EdgeVector::const_iterator i = incoming.begin(); i != incoming.end(); i++) {
439 for (
int lane = noLanes; lane < (int)
myLanes.size(); ++lane) {
440 (*i)->removeFromConnections(
this, -1, lane);
445 for (
int i = 0; i < noLanes; i++) {
451 #ifdef DEBUG_CONNECTION_GUESSING 453 std::cout <<
"init edge=" <<
getID() <<
"\n";
455 std::cout <<
" conn " <<
getID() <<
"_" << (*i).fromLane <<
" to " <<
Named::getIDSecure((*i).toEdge) <<
"_" << (*i).toLane <<
"\n";
456 (*i).shape.mirrorX();
457 (*i).viaShape.mirrorX();
471 for (
int i = 0; i < (int)
myLanes.size(); i++) {
472 myLanes[i].shape.add(xoff, yoff, 0);
481 for (
int i = 0; i < (int)
myLanes.size(); i++) {
485 (*i).shape.mirrorX();
486 (*i).viaShape.mirrorX();
518 assert(node ==
myTo);
548 assert(node ==
myTo);
577 if (rectangularCut) {
578 const double extend = 100;
582 border.push_back(p2);
584 if (border.size() == 2) {
585 double edgeWidth = 0;
586 for (
int i = 0; i < (int)
myLanes.size(); i++) {
593 assert(node ==
myTo);
597 #ifdef DEBUG_NODE_BORDER 600 <<
" rect=" << rectangularCut
601 <<
" p=" << p <<
" p2=" << p2
602 <<
" border=" << border
615 assert(node ==
myTo);
625 if (shape.size() < 2) {
627 const double oldLength = old.
length();
636 const double midpoint = old.
length() / 2;
639 assert(shape.size() >= 2);
640 assert(shape.
length() > 0);
648 tmp.push_back(shape[0]);
649 tmp.push_back(shape[-1]);
665 const double midpoint = old.
length() / 2;
668 assert(shape.size() >= 2);
669 assert(shape.
length() > 0);
672 const double midpoint = shape.
length() / 2;
689 for (
int i = 0; i < (int)
myLanes.size(); i++) {
693 double avgLength = 0;
694 for (
int i = 0; i < (int)
myLanes.size(); i++) {
695 assert(
myLanes[i].shape.length() > 0);
696 avgLength +=
myLanes[i].shape.length();
705 if (nodeShape.size() == 0) {
715 assert(pbv.size() > 0);
727 const double dZ = ns.size() >= 2 ? fabs(ns[0].z() - ns[1].z()) : 0;
733 assert(ns.size() >= 2);
738 assert(pbv.size() > 0);
748 const double dZ = result.size() >= 2 ? fabs(result[0].z() - result[1].z()) : 0;
801 NBEdge* currentEdge =
this;
802 for (
int i = 1; i < (int)
myGeom.size() - 1; i++) {
804 if (i != (
int)
myGeom.size() - 2) {
805 std::string nodename =
myID +
"_in_between#" +
toString(i);
807 throw ProcessError(
"Error on adding in-between node '" + nodename +
"'.");
815 currentEdge->
myTo = newTo;
818 std::string edgename =
myID +
"[" +
toString(i - 1) +
"]";
822 if (!ec.
insert(currentEdge,
true)) {
823 throw ProcessError(
"Error on adding splitted edge '" + edgename +
"'.");
848 std::vector<double> angles;
850 for (
int i = 0; i < (int)
myGeom.size() - 1; ++i) {
855 for (
int i = 0; i < (int)angles.size() - 1; ++i) {
858 if (maxAngle > 0 && relAngle > maxAngle) {
864 if (i == 0 || i == (
int)angles.size() - 2) {
865 const bool start = i == 0;
867 const double r = tan(0.5 * (
M_PI - relAngle)) * dist;
869 if (minRadius > 0 && r < minRadius) {
872 (start ?
"start" :
"end") +
" of edge '" +
getID() +
"'.");
878 (start ?
"start" :
"end") +
" of edge '" +
getID() +
"'.");
915 bool mayUseSameDestination,
916 bool mayDefinitelyPass,
932 return setConnection(from, dest, toLane, type, mayUseSameDestination, mayDefinitelyPass, keepClear, contPos, visibility);
940 bool invalidatePrevious,
941 bool mayDefinitelyPass) {
942 if (invalidatePrevious) {
946 for (
int i = 0; i < no && ok; i++) {
956 bool mayUseSameDestination,
957 bool mayDefinitelyPass,
985 if ((*i).toEdge == destEdge && ((*i).fromLane == -1 || (*i).toLane == -1)) {
992 if (mayDefinitelyPass) {
1022 std::vector<NBEdge::Connection>
1024 std::vector<NBEdge::Connection> ret;
1026 if ((*i).fromLane == lane) {
1038 (*i).fromLane == fromLane
1039 && (*i).toEdge == to
1040 && (*i).toLane == toLane) {
1045 +
" to " + to->
getID() +
"_" +
toString(toLane) +
" not found");
1052 (*i).fromLane == fromLane
1053 && (*i).toEdge == to
1054 && (*i).toLane == toLane) {
1059 +
" to " + to->
getID() +
"_" +
toString(toLane) +
" not found");
1090 if (find(outgoing.begin(), outgoing.end(), (*i).toEdge) == outgoing.end()) {
1091 outgoing.push_back((*i).toEdge);
1096 if (it->fromLane < 0 && it->toLane < 0) {
1098 EdgeVector::iterator forbidden = find(outgoing.begin(), outgoing.end(), it->toEdge);
1099 if (forbidden != outgoing.end()) {
1100 outgoing.erase(forbidden);
1105 int size = (int) outgoing.size();
1107 edges->reserve(size);
1108 for (EdgeVector::const_iterator i = outgoing.begin(); i != outgoing.end(); i++) {
1111 edges->push_back(outedge);
1123 if (find(ret.begin(), ret.end(), (*i).toEdge) == ret.end()) {
1124 ret.push_back((*i).toEdge);
1135 for (EdgeVector::const_iterator i = candidates.begin(); i != candidates.end(); i++) {
1136 if ((*i)->isConnectedTo(
this)) {
1146 std::vector<int> ret;
1149 if ((*i).toEdge == currentOutgoing) {
1150 ret.push_back((*i).fromLane);
1173 for (EdgeVector::const_iterator i = incoming.begin(); i != incoming.end(); i++) {
1178 for (EdgeVector::iterator j = connected.begin(); j != connected.end(); j++) {
1189 const int fromLaneRemoved = adaptToLaneRemoval && fromLane >= 0 ? fromLane : -1;
1190 const int toLaneRemoved = adaptToLaneRemoval && toLane >= 0 ? toLane : -1;
1193 if ((toEdge == 0 || c.
toEdge == toEdge)
1194 && (fromLane < 0 || c.
fromLane == fromLane)
1195 && (toLane < 0 || c.
toLane == toLane)) {
1198 for (std::set<NBTrafficLightDefinition*>::iterator it = tldefs.begin(); it != tldefs.end(); it++) {
1205 if (fromLaneRemoved >= 0 && c.
fromLane > fromLaneRemoved) {
1208 for (std::set<NBTrafficLightDefinition*>::iterator it = tldefs.begin(); it != tldefs.end(); it++) {
1209 for (NBConnectionVector::iterator tlcon = (*it)->getControlledLinks().begin(); tlcon != (*it)->getControlledLinks().end(); ++tlcon) {
1219 if (toLaneRemoved >= 0 && c.
toLane > toLaneRemoved) {
1242 if (((*i).toEdge == connectionToRemove.
toEdge) && ((*i).fromLane == connectionToRemove.
fromLane) && ((*i).toLane == connectionToRemove.
toLane)) {
1257 if (reallowSetting) {
1269 if ((*i).toEdge == which) {
1271 (*i).toLane += laneOff;
1282 std::map<int, int> laneMap;
1286 bool wasConnected =
false;
1288 if ((*i).toEdge != which) {
1291 wasConnected =
true;
1292 if ((*i).fromLane != -1) {
1293 int fromLane = (*i).fromLane;
1294 laneMap[(*i).toLane] = fromLane;
1295 if (minLane == -1 || minLane > fromLane) {
1298 if (maxLane == -1 || maxLane < fromLane) {
1303 if (!wasConnected) {
1309 std::vector<NBEdge::Connection> conns = origConns;
1310 for (std::vector<NBEdge::Connection>::iterator i = conns.begin(); i != conns.end(); ++i) {
1311 if ((*i).toEdge == which) {
1314 int fromLane = (*i).fromLane;
1316 if (laneMap.find(fromLane) == laneMap.end()) {
1317 if (fromLane >= 0 && fromLane <= minLane) {
1320 if (fromLane >= 0 && fromLane >= maxLane) {
1324 toUse = laneMap[fromLane];
1358 std::vector<Connection>::iterator i =
myConnections.begin() + index;
1382 std::string innerID =
":" + n.
getID();
1384 int edgeIndex = linkIndex;
1385 int internalLaneIndex = 0;
1397 if (con.
toEdge != toEdge || (isTurn && !joinTurns)) {
1400 edgeIndex = linkIndex;
1401 toEdge = (*i).toEdge;
1402 internalLaneIndex = 0;
1405 std::vector<int> foeInternalLinks;
1412 std::pair<double, std::vector<int> > crossingPositions(-1, std::vector<int>());
1413 std::set<std::string> tmpFoeIncomingLanes;
1422 for (EdgeVector::const_iterator i2 = incoming.begin(); i2 != incoming.end(); ++i2) {
1423 const std::vector<Connection>& elv = (*i2)->getConnections();
1424 for (std::vector<NBEdge::Connection>::const_iterator k2 = elv.begin(); k2 != elv.end(); k2++) {
1425 if ((*k2).toEdge == 0) {
1428 bool needsCont = n.
needsCont(
this, *i2, con, *k2);
1431 crossingPositions.second.push_back(index);
1435 double width2 = (*k2).toEdge->getLaneWidth((*k2).toLane);
1436 if ((*k2).toEdge->getPermissions((*k2).toLane) !=
SVC_BICYCLE) {
1442 if (crossingPositions.first < 0 || crossingPositions.first > minDV) {
1443 crossingPositions.first = minDV;
1448 this, con.
toEdge, con.
fromLane, (*i2), (*k2).toEdge, (*k2).fromLane);
1450 if (n.
foes(
this, con.
toEdge, *i2, (*k2).toEdge) || rightTurnConflict) {
1451 foeInternalLinks.push_back(index);
1455 if ((n.
forbids(*i2, (*k2).toEdge,
this, con.
toEdge, signalised) || rightTurnConflict) && (needsCont || dir ==
LINKDIR_TURN)) {
1456 tmpFoeIncomingLanes.insert((*i2)->getID() +
"_" +
toString((*k2).fromLane));
1462 std::vector<NBNode::Crossing*> crossings = n.
getCrossings();
1463 for (
auto c : crossings) {
1465 for (EdgeVector::const_iterator it_e = crossing.
edges.begin(); it_e != crossing.
edges.end(); ++it_e) {
1466 const NBEdge* edge = *it_e;
1468 if (
this == edge || con.
toEdge == edge) {
1469 foeInternalLinks.push_back(index);
1470 if (con.
toEdge == edge &&
1478 if (crossingPositions.first < 0 || crossingPositions.first > minDV) {
1479 crossingPositions.first = minDV;
1502 crossingPositions.first = -1;
1505 crossingPositions.first = con.
contPos;
1523 assert(shape.size() >= 2);
1525 if (crossingPositions.first >= 0) {
1526 std::pair<PositionVector, PositionVector>
split = shape.
splitAt(crossingPositions.first);
1527 con.
id = innerID +
"_" +
toString(edgeIndex);
1528 con.
shape = split.first;
1531 con.
viaID = innerID +
"_" +
toString(splitIndex + noInternalNoSplits);
1537 con.
id = innerID +
"_" +
toString(edgeIndex);
1542 ++internalLaneIndex;
1562 if (tmp.size() > 0) {
1563 intersect =
MIN2(intersect, tmp[0]);
1566 if (tmp.size() > 0) {
1567 intersect =
MIN2(intersect, tmp[0]);
1600 assert(atNode ==
myTo);
1615 assert(atNode ==
myTo);
1623 if (!onlyPossible) {
1643 std::vector<double> offsets(
myLanes.size(), 0.);
1645 for (
int i = (
int)
myLanes.size() - 2; i >= 0; --i) {
1647 offsets[i] = offset;
1654 for (
int i = 0; i < (int)
myLanes.size(); ++i) {
1660 for (
int i = 0; i < (int)
myLanes.size(); ++i) {
1661 offsets[i] += offset;
1665 for (
int i = 0; i < (int)
myLanes.size(); ++i) {
1666 if (
myLanes[i].customShape.size() != 0) {
1673 WRITE_WARNING(
"In edge '" +
getID() +
"': lane shape could not be determined (" + e.what() +
").");
1726 if (
DEBUGCOND) std::cout <<
"computeAngle edge=" <<
getID() <<
" fromCenter=" << fromCenter <<
" toCenter=" << toCenter
1727 <<
" refStart=" << referencePosStart <<
" refEnd=" << referencePosEnd <<
" shape=" << shape
1728 <<
" hasFromShape=" << hasFromShape
1729 <<
" hasToShape=" << hasToShape
1755 for (std::vector<Lane>::const_iterator i =
myLanes.begin(); i !=
myLanes.end(); ++i) {
1756 if ((*i).permissions !=
SVCAll) {
1766 std::vector<Lane>::const_iterator i =
myLanes.begin();
1769 for (; i !=
myLanes.end(); ++i) {
1770 if (i->permissions != firstLanePermissions) {
1780 for (std::vector<Lane>::const_iterator i =
myLanes.begin(); i !=
myLanes.end(); ++i) {
1791 for (std::vector<Lane>::const_iterator i =
myLanes.begin(); i !=
myLanes.end(); ++i) {
1792 if (i->width !=
myLanes.begin()->width) {
1802 for (std::vector<Lane>::const_iterator i =
myLanes.begin(); i !=
myLanes.end(); ++i) {
1803 if (i->endOffset !=
myLanes.begin()->endOffset) {
1813 for (std::vector<Lane>::const_iterator i =
myLanes.begin(); i !=
myLanes.end(); ++i) {
1824 for (std::vector<Lane>::const_iterator i =
myLanes.begin(); i !=
myLanes.end(); ++i) {
1825 if (i->customShape.size() > 0) {
1853 for (EdgeVector::const_iterator i = o.begin(); i != o.end(); ++i) {
1890 #ifdef DEBUG_CONNECTION_GUESSING 1892 std::cout <<
"recheckLanes (initial) edge=" <<
getID() <<
"\n";
1894 std::cout <<
" conn " <<
getID() <<
"_" << (*i).fromLane <<
" to " <<
Named::getIDSecure((*i).toEdge) <<
"_" << (*i).toLane <<
"\n";
1895 (*i).shape.mirrorX();
1896 (*i).viaShape.mirrorX();
1900 std::vector<int> connNumbersPerLane(
myLanes.size(), 0);
1902 if ((*i).toEdge == 0 || (*i).fromLane < 0 || (*i).toLane < 0) {
1905 if ((*i).fromLane >= 0) {
1906 ++connNumbersPerLane[(*i).fromLane];
1917 for (
int i = 0; i < (int)
myLanes.size(); i++) {
1933 }
else if (common == 0) {
1936 const int origToLane = c.
toLane;
1938 int toLane = origToLane;
1951 int toLane = origToLane;
1986 if (incoming.size() > 1) {
1987 for (
int i = 0; i < (int)
myLanes.size(); i++) {
1989 bool connected =
false;
1990 for (std::vector<NBEdge*>::const_iterator in = incoming.begin(); in != incoming.end(); ++in) {
1991 if ((*in)->hasConnectionTo(
this, i)) {
2003 #ifdef DEBUG_CONNECTION_GUESSING 2005 std::cout <<
"recheckLanes (final) edge=" <<
getID() <<
"\n";
2007 std::cout <<
" conn " <<
getID() <<
"_" << (*i).fromLane <<
" to " <<
Named::getIDSecure((*i).toEdge) <<
"_" << (*i).toLane <<
"\n";
2008 (*i).shape.mirrorX();
2009 (*i).viaShape.mirrorX();
2019 if (outgoing->size() == 0) {
2031 #ifdef DEBUG_CONNECTION_GUESSING 2033 std::cout <<
" divideOnEdges " <<
getID() <<
" outgoing=" <<
toString(*outgoing) <<
" prios=" <<
toString(*priorities) <<
"\n";
2038 std::vector<int> availableLanes;
2039 for (
int i = 0; i < (int)
myLanes.size(); ++i) {
2041 availableLanes.push_back(i);
2044 if (availableLanes.size() > 0) {
2048 availableLanes.clear();
2049 for (
int i = 0; i < (int)
myLanes.size(); ++i) {
2054 availableLanes.push_back(i);
2056 if (availableLanes.size() > 0) {
2060 availableLanes.clear();
2061 for (
int i = 0; i < (int)
myLanes.size(); ++i) {
2066 availableLanes.push_back(i);
2068 if (availableLanes.size() > 0) {
2072 availableLanes.clear();
2073 for (
int i = 0; i < (int)
myLanes.size(); ++i) {
2078 availableLanes.push_back(i);
2080 if (availableLanes.size() > 0) {
2085 if ((*i).fromLane == -1) {
2104 const int numOutgoing = (int) outgoing->size();
2105 std::vector<double> resultingLanes;
2106 resultingLanes.reserve(numOutgoing);
2107 double sumResulting = 0.;
2108 double minResulting = 10000.;
2109 for (
int i = 0; i < numOutgoing; i++) {
2113 (double)(*priorities)[i] *
2114 (double) availableLanes.size() / (double) prioSum;
2116 if (res > availableLanes.size()) {
2117 res = (double) availableLanes.size();
2120 resultingLanes.push_back(res);
2121 sumResulting += res;
2122 if (minResulting > res && res > 0) {
2134 transition.reserve(numOutgoing);
2135 for (
int i = 0; i < numOutgoing; i++) {
2138 assert(i < (
int)resultingLanes.size());
2139 const int tmpNum = (int)std::ceil(resultingLanes[i] / minResulting);
2140 numVirtual += tmpNum;
2141 for (
double j = 0; j < tmpNum; j++) {
2142 transition.push_back((*outgoing)[i]);
2145 #ifdef DEBUG_CONNECTION_GUESSING 2147 std::cout <<
" prioSum=" << prioSum <<
" sumResulting=" << sumResulting <<
" minResulting=" << minResulting <<
" numVirtual=" << numVirtual <<
" availLanes=" <<
toString(availableLanes) <<
" resLanes=" <<
toString(resultingLanes) <<
" transition=" <<
toString(transition) <<
"\n";
2156 for (EdgeVector::const_iterator i = outgoing->begin(); i != outgoing->end(); ++i) {
2158 assert(l2eConns.find(target) != l2eConns.end());
2159 const std::vector<int> lanes = (l2eConns.find(target))->second;
2160 for (std::vector<int>::const_iterator j = lanes.begin(); j != lanes.end(); ++j) {
2161 const int fromIndex = availableLanes[*j];
2180 if (numConsToTarget >= targetLanes) {
2185 for (
int ii = 0; ii < (int)
myLanes.size(); ++ii) {
2193 if (
myLanes[fromIndex].connectionsDone) {
2199 #ifdef DEBUG_CONNECTION_GUESSING 2201 std::cout <<
" request connection from " <<
getID() <<
"_" << fromIndex <<
" to " << target->
getID() <<
"\n";
2214 const int numOutgoing = (int) outgoing->size();
2216 NBEdge* rightOfTarget = 0;
2217 NBEdge* leftOfTarget = 0;
2219 for (
int i = 0; i < numOutgoing; i++) {
2220 if (maxPrio < (*priorities)[i]) {
2223 maxPrio = (*priorities)[i];
2224 target = (*outgoing)[i];
2225 rightOfTarget = i == 0 ? outgoing->back() : (*outgoing)[i - 1];
2226 leftOfTarget = i + 1 == numOutgoing ? outgoing->front() : (*outgoing)[i + 1];
2238 const int numDesiredConsToTarget =
MIN2(targetLanes, (
int)availableLanes.size());
2239 #ifdef DEBUG_CONNECTION_GUESSING 2241 std::cout <<
" checking extra lanes for target=" << target->
getID() <<
" cons=" << numConsToTarget <<
" desired=" << numDesiredConsToTarget <<
"\n";
2244 std::vector<int>::const_iterator it_avail = availableLanes.begin();
2245 while (numConsToTarget < numDesiredConsToTarget && it_avail != availableLanes.end()) {
2246 const int fromIndex = *it_avail;
2255 && !
myLanes[fromIndex].connectionsDone
2257 #ifdef DEBUG_CONNECTION_GUESSING 2259 std::cout <<
" candidate from " <<
getID() <<
"_" << fromIndex <<
" to " << target->
getID() <<
"\n";
2268 #ifdef DEBUG_CONNECTION_GUESSING 2270 std::cout <<
" request additional connection from " <<
getID() <<
"_" << fromIndex <<
" to " << target->
getID() <<
"\n";
2276 #ifdef DEBUG_CONNECTION_GUESSING 2281 <<
" rightOfTarget=" << rightOfTarget->
getID()
2282 <<
" leftOfTarget=" << leftOfTarget->
getID()
2296 std::vector<int>* priorities =
new std::vector<int>();
2297 if (outgoing->size() == 0) {
2300 priorities->reserve(outgoing->size());
2301 EdgeVector::const_iterator i;
2302 for (i = outgoing->begin(); i != outgoing->end(); i++) {
2305 assert((prio + 1) * 2 > 0);
2306 prio = (prio + 1) * 2;
2307 priorities->push_back(prio);
2314 i = find(outgoing->begin(), outgoing->end(), *(tmp.begin()));
2315 int dist = (int) distance(outgoing->begin(), i);
2317 #ifdef DEBUG_CONNECTION_GUESSING 2319 <<
" outgoing=" <<
toString(*outgoing)
2320 <<
" priorities1=" <<
toString(*priorities)
2327 assert(priorities->size() > 0);
2328 (*priorities)[0] /= 2;
2329 #ifdef DEBUG_CONNECTION_GUESSING 2331 std::cout <<
" priorities2=" <<
toString(*priorities) <<
"\n";
2338 if (mainDirections.
empty()) {
2339 assert(dist < (
int)priorities->size());
2340 (*priorities)[dist] *= 2;
2341 #ifdef DEBUG_CONNECTION_GUESSING 2343 std::cout <<
" priorities3=" <<
toString(*priorities) <<
"\n";
2348 (*priorities)[dist] += 1;
2352 (*priorities)[0] /= 4;
2353 (*priorities)[(int)priorities->size() - 1] /= 2;
2354 #ifdef DEBUG_CONNECTION_GUESSING 2356 std::cout <<
" priorities6=" <<
toString(*priorities) <<
"\n";
2363 (*priorities)[dist] *= 2;
2364 #ifdef DEBUG_CONNECTION_GUESSING 2366 std::cout <<
" priorities4=" <<
toString(*priorities) <<
"\n";
2370 (*priorities)[dist] *= 3;
2371 #ifdef DEBUG_CONNECTION_GUESSING 2373 std::cout <<
" priorities5=" <<
toString(*priorities) <<
"\n";
2386 for (std::vector<int>::const_iterator i = priorities.begin(); i != priorities.end(); i++) {
2404 const int fromLane = (int)
myLanes.size() - 1;
2406 if (checkPermissions) {
2437 if (pos < tolerance) {
2451 for (
int i = 0; i < lanes; i++) {
2453 for (std::vector<NBEdge::Connection>::iterator j = elv.begin(); j != elv.end(); j++) {
2455 assert(el.
tlID ==
"");
2501 assert(fromLane < 0 || fromLane < (
int)
myLanes.size());
2503 if (fromLane >= 0 && toLane >= 0) {
2505 std::vector<Connection>::iterator i =
2513 connection.
tlID = tlID;
2521 bool hadError =
false;
2523 if ((*i).toEdge != toEdge) {
2526 if (fromLane >= 0 && fromLane != (*i).fromLane) {
2529 if (toLane >= 0 && toLane != (*i).toLane) {
2532 if ((*i).tlID ==
"") {
2534 (*i).tlLinkNo = tlIndex;
2537 if ((*i).tlID != tlID && (*i).tlLinkNo == tlIndex) {
2538 WRITE_WARNING(
"The lane '" + toString<int>((*i).fromLane) +
"' on edge '" +
getID() +
"' already had a traffic light signal.");
2543 if (hadError && no == 0) {
2544 WRITE_WARNING(
"Could not set any signal of the tlLogic '" + tlID +
"' (unknown group)");
2578 ret =
myLanes.back().shape.reverse();
2596 ret =
myLanes[0].shape.reverse();
2608 reason =
"laneNumber";
2613 reason =
"priority";
2623 reason =
"spreadType";
2632 for (
int i = 0; i < (int)
myLanes.size(); i++) {
2634 reason =
"lane " +
toString(i) +
" speed";
2636 }
else if (
myLanes[i].permissions != possContinuation->
myLanes[i].permissions) {
2637 reason =
"lane " +
toString(i) +
" permissions";
2639 }
else if (
myLanes[i].width != possContinuation->
myLanes[i].width) {
2640 reason =
"lane " +
toString(i) +
" width";
2664 if (find(conn.begin(), conn.end(), possContinuation) == conn.end()) {
2665 reason =
"disconnected";
2676 reason =
"disconnected";
2682 if (conns.size() !=
myLanes.size() - offset) {
2683 reason =
"some lanes disconnected";
2699 for (
int i = 0; i < (int)
myLanes.size(); i++) {
2728 if ((*i).toEdge == e && (*i).tlID !=
"") {
2760 assert(distances.size() > 0);
2767 assert(index <= (
int)
myLanes.size());
2771 int templateIndex = index > 0 ? index - 1 : index + 1;
2782 for (EdgeVector::const_iterator i = incs.begin(); i != incs.end(); ++i) {
2783 (*i)->invalidateConnections(
true);
2791 int newLaneNo = (int)
myLanes.size() + by;
2792 while ((
int)
myLanes.size() < newLaneNo) {
2802 assert(index < (
int)
myLanes.size());
2807 for (EdgeVector::const_iterator i = incs.begin(); i != incs.end(); ++i) {
2808 (*i)->invalidateConnections(
true);
2817 int newLaneNo = (int)
myLanes.size() - by;
2818 assert(newLaneNo > 0);
2819 while ((
int)
myLanes.size() > newLaneNo) {
2837 for (
int i = 0; i < (int)
myLanes.size(); i++) {
2841 assert(lane < (
int)
myLanes.size());
2842 myLanes[lane].permissions |= vclass;
2850 for (
int i = 0; i < (int)
myLanes.size(); i++) {
2854 assert(lane < (
int)
myLanes.size());
2855 myLanes[lane].permissions &= ~vclass;
2863 for (
int i = 0; i < (int)
myLanes.size(); i++) {
2867 assert(lane < (
int)
myLanes.size());
2868 myLanes[lane].preferred |= vclass;
2878 for (
int i = 0; i < (int)
myLanes.size(); i++) {
2884 assert(lane < (
int)
myLanes.size());
2900 for (
int i = 0; i < (int)
myLanes.size(); i++) {
2917 for (
int i = 0; i < (int)
myLanes.size(); i++) {
2923 assert(lane < (
int)
myLanes.size());
2924 myLanes[lane].endOffset = offset;
2933 for (
int i = 0; i < (int)
myLanes.size(); i++) {
2939 assert(lane < (
int)
myLanes.size());
2946 assert(lane < (
int)
myLanes.size());
2947 myLanes[lane].accelRamp = accelRamp;
2954 assert(lane < (
int)
myLanes.size());
2955 myLanes[lane].customShape = shape;
2962 for (
int i = 0; i < (int)
myLanes.size(); i++) {
2967 assert(lane < (
int)
myLanes.size());
2968 myLanes[lane].permissions = permissions;
2976 for (
int i = 0; i < (int)
myLanes.size(); i++) {
2981 assert(lane < (
int)
myLanes.size());
2982 myLanes[lane].preferred = permissions;
2991 for (
int i = 0; i < (int)
myLanes.size(); i++) {
2996 assert(lane < (
int)
myLanes.size());
2997 return myLanes[lane].permissions;
3010 for (std::vector<Lane>::iterator i =
myLanes.begin(); i !=
myLanes.end(); ++i) {
3011 (*i).permissions =
SVCAll;
3034 for (
int i = start; i != end; i += direction) {
3046 std::set<SVCPermissions>
3048 std::set<SVCPermissions> result;
3052 for (
int i = iStart; i < iEnd; ++i) {
3069 std::cout <<
getID() <<
" angle=" <<
getAngleAtNode(node) <<
" convAngle=" << angle <<
"\n";
3111 if (
myLanes[0].permissions == vclass) {
3123 myLanes[0].permissions = vclass;
3134 for (EdgeVector::const_iterator it = incoming.begin(); it != incoming.end(); ++it) {
3135 (*it)->shiftToLanesToEdge(
this, 1);
3146 if (
myLanes[0].permissions != vclass) {
3156 for (EdgeVector::const_iterator it = incoming.begin(); it != incoming.end(); ++it) {
3157 (*it)->shiftToLanesToEdge(
this, 0);
3170 if ((*it).toEdge == to && (*it).toLane >= 0) {
3171 (*it).toLane += laneOff;
3180 const int i = (node ==
myTo ? -1 : 0);
3181 const int i2 = (node ==
myTo ? 0 : -1);
3187 if (dist < neededOffset && dist2 < neededOffset2) {
3195 WRITE_WARNING(
"Could not avoid overlapping shape at node '" + node->
getID() +
"' for edge '" +
getID() +
"'");
NBEdge::Lane getFirstNonPedestrianLane(int direction) const
get first non-pedestrian lane
bool gDebugFlag1
global utility flags for debugging
std::string id
id of Connection
void moveConnectionToRight(int lane)
void invalidateConnections(bool reallowSetting=false)
invalidate current connections of edge
NBNode * tryGetNodeAtPosition(double pos, double tolerance=5.0) const
Returns the node at the given edges length (using an epsilon)
int tlLinkNo
The index of this connection within the controlling traffic light.
void init(int noLanes, bool tryIgnoreNodePositions, const std::string &origID)
Initialization routines common to all constructors.
The link is a partial left direction.
std::vector< Lane > myLanes
Lane information.
bool includes(Direction d) const
returns the information whether the street in the given direction has a higher priority ...
double vmax
maximun velocity
PositionVector cutAtIntersection(const PositionVector &old) const
cut shape at the intersection shapes
double z() const
Returns the z-position.
const EdgeVector & getIncomingEdges() const
Returns this node's incoming edges (The edges which yield in this node)
const std::string & getTypeID() const
get ID of type
bool setControllingTLInformation(const NBConnection &c, const std::string &tlID)
Returns if the link could be set as to be controlled.
void divideOnEdges(const EdgeVector *outgoing)
divides the lanes on the outgoing edges
A structure which describes a connection between edges or lanes.
int toLane
The lane the connections yields in.
std::string foeIncomingLanes
FOE Incomings lanes.
static const double UNSPECIFIED_LOADED_LENGTH
no length override given
int getTLIndex() const
returns the index within the controlling tls or InvalidTLIndex if this link is unontrolled ...
std::vector< TLSDisabledConnection > myTLSDisabledConnections
vector with the disabled connections
void append(const PositionVector &v, double sameThreshold=2.0)
LaneSpreadFunction myLaneSpreadFunction
The information about how to spread the lanes.
void sortOutgoingConnectionsByAngle()
sorts the outgoing connections by their angle relative to their junction
std::string viaID
if Connection have a via, ID of it
double getAngleAtNodeToCenter(const NBNode *const node) const
Returns the angle of from the node shape center to where the edge meets the node shape.
NBEdge * toEdge
The edge the connections yields in.
bool hasDefaultGeometry() const
Returns whether the geometry consists only of the node positions.
void shiftTLConnectionLaneIndex(NBEdge *edge, int offset)
patches loaded signal plans by modifying lane indices
void mirrorX()
mirror coordinates along the x-axis
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types...
static const double UNSPECIFIED_VISIBILITY_DISTANCE
unspecified foe visibility for connections
bool hasAccelLane() const
whether one of the lanes is an acceleration lane
void setEndOffset(int lane, double offset)
set lane specific end-offset (negative lane implies set for all lanes)
The relationships between edges are computed/loaded.
double getAngleAtNode(const NBNode *const node) const
Returns the angle of the edge's geometry at the given node.
void reduceGeometry(const double minDist)
Removes points with a distance lesser than the given.
bool expandableBy(NBEdge *possContinuation, std::string &reason) const
Check if Node is expandable.
bool around(const Position &p, double offset=0) const
Returns the information whether the position vector describes a polygon lying around the given point...
double myLaneWidth
This width of this edge's lanes.
bool empty() const
returns the information whether no following street has a higher priority
std::vector< Connection > getConnectionsFromLane(int lane) const
Returns connections from a given lane.
bool isNearEnough2BeJoined2(NBEdge *e, double threshold) const
Check if edge is near enought to be joined to another edge.
double getLoadedLength() const
Returns the length was set explicitly or the computed length if it wasn't set.
double nearest_offset_to_point2D(const Position &p, bool perpendicular=true) const
return the nearest offest to point 2D
bool hasLaneSpecificEndOffset() const
whether lanes differ in offset
double myEndOffset
This edges's offset to the intersection begin (will be applied to all lanes)
void setSpeed(int lane, double speed)
set lane specific speed (negative lane implies set for all lanes)
bool isTLControlled() const
Returns whether this node is controlled by any tls.
Holds (- relative to the edge it is build from -!!!) the list of main directions a vehicle that drive...
double getFloat(const std::string &name) const
Returns the double-value of the named option (only for Option_Float)
double getTotalWidth() const
Returns the combined width of all lanes of this edge.
Some static methods for string processing.
static const double ANGLE_LOOKAHEAD
the distance at which to take the default angle
const std::vector< NBEdge::Lane > & getLanes() const
Returns the lane definitions.
void moveConnectionToLeft(int lane)
void removeEdge(NBEdge *edge, bool removeFromConnections=true)
Removes edge from this node and optionally removes connections as well.
const double SUMO_const_laneWidth
std::vector< double > intersectsAtLengths2D(const PositionVector &other) const
For all intersections between this vector and other, return the 2D-length of the subvector from this ...
void addIncomingEdge(NBEdge *edge)
adds an incoming edge
int SVCPermissions
bitset where each bit declares whether a certain SVC may use this edge/lane
bool getBool(const std::string &name) const
Returns the boolean-value of the named option (only for Option_Bool)
The representation of a single edge during network building.
void reinitNodes(NBNode *from, NBNode *to)
Resets nodes but keeps all other values the same (used when joining)
void clearControllingTLInformation()
clears tlID for all connections
void setNodeBorder(const NBNode *node, const Position &p, const Position &p2, bool rectangularCut)
Set Node border.
Lane2LaneInfoType
Modes of setting connections between lanes.
std::vector< int > * prepareEdgePriorities(const EdgeVector *outgoing)
recomputes the edge priorities and manipulates them for a distribution of lanes on edges which is mor...
bool mayBeTLSControlled(int fromLane, NBEdge *toEdge, int toLane) const
return true if certain connection must be controlled by TLS
bool hasDefaultGeometryEndpoints() const
Returns whether the geometry is terminated by the node positions This default may be violated by init...
Lane(NBEdge *e, const std::string &_origID)
constructor
const double SUMO_const_laneWidthAndOffset
The link is a 180 degree turn.
Position getCentroid() const
Returns the centroid (closes the polygon if unclosed)
int getFromLane() const
returns the from-lane
static const double UNSPECIFIED_SIGNAL_OFFSET
unspecified signal offset
PositionVector getCCWBoundaryLine(const NBNode &n) const
get the outer boundary of this edge when going counter-clock-wise around the given node ...
bool intersects(const Position &p1, const Position &p2) const
Returns the information whether this list of points interesects the given line.
std::string getDescription(const NBEdge *parent) const
get string describing this connection
EdgeVector getIncomingEdges() const
Returns the list of incoming edges unsorted.
std::vector< Direction > myDirs
list of the main direction within the following junction relative to the edge
void markAsInLane2LaneState()
mark edge as in lane to state lane
double distance2D(const Position &p, bool perpendicular=false) const
closest 2D-distance to point p (or -1 if perpendicular is true and the point is beyond this vector) ...
static const double UNSPECIFIED_OFFSET
unspecified lane offset
void removeFromConnections(NBEdge *toEdge, int fromLane=-1, int toLane=-1, bool tryLater=false, const bool adaptToLaneRemoval=false)
Removes the specified connection(s)
double getMaxLaneOffset()
get max lane offset
double getSignalOffset() const
Returns the offset of a traffic signal from the end of this edge.
PositionVector computeInternalLaneShape(NBEdge *fromE, const NBEdge::Connection &con, int numPoints, NBNode *recordError=0) const
Compute the shape for an internal lane.
TLS Disabled Connections.
Lanes to lanes - relationships are computed; should be recheked.
void setPermissions(SVCPermissions permissions, int lane=-1)
set allowed/disallowed classes for the given lane or for all lanes if -1 is given ...
double getEndOffset() const
Returns the offset to the destination node.
double getSpeed() const
Returns the speed allowed on this edge.
PositionVector shape
The lane's shape.
int myFromJunctionPriority
The priority normalised for the node the edge is outgoing of.
void setLoadedLength(double val)
set loaded lenght
static std::string getIDSecure(const T *obj, const std::string &fallBack="NULL")
get an identifier for Named-like object which may be Null
void computeLaneShapes()
compute lane shapes
bool mayDefinitelyPass
Information about being definitely free to drive (on-ramps)
PositionVector getSubpartByIndex(int beginIndex, int count) const
get subpart of a position vector using index and a cout
bool hasDefaultGeometryEndpointAtNode(const NBNode *node) const
Returns whether the geometry is terminated by the node positions This default may be violated by init...
NBEdge(const std::string &id, NBNode *from, NBNode *to, std::string type, double speed, int nolanes, int priority, double width, double offset, const std::string &streetName="", LaneSpreadFunction spread=LANESPREAD_RIGHT)
Constructor.
PositionVector getSubpart2D(double beginOffset, double endOffset) const
get subpart of a position vector in two dimensions (Z is ignored)
PositionVector myGeom
The geometry for the edge.
double visibility
custom foe visiblity for connection
bool isForbidden(SVCPermissions permissions)
Returns whether an edge with the given permission is a forbidden edge.
void remapConnections(const EdgeVector &incoming)
Remaps the connection in a way that allows the removal of it.
const double SUMO_const_laneOffset
PositionVector getOrthogonal(const Position &p, double extend, bool before, double length=1.0) const
return orthogonal through p (extending this vector if necessary)
void insert_noDoublePos(const std::vector< Position >::iterator &at, const Position &p)
insert in front a non double position
bool isRailway(SVCPermissions permissions)
Returns whether an edge with the given permission is a railway edge.
const SVCPermissions SVCAll
all VClasses are allowed
PositionVector myFromBorder
intersection borders (because the node shape might be invalid)
void restoreBikelane(std::vector< NBEdge::Lane > oldLanes, PositionVector oldGeometry, std::vector< NBEdge::Connection > oldConnections)
restore an previously added BikeLane
void addSidewalk(double width)
add a pedestrian sidewalk of the given width and shift existing connctions
void addOutgoingEdge(NBEdge *edge)
adds an outgoing edge
void setGeometry(const PositionVector &g, bool inner=false)
(Re)sets the edge's geometry
void shiftLaneIndex(NBEdge *edge, int offset)
patches lane indices refering to the given edge
static const double UNSPECIFIED_WIDTH
unspecified lane width
The link is a (hard) left direction.
#define WRITE_WARNING(msg)
bool isConnectedTo(const NBEdge *e) const
Returns the information whethe a connection to the given edge has been added (or computed) ...
The connection was computed and validated.
static OptionsCont & getOptions()
Retrieves the options.
bool setConnection(int lane, NBEdge *destEdge, int destLane, Lane2LaneInfoType type, bool mayUseSameDestination=false, bool mayDefinitelyPass=false, bool keepClear=true, double contPos=UNSPECIFIED_CONTPOS, double visibility=UNSPECIFIED_VISIBILITY_DISTANCE)
Adds a connection to a certain lane of a certain edge.
void shortenGeometryAtNode(const NBNode *node, double reduction)
linearly extend the geometry at the given node
void setLaneShape(int lane, const PositionVector &shape)
sets a custom lane shape
void setAcceleration(int lane, bool accelRamp)
marks one lane as acceleration lane
static bool rightTurnConflict(const NBEdge *from, const NBEdge *to, int fromLane, const NBEdge *prohibitorFrom, const NBEdge *prohibitorTo, int prohibitorFromLane, bool lefthand=false)
return whether the given laneToLane connection is a right turn which must yield to a bicycle crossing...
static double legacyDegree(const double angle, const bool positive=false)
PositionVector reverse() const
reverse position vector
The edge has been loaded, nothing is computed yet.
LinkDirection
The different directions a link between two lanes may take (or a stream between two edges)...
int myToJunctionPriority
The priority normalised for the node the edge is incoming in.
EdgeVector getConnectedEdges() const
Returns the list of outgoing edges unsorted.
The link is a straight direction.
PositionVector shape
shape of Connection
static const double UNSPECIFIED_SPEED
unspecified lane speed
void restoreSidewalk(std::vector< NBEdge::Lane > oldLanes, PositionVector oldGeometry, std::vector< NBEdge::Connection > oldConnections)
restore an previously added sidewalk
bool keepClear
whether the junction must be kept clear when using this connection
void addRestrictedLane(double width, SUMOVehicleClass vclass)
add a lane of the given width, restricted to the given class and shift existing connections ...
const EdgeVector & getOutgoingEdges() const
Returns this node's outgoing edges (The edges which start at this node)
bool hasPermissions() const
whether at least one lane has restrictions
An (internal) definition of a single lane of an edge.
const std::string & getID() const
Returns the id.
void addLane(int index, bool recompute=true)
add lane
bool needsCont(const NBEdge *fromE, const NBEdge *otherFromE, const NBEdge::Connection &c, const NBEdge::Connection &otherC) const
whether an internal junction should be built at from and respect other
bool addEdge2EdgeConnection(NBEdge *dest)
Adds a connection to another edge.
void extrapolate2D(const double val, const bool onlyFirst=false)
extrapolate position vector in two dimensions (Z is ignored)
void incLaneNo(int by)
increment lane
bool myAmMacroscopicConnector
Information whether this edge is a (macroscopic) connector.
double getShapeEndAngle() const
Returns the angle at the end of the edge.
const PositionVector getInnerGeometry() const
Returns the geometry of the edge without the endpoints.
void push_front_noDoublePos(const Position &p)
insert in front a non double position
void removeDoublePoints(double minDist=POSITION_EPS, bool assertLength=false)
Removes positions if too near.
const Position & getPosition() const
std::vector< double > distances(const PositionVector &s, bool perpendicular=false) const
distances of all my points to s and all of s points to myself
bool computeLanes2Edges()
computes the edge, step2: computation of which lanes approach the edges)
NBEdge * myTurnDestination
The turn destination edge (if a connection exists)
double myStartAngle
The angles of the edge.
Lanes to lanes - relationships are loaded; no recheck is necessary/wished.
Connection getConnection(int fromLane, const NBEdge *to, int toLane) const
Returns the specified connection This method goes through "myConnections" and returns the specified o...
double getLaneWidth() const
Returns the default width of lanes of this edge.
int operator()(const Connection &c1, const Connection &c2) const
comparing operation
bool hasConnectionTo(NBEdge *destEdge, int destLane, int fromLane=-1) const
Retrieves info about a connection to a certain lane of a certain edge.
const std::set< NBTrafficLightDefinition * > & getControllingTLS() const
Returns the traffic lights that were assigned to this node (The set of tls that control this node) ...
bool hasLaneSpecificSpeed() const
whether lanes differ in speed
int getPriority() const
Returns the priority of the edge.
bool insert(NBEdge *edge, bool ignorePrunning=false)
Adds an edge to the dictionary.
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
static const int FORWARD
edge directions (for pedestrian related stuff)
void decLaneNo(int by)
decrement lane
std::string tlID
The id of the traffic light that controls this connection.
std::string getInternalLaneID() const
get ID of internal lane
int fromLane
The lane the connections starts at.
A point in 2D or 3D with translation and scaling methods.
void deleteLane(int index, bool recompute=true)
delete lane
bool addLane2LaneConnections(int fromLane, NBEdge *dest, int toLane, int no, Lane2LaneInfoType type, bool invalidatePrevious=false, bool mayDefinitelyPass=false)
Builds no connections starting at the given lanes.
void moveOutgoingConnectionsFrom(NBEdge *e, int laneOff)
move outgoing connection
bool hasLaneSpecificPermissions() const
whether lanes differ in allowed vehicle classes
bool lanesWereAssigned() const
Check if lanes were assigned.
static int computePrioritySum(const std::vector< int > &priorities)
computes the sum of the given list's entries (sic!)
static bool connections_sorter(const Connection &c1, const Connection &c2)
connections_sorter sort by fromLane, toEdge and toLane
void resetNodeBorder(const NBNode *node)
static const double UNSPECIFIED_CONTPOS
unspecified internal junction position
const std::map< NBEdge *, std::vector< int > > & getBuiltConnections() const
get built connections
SumoXMLNodeType getType() const
Returns the type of this node.
bool geometryLike() const
whether this is structurally similar to a geometry node
NBEdge * myPossibleTurnDestination
The edge that would be the turn destination if there was one.
PositionVector getCWBoundaryLine(const NBNode &n) const
get the outer boundary of this edge when going clock-wise around the given node
PositionVector computeLaneShape(int lane, double offset) const
Computes the shape for the given lane.
bool hasLoadedLength() const
Returns whether a length was set explicitly.
int getNumLanes() const
Returns the number of lanes.
bool isTurningDirectionAt(const NBEdge *const edge) const
Returns whether the given edge is the opposite direction to this edge.
double length() const
Returns the length.
int myPriority
The priority of the edge.
static double firstIntersection(const PositionVector &v1, const PositionVector &v2, double width2)
compute the first intersection point between the given lane geometries considering their rspective wi...
int getFirstNonPedestrianLaneIndex(int direction, bool exclusive=false) const
return the first lane with permissions other than SVC_PEDESTRIAN and 0
Storage for edges, including some functionality operating on multiple edges.
std::string origID
origin ID
bool needsLaneSpecificOutput() const
whether at least one lane has values differing from the edges values
std::vector< std::string > & split(const std::string &s, char delim, std::vector< std::string > &elems)
The link is a (hard) right direction.
Connection(int fromLane_, NBEdge *toEdge_, int toLane_)
Constructor.
EdgeBuildingStep myStep
The building step.
bool canMoveConnection(const Connection &con, int newFromLane) const
whether the connection can originate on newFromLane
std::string getLaneIDInsecure(int lane) const
get Lane ID (Insecure)
Position positionAtOffset2D(double pos, double lateralOffset=0) const
Returns the position at the given length.
Class to sort edges by their angle.
void buildInnerEdges(const NBNode &n, int noInternalNoSplits, int &linkIndex, int &splitIndex)
LinkDirection getDirection(const NBEdge *const incoming, const NBEdge *const outgoing, bool leftHand=false) const
Returns the representation of the described stream's direction.
static const double INVALID_OFFSET
a value to signify offsets outside the range of [0, Line.length()]
std::vector< Connection > myConnections
List of connections to following edges.
void execute(const int lane, const int virtEdge)
executes a bresenham - step
The connection was given by the user.
void reinit(NBNode *from, NBNode *to, const std::string &type, double speed, int nolanes, int priority, PositionVector geom, double width, double offset, const std::string &streetName, LaneSpreadFunction spread=LANESPREAD_RIGHT, bool tryIgnoreNodePositions=false)
Resets initial values.
const PositionVector & getShape() const
retrieve the junction shape
The link is a partial right direction.
double speed
The speed allowed on this lane.
void move2side(double amount)
move position vector to side using certain ammount
vehicle is a passenger car (a "normal" car)
double distanceTo(const Position &p2) const
returns the euclidean distance in 3 dimension
bool myAmInnerEdge
Information whether this is a junction-inner edge.
bool isLeftMover(const NBEdge *const from, const NBEdge *const to) const
Computes whether the given connection is a left mover across the junction.
Base class for objects which have an id.
bool recheckLanes()
recheck whether all lanes within the edge are all right and optimises the connections once again ...
int getJunctionPriority(const NBNode *const node) const
Returns the junction priority (normalised for the node currently build)
PositionVector startShapeAt(const PositionVector &laneShape, const NBNode *startNode, PositionVector nodeShape) const
double mySpeed
The maximal speed.
static std::string convertUmlaute(std::string str)
Converts german "Umlaute" to their latin-version.
int internalLaneIndex
The lane index of this internal lane within the internal edge.
void extendGeometryAtNode(const NBNode *node, double maxExtent)
linearly extend the geometry at the given node
SVCPermissions getPermissions(int lane=-1) const
get the union of allowed classes over all lanes or for a specific lane
PositionVector smoothedZFront(double dist=std::numeric_limits< double >::max()) const
returned vector that is smoothed at the front (within dist)
void setTurningDestination(NBEdge *e, bool onlyPossible=false)
Sets the turing destination at the given edge.
static const int BACKWARD
double getLaneSpeed(int lane) const
get lane speed
std::string myID
The name of the object.
void extrapolate(const double val, const bool onlyFirst=false, const bool onlyLast=false)
extrapolate position vector
NBNode * getToNode() const
Returns the destination node of the edge.
double getLength() const
Returns the computed length of the edge.
double width
This lane's width.
std::vector< int > getConnectionLanes(NBEdge *currentOutgoing) const
Returns the list of lanes that may be used to reach the given edge.
double length2D() const
Returns the length.
void computeEdgeShape()
Recomputeds the lane shapes to terminate at the node shape For every lane the intersection with the f...
void addStraightConnections(const EdgeVector *outgoing, const std::vector< int > &availableLanes, const std::vector< int > *priorities)
add some straight connections
void disableConnection4TLS(int fromLane, NBEdge *toEdge, int toLane)
disable connections for TLS
PositionVector viaShape
shape of via
PositionVector myToBorder
double getCrossingAngle(NBNode *node)
return the angle for computing pedestrian crossings at the given node
std::vector< NBEdge * > EdgeVector
container for (sorted) edges
static const int UNSPECIFIED_INTERNAL_LANE_INDEX
internal lane computation not yet done
void setPreferredVehicleClass(SVCPermissions permissions, int lane=-1)
set preferred Vehicle Class
double mySignalOffset
the offset of a traffic light signal from the end of this edge (-1 for None)
const PositionVector & getGeometry() const
Returns the geometry of the edge.
The edge has been loaded and connections shall not be added.
double getFinalLength() const
get length that will be assigned to the lanes in the final network
int getToLane() const
returns the to-lane
std::vector< Connection > myConnectionsToDelete
List of connections marked for delayed removal.
double contPos
custom position for internal junction on this connection
bool uncontrolled
check if Connection is uncontrolled
void setJunctionPriority(const NBNode *const node, int prio)
Sets the junction priority of the edge.
void addBikeLane(double width)
add a bicycle lane of the given width and shift existing connctions
bool insert(const std::string &id, const Position &position, NBDistrict *district=0)
Inserts a node into the map.
const EdgeVector * getConnectedSorted()
Returns the list of outgoing edges without the turnaround sorted in clockwise direction.
void restoreRestrictedLane(SUMOVehicleClass vclass, std::vector< NBEdge::Lane > oldLanes, PositionVector oldGeometry, std::vector< NBEdge::Connection > oldConnections)
restore a restricted lane
void sortOutgoingConnectionsByIndex()
sorts the outgoing connections by their from-lane-index and their to-lane-index
std::string myType
The type of the edge.
LaneSpreadFunction
Numbers representing special SUMO-XML-attribute values Information how the edge's lateral offset shal...
void append(NBEdge *continuation)
append another edge
bool addLane2LaneConnection(int fromLane, NBEdge *dest, int toLane, Lane2LaneInfoType type, bool mayUseSameDestination=false, bool mayDefinitelyPass=false, bool keepClear=true, double contPos=UNSPECIFIED_CONTPOS, double visibility=UNSPECIFIED_VISIBILITY_DISTANCE)
Adds a connection between the specified this edge's lane and an approached one.
NBEdge * getTo() const
returns the to-edge (end of the connection)
The connection was computed.
LaneSpreadFunction getLaneSpreadFunction() const
Returns how this edge's lanes' lateral offset is computed.
EdgeVector edges
The edges being crossed.
Represents a single node (junction) during network building.
MainDirections(const EdgeVector &outgoing, NBEdge *parent, NBNode *to, int indexOfStraightest)
constructor
void dismissVehicleClassInformation()
dimiss vehicle class information
bool hasSignalisedConnectionTo(const NBEdge *const e) const
Check if edge has signalised connections.
Lanes to lanes - relationships are computed; no recheck is necessary/wished.
A definition of a pedestrian crossing.
void replaceInConnections(NBEdge *which, NBEdge *by, int laneOff)
replace in current connections of edge
PositionVector getSubpart(double beginOffset, double endOffset) const
get subpart of a position vector
bool hasLaneSpecificWidth() const
whether lanes differ in width
bool hasCustomLaneShape() const
whether one of the lanes has a custom shape
void appendTurnaround(bool noTLSControlled, bool checkPermissions)
Add a connection to the previously computed turnaround, if wished.
static void compute(BresenhamCallBack *callBack, const int val1, const int val2)
double getShapeStartAngle() const
Returns the angle at the start of the edge.
Direction
enum of possible directions
std::pair< PositionVector, PositionVector > splitAt(double where) const
Returns the two lists made when this list vector is splitted at the given point.
void preferVehicleClass(int lane, SUMOVehicleClass vclass)
prefer certain vehicle class
void checkGeometry(const double maxAngle, const double minRadius, bool fix)
Check the angles of successive geometry segments.
void push_back_noDoublePos(const Position &p)
insert in back a non double position
std::string getLaneID(int lane) const
get Lane ID (Secure)
void allowVehicleClass(int lane, SUMOVehicleClass vclass)
set allowed class for the given lane or for all lanes if -1 is given
void insertConnection(NBEdge::Connection connection)
insert a previously created NBEdge::connection
void addGeometryPoint(int index, const Position &p)
Adds a further geometry point.
void shiftToLanesToEdge(NBEdge *to, int laneOff)
modifify the toLane for all connections to the given edge
void computeAngle()
computes the angle of this edge and stores it in myAngle
NBNode * retrieve(const std::string &id) const
Returns the node with the given name.
Container for nodes during the netbuilding process.
bool computeEdge2Edges(bool noLeftMovers)
computes the edge (step1: computation of approached edges)
static T maxValue(const std::vector< T > &v)
static double angleDiff(const double angle1, const double angle2)
Returns the difference of the second angle to the first angle in radiants.
bool haveVia
check if Connection have a Via
int getInt(const std::string &name) const
Returns the int-value of the named option (only for Option_Integer)
void add(double xoff, double yoff, double zoff)
bool foes(const NBEdge *const from1, const NBEdge *const to1, const NBEdge *const from2, const NBEdge *const to2) const
Returns the information whether the given flows cross.
void setLaneSpreadFunction(LaneSpreadFunction spread)
(Re)sets how the lanes lateral offset shall be computed
double myLength
The length of the edge.
std::vector< Crossing * > getCrossings() const
return this junctions pedestrian crossings
#define WRITE_MESSAGE(msg)
void divideSelectedLanesOnEdges(const EdgeVector *outgoing, const std::vector< int > &availableLanes, const std::vector< int > *priorities)
divide selected lanes on edges
std::set< SVCPermissions > getPermissionVariants(int iStart, int iEnd) const
return all permission variants within the specified lane range [iStart, iEnd[
double myLoadedLength
An optional length to use (-1 if not valid)
void closePolygon()
ensures that the last position equals the first
Lanes to edges - relationships are computed/loaded.
std::string myStreetName
The street name (or whatever arbitrary string you wish to attach)
double viaVmax
Maximun velocity of via.
const std::string & getStreetName() const
Returns the street name of this edge.
NBNode * myFrom
The source and the destination node.
NBEdge * getTurnDestination(bool possibleDestination=false) const
Connection & getConnectionRef(int fromLane, const NBEdge *to, int toLane)
Returns reference to the specified connection This method goes through "myConnections" and returns th...
std::vector< int > foeInternalLinks
FOE Internal links.
~MainDirections()
destructor
const PositionVector & getLaneShape(int i) const
Returns the shape of the nth lane.
static bool isTrafficLight(SumoXMLNodeType type)
return whether the given type is a traffic light
void shiftPositionAtNode(NBNode *node, NBEdge *opposite)
shift geometry at the given node to avoid overlap
double angleAt2D(int pos) const
get angle in certain position of position vector
std::string joinToString(const std::vector< T > &v, const T_BETWEEN &between, std::streamsize accuracy=gPrecision)
void disallowVehicleClass(int lane, SUMOVehicleClass vclass)
set disallowed class for the given lane or for all lanes if -1 is given
double angleTo2D(const Position &other) const
returns the angle in the plane of the vector pointing from here to the other position ...
void copyConnectionsFrom(NBEdge *src)
copy connections from antoher edge
A class that being a bresenham-callback assigns the incoming lanes to the edges.
void setLaneWidth(int lane, double width)
set lane specific width (negative lane implies set for all lanes)
double beginEndAngle() const
returns the angle in radians of the line connecting the first and the last position ...
void reshiftPosition(double xoff, double yoff)
Applies an offset to the edge.
bool forbids(const NBEdge *const possProhibitorFrom, const NBEdge *const possProhibitorTo, const NBEdge *const possProhibitedFrom, const NBEdge *const possProhibitedTo, bool regardNonSignalisedLowerPriority) const
Returns the information whether "prohibited" flow must let "prohibitor" flow pass.
void setz(double z)
set position z
NBNode * getFromNode() const
Returns the origin node of the edge.
bool splitGeometry(NBEdgeCont &ec, NBNodeCont &nc)
Splits this edge at geometry points.