57 #ifdef CHECK_MEMORY_LEAKS
59 #endif // CHECK_MEMORY_LEAKS
86 assert(myTransitions.size() > virtEdge);
88 NBEdge* succEdge = myTransitions[virtEdge];
89 std::vector<unsigned int> lanes;
93 std::map<NBEdge*, std::vector<unsigned int> >::iterator i =
myConnections.find(succEdge);
101 std::vector<unsigned int>::iterator j = find(lanes.begin(), lanes.end(), lane);
102 if (j == lanes.end()) {
104 lanes.push_back(lane);
117 if (outgoing.size() == 0) {
121 assert(outgoing.size() > 0);
126 if (outgoing.back()->getJunctionPriority(to) == 1) {
132 if (outgoing.back()->getPriority() > tmp[0]->getPriority()) {
135 if (outgoing.back()->getNumLanes() > tmp[0]->getNumLanes()) {
144 NBEdge* edge = *(tmp.begin());
157 return myDirs.empty();
163 return find(myDirs.begin(), myDirs.end(), d) != myDirs.end();
183 std::string type,
SUMOReal speed,
unsigned int nolanes,
185 const std::string& streetName,
201 init(nolanes,
false);
206 std::string type,
SUMOReal speed,
unsigned int nolanes,
209 const std::string& streetName,
214 myFrom(from), myTo(to),
215 myStartAngle(0), myEndAngle(0), myTotalAngle(0),
216 myPriority(priority), mySpeed(speed),
217 myTurnDestination(0),
218 myPossibleTurnDestination(0),
219 myFromJunctionPriority(-1), myToJunctionPriority(-1),
220 myGeom(geom), myLaneSpreadFunction(spread), myEndOffset(offset), myLaneWidth(laneWidth),
221 myLoadedLength(UNSPECIFIED_LOADED_LENGTH), myAmLeftHand(false),
222 myAmInnerEdge(false), myAmMacroscopicConnector(false),
223 myStreetName(streetName),
224 mySignalOffset(UNSPECIFIED_SIGNAL_OFFSET) {
225 init(nolanes, tryIgnoreNodePositions);
232 myType(tpl->getTypeID()),
233 myFrom(from), myTo(to),
234 myStartAngle(0), myEndAngle(0), myTotalAngle(0),
235 myPriority(tpl->getPriority()), mySpeed(tpl->getSpeed()),
236 myTurnDestination(0),
237 myPossibleTurnDestination(0),
238 myFromJunctionPriority(-1), myToJunctionPriority(-1),
240 myLaneSpreadFunction(tpl->getLaneSpreadFunction()),
241 myEndOffset(tpl->getEndOffset()),
242 myLaneWidth(tpl->getLaneWidth()),
243 myLoadedLength(UNSPECIFIED_LOADED_LENGTH),
245 myAmInnerEdge(false),
246 myAmMacroscopicConnector(false),
247 myStreetName(tpl->getStreetName()),
248 mySignalOffset(to == tpl->myTo ? tpl->mySignalOffset : UNSPECIFIED_SIGNAL_OFFSET) {
255 if (to == tpl->
myTo) {
264 SUMOReal speed,
unsigned int nolanes,
int priority,
266 const std::string& streetName,
268 bool tryIgnoreNodePositions) {
290 const std::vector<Lane> oldLanes =
myLanes;
291 init(nolanes, tryIgnoreNodePositions);
292 for (
int i = 0; i < (int)nolanes; ++i) {
294 myLanes[i] = oldLanes[
MIN2(i, (
int)oldLanes.size() - 1)];
313 if (from == 0 || to == 0) {
314 throw ProcessError(
"At least one of edge's '" +
myID +
"' nodes is not known.");
336 throw ProcessError(
"At least one of edge's '" +
myID +
"' nodes is not known.");
342 if (!tryIgnoreNodePositions ||
myGeom.size() < 2) {
357 WRITE_ERROR(
"Edge's '" +
myID +
"' from- and to-node are at the same position.");
365 assert(
myGeom.size() >= 2);
367 for (
unsigned int i = 0; i < noLanes; i++) {
382 for (
unsigned int i = 0; i <
myLanes.size(); i++) {
383 myLanes[i].shape.reshiftRotate(xoff, yoff, 0);
428 for (
unsigned int i = 0; i <
myLanes.size(); i++) {
432 if (shape.size() >= 2) {
443 assert(shape.size() >= 2);
444 assert(shape.
length() > 0);
449 Line lc(shape[0], shape[-1]);
450 Line lo(old[0], old[-1]);
459 for (
unsigned int i = 0; i <
myLanes.size(); i++) {
460 assert(
myLanes[i].shape.length() > 0);
461 avgLength +=
myLanes[i].shape.length();
477 assert(pbv.size() > 0);
481 ns[0].set(ns[0].x(), ns[0].y(), startNode->
getPosition().
z());
486 assert(pbv.size() > 0);
537 NBEdge* currentEdge =
this;
538 for (
int i = 1; i < (int)
myGeom.size() - 1; i++) {
540 if (i != (
int)
myGeom.size() - 2) {
541 std::string nodename =
myID +
"_in_between#" +
toString(i);
543 throw ProcessError(
"Error on adding in-between node '" + nodename +
"'.");
551 currentEdge->
myTo = newTo;
554 std::string edgename =
myID +
"[" +
toString(i - 1) +
"]";
558 if (!ec.
insert(currentEdge,
true)) {
559 throw ProcessError(
"Error on adding splitted edge '" + edgename +
"'.");
584 std::vector<SUMOReal> angles;
586 for (
int i = 0; i < (int)
myGeom.size() - 1; ++i) {
591 for (
int i = 0; i < (int)angles.size() - 1; ++i) {
594 if (maxAngle > 0 && relAngle > maxAngle) {
600 if (i == 0 || i == (
int)angles.size() - 2) {
601 const bool start = i == 0;
605 if (minRadius > 0 && r < minRadius) {
608 (start ?
"start" :
"end") +
" of edge " +
getID());
614 (start ?
"start" :
"end") +
" of edge " +
getID());
651 bool mayUseSameDestination,
652 bool mayDefinitelyPass) {
665 setConnection(from, dest, toLane, type, mayUseSameDestination, mayDefinitelyPass);
672 NBEdge* dest,
unsigned int toLane,
674 bool invalidatePrevious,
675 bool mayDefinitelyPass) {
676 if (invalidatePrevious) {
680 for (
unsigned int i = 0; i < no && ok; i++) {
690 bool mayUseSameDestination,
691 bool mayDefinitelyPass) {
719 if ((*i).toEdge == destEdge && ((*i).fromLane == -1 || (*i).toLane == -1)) {
726 if (mayDefinitelyPass) {
746 std::vector<NBEdge::Connection>
748 std::vector<NBEdge::Connection> ret;
750 if ((*i).fromLane == static_cast<int>(lane)) {
785 if (find(outgoing.begin(), outgoing.end(), (*i).toEdge) == outgoing.end()) {
786 outgoing.push_back((*i).toEdge);
791 if (it->fromLane < 0 && it->toLane < 0) {
793 EdgeVector::iterator forbidden = find(outgoing.begin(), outgoing.end(), it->toEdge);
794 if (forbidden != outgoing.end()) {
795 outgoing.erase(forbidden);
800 unsigned int size = (
unsigned int) outgoing.size();
802 edges->reserve(size);
803 for (EdgeVector::const_iterator i = outgoing.begin(); i != outgoing.end(); i++) {
806 edges->push_back(outedge);
818 if (find(ret.begin(), ret.end(), (*i).toEdge) == ret.end()) {
819 ret.push_back((*i).toEdge);
828 std::vector<int> ret;
831 if ((*i).toEdge == currentOutgoing) {
832 ret.push_back((*i).fromLane);
855 for (EdgeVector::const_iterator i = incoming.begin(); i != incoming.end(); i++) {
860 for (EdgeVector::iterator j = connected.begin(); j != connected.end(); j++) {
874 && (fromLane < 0 || c.
fromLane == fromLane)
875 && (toLane < 0 || c.
toLane == toLane)) {
899 if (reallowSetting) {
912 if ((*i).toEdge == which) {
924 std::map<int, int> laneMap;
928 bool wasConnected =
false;
930 if ((*i).toEdge != which) {
934 if ((*i).fromLane != -1) {
935 int fromLane = (*i).fromLane;
936 laneMap[(*i).toLane] = fromLane;
937 if (minLane == -1 || minLane > fromLane) {
940 if (maxLane == -1 || maxLane < fromLane) {
951 std::vector<NBEdge::Connection> conns = origConns;
952 for (std::vector<NBEdge::Connection>::iterator i = conns.begin(); i != conns.end(); ++i) {
953 if ((*i).toEdge == which) {
956 int fromLane = (*i).fromLane;
958 if (laneMap.find(fromLane) == laneMap.end()) {
959 if (fromLane >= 0 && fromLane <= minLane) {
962 if (fromLane >= 0 && fromLane >= maxLane) {
966 toUse = laneMap[fromLane];
988 return (common > 0 && (!buildCrossingsAndWalkingAreas || common !=
SVC_PEDESTRIAN));
994 unsigned int index = 0;
1010 std::vector<Connection>::iterator i =
myConnections.begin() + index;
1030 if ((*i).fromLane == (
int)lane &&
canMoveConnection(*i, lane - 1, buildCrossingsAndWalkingAreas)) {
1043 std::string innerID =
":" + n.
getID();
1045 unsigned int edgeIndex = linkIndex;
1046 unsigned int internalLaneIndex = 0;
1053 if (con.
toEdge != toEdge) {
1056 edgeIndex = linkIndex;
1057 toEdge = (*i).toEdge;
1058 internalLaneIndex = 0;
1061 std::vector<unsigned int> foeInternalLinks;
1071 std::pair<SUMOReal, std::vector<unsigned int> > crossingPositions(-1, std::vector<unsigned int>());
1072 std::set<std::string> tmpFoeIncomingLanes;
1079 unsigned int index = 0;
1081 for (EdgeVector::const_iterator i2 = incoming.begin(); i2 != incoming.end(); ++i2) {
1082 const std::vector<Connection>& elv = (*i2)->getConnections();
1083 for (std::vector<NBEdge::Connection>::const_iterator k2 = elv.begin(); k2 != elv.end(); k2++) {
1084 if ((*k2).toEdge == 0) {
1087 bool needsCont = n.
needsCont(
this, *i2, con, *k2);
1090 crossingPositions.second.push_back(index);
1094 SUMOReal width2 = (*k2).toEdge->getLaneWidth((*k2).toLane);
1095 if ((*k2).toEdge->getPermissions((*k2).toLane) !=
SVC_BICYCLE) {
1101 if (crossingPositions.first < 0 || crossingPositions.first > minDV) {
1102 crossingPositions.first = minDV;
1107 this, con.
toEdge, con.
fromLane, (*i2), (*k2).toEdge, (*k2).fromLane);
1109 if (n.
foes(
this, con.
toEdge, *i2, (*k2).toEdge) || rightTurnConflict) {
1110 foeInternalLinks.push_back(index);
1114 if ((n.
forbids(*i2, (*k2).toEdge,
this, con.
toEdge, signalised) || rightTurnConflict) && (needsCont || dir ==
LINKDIR_TURN)) {
1115 tmpFoeIncomingLanes.insert((*i2)->getID() +
"_" +
toString((*k2).fromLane));
1121 const std::vector<NBNode::Crossing>& crossings = n.
getCrossings();
1122 for (std::vector<NBNode::Crossing>::const_iterator it_c = crossings.begin(); it_c != crossings.end(); ++it_c) {
1124 for (EdgeVector::const_iterator it_e = crossing.
edges.begin(); it_e != crossing.
edges.end(); ++it_e) {
1125 const NBEdge* edge = *it_e;
1127 if (
this == edge || con.
toEdge == edge) {
1128 foeInternalLinks.push_back(index);
1129 if (con.
toEdge == edge &&
1137 if (crossingPositions.first < 0 || crossingPositions.first > minDV) {
1138 crossingPositions.first = minDV;
1173 assert(shape.size() >= 2);
1175 if (crossingPositions.first >= 0) {
1176 std::pair<PositionVector, PositionVector> split = shape.
splitAt(crossingPositions.first);
1177 con.
id = innerID +
"_" +
toString(edgeIndex);
1178 con.
shape = split.first;
1181 con.
viaID = innerID +
"_" +
toString(splitIndex + noInternalNoSplits);
1187 con.
id = innerID +
"_" +
toString(edgeIndex);
1192 ++internalLaneIndex;
1212 if (tmp.size() > 0) {
1213 intersect =
MIN2(intersect, tmp[0]);
1216 if (tmp.size() > 0) {
1217 intersect =
MIN2(intersect, tmp[0]);
1250 assert(atNode ==
myTo);
1265 assert(atNode ==
myTo);
1273 if (!onlyPossible) {
1293 std::vector<SUMOReal> offsets;
1294 for (
unsigned int i = 0; i <
myLanes.size(); ++i) {
1295 offsets.push_back(0);
1298 for (
int i = (
int)
myLanes.size() - 2; i >= 0; --i) {
1300 offsets[i] = offset;
1307 for (
unsigned int i = 0; i <
myLanes.size(); ++i) {
1313 for (
unsigned int i = 0; i <
myLanes.size(); ++i) {
1314 offsets[i] += offset;
1321 for (
unsigned int i = 0; i <
myLanes.size(); ++i) {
1325 WRITE_WARNING(
"In edge '" +
getID() +
"': lane shape could not be determined (" + e.what() +
")");
1335 bool haveWarned =
false;
1336 for (
int i = 0; i < (int)
myGeom.size(); i++) {
1340 std::pair<SUMOReal, SUMOReal> offsets =
laneOffset(from, to, offset,
false);
1343 Position(from.
x() - offsets.first, from.
y() - offsets.second, from.
z()));
1344 }
else if (i == static_cast<int>(
myGeom.size() - 1)) {
1347 std::pair<SUMOReal, SUMOReal> offsets =
laneOffset(from, to, offset,
false);
1350 Position(to.
x() - offsets.first, to.
y() - offsets.second, to.
z()));
1355 std::pair<SUMOReal, SUMOReal> offsets =
laneOffset(from, me, offset,
false);
1356 std::pair<SUMOReal, SUMOReal> offsets2 =
laneOffset(me, to, offset,
false);
1358 Position(from.
x() - offsets.first, from.
y() - offsets.second),
1359 Position(me.
x() - offsets.first, me.
y() - offsets.second));
1362 Position(me.
x() - offsets2.first, me.
y() - offsets2.second),
1363 Position(to.
x() - offsets2.first, to.
y() - offsets2.second));
1365 if (angle < 10. || angle > 350.) {
1368 Position(me.
x() - offsets.first, me.
y() - offsets.second, me.
z()));
1393 std::pair<SUMOReal, SUMOReal>
1397 return std::pair<SUMOReal, SUMOReal>(-offsets.first, -offsets.second);
1399 return std::pair<SUMOReal, SUMOReal>(offsets.first, offsets.second);
1432 fromCenter.
x(), fromCenter.
y(),
1433 referencePosStart.x(), referencePosStart.y());
1436 referencePosEnd.x(), referencePosEnd.y(),
1437 toCenter.
x(), toCenter.
y());
1447 for (std::vector<Lane>::const_iterator i =
myLanes.begin(); i !=
myLanes.end(); ++i) {
1448 if ((*i).permissions !=
SVCAll) {
1458 std::vector<Lane>::const_iterator i =
myLanes.begin();
1461 for (; i !=
myLanes.end(); ++i) {
1462 if (i->permissions != firstLanePermissions) {
1472 for (std::vector<Lane>::const_iterator i =
myLanes.begin(); i !=
myLanes.end(); ++i) {
1473 if (i->width !=
myLanes.begin()->width) {
1483 for (std::vector<Lane>::const_iterator i =
myLanes.begin(); i !=
myLanes.end(); ++i) {
1494 for (std::vector<Lane>::const_iterator i =
myLanes.begin(); i !=
myLanes.end(); ++i) {
1495 if (i->endOffset !=
myLanes.begin()->endOffset) {
1519 for (EdgeVector::const_iterator i = o.begin(); i != o.end(); ++i) {
1557 std::vector<unsigned int> connNumbersPerLane(
myLanes.size(), 0);
1559 if ((*i).toEdge == 0 || (*i).fromLane < 0 || (*i).toLane < 0) {
1562 if ((*i).fromLane >= 0) {
1563 ++connNumbersPerLane[(*i).fromLane];
1574 for (
unsigned int i = 0; i <
myLanes.size(); i++) {
1576 if (i > 0 && connNumbersPerLane[i - 1] > 1) {
1578 }
else if (i <
myLanes.size() - 1 && connNumbersPerLane[i + 1] > 1) {
1594 if (outgoing->size() == 0) {
1606 std::vector<int> availableLanes;
1607 for (
int i = 0; i < (int)
myLanes.size(); ++i) {
1612 availableLanes.push_back(i);
1616 unsigned int size = (
unsigned int) outgoing->size();
1617 std::vector<SUMOReal> resultingLanes;
1618 resultingLanes.reserve(size);
1622 for (i = 0; i < size; i++) {
1629 if (res > availableLanes.size()) {
1630 res = (
SUMOReal) availableLanes.size();
1633 resultingLanes.push_back(res);
1634 sumResulting += res;
1635 if (minResulting > res && res > 0) {
1644 sumResulting += minResulting / (
SUMOReal) 2.;
1645 unsigned int noVirtual = (
unsigned int)(sumResulting / minResulting);
1648 transition.reserve(size);
1649 for (i = 0; i < size; i++) {
1652 assert(i < resultingLanes.size());
1654 for (
SUMOReal j = 0; j < tmpNo; j++) {
1655 assert(outgoing->size() > i);
1656 transition.push_back((*outgoing)[i]);
1662 Bresenham::compute(&adder, static_cast<unsigned int>(availableLanes.size()), noVirtual);
1663 const std::map<NBEdge*, std::vector<unsigned int> >& l2eConns = adder.
getBuiltConnections();
1665 for (std::map<
NBEdge*, std::vector<unsigned int> >::const_iterator i = l2eConns.begin(); i != l2eConns.end(); ++i) {
1666 const std::vector<unsigned int> lanes = (*i).second;
1667 for (std::vector<unsigned int>::const_iterator j = lanes.begin(); j != lanes.end(); ++j) {
1668 const int fromIndex = availableLanes[*j];
1669 if ((
getPermissions(fromIndex) & (*i).first->getPermissions()) == 0) {
1688 std::vector<unsigned int>*
1691 std::vector<unsigned int>* priorities =
new std::vector<unsigned int>();
1692 if (outgoing->size() == 0) {
1695 priorities->reserve(outgoing->size());
1696 EdgeVector::const_iterator i;
1697 for (i = outgoing->begin(); i != outgoing->end(); i++) {
1698 int prio = (*i)->getJunctionPriority(
myTo);
1699 assert((prio + 1) * 2 > 0);
1700 prio = (prio + 1) * 2;
1701 priorities->push_back(prio);
1709 i = find(outgoing->begin(), outgoing->end(), *(tmp.begin()));
1710 unsigned int dist = (
unsigned int) distance(outgoing->begin(), i);
1712 assert(priorities->size() > 0);
1713 (*priorities)[0] = (*priorities)[0] / 2;
1718 if (mainDirections.
empty()) {
1719 assert(dist < priorities->size());
1720 (*priorities)[dist] = (*priorities)[dist] * 2;
1723 (*priorities)[dist] = (*priorities)[dist] * 2;
1732 unsigned int sum = 0;
1733 for (std::vector<unsigned int>::iterator i = priorities->begin(); i != priorities->end(); i++) {
1771 if (pos < tolerance) {
1785 for (
unsigned int i = 0; i < lanes; i++) {
1787 for (std::vector<NBEdge::Connection>::iterator j = elv.begin(); j != elv.end(); j++) {
1789 assert(el.
tlID ==
"");
1837 assert(fromLane < 0 || fromLane < (
int)
myLanes.size());
1839 if (fromLane >= 0 && toLane >= 0) {
1841 std::vector<Connection>::iterator i =
1849 connection.
tlID = tlID;
1856 unsigned int no = 0;
1857 bool hadError =
false;
1859 if ((*i).toEdge != toEdge) {
1862 if (fromLane >= 0 && fromLane != (*i).fromLane) {
1865 if (toLane >= 0 && toLane != (*i).toLane) {
1868 if ((*i).tlID ==
"") {
1870 (*i).tlLinkNo = tlIndex;
1873 if ((*i).tlID != tlID && static_cast<int>((*i).tlLinkNo) == tlIndex) {
1874 WRITE_WARNING(
"The lane " + toString<int>((*i).fromLane) +
" on edge " +
getID() +
" already had a traffic light signal.");
1879 if (hadError && no == 0) {
1880 WRITE_WARNING(
"Could not set any signal of the traffic light '" + tlID +
"' (unknown group)");
1973 if (find(conn.begin(), conn.end(), possContinuation)
1990 if (conns.size() !=
myLanes.size()) {
2006 for (
unsigned int i = 0; i <
myLanes.size(); i++) {
2030 if ((*i).toEdge == e && (*i).tlID !=
"") {
2049 assert(lane <
myLanes.size());
2063 assert(distances.size() > 0);
2070 unsigned int newLaneNo = (
unsigned int)
myLanes.size() + by;
2071 while (
myLanes.size() < newLaneNo) {
2076 for (EdgeVector::const_iterator i = incs.begin(); i != incs.end(); ++i) {
2077 (*i)->invalidateConnections(
true);
2085 unsigned int newLaneNo = (
unsigned int)
myLanes.size() - by;
2086 while (
myLanes.size() > newLaneNo) {
2091 for (EdgeVector::const_iterator i = incs.begin(); i != incs.end(); ++i) {
2092 (*i)->invalidateConnections(
true);
2098 assert(outs.size() == 1);
2119 for (
unsigned int i = 0; i <
myLanes.size(); i++) {
2123 assert(lane < (
int)
myLanes.size());
2124 myLanes[lane].permissions |= vclass;
2132 for (
unsigned int i = 0; i <
myLanes.size(); i++) {
2136 assert(lane < (
int)
myLanes.size());
2137 myLanes[lane].permissions &= ~vclass;
2145 for (
unsigned int i = 0; i <
myLanes.size(); i++) {
2149 assert(lane < (
int)
myLanes.size());
2150 myLanes[lane].preferred |= vclass;
2160 for (
unsigned int i = 0; i <
myLanes.size(); i++) {
2166 assert(lane < (
int)
myLanes.size());
2182 for (
unsigned int i = 0; i <
myLanes.size(); i++) {
2199 for (
unsigned int i = 0; i <
myLanes.size(); i++) {
2205 assert(lane < (
int)
myLanes.size());
2206 myLanes[lane].endOffset = offset;
2215 for (
unsigned int i = 0; i <
myLanes.size(); i++) {
2221 assert(lane < (
int)
myLanes.size());
2229 for (
unsigned int i = 0; i <
myLanes.size(); i++) {
2234 assert(lane < (
int)
myLanes.size());
2235 myLanes[lane].permissions = permissions;
2243 for (
unsigned int i = 0; i <
myLanes.size(); i++) {
2248 assert(lane < (
int)
myLanes.size());
2249 myLanes[lane].preferred = permissions;
2258 for (
unsigned int i = 0; i <
myLanes.size(); i++) {
2263 assert(lane < (
int)
myLanes.size());
2264 return myLanes[lane].permissions;
2277 for (std::vector<Lane>::iterator i =
myLanes.begin(); i !=
myLanes.end(); ++i) {
2278 (*i).permissions =
SVCAll;
2301 for (
int i = start; i != end; i += direction) {
2323 std::cout <<
getID() <<
" angle=" <<
getAngleAtNode(node) <<
" convAngle=" << angle <<
"\n";
2341 WRITE_WARNING(
"Edge '" +
getID() +
"' already has a sidewalk. Not adding another one.");
2363 for (EdgeVector::const_iterator it = incoming.begin(); it != incoming.end(); ++it) {
2364 (*it)->shiftToLanesToEdge(
this, 1);
2376 if ((*it).toEdge == to && (*it).toLane >= 0) {
2377 (*it).toLane += laneOff;
2386 const int i = (node ==
myTo ? -1 : 0);
2387 const int i2 = (node ==
myTo ? 0 : -1);
2393 if (dist < neededOffset && dist2 < neededOffset2) {
NBEdge::Lane getFirstNonPedestrianLane(int direction) const
SUMOReal length2D() const
bool gDebugFlag1
global utility flags for debugging
void invalidateConnections(bool reallowSetting=false)
The link is a partial left direction.
SUMOReal atan2DegreeAngle() const
const PositionVector & getLaneShape(unsigned int i) const
Returns the shape of the nth lane.
std::vector< Lane > myLanes
Lane information.
static std::pair< SUMOReal, SUMOReal > getNormal90D_CW(const Position &beg, const Position &end, SUMOReal length, SUMOReal wanted_offset)
bool includes(Direction d) const
const Position & p2() const
bool hasConnectionTo(NBEdge *destEdge, unsigned int destLane, int fromLane=-1) const
Retrieves info about a connection to a certain lane of a certain edge.
const EdgeVector & getIncomingEdges() const
Returns this node's incoming edges.
bool setControllingTLInformation(const NBConnection &c, const std::string &tlID)
Returns if the link could be set as to be controlled.
static SUMOReal getCWAngleDiff(SUMOReal angle1, SUMOReal angle2)
Returns the distance of second angle from first angle clockwise.
A structure which describes a connection between edges or lanes.
int toLane
The lane the connections yields in.
static const SUMOReal UNSPECIFIED_WIDTH
unspecified lane width
SUMOReal width
This lane's width.
SUMOReal distance(const Position &p, bool perpendicular=false) const
std::string foeIncomingLanes
const SUMOReal SUMO_const_laneWidth
SUMOReal myEndOffset
This edges's offset to the intersection begin (will be applied to all lanes)
std::vector< TLSDisabledConnection > myTLSDisabledConnections
static const SUMOReal UNSPECIFIED_SIGNAL_OFFSET
unspecified signal offset
LaneSpreadFunction myLaneSpreadFunction
The information about how to spread the lanes.
PositionVector getSubpart2D(SUMOReal beginOffset, SUMOReal endOffset) const
void sortOutgoingConnectionsByAngle()
sorts the outgoing connections by their angle relative to their junction
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
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types...
The relationships between edges are computed/loaded.
void insertAt(int index, const Position &p)
void appendTurnaround(bool noTLSControlled)
Add a connection to the previously computed turnaround, if wished.
bool hasLaneSpecificEndOffset() const
whether lanes differ in offset
void setLaneWidth(int lane, SUMOReal width)
set lane specific width (negative lane implies set for all lanes)
void moveConnectionToRight(unsigned int lane, const bool buildCrossingsAndWalkingAreas)
bool isTLControlled() const
Returns whether this node is controlled by any tls.
void setSpeed(int lane, SUMOReal speed)
set lane specific speed (negative lane implies set for all lanes)
Some static methods for string processing.
void moveOutgoingConnectionsFrom(NBEdge *e, unsigned int laneOff)
const SUMOReal SUMO_const_laneWidthAndOffset
void addSidewalk(SUMOReal width)
add a pedestrian sidewalk of the given width and shift existing connctions
void removeEdge(NBEdge *edge, bool removeFromConnections=true)
Removes edge from this node and optionally removes connections as well.
Position getPositionAtDistance2D(SUMOReal offset) const
void addIncomingEdge(NBEdge *edge)
adds an incoming edge
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
Lane2LaneInfoType
Modes of setting connections between lanes.
bool mayBeTLSControlled(int fromLane, NBEdge *toEdge, int toLane) const
bool hasDefaultGeometryEndpoints() const
Returns whether the geometry is terminated by the node positions This default may be violated by init...
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
void incLaneNo(unsigned int by)
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
static std::pair< SUMOReal, SUMOReal > laneOffset(const Position &from, const Position &to, SUMOReal laneCenterOffset, bool leftHand)
Computes the offset from the edge shape on the current segment.
const std::vector< Crossing > & getCrossings() const
return this junctions pedestrian crossings
bool addLane2LaneConnections(unsigned int fromLane, NBEdge *dest, unsigned int toLane, unsigned int no, Lane2LaneInfoType type, bool invalidatePrevious=false, bool mayDefinitelyPass=false)
Builds no connections starting at the given lanes.
static const SUMOReal UNSPECIFIED_SPEED
unspecified lane speed
void buildInnerEdges(const NBNode &n, unsigned int noInternalNoSplits, unsigned int &linkIndex, unsigned int &splitIndex)
void markAsInLane2LaneState()
SUMOReal getTotalWidth() const
Returns the combined width of all lanes of this edge.
bool addLane2LaneConnection(unsigned int fromLane, NBEdge *dest, unsigned int toLane, Lane2LaneInfoType type, bool mayUseSameDestination=false, bool mayDefinitelyPass=false)
Adds a connection between the specified this edge's lane and an approached one.
Lanes to lanes - relationships are computed; should be recheked.
PositionVector computeLaneShape(unsigned int lane, SUMOReal offset)
Computes the shape for the given lane.
SUMOReal getLaneWidth() const
Returns the default width of lanes of this edge.
std::string getLaneIDInsecure(unsigned int lane) const
void setPermissions(SVCPermissions permissions, int lane=-1)
set allowed/disallowed classes for the given lane or for all lanes if -1 is given ...
PositionVector shape
The lane's shape.
int myFromJunctionPriority
The priority normalised for the node the edge is outgoing of.
void computeLaneShapes()
Computes the offset from the edge shape on the current segment.
PositionVector myGeom
The geometry for the edge.
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.
SUMOReal distanceTo(const Position &p2) const
returns the euclidean distance in 3 dimension
const SUMOReal SUMO_const_laneOffset
bool around(const Position &p, SUMOReal offset=0) const
Returns the information whether the position vector describes a polygon lying around the given point ...
bool isRailway(SVCPermissions permissions)
Returns whether an edge with the given permission is a railway edge.
const SVCPermissions SVCAll
void divideOnEdges(const EdgeVector *outgoing, const bool buildCrossingsAndWalkingAreas)
static const SUMOReal UNSPECIFIED_OFFSET
unspecified lane offset
std::vector< Connection > getConnectionsFromLane(unsigned int lane) const
Returns connections from a given lane.
SUMOReal x() const
Returns the x-position.
void addOutgoingEdge(NBEdge *edge)
adds an outgoing edge
Position positionAtOffset2D(SUMOReal pos, SUMOReal lateralOffset=0) const
Returns the position at the given length.
void setGeometry(const PositionVector &g, bool inner=false)
(Re)sets the edge's geometry
#define UNUSED_PARAMETER(x)
static SUMOReal firstIntersection(const PositionVector &v1, const PositionVector &v2, SUMOReal width2)
void moveConnectionToLeft(unsigned int lane, const bool buildCrossingsAndWalkingAreas)
The link is a (hard) left direction.
#define WRITE_WARNING(msg)
The connection was computed and validated.
PositionVector startShapeAt(const PositionVector &laneShape, const NBNode *startNode) const
PositionVector reverse() const
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 computeInternalLaneShape(NBEdge *fromE, const NBEdge::Connection &con, int numPoints=5) const
Compute the shape for an internal lane.
const EdgeVector & getOutgoingEdges() const
Returns this node's outgoing edges.
An (internal) definition of a single lane of an edge.
const std::string & getID() const
Returns the id.
SUMOReal length2D() const
Returns the length.
SUMOReal mySpeed
The maximal speed.
std::vector< SUMOReal > distances(const PositionVector &s, bool perpendicular=false) const
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.
bool recheckLanes(const bool buildCrossingsAndWalkingAreas)
Line lineAt(int pos) const
bool myAmMacroscopicConnector
Information whether this edge is a (macroscopic) connector.
bool isConnectedTo(NBEdge *e)
Returns the information whethe a connection to the given edge has been added (or computed) ...
const PositionVector getInnerGeometry() const
Returns the geometry of the edge without the endpoints.
void push_front_noDoublePos(const Position &p)
bool computeLanes2Edges(const bool buildCrossingsAndWalkingAreas)
computes the edge, step2: computation of which lanes approach the edges)
void reshiftPosition(SUMOReal xoff, SUMOReal yoff)
Applies an offset to the edge.
const Position & getPosition() const
Returns the position of this node.
const Position & p1() const
NBEdge * myTurnDestination
The turn destination edge (if a connection exists)
const std::map< NBEdge *, std::vector< unsigned int > > & getBuiltConnections() const
Lanes to lanes - relationships are loaded; no recheck is necessary/wished.
int operator()(const Connection &c1, const Connection &c2) const
comparing operation
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.
void checkGeometry(const SUMOReal maxAngle, const SUMOReal minRadius, bool fix)
Check the angles of successive geometry segments.
std::string getLaneID(unsigned int lane) const
bool myAmLeftHand
Whether this edge is a left-hand edge.
void reshiftRotate(SUMOReal xoff, SUMOReal yoff, SUMOReal rot)
static const int FORWARD
edge directions (for pedestrian related stuff)
std::string tlID
The id of the traffic light that controls this connection.
std::string getInternalLaneID() const
int fromLane
The lane the connections starts at.
bool canMoveConnection(const Connection &con, unsigned int newFromLane, const bool buildCrossingsAndWalkingAreas) const
whether the connection can originate on newFromLane
A point in 2D or 3D with translation and scaling methods.
Position pop_front()
Removes and returns the position at the fron of the list.
void add(SUMOReal xoff, SUMOReal yoff, SUMOReal zoff)
bool hasLaneSpecificPermissions() const
whether lanes differ in allowed vehicle classes
bool lanesWereAssigned() const
static bool connections_sorter(const Connection &c1, const Connection &c2)
std::vector< unsigned int > foeInternalLinks
void push_front(const Position &p)
Puts the given position at the front of the list.
unsigned int getNumLanes() const
Returns the number of lanes.
SUMOReal z() const
Returns the z-position.
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
bool isTurningDirectionAt(const NBEdge *const edge) const
Returns whether the given edge is the opposite direction to this edge.
static SUMOReal angle(SUMOReal x1, SUMOReal y1, SUMOReal x2, SUMOReal y2)
SUMOReal myLaneWidth
This width of this edge's lanes.
int myPriority
The priority of the edge.
int getFirstNonPedestrianLaneIndex(int direction, bool exclusive=false) const
return the first lane with permissions other than SVC_PEDESTRIAN and 0
void init(unsigned int noLanes, bool tryIgnoreNodePositions)
Initialization routines common to all constructors.
Storage for edges, including some functionality operating on multiple edges.
bool needsLaneSpecificOutput() const
whether at least one lane has values differing from the edges values
The link is a (hard) right direction.
EdgeBuildingStep myStep
The building step.
unsigned int computePrioritySum(std::vector< unsigned int > *priorities)
SUMOReal getAngleAtNodeToCenter(const NBNode *const node) const
Returns the angle of from the node shape center to where the edge meets the node shape.
std::vector< Connection > myConnections
List of connections to following edges.
void setLoadedLength(SUMOReal val)
std::string toString(const T &t, std::streamsize accuracy=OUTPUT_ACCURACY)
The connection was given by the user.
const PositionVector & getShape() const
retrieve the junction shape
SUMOReal getSignalOffset() const
Returns the offset of a traffic signal from the end of this edge.
void removeFromConnections(NBEdge *toEdge, int fromLane=-1, int toLane=-1, bool tryLater=false)
Removes the specified connection(s)
The link is a partial right direction.
static void compute(BresenhamCallBack *callBack, const unsigned int val1, const unsigned int val2)
SUMOReal getEndOffset() const
Returns the offset to the destination node.
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 intersects(const Line &l) const
int getJunctionPriority(const NBNode *const node) const
Returns the junction priority (normalised for the node currently build)
SUMOReal myLoadedLength
An optional length to use (-1 if not valid)
std::pair< PositionVector, PositionVector > splitAt(SUMOReal where) const
Returns the two lists made when this list vector is splitted at the given point.
static std::string convertUmlaute(std::string str)
Converts german "Umlaute" to their latin-version.
void extrapolate(SUMOReal val)
bool hasRestrictions() const
whether at least one lane has restrictions
SVCPermissions getPermissions(int lane=-1) const
get the union of allowed classes over all lanes or for a specific lane
SUMOReal getCrossingAngle(NBNode *node)
return the angle for computing pedestrian crossings at the given node
void extrapolateBy(SUMOReal length)
SUMOReal length() const
Returns the length.
void push_back(const PositionVector &p)
Appends all positions from the given vector.
bool rightTurnConflict(const NBEdge *from, const NBEdge *to, int fromLane, const NBEdge *prohibitorFrom, const NBEdge *prohibitorTo, int prohibitorFromLane) const
return whether the given laneToLane connection is a right turn which must yield to a bicycle crossing...
void setTurningDestination(NBEdge *e, bool onlyPossible=false)
Sets the turing destination at the given edge.
static const int BACKWARD
std::string myID
The name of the object.
void decLaneNo(unsigned int by, int dir=0)
std::vector< int > getConnectionLanes(NBEdge *currentOutgoing) const
Returns the list of lanes that may be used to reach the given edge.
void removeDoublePoints(SUMOReal minDist=POSITION_EPS, bool assertLength=false)
Removes positions if too near.
void execute(const unsigned int lane, const unsigned int virtEdge)
executes a bresenham - step
void computeEdgeShape()
Recomputeds the lane shapes to terminate at the node shape For every lane the intersection with the f...
void disableConnection4TLS(int fromLane, NBEdge *toEdge, int toLane)
SUMOReal getMaxLaneOffset()
static const SUMOReal UNSPECIFIED_LOADED_LENGTH
no length override given
std::vector< NBEdge * > EdgeVector
std::vector< unsigned int > * prepareEdgePriorities(const EdgeVector *outgoing)
SUMOReal myLength
The length of the edge.
void setPreferredVehicleClass(SVCPermissions permissions, int lane=-1)
const PositionVector & getGeometry() const
Returns the geometry of the edge.
The edge has been loaded and connections shall not be added.
int getToLane() const
returns the to-lane
SUMOReal y() const
Returns the y-position.
std::vector< Connection > myConnectionsToDelete
List of connections marked for delayed removal.
static SUMOReal getMinAngleDiff(SUMOReal angle1, SUMOReal angle2)
Returns the minimum distance (clockwise/counter-clockwise) between both angles.
void reduceGeometry(const SUMOReal minDist)
Removes points with a distance lesser than the given.
void setJunctionPriority(const NBNode *const node, int prio)
Sets the junction priority of the edge.
bool insert(const std::string &id, const Position &position, NBDistrict *district=0)
Inserts a node into the map.
void replaceInConnections(NBEdge *which, NBEdge *by, unsigned int laneOff)
const EdgeVector * getConnectedSorted()
Returns the list of outgoing edges without the turnaround sorted in clockwise direction.
void sortOutgoingConnectionsByIndex()
sorts the outgoing connections by their from-lane-index and their to-lane-index
SUMOReal mySignalOffset
the offset of a traffic light signal from the end of this edge (-1 for None)
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)
unsigned int tlLinkNo
The index of this connection within the controlling traffic light.
NBEdge * getTo() const
returns the to-edge (end of the connection)
SUMOReal getLaneSpeed(unsigned int lane) const
void shiftToLanesToEdge(NBEdge *to, unsigned int laneOff)
modifify the toLane for all connections to the given edge
NBNode * tryGetNodeAtPosition(SUMOReal pos, SUMOReal tolerance=5.0) const
Returns the node at the given edges length (using an epsilon) When no node is existing at the given p...
The connection was computed.
SUMOReal myStartAngle
The angles of the edge.
EdgeVector edges
The edges being crossed.
Represents a single node (junction) during network building.
void dismissVehicleClassInformation()
bool hasSignalisedConnectionTo(const NBEdge *const e) const
Lanes to lanes - relationships are computed; no recheck is necessary/wished.
std::string joinToString(const std::vector< T > &v, const T_BETWEEN &between, std::streamsize accuracy=OUTPUT_ACCURACY)
A definition of a pedestrian crossing.
void move2side(SUMOReal amount)
bool hasLaneSpecificWidth() const
whether lanes differ in width
void setEndOffset(int lane, SUMOReal offset)
set lane specific end-offset (negative lane implies set for all lanes)
Direction
enum of possible directions
bool isNearEnough2BeJoined2(NBEdge *e, SUMOReal threshold) const
void preferVehicleClass(int lane, SUMOVehicleClass vclass)
static SUMOReal relAngle(SUMOReal angle1, SUMOReal angle2)
void push_back_noDoublePos(const Position &p)
void allowVehicleClass(int lane, SUMOVehicleClass vclass)
set allowed class for the given lane or for all lanes if -1 is given
void addGeometryPoint(int index, const Position &p)
Adds a further geometry point.
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.
SUMOReal getSpeed() const
Returns the speed allowed on this edge.
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)
std::vector< SUMOReal > intersectsAtLengths2D(const PositionVector &v)
void setConnection(unsigned int lane, NBEdge *destEdge, unsigned int destLane, Lane2LaneInfoType type, bool mayUseSameDestination=false, bool mayDefinitelyPass=false)
Adds a connection to a certain lane of a certain edge.
unsigned int internalLaneIndex
The lane index of this internal lane within the internal edge.
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
NBEdge(const std::string &id, NBNode *from, NBNode *to, std::string type, SUMOReal speed, unsigned int nolanes, int priority, SUMOReal width, SUMOReal offset, const std::string &streetName="", LaneSpreadFunction spread=LANESPREAD_RIGHT)
Constructor.
#define WRITE_MESSAGE(msg)
std::vector< SUMOReal > intersectsAtLengths2D(const PositionVector &other) const
For all intersections between this vector and other, return the 2D-length of the subvector from this ...
Lanes to edges - relationships are computed/loaded.
std::string myStreetName
The street name (or whatever arbitrary string you wish to attach)
NBNode * myFrom
The source and the destination node.
bool expandableBy(NBEdge *possContinuation) const
NBEdge * getTurnDestination(bool possibleDestination=false) const
Position intersectsAt(const Line &l) const
PositionVector getSubpart(SUMOReal beginOffset, SUMOReal endOffset) const
~MainDirections()
destructor
void shiftPositionAtNode(NBNode *node, NBEdge *opposite)
shift geometry at the given node to avoid overlap
void disallowVehicleClass(int lane, SUMOVehicleClass vclass)
set disallowed class for the given lane or for all lanes if -1 is given
void append(const PositionVector &v, SUMOReal sameThreshold=2.0)
MainDirections(const EdgeVector &outgoing, NBEdge *parent, NBNode *to)
constructor
void copyConnectionsFrom(NBEdge *src)
void reinit(NBNode *from, NBNode *to, const std::string &type, SUMOReal speed, unsigned int nolanes, int priority, PositionVector geom, SUMOReal width, SUMOReal offset, const std::string &streetName, LaneSpreadFunction spread=LANESPREAD_RIGHT, bool tryIgnoreNodePositions=false)
Resets initial values.
static const SUMOReal ANGLE_LOOKAHEAD
the distance at which to take the default angle
SUMOReal getLength() const
Returns the computed length of the edge.
SUMOReal getAngleAtNode(const NBNode *const node) const
Returns the angle of the edge's geometry at the given node.
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.
LinkDirection getDirection(const NBEdge *const incoming, const NBEdge *const outgoing) const
Returns the representation of the described stream's direction.
NBNode * getFromNode() const
Returns the origin node of the edge.
bool splitGeometry(NBEdgeCont &ec, NBNodeCont &nc)
Splits this edge at geometry points.