57 #ifdef CHECK_MEMORY_LEAKS
59 #endif // CHECK_MEMORY_LEAKS
83 assert(myTransitions.size() > virtEdge);
85 NBEdge* succEdge = myTransitions[virtEdge];
86 std::vector<unsigned int> lanes;
90 std::map<NBEdge*, std::vector<unsigned int> >::iterator i =
myConnections.find(succEdge);
98 std::vector<unsigned int>::iterator j = find(lanes.begin(), lanes.end(), lane);
99 if (j == lanes.end()) {
101 lanes.push_back(lane);
114 if (outgoing.size() == 0) {
118 assert(outgoing.size() > 0);
123 if (outgoing.back()->getJunctionPriority(to) == 1) {
129 if (outgoing.back()->getPriority() > tmp[0]->getPriority()) {
132 if (outgoing.back()->getNumLanes() > tmp[0]->getNumLanes()) {
141 NBEdge* edge = *(tmp.begin());
154 return myDirs.empty();
160 return find(myDirs.begin(), myDirs.end(), d) != myDirs.end();
180 std::string type,
SUMOReal speed,
unsigned int nolanes,
182 const std::string& streetName,
196 init(nolanes,
false);
201 std::string type,
SUMOReal speed,
unsigned int nolanes,
204 const std::string& streetName,
209 myFrom(from), myTo(to),
210 myStartAngle(0), myEndAngle(0), myTotalAngle(0),
211 myPriority(priority), mySpeed(speed),
212 myTurnDestination(0),
213 myFromJunctionPriority(-1), myToJunctionPriority(-1),
214 myGeom(geom), myLaneSpreadFunction(spread), myOffset(offset), myLaneWidth(laneWidth),
215 myLoadedLength(UNSPECIFIED_LOADED_LENGTH), myAmLeftHand(false),
216 myAmInnerEdge(false), myAmMacroscopicConnector(false),
217 myStreetName(streetName) {
218 init(nolanes, tryIgnoreNodePositions);
225 myType(tpl->getTypeID()),
226 myFrom(from), myTo(to),
227 myStartAngle(0), myEndAngle(0), myTotalAngle(0),
228 myPriority(tpl->getPriority()), mySpeed(tpl->getSpeed()),
229 myTurnDestination(0),
230 myFromJunctionPriority(-1), myToJunctionPriority(-1),
231 myLaneSpreadFunction(tpl->getLaneSpreadFunction()),
232 myOffset(tpl->getOffset()),
233 myLaneWidth(tpl->getLaneWidth()),
234 myLoadedLength(UNSPECIFIED_LOADED_LENGTH), myAmLeftHand(false),
235 myAmInnerEdge(false), myAmMacroscopicConnector(false),
236 myStreetName(tpl->getStreetName()) {
249 SUMOReal speed,
unsigned int nolanes,
int priority,
251 const std::string& streetName,
253 bool tryIgnoreNodePositions) {
275 init(nolanes, tryIgnoreNodePositions);
282 if (from == 0 || to == 0) {
283 throw ProcessError(
"At least one of edge's '" +
myID +
"' nodes is not known.");
305 throw ProcessError(
"At least one of edge's '" +
myID +
"' nodes is not known.");
311 if (!tryIgnoreNodePositions ||
myGeom.size() < 2) {
326 WRITE_ERROR(
"Edge's '" +
myID +
"' from- and to-node are at the same position.");
334 assert(
myGeom.size() >= 2);
336 for (
unsigned int i = 0; i < noLanes; i++) {
351 for (
unsigned int i = 0; i <
myLanes.size(); i++) {
352 myLanes[i].shape.reshiftRotate(xoff, yoff, 0);
396 for (
unsigned int i = 0; i <
myLanes.size(); i++) {
400 if (shape.size() >= 2) {
411 assert(shape.size() >= 2);
412 assert(shape.
length() > 0);
417 Line lc(shape[0], shape[-1]);
418 Line lo(old[0], old[-1]);
427 for (
unsigned int i = 0; i <
myLanes.size(); i++) {
428 assert(
myLanes[i].shape.length() > 0);
429 avgLength +=
myLanes[i].shape.length();
445 assert(pbv.size() > 0);
449 ns[0].set(ns[0].x(), ns[0].y(), startNode->
getPosition().
z());
454 assert(pbv.size() > 0);
505 NBEdge* currentEdge =
this;
506 for (
int i = 1; i < (
int)
myGeom.size() - 1; i++) {
508 if (i != (
int)
myGeom.size() - 2) {
509 std::string nodename =
myID +
"_in_between#" +
toString(i);
511 throw ProcessError(
"Error on adding in-between node '" + nodename +
"'.");
519 currentEdge->
myTo = newTo;
522 std::string edgename =
myID +
"[" +
toString(i - 1) +
"]";
526 if (!ec.
insert(currentEdge,
true)) {
527 throw ProcessError(
"Error on adding splitted edge '" + edgename +
"'.");
552 std::vector<SUMOReal> angles;
554 for (
int i = 0; i < (
int)
myGeom.size() - 1; ++i) {
559 for (
int i = 0; i < (
int)angles.size() - 1; ++i) {
562 if (maxAngle > 0 && relAngle > maxAngle) {
568 if (i == 0 || i == (
int)angles.size() - 2) {
569 const bool start = i == 0;
573 if (minRadius > 0 && r < minRadius) {
576 (start ?
"start" :
"end") +
" of edge " +
getID());
582 (start ?
"start" :
"end") +
" of edge " +
getID());
619 bool mayUseSameDestination,
620 bool mayDefinitelyPass) {
633 setConnection(from, dest, toLane, type, mayUseSameDestination, mayDefinitelyPass);
640 NBEdge* dest,
unsigned int toLane,
642 bool invalidatePrevious,
643 bool mayDefinitelyPass) {
644 if (invalidatePrevious) {
648 for (
unsigned int i = 0; i < no && ok; i++) {
658 bool mayUseSameDestination,
659 bool mayDefinitelyPass) {
687 if ((*i).toEdge == destEdge && ((*i).fromLane == -1 || (*i).toLane == -1)) {
694 if (mayDefinitelyPass) {
714 std::vector<NBEdge::Connection>
716 std::vector<NBEdge::Connection> ret;
718 if ((*i).fromLane == static_cast<int>(lane)) {
753 if (find(outgoing.begin(), outgoing.end(), (*i).toEdge) == outgoing.end()) {
754 outgoing.push_back((*i).toEdge);
759 unsigned int size = (
unsigned int) outgoing.size();
761 edges->reserve(size);
762 for (EdgeVector::const_iterator i = outgoing.begin(); i != outgoing.end(); i++) {
765 edges->push_back(outedge);
777 if (find(ret.begin(), ret.end(), (*i).toEdge) == ret.end()) {
778 ret.push_back((*i).toEdge);
787 std::vector<int> ret;
790 if ((*i).toEdge == currentOutgoing) {
791 ret.push_back((*i).fromLane);
814 for (EdgeVector::const_iterator i = incoming.begin(); i != incoming.end(); i++) {
819 for (EdgeVector::iterator j = connected.begin(); j != connected.end(); j++) {
833 && (fromLane < 0 || c.
fromLane == fromLane)
834 && (toLane < 0 || c.
toLane == toLane)) {
855 if (reallowSetting) {
868 if ((*i).toEdge == which) {
880 std::map<int, int> laneMap;
884 bool wasConnected =
false;
886 if ((*i).toEdge != which) {
890 if ((*i).fromLane != -1) {
891 int fromLane = (*i).fromLane;
892 laneMap[(*i).toLane] = fromLane;
893 if (minLane == -1 || minLane > fromLane) {
896 if (maxLane == -1 || maxLane < fromLane) {
907 std::vector<NBEdge::Connection> conns = origConns;
908 for (std::vector<NBEdge::Connection>::iterator i = conns.begin(); i != conns.end(); ++i) {
909 if ((*i).toEdge == which) {
912 int fromLane = (*i).fromLane;
914 if (laneMap.find(fromLane) == laneMap.end()) {
915 if (fromLane >= 0 && fromLane <= minLane) {
918 if (fromLane >= 0 && fromLane >= maxLane) {
922 toUse = laneMap[fromLane];
941 unsigned int index = 0;
955 std::vector<Connection>::iterator i =
myConnections.begin() + index;
975 if ((*i).fromLane == static_cast<int>(lane)) {
988 std::string innerID =
":" + n.
getID();
990 unsigned int edgeIndex = linkIndex;
991 unsigned int internalLaneIndex = 0;
998 if (con.
toEdge != toEdge) {
1001 edgeIndex = linkIndex;
1002 toEdge = (*i).toEdge;
1003 internalLaneIndex = 0;
1006 std::vector<unsigned int> foeInternalLinks;
1010 std::pair<SUMOReal, std::vector<unsigned int> > crossingPositions(-1, std::vector<unsigned int>());
1011 std::set<std::string> tmpFoeIncomingLanes;
1016 unsigned int index = 0;
1018 for (EdgeVector::const_iterator i2 = incoming.begin(); i2 != incoming.end(); ++i2) {
1019 const std::vector<Connection>& elv = (*i2)->getConnections();
1020 for (std::vector<NBEdge::Connection>::const_iterator k2 = elv.begin(); k2 != elv.end(); k2++) {
1021 if ((*k2).toEdge == 0) {
1024 bool needsCont = n.
needsCont(
this, con.
toEdge, *i2, (*k2).toEdge, *k2);
1027 crossingPositions.second.push_back(index);
1030 if (dv.size() > 0) {
1032 if (minDV < shape.
length() - .1 && minDV > .1) {
1034 if (crossingPositions.first < 0 || crossingPositions.first > minDV) {
1035 crossingPositions.first = minDV;
1041 if (n.
foes(
this, con.
toEdge, *i2, (*k2).toEdge)) {
1042 foeInternalLinks.push_back(index);
1047 tmpFoeIncomingLanes.insert((*i2)->getID() +
"_" +
toString((*k2).fromLane));
1052 if (dir ==
LINKDIR_TURN && crossingPositions.first < 0 && crossingPositions.second.size() != 0) {
1075 assert(shape.size() >= 2);
1077 if (crossingPositions.first >= 0) {
1078 std::pair<PositionVector, PositionVector> split = shape.
splitAt(crossingPositions.first);
1079 con.
id = innerID +
"_" +
toString(edgeIndex);
1080 con.
shape = split.first;
1083 con.
viaID = innerID +
"_" +
toString(splitIndex + noInternalNoSplits);
1089 con.
id = innerID +
"_" +
toString(edgeIndex);
1094 ++internalLaneIndex;
1126 assert(atNode ==
myTo);
1151 std::vector<SUMOReal> offsets;
1152 for (
unsigned int i = 0; i <
myLanes.size(); ++i) {
1153 offsets.push_back(0);
1156 for (
int i = (
int)
myLanes.size() - 2; i >= 0; --i) {
1158 offsets[i] = offset;
1166 for (
unsigned int i = 0; i <
myLanes.size(); ++i) {
1172 for (
unsigned int i = 0; i <
myLanes.size(); ++i) {
1173 offsets[i] += offset;
1180 for (
unsigned int i = 0; i <
myLanes.size(); ++i) {
1184 WRITE_WARNING(
"In edge '" +
getID() +
"': lane shape could not be determined (" + e.what() +
")");
1194 bool haveWarned =
false;
1195 for (
int i = 0; i < (
int)
myGeom.size(); i++) {
1199 std::pair<SUMOReal, SUMOReal> offsets =
laneOffset(from, to, offset,
false);
1202 Position(from.
x() - offsets.first, from.
y() - offsets.second, from.
z()));
1203 }
else if (i == static_cast<int>(
myGeom.size() - 1)) {
1206 std::pair<SUMOReal, SUMOReal> offsets =
laneOffset(from, to, offset,
false);
1209 Position(to.
x() - offsets.first, to.
y() - offsets.second, to.
z()));
1214 std::pair<SUMOReal, SUMOReal> offsets =
laneOffset(from, me, offset,
false);
1215 std::pair<SUMOReal, SUMOReal> offsets2 =
laneOffset(me, to, offset,
false);
1217 Position(from.
x() - offsets.first, from.
y() - offsets.second),
1218 Position(me.
x() - offsets.first, me.
y() - offsets.second));
1221 Position(me.
x() - offsets2.first, me.
y() - offsets2.second),
1222 Position(to.
x() - offsets2.first, to.
y() - offsets2.second));
1224 if (angle < 10. || angle > 350.) {
1227 Position(me.
x() - offsets.first, me.
y() - offsets.second, me.
z()));
1252 std::pair<SUMOReal, SUMOReal>
1256 return std::pair<SUMOReal, SUMOReal>(-offsets.first, -offsets.second);
1258 return std::pair<SUMOReal, SUMOReal>(offsets.first, offsets.second);
1291 fromCenter.
x(), fromCenter.
y(),
1292 referencePosStart.x(), referencePosStart.y());
1295 referencePosEnd.x(), referencePosEnd.y(),
1296 toCenter.
x(), toCenter.
y());
1306 for (std::vector<Lane>::const_iterator i =
myLanes.begin(); i !=
myLanes.end(); ++i) {
1317 std::vector<Lane>::const_iterator i =
myLanes.begin();
1320 for (; i !=
myLanes.end(); ++i) {
1321 if (i->permissions != firstLanePermissions) {
1331 for (std::vector<Lane>::const_iterator i =
myLanes.begin(); i !=
myLanes.end(); ++i) {
1332 if (i->width !=
myLanes.begin()->width) {
1342 for (std::vector<Lane>::const_iterator i =
myLanes.begin(); i !=
myLanes.end(); ++i) {
1353 for (std::vector<Lane>::const_iterator i =
myLanes.begin(); i !=
myLanes.end(); ++i) {
1354 if (i->offset !=
myLanes.begin()->offset) {
1378 for (EdgeVector::const_iterator i = o.begin(); i != o.end(); ++i) {
1416 std::vector<unsigned int> connNumbersPerLane(
myLanes.size(), 0);
1418 if ((*i).toEdge == 0 || (*i).fromLane < 0 || (*i).toLane < 0) {
1421 if ((*i).fromLane >= 0) {
1422 ++connNumbersPerLane[(*i).fromLane];
1433 for (
unsigned int i = 0; i <
myLanes.size(); i++) {
1434 if (connNumbersPerLane[i] == 0) {
1435 if (i > 0 && connNumbersPerLane[i - 1] > 1) {
1437 }
else if (i <
myLanes.size() - 1 && connNumbersPerLane[i + 1] > 1) {
1453 if (outgoing->size() == 0) {
1466 unsigned int size = (
unsigned int) outgoing->size();
1467 std::vector<SUMOReal> resultingLanes;
1468 resultingLanes.reserve(size);
1472 for (i = 0; i < size; i++) {
1483 resultingLanes.push_back(res);
1484 sumResulting += res;
1485 if (minResulting > res) {
1493 sumResulting += minResulting / (
SUMOReal) 2.;
1494 unsigned int noVirtual = (
unsigned int)(sumResulting / minResulting);
1497 transition.reserve(size);
1498 for (i = 0; i < size; i++) {
1501 assert(i < resultingLanes.size());
1503 for (
SUMOReal j = 0; j < tmpNo; j++) {
1504 assert(outgoing->size() > i);
1505 transition.push_back((*outgoing)[i]);
1513 const std::map<NBEdge*, std::vector<unsigned int> >& l2eConns = adder.
getBuiltConnections();
1515 for (std::map<
NBEdge*, std::vector<unsigned int> >::const_iterator i = l2eConns.begin(); i != l2eConns.end(); ++i) {
1516 const std::vector<unsigned int> lanes = (*i).second;
1517 for (std::vector<unsigned int>::const_iterator j = lanes.begin(); j != lanes.end(); ++j) {
1529 std::vector<unsigned int>*
1532 std::vector<unsigned int>* priorities =
new std::vector<unsigned int>();
1533 if (outgoing->size() == 0) {
1536 priorities->reserve(outgoing->size());
1537 EdgeVector::const_iterator i;
1538 for (i = outgoing->begin(); i != outgoing->end(); i++) {
1539 int prio = (*i)->getJunctionPriority(
myTo);
1540 assert((prio + 1) * 2 > 0);
1541 prio = (prio + 1) * 2;
1542 priorities->push_back(prio);
1550 i = find(outgoing->begin(), outgoing->end(), *(tmp.begin()));
1551 unsigned int dist = (
unsigned int) distance(outgoing->begin(), i);
1553 assert(priorities->size() > 0);
1554 (*priorities)[0] = (*priorities)[0] / 2;
1559 if (mainDirections.
empty()) {
1560 assert(dist < priorities->size());
1561 (*priorities)[dist] = (*priorities)[dist] * 2;
1564 (*priorities)[dist] = (*priorities)[dist] * 2;
1573 unsigned int sum = 0;
1574 for (std::vector<unsigned int>::iterator i = priorities->begin(); i != priorities->end(); i++) {
1613 if (thisFromAngle2 < otherToAngle2) {
1614 std::swap(thisFromAngle2, otherToAngle2);
1616 if (thisFromAngle2 - otherToAngle2 > 170 && thisFromAngle2 - otherToAngle2 < 190) {
1627 if (pos < tolerance) {
1641 for (
unsigned int i = 0; i < lanes; i++) {
1643 for (std::vector<NBEdge::Connection>::iterator j = elv.begin(); j != elv.end(); j++) {
1645 assert(el.
tlID ==
"");
1693 assert(fromLane < 0 || fromLane < (
int)
myLanes.size());
1695 if (fromLane >= 0 && toLane >= 0) {
1697 std::vector<Connection>::iterator i =
1705 connection.
tlID = tlID;
1712 unsigned int no = 0;
1713 bool hadError =
false;
1715 if ((*i).toEdge != toEdge) {
1718 if (fromLane >= 0 && fromLane != (*i).fromLane) {
1721 if (toLane >= 0 && toLane != (*i).toLane) {
1724 if ((*i).tlID ==
"") {
1726 (*i).tlLinkNo = tlIndex;
1729 if ((*i).tlID != tlID && static_cast<int>((*i).tlLinkNo) == tlIndex) {
1730 WRITE_WARNING(
"The lane " + toString<int>((*i).fromLane) +
" on edge " +
getID() +
" already had a traffic light signal.");
1735 if (hadError && no == 0) {
1736 WRITE_WARNING(
"Could not set any signal of the traffic light '" + tlID +
"' (unknown group)");
1829 if (find(conn.begin(), conn.end(), possContinuation)
1846 if (conns.size() !=
myLanes.size()) {
1862 for (
unsigned int i = 0; i <
myLanes.size(); i++) {
1880 if ((*i).toEdge == e && (*i).tlID !=
"") {
1896 assert(lane <
myLanes.size());
1910 assert(distances.size() > 0);
1917 unsigned int newLaneNo = (
unsigned int)
myLanes.size() + by;
1918 while (
myLanes.size() < newLaneNo) {
1923 for (EdgeVector::const_iterator i = incs.begin(); i != incs.end(); ++i) {
1924 (*i)->invalidateConnections(
true);
1932 unsigned int newLaneNo = (
unsigned int)
myLanes.size() - by;
1933 while (
myLanes.size() > newLaneNo) {
1938 for (EdgeVector::const_iterator i = incs.begin(); i != incs.end(); ++i) {
1939 (*i)->invalidateConnections(
true);
1945 assert(outs.size() == 1);
1966 for (
unsigned int i = 0; i <
myLanes.size(); i++) {
1970 assert(lane < (
int)
myLanes.size());
1971 myLanes[lane].permissions |= vclass;
1979 for (
unsigned int i = 0; i <
myLanes.size(); i++) {
1983 assert(lane < (
int)
myLanes.size());
1984 myLanes[lane].permissions &= ~vclass;
1992 for (
unsigned int i = 0; i <
myLanes.size(); i++) {
1996 assert(lane < (
int)
myLanes.size());
1997 myLanes[lane].preferred |= vclass;
2007 for (
unsigned int i = 0; i <
myLanes.size(); i++) {
2013 assert(lane < (
int)
myLanes.size());
2037 for (
unsigned int i = 0; i <
myLanes.size(); i++) {
2043 assert(lane < (
int)
myLanes.size());
2044 myLanes[lane].offset = offset;
2053 for (
unsigned int i = 0; i <
myLanes.size(); i++) {
2059 assert(lane < (
int)
myLanes.size());
2067 for (
unsigned int i = 0; i <
myLanes.size(); i++) {
2072 assert(lane < (
int)
myLanes.size());
2073 myLanes[lane].permissions = permissions;
2081 for (
unsigned int i = 0; i <
myLanes.size(); i++) {
2086 assert(lane < (
int)
myLanes.size());
2087 myLanes[lane].preferred = permissions;
2096 for (
unsigned int i = 0; i <
myLanes.size(); i++) {
2101 assert(lane < (
int)
myLanes.size());
2102 return myLanes[lane].permissions;
2115 for (std::vector<Lane>::iterator i =
myLanes.begin(); i !=
myLanes.end(); ++i) {
SUMOReal length2D() const
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
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.
void divideOnEdges(const EdgeVector *outgoing)
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
std::vector< unsigned int > * preparePriorities(const EdgeVector *outgoing)
std::string foeIncomingLanes
const SUMOReal SUMO_const_laneWidth
std::vector< TLSDisabledConnection > myTLSDisabledConnections
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.
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.
PositionVector getCCWBoundaryLine(const NBNode &n, SUMOReal offset) const
void setLaneWidth(int lane, SUMOReal width)
set lane specific width (negative lane implies set for all lanes)
std::vector< SUMOReal > distances(const PositionVector &s) const
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.
PositionVector computeInternalLaneShape(NBEdge *fromE, int fromL, NBEdge *toE, int toL, int numPoints=5) const
Compute the shape for an internal lane.
void setOffset(int lane, SUMOReal offset)
set lane specific end-offset (negative lane implies set for all lanes)
void moveOutgoingConnectionsFrom(NBEdge *e, unsigned int laneOff)
const SUMOReal SUMO_const_laneWidthAndOffset
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)
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.
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.
void buildInnerEdges(const NBNode &n, unsigned int noInternalNoSplits, unsigned int &linkIndex, unsigned int &splitIndex)
void markAsInLane2LaneState()
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 ...
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.
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 isTurningDirectionAt(const NBNode *n, const NBEdge *const edge) const
Returns whether the given edge is the opposite direction to this edge.
static const SUMOReal UNSPECIFIED_OFFSET
unspecified lane offset
PositionVector getCWBoundaryLine(const NBNode &n, SUMOReal offset) const
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
void setGeometry(const PositionVector &g, bool inner=false)
(Re)sets the edge's geometry
#define UNUSED_PARAMETER(x)
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.
const EdgeVector & getOutgoingEdges() const
Returns this node's outgoing edges.
void moveConnectionToRight(unsigned int lane)
void setTurningDestination(NBEdge *e)
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.
bool addEdge2EdgeConnection(NBEdge *dest)
Adds a connection to another edge.
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)
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
bool computeLanes2Edges()
computes the edge, step2: computation of which lanes approach the edges)
NBEdge * myTurnDestination
The turn destination edge.
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
void moveConnectionToLeft(unsigned int lane)
bool myAmLeftHand
Whether this edge is a left-hand edge.
void reshiftRotate(SUMOReal xoff, SUMOReal yoff, SUMOReal rot)
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.
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
bool needsCont(NBEdge *fromE, NBEdge *toE, NBEdge *otherFromE, NBEdge *otherToE, const NBEdge::Connection &c) 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.
SUMOReal distance(const Position &p) const
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.
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
EdgeBuildingStep myStep
The building step.
unsigned int computePrioritySum(std::vector< unsigned int > *priorities)
SUMOReal myOffset
This edges's offset to the intersection begin (will be applied to all lanes)
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
void removeFromConnections(NBEdge *toEdge, int fromLane=-1, int toLane=-1, bool tryLater=false)
Removes the specified connection(s)
static void compute(BresenhamCallBack *callBack, const unsigned int val1, const unsigned int val2)
const SVCPermissions SVCFreeForAll
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.
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
void extrapolateBy(SUMOReal length)
SUMOReal length() const
Returns the length.
void push_back(const PositionVector &p)
Appends all positions from the given vector.
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)
bool hasLaneSpecificOffset() const
whether lanes differ in offset
SUMOReal getMaxLaneOffset()
static const SUMOReal UNSPECIFIED_LOADED_LENGTH
no length override given
Position positionAtOffset2D(SUMOReal pos) const
Returns the position at the given length.
std::vector< NBEdge * > EdgeVector
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
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
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.
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)
void move2side(SUMOReal amount)
NBEdge * getTurnDestination() const
bool hasLaneSpecificWidth() const
whether lanes differ in width
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.
bool hasConnectionTo(NBEdge *destEdge, unsigned int destLane) const
Retrieves info about a connection to a certain lane of a certain edge.
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)
void append(const PositionVector &v)
NBNode * myFrom
The source and the destination node.
bool expandableBy(NBEdge *possContinuation) const
Position intersectsAt(const Line &l) const
SUMOReal getOffset() const
Returns the offset to the destination node.
PositionVector getSubpart(SUMOReal beginOffset, SUMOReal endOffset) const
~MainDirections()
destructor
void disallowVehicleClass(int lane, SUMOVehicleClass vclass)
set disallowed class for the given lane or for all lanes if -1 is given
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 anglen
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.
bool splitGeometry(NBEdgeCont &ec, NBNodeCont &nc)
Splits this edge at geometry points.