69 #ifdef CHECK_MEMORY_LEAKS
71 #endif // CHECK_MEMORY_LEAKS
74 #define EXTEND_CROSSING_ANGLE_THRESHOLD 35.0 // degrees
76 #define SPLIT_CROSSING_WIDTH_THRESHOLD 1.5 // meters
77 #define SPLIT_CROSSING_ANGLE_THRESHOLD 5 // degrees
79 #define UNCONTROLLED_CROSSING_SPEED_THRESHOLD 13.89 // meters/second
96 EdgeVector* approaching,
NBEdge* currentOutgoing,
const bool buildCrossingsAndWalkingAreas) :
97 myApproaching(approaching), myCurrentOutgoing(currentOutgoing) {
101 std::set<int> approachedLanes;
103 const std::vector<NBEdge::Connection> conns = (*it)->getConnections();
104 for (std::vector<NBEdge::Connection>::const_iterator it_con = conns.begin(); it_con != conns.end(); ++it_con) {
106 approachedLanes.insert((*it_con).toLane);
117 && approachedLanes.count(i) == 0) {
130 assert(myApproaching->size() > src);
132 NBEdge* incomingEdge = (*myApproaching)[src];
136 std::vector<int> approachingLanes =
138 assert(approachingLanes.size() != 0);
139 std::deque<int>* approachedLanes = spread(approachingLanes, dest);
140 assert(approachedLanes->size() <= myAvailableLanes.size());
142 for (
unsigned int i = 0; i < approachedLanes->size(); i++) {
143 assert(approachedLanes->size() > i);
144 assert(approachingLanes.size() > i);
145 unsigned int approached = myAvailableLanes[(*approachedLanes)[i]];
147 incomingEdge->setConnection((
unsigned int) approachingLanes[i], myCurrentOutgoing,
150 delete approachedLanes;
157 std::deque<int>* ret =
new std::deque<int>();
158 unsigned int noLanes = (
unsigned int) approachingLanes.size();
162 ret->push_back(dest);
166 unsigned int noOutgoingLanes = (
unsigned int)myAvailableLanes.size();
168 ret->push_back(dest);
169 unsigned int noSet = 1;
172 while (noSet < noLanes) {
178 if (noOutgoingLanes == noSet) {
187 if (dest + loffset >= static_cast<int>(noOutgoingLanes)) {
190 for (
unsigned int i = 0; i < ret->size(); i++) {
191 (*ret)[i] = (*ret)[i] - 1;
196 ret->push_back(dest + loffset);
201 if (noOutgoingLanes == noSet) {
206 if (noSet < noLanes) {
209 if (dest < roffset) {
212 for (
unsigned int i = 0; i < ret->size(); i++) {
213 (*ret)[i] = (*ret)[i] + 1;
216 ret->push_front(dest - roffset);
241 myPosition(position),
243 myDistrict(district),
244 myHaveCustomPoly(false),
256 bool updateEdgeGeometries) {
263 if (updateEdgeGeometries) {
267 (*i)->setGeometry(geom);
272 (*i)->setGeometry(geom);
307 for (std::set<NBTrafficLightDefinition*>::const_iterator i = trafficLights.begin(); i != trafficLights.end(); ++i) {
319 if ((*i)->getID().find(
"joined") == 0) {
331 for (std::set<NBTrafficLightDefinition*>::iterator it = oldDefs.begin(); it != oldDefs.end(); ++it) {
333 if (dynamic_cast<NBOwnTLDef*>(orig) == 0) {
335 const std::vector<NBNode*>& nodes = orig->
getNodes();
336 while (!nodes.empty()) {
337 nodes.front()->removeTrafficLight(orig);
338 newDef->
addNode(nodes.front());
351 (*it)->shiftTLConnectionLaneIndex(edge, offset);
358 unsigned int ret = 0;
359 unsigned int pos = 0;
375 if ((*i)->isConnectedTo(dummy) && *i != dummy) {
376 incomingConnected.push_back(*i);
383 outgoingConnected.push_back(*i);
388 remapRemoved(tc, dummy, incomingConnected, outgoingConnected);
437 if (in->
getNumLanes() != (*opposite)->getNumLanes()) {
450 NBEdge* toE,
int toL,
int numPoints)
const {
457 bool noSpline =
false;
463 unsigned int noInitialPoints = 0;
477 Line cross(straightConn);
478 cross.
sub(cross.
p1().
x(), cross.
p1().
y());
480 center.
sub(cross.
p2());
485 if (angle < M_PI / 4. || angle > 7. / 4.*
M_PI) {
526 WRITE_WARNING(
"Could not use edge geometry for internal lane, node '" +
getID() +
"'.");
543 for (
int i = 0; i < (
int) init.size(); ++i) {
545 def[i * 3 + 1] = init[i].x();
547 def[i * 3 + 3] = init[i].y();
550 bezier(noInitialPoints, def, numPoints, ret_buf);
553 for (
int i = 0; i < (
int) numPoints; i++) {
554 Position current(ret_buf[i * 3 + 1], ret_buf[i * 3 + 3]);
555 if (prev != current) {
577 if (fromE == otherFromE) {
581 if (!
foes(otherFromE, otherToE, fromE, toE)) {
589 bool bothLeft = thisLeft && otherLeft;
590 if (c.
tlID !=
"" && !bothLeft) {
624 WRITE_WARNING(
"Junction '" +
getID() +
"' is too complicated (#links>64); will be set to unregulated.");
628 }
else if (numConnections == 0) {
666 if (mismatchThreshold >= 0
725 std::swap(inc1, inc2);
748 std::swap(out1, out2);
759 EdgeVector::reverse_iterator i;
761 NBEdge* currentOutgoing = *i;
764 const unsigned int numApproaching = (
unsigned int)approaching->size();
765 if (numApproaching != 0) {
766 ApproachingDivider divider(approaching, currentOutgoing, buildCrossingsAndWalkingAreas);
776 (*i)->markAsInLane2LaneState();
794 EdgeVector::const_iterator i = find(
myAllEdges.begin(),
800 for (; *i != currentOutgoing;) {
802 if ((*i)->getToNode() ==
this && (*i)->getTurnDestination() != currentOutgoing) {
803 std::vector<int> connLanes = (*i)->getConnectionLanes(currentOutgoing);
804 if (connLanes.size() != 0) {
805 approaching->push_back(*i);
835 unsigned int laneOff = 0;
836 for (EdgeVector::const_iterator i = which.begin(); i != which.end(); i++) {
838 laneOff += (*i)->getNumLanes();
867 unsigned int laneOff = 0;
868 for (EdgeVector::const_iterator i = which.begin(); i != which.end(); i++) {
870 laneOff += (*i)->getNumLanes();
885 unsigned int whichLaneOff,
unsigned int byLaneOff) {
889 bool changed =
false;
891 if (c.
replaceFrom(which, whichLaneOff, by, byLaneOff)) {
894 if (c.
replaceTo(which, whichLaneOff, by, byLaneOff)) {
908 for (NBConnectionVector::iterator k = prohibiting.begin(); k != prohibiting.end(); k++) {
910 sprohibiting.
replaceFrom(which, whichLaneOff, by, byLaneOff);
911 sprohibiting.
replaceTo(which, whichLaneOff, by, byLaneOff);
972 if (find(edges.begin(), edges.end(), e) != edges.end()) {
973 edges.erase(find(edges.begin(), edges.end(), e));
975 if (edges.size() == 0) {
991 mayDrive.
getTo() == 0 ||
993 mustStop.
getTo() == 0) {
995 WRITE_WARNING(
"Something went wrong during the building of a connection...");
999 conn.push_back(mayDrive);
1006 unsigned int size = (
unsigned int) edgeid.length();
1008 std::string
id = (*i)->
getID();
1009 if (
id.substr(0, size) == edgeid) {
1019 unsigned int size = (
unsigned int) edgeid.length();
1021 std::string
id = (*i)->
getID();
1022 if (
id.substr(0, size) == edgeid) {
1047 if (removeFromConnections) {
1049 (*i)->removeFromConnections(edge);
1059 EdgeVector::const_iterator i;
1061 NBNode* conn = (*i)->getFromNode();
1064 toAdd.
mul((
SUMOReal) 1.0 / sqrt(toAdd.
x()*toAdd.
x() + toAdd.
y()*toAdd.
y()));
1068 NBNode* conn = (*i)->getToNode();
1071 toAdd.
mul((
SUMOReal) 1.0 / sqrt(toAdd.
x()*toAdd.
x() + toAdd.
y()*toAdd.
y()));
1075 if (pos.
x() == 0 && pos.
y() == 0) {
1087 (*i)->invalidateConnections();
1095 (*i)->invalidateConnections();
1140 std::vector<NBEdge*>::const_iterator i = std::find(
myAllEdges.begin(),
myAllEdges.end(), from);
1150 const NBEdge*
const possProhibitedFrom,
const NBEdge*
const possProhibitedTo,
1151 bool regardNonSignalisedLowerPriority)
const {
1153 possProhibitedFrom, possProhibitedTo,
1154 regardNonSignalisedLowerPriority);
1160 const NBEdge*
const from2,
const NBEdge*
const to2)
const {
1169 assert(find(incoming.begin(), incoming.end(), removed) == incoming.end());
1170 bool changed =
true;
1176 for (NBConnectionProhibits::iterator i = blockedConnectionsTmp.begin(); i != blockedConnectionsTmp.end(); i++) {
1181 bool blockedChanged =
false;
1183 NBConnectionVector::const_iterator j;
1184 for (j = blocked.begin(); j != blocked.end(); j++) {
1186 if (sblocked.
getFrom() == removed || sblocked.
getTo() == removed) {
1187 blockedChanged =
true;
1191 for (j = blocked.begin(); blockedChanged && j != blocked.end(); j++) {
1193 if (sblocked.
getFrom() == removed && sblocked.
getTo() == removed) {
1197 }
else if (sblocked.
getFrom() == removed) {
1198 assert(sblocked.
getTo() != removed);
1199 for (EdgeVector::const_iterator k = incoming.begin(); k != incoming.end(); k++) {
1202 }
else if (sblocked.
getTo() == removed) {
1203 assert(sblocked.
getFrom() != removed);
1204 for (EdgeVector::const_iterator k = outgoing.begin(); k != outgoing.end(); k++) {
1211 if (blockedChanged) {
1212 blockedConnectionsNew[blocker] = newBlocked;
1217 if (blocker.
getFrom() == removed && blocker.
getTo() == removed) {
1222 }
else if (blocker.
getFrom() == removed) {
1223 assert(blocker.
getTo() != removed);
1225 for (EdgeVector::const_iterator k = incoming.begin(); k != incoming.end(); k++) {
1228 }
else if (blocker.
getTo() == removed) {
1229 assert(blocker.
getFrom() != removed);
1231 for (EdgeVector::const_iterator k = outgoing.begin(); k != outgoing.end(); k++) {
1235 blockedConnectionsNew[blocker] = blocked;
1249 if (outgoing == 0) {
1260 if (
abs((
int) angle) + 1 < 45) {
1267 EdgeVector::const_iterator i =
1270 while ((*i) != incoming) {
1271 if ((*i)->getFromNode() ==
this) {
1279 EdgeVector::const_iterator i =
1282 while ((*i) != incoming) {
1294 bool mayDefinitelyPass,
const std::string& tlID)
const {
1298 if (outgoing == 0) {
1307 if ((!incoming->
isInnerEdge() &&
mustBrake(incoming, outgoing, fromlane)) && !mayDefinitelyPass) {
1321 EdgeVector::const_iterator i;
1334 std::set<NBNode*> origSet;
1336 origSet.insert((*i)->getFromNode());
1338 if (origSet.size() < 2) {
1345 NBNode* origin = (*i)->getFromNode();
1347 EdgeVector::const_iterator j =
1356 if (!(*i)->expandableBy(*j)) {
1372 std::vector<std::pair<NBEdge*, NBEdge*> >
1375 std::vector<std::pair<NBEdge*, NBEdge*> > ret;
1379 std::pair<NBEdge*, NBEdge*>(
1385 NBNode* origin = (*i)->getFromNode();
1386 EdgeVector::const_iterator j =
1390 ret.push_back(std::pair<NBEdge*, NBEdge*>(*i, *j));
1412 if ((*i)->getToNode() == n) {
1427 back_inserter(edges));
1429 back_inserter(edges));
1430 for (EdgeVector::const_iterator j = edges.begin(); j != edges.end(); ++j) {
1441 for (EdgeVector::const_iterator k = edges2.begin(); k != edges2.end(); ++k) {
1442 if ((*k)->getFromNode()->isDistrict() || (*k)->getToNode()->isDistrict()) {
1466 std::cout <<
"guess crossings for " <<
getID() <<
"\n";
1472 std::vector<std::pair<NBEdge*, bool> > normalizedLanes;
1475 const std::vector<NBEdge::Lane>& lanes = edge->
getLanes();
1477 for (std::vector<NBEdge::Lane>::const_reverse_iterator it_l = lanes.rbegin(); it_l != lanes.rend(); ++it_l) {
1478 normalizedLanes.push_back(std::make_pair(edge, ((*it_l).permissions &
SVC_PEDESTRIAN) != 0));
1481 for (std::vector<NBEdge::Lane>::const_iterator it_l = lanes.begin(); it_l != lanes.end(); ++it_l) {
1482 normalizedLanes.push_back(std::make_pair(edge, ((*it_l).permissions &
SVC_PEDESTRIAN) != 0));
1487 int firstSidewalk = -1;
1488 for (
int i = 0; i < (
int)normalizedLanes.size(); ++i) {
1489 if (normalizedLanes[i].second) {
1494 if (firstSidewalk != -1) {
1496 std::vector<std::pair<NBEdge*, bool> > tmp;
1497 copy(normalizedLanes.begin() + firstSidewalk, normalizedLanes.end(), std::back_inserter(tmp));
1498 copy(normalizedLanes.begin(), normalizedLanes.begin() + firstSidewalk, std::back_inserter(tmp));
1499 normalizedLanes = tmp;
1502 bool hadCandidates =
false;
1503 for (
int i = 0; i < (
int)normalizedLanes.size(); ++i) {
1504 NBEdge* edge = normalizedLanes[i].first;
1505 const bool allowsPed = normalizedLanes[i].second;
1507 std::cout <<
" cands=" <<
toString(candidates) <<
" edge=" << edge->
getID() <<
" allowsPed=" << allowsPed <<
"\n";
1509 if (!allowsPed && (candidates.size() == 0 || candidates.back() != edge)) {
1510 candidates.push_back(edge);
1511 }
else if (allowsPed) {
1512 if (candidates.size() > 0) {
1513 hadCandidates =
true;
1519 if (hadCandidates) {
1532 std::cout <<
"checkCrossing candidates=" <<
toString(candidates) <<
"\n";
1534 if (candidates.size() == 0) {
1536 std::cout <<
"no crossing added (numCandidates=" << candidates.size() <<
")\n";
1542 for (
size_t i = 0; i < candidates.size(); ++i) {
1543 NBEdge* edge = candidates[i];
1548 std::cout <<
"no crossing added (found angle difference of " << fabs(angle - prevAngle) <<
" at i=" << i <<
"\n";
1554 std::cout <<
"no crossing added (uncontrolled, edge with speed=" << edge->
getSpeed() <<
")\n";
1560 if (candidates.size() == 1) {
1563 std::cout <<
"adding crossing: " <<
toString(candidates) <<
"\n";
1569 for (EdgeVector::iterator it = candidates.begin(); it != candidates.end(); ++it) {
1570 SUMOReal angle = (*it)->getCrossingAngle(
this);
1571 if (it != candidates.begin()) {
1572 NBEdge* prev = *(it - 1);
1580 prevPos = prev->
getLanes()[laneI].shape[-1];
1583 prevPos = prev->
getLanes()[laneI].shape[0];
1588 currPos = curr->
getLanes()[laneI].shape[0];
1591 currPos = curr->
getLanes()[laneI].shape[-1];
1597 <<
" prevAngle=" << prevAngle
1598 <<
" angle=" << angle
1599 <<
" intermediateWidth=" << intermediateWidth
1612 std::cout <<
"adding crossing: " <<
toString(candidates) <<
"\n";
1623 unsigned int noInternalNoSplits = 0;
1625 const std::vector<NBEdge::Connection>& elv = (*i)->getConnections();
1626 for (std::vector<NBEdge::Connection>::const_iterator k = elv.begin(); k != elv.end(); ++k) {
1627 if ((*k).toEdge == 0) {
1630 noInternalNoSplits++;
1633 unsigned int lno = 0;
1634 unsigned int splitNo = 0;
1636 (*i)->buildInnerEdges(*
this, noInternalNoSplits, lno, splitNo);
1638 if (buildCrossingsAndWalkingAreas) {
1643 if ((*it).prevWalkingArea ==
"" || (*it).nextWalkingArea ==
"") {
1658 unsigned int index = 0;
1661 if ((*it).edges.size() > 2) {
1662 WRITE_ERROR(
"Crossings across more than 2 edges not yet implemented (" +
toString((*it).edges) +
")");
1667 (*it).shape.clear();
1669 const int begDir = (edges.front()->getFromNode() ==
this ?
FORWARD :
BACKWARD);
1670 const int endDir = (edges.back()->getToNode() ==
this ?
FORWARD :
BACKWARD);
1671 NBEdge::Lane crossingBeg = edges.front()->getFirstNonPedestrianLane(begDir);
1672 NBEdge::Lane crossingEnd = edges.back()->getFirstNonPedestrianLane(endDir);
1679 (*it).shape.push_back(crossingBeg.
shape[begDir ==
FORWARD ? 0 : -1]);
1680 (*it).shape.push_back(crossingEnd.
shape[endDir ==
FORWARD ? -1 : 0]);
1689 unsigned int index = 0;
1692 std::cout <<
"build walkingAreas for " <<
getID() <<
":\n";
1695 std::vector<std::pair<NBEdge*, NBEdge::Lane> > normalizedLanes;
1698 const std::vector<NBEdge::Lane>& lanes = edge->
getLanes();
1700 for (std::vector<NBEdge::Lane>::const_reverse_iterator it_l = lanes.rbegin(); it_l != lanes.rend(); ++it_l) {
1703 normalizedLanes.
push_back(std::make_pair(edge, l));
1706 for (std::vector<NBEdge::Lane>::const_iterator it_l = lanes.begin(); it_l != lanes.end(); ++it_l) {
1710 normalizedLanes.
push_back(std::make_pair(edge, l));
1716 std::vector<std::pair<int, int> > waIndices;
1718 NBEdge* prevEdge = normalizedLanes.back().first;
1719 for (
int i = 0; i < (
int)normalizedLanes.size(); ++i) {
1720 NBEdge* edge = normalizedLanes[i].first;
1728 waIndices.push_back(std::make_pair(start, i - start));
1738 <<
" waI=" << waIndices.size() <<
" crossingBetween=" <<
crossingBetween(edge, prevEdge) <<
"\n";
1743 const int waNumLanes = (
int)normalizedLanes.size() - start;
1744 if (waIndices.size() == 0) {
1745 waIndices.push_back(std::make_pair(start, waNumLanes));
1747 std::cout <<
" single wa, end at wrap-around\n";
1750 if (waIndices.front().first == 0) {
1751 NBEdge* edge = normalizedLanes.front().first;
1752 NBEdge* prevEdge = normalizedLanes.back().first;
1755 waIndices.push_back(std::make_pair(start, waNumLanes));
1757 std::cout <<
" do not wrap around, turn-around in between\n";
1761 waIndices.front().first = start;
1762 waIndices.front().second = waNumLanes + waIndices.front().second;
1764 std::cout <<
" wrapping around\n";
1769 waIndices.push_back(std::make_pair(start, waNumLanes));
1771 std::cout <<
" end at wrap-around\n";
1777 std::cout <<
" normalizedLanes=" << normalizedLanes.size() <<
" waIndices:\n";
1778 for (
int i = 0; i < (
int)waIndices.size(); ++i) {
1779 std::cout <<
" " << waIndices[i].first <<
", " << waIndices[i].second <<
"\n";
1783 for (
int i = 0; i < (
int)waIndices.size(); ++i) {
1784 const bool buildExtensions = waIndices[i].second != (
int)normalizedLanes.size();
1785 const int start = waIndices[i].first;
1786 const int prev = start > 0 ? start - 1 : (
int)normalizedLanes.size() - 1;
1787 const int count = waIndices[i].second;
1788 const int end = (start + count) % normalizedLanes.size();
1792 std::cout <<
"build walkingArea " << wa.
id <<
" start=" << start <<
" end=" << end <<
" count=" << count <<
" prev=" << prev <<
":\n";
1797 bool connectsCrossing =
false;
1798 std::vector<Position> connectedPoints;
1800 if ((*it).edges.back() == normalizedLanes[end].first
1801 && (normalizedLanes[end].second.permissions &
SVC_PEDESTRIAN) == 0) {
1803 (*it).nextWalkingArea = wa.
id;
1804 endCrossingWidth = (*it).width;
1805 connectsCrossing =
true;
1806 connectedPoints.push_back((*it).shape[-1]);
1808 std::cout <<
" crossing " << (*it).id <<
" ends\n";
1811 if ((*it).edges.front() == normalizedLanes[prev].first
1812 && (normalizedLanes[prev].second.permissions &
SVC_PEDESTRIAN) == 0) {
1814 (*it).prevWalkingArea = wa.
id;
1816 startCrossingWidth = (*it).width;
1817 connectsCrossing =
true;
1821 connectedPoints.push_back((*it).shape[0]);
1823 std::cout <<
" crossing " << (*it).id <<
" starts\n";
1826 if (
gDebugFlag1) std::cout <<
" check connections to crossing " << (*it).id
1827 <<
" cFront=" << (*it).edges.front()->getID() <<
" cBack=" << (*it).edges.back()->getID()
1828 <<
" wEnd=" << normalizedLanes[end].first->getID() <<
" wStart=" << normalizedLanes[start].first->getID()
1829 <<
" wStartPrev=" << normalizedLanes[prev].first->getID()
1832 if (count < 2 && !connectsCrossing) {
1836 wa.
width = (endCrossingWidth + startCrossingWidth) / 2;
1838 std::set<NBEdge*> connected;
1839 for (
int j = 0; j < count; ++j) {
1840 const int nlI = (start + j) % normalizedLanes.size();
1841 NBEdge* edge = normalizedLanes[nlI].first;
1844 if (connected.count(edge) == 0) {
1852 connected.insert(edge);
1859 if (buildExtensions) {
1866 l = normalizedLanes[end > 0 ? end - 1 : normalizedLanes.size() - 1].second;
1873 NBEdge* e1 = *connected.begin();
1874 NBEdge* e2 = *(++connected.begin());
1881 int combinations = 0;
1882 for (std::vector<Position>::const_iterator it1 = connectedPoints.begin(); it1 != connectedPoints.end(); ++it1) {
1883 for (std::vector<Position>::const_iterator it2 = connectedPoints.begin(); it2 != connectedPoints.end(); ++it2) {
1893 std::cout <<
" combinations=" << combinations <<
" connectedPoints=" << connectedPoints <<
"\n";
1896 if (combinations > 0) {
1940 EdgeVector::const_iterator it1 = find(edges.begin(), edges.end(), e1);
1941 EdgeVector::const_iterator it2 = find(edges.begin(), edges.end(), e2);
1942 if (it1 != edges.end() && it2 != edges.end()) {
1958 while (it != it_end) {
1959 result.push_back(*it);
1980 if (
MAX2(angle0, angle1) <= 160) {
2008 if ((*it).id ==
id) {
2012 throw ProcessError(
"Request for unknown crossing '" +
id +
"'");
2019 (*it).tlLinkNo = startIndex++;
bool gDebugFlag1
global utility flags for debugging
void sub(SUMOReal dx, SUMOReal dy)
Substracts the given position from this one.
The link is a partial left direction.
const PositionVector & getLaneShape(unsigned int i) const
Returns the shape of the nth lane.
void replaceIncoming(NBEdge *which, NBEdge *by, unsigned int laneOff)
Replaces occurences of the first edge within the list of incoming by the second Connections are remap...
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.
void replaceOutgoing(const EdgeVector &which, NBEdge *const by)
Replaces outgoing edges from the vector (source) by the given edge.
Position getEmptyDir() const
Returns something like the most unused direction Should only be used to add source or sink nodes...
SUMOReal endOffset
This lane's offset to the intersection begin.
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.
void setRoundabout()
update the type of this node as a roundabout
std::vector< Crossing > myCrossings
Vector of crossings.
Position getCenter() const
Returns a position that is guaranteed to lie within the node shape.
static const SUMOReal UNSPECIFIED_WIDTH
unspecified lane width
SUMOReal width
This lane's width.
static SUMOReal getCCWAngleDiff(SUMOReal angle1, SUMOReal angle2)
Returns the distance of second angle from first angle counter-clockwise.
PositionVector shape
The lane's shape.
const SUMOReal SUMO_const_laneWidth
virtual void addNode(NBNode *node)
Adds a node to the traffic light logic.
bool mustBrakeForCrossing(const NBEdge *const from, const NBEdge *const to, const NBNode::Crossing &crossing) const
Returns the information whether the described flow must brake for the given crossing.
bool isInStringVector(const std::string &optionName, const std::string &itemName)
Returns the named option is a list of string values containing the specified item.
#define EXTEND_CROSSING_ANGLE_THRESHOLD
Sorts crossings by minimum clockwise clockwise edge angle. Use the ordering found in myAllEdges of th...
void shiftTLConnectionLaneIndex(NBEdge *edge, int offset)
patches loaded signal plans by modifying lane indices
std::string id
the (edge)-id of this crossing
void add(const Position &pos)
Adds the given position to this one.
PositionVector myPoly
the (outer) shape of the junction
NBEdge * getOppositeIncoming(NBEdge *e) const
void execute(const unsigned int src, const unsigned int dest)
SumoXMLNodeType myType
The type of the junction.
A container for traffic light definitions and built programs.
SUMOReal length
This lane's width.
void reinit(const Position &position, SumoXMLNodeType type, bool updateEdgeGeometries=false)
Resets initial values.
SUMOReal width
This lane's width.
static SUMOReal normRelAngle(SUMOReal angle1, SUMOReal angle2)
ensure that reverse relAngles (>=179.999) always count as turnarounds (-180)
bool isTLControlled() const
Returns whether this node is controlled by any tls.
Some static methods for string processing.
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.
TrafficLightType getType() const
get the algorithm type (static etc..)
PositionVector computeInternalLaneShape(NBEdge *fromE, int fromL, NBEdge *toE, int toL, int numPoints=5) const
Compute the shape for an internal lane.
const std::vector< NBEdge::Lane > & getLanes() const
Returns the lane definitions.
This class computes shapes of junctions.
This is an uncontrolled, minor link, has to stop.
const Crossing & getCrossing(const std::string &id) const
return the crossing with the given id
void removeEdge(NBEdge *edge, bool removeFromConnections=true)
Removes edge from this node and optionally removes connections as well.
void addIncomingEdge(NBEdge *edge)
adds an incoming edge
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.
Class to sort edges by their angle in relation to the given edge.
bool replaceTo(NBEdge *which, NBEdge *by)
replaces the to-edge by the one given
The link is a 180 degree turn.
int numNormalConnections() const
return the number of lane-to-lane connections at this junction (excluding crossings) ...
void rotateAtP1(SUMOReal rot)
ApproachingDivider(EdgeVector *approaching, NBEdge *currentOutgoing, const bool buildCrossingsAndWalkingAreas)
Constructor.
void addCrossing(EdgeVector edges, SUMOReal width, bool priority)
add a pedestrian crossing to this node
bool mustBrake(const NBEdge *const from, const NBEdge *const to, int toLane) const
Returns the information whether the described flow must let any other flow pass.
bool hasOutgoing(const NBEdge *const e) const
Returns whether the given edge starts at this node.
A container for districts.
The base class for traffic light logic definitions.
EdgeVector edgesBetween(const NBEdge *e1, const NBEdge *e2) const
return all edges that lie clockwise between the given edges
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.
bool isJoinedTLSControlled() const
Returns whether this node is controlled by a tls that spans over more than one node.
SUMOReal getLaneWidth() const
Returns the default width of lanes of this edge.
void extrapolateFirstBy(SUMOReal length)
PositionVector shape
The lane's shape.
#define SPLIT_CROSSING_ANGLE_THRESHOLD
PositionVector getSubpartByIndex(int beginIndex, int count) const
static const int MAX_CONNECTIONS
maximum number of connections allowed
bool isInnerEdge() const
Returns whether this edge was marked as being within an intersection.
This is an uncontrolled, right-before-left link.
static void nextCW(const EdgeVector &edges, EdgeVector::const_iterator &from)
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.
std::string id
the (edge)-id of this walkingArea
SUMOReal distanceTo(const Position &p2) const
returns the euclidean distance in 3 dimension
bool checkIsRemovable() const
void computeLanes2Lanes(const bool buildCrossingsAndWalkingAreas)
computes the connections of lanes to edges
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.
bool almostSame(const Position &p2, SUMOReal maxDiv=POSITION_EPS) const
void removeTrafficLight(NBTrafficLightDefinition *tlDef)
Removes the given traffic light from this node.
void setCustomShape(const PositionVector &shape)
set the junction shape
The link is controlled by a tls which is off, not blinking, may pass.
NBConnectionProhibits myBlockedConnections
void writeLogic(std::string key, OutputDevice &into, const bool checkLaneFoes) const
bool hasIncoming(const NBEdge *const e) const
Returns whether the given edge ends at this node.
SUMOReal x() const
Returns the x-position.
This is an uncontrolled, all-way stop link.
void addOutgoingEdge(NBEdge *edge)
adds an outgoing edge
NBEdge * getFrom() const
returns the from-edge (start of the connection)
unsigned int numAvailableLanes() const
The link is a (hard) left direction.
#define WRITE_WARNING(msg)
The connection was computed and validated.
PositionVector reverse() const
LinkDirection
The different directions a link between two lanes may take (or a stream between two edges)...
The link is a straight direction.
SUMOTime getOffset()
Returns the offset.
NBDistrict * myDistrict
The district the node is the centre of.
A class representing a single district.
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.
EdgeVector myAllEdges
Vector of incoming and outgoing edges.
SVCPermissions permissions
List of vehicle types that are allowed on this lane.
Position getPositionAtDistance(SUMOReal offset) const
void invalidateIncomingConnections()
bool isConnectedTo(NBEdge *e)
Returns the information whethe a connection to the given edge has been added (or computed) ...
const Position & getPosition() const
Returns the position of this node.
const Position & p1() const
bool replaceFrom(NBEdge *which, NBEdge *by)
replaces the from-edge by the one given
Lanes to lanes - relationships are loaded; no recheck is necessary/wished.
std::string prevWalkingArea
the lane-id of the previous walkingArea
NBEdge * getPossiblySplittedIncoming(const std::string &edgeid)
void computeNodeShape(bool leftHand, SUMOReal mismatchThreshold)
Compute the junction shape for this node.
const std::set< NBTrafficLightDefinition * > & getControllingTLS() const
Returns the traffic lights that were assigned to this node.
bool isSimpleContinuation() const
void buildBitfieldLogic(bool leftHanded)
int checkCrossing(EdgeVector candidates)
static const int FORWARD
edge directions (for pedestrian related stuff)
std::vector< unsigned int > myAvailableLanes
The available lanes to which connections shall be built.
void remapRemoved(NBEdge *removed, const EdgeVector &incoming, const EdgeVector &outgoing)
Replaces occurences of the removed edge in incoming/outgoing edges of all definitions.
std::string tlID
The id of the traffic light that controls this connection.
This is an uncontrolled, minor link, has to brake.
A point in 2D or 3D with translation and scaling methods.
bool mustBrakeForCrossing(const NBEdge *const from, const NBEdge *const to, const Crossing &crossing) const
Returns the information whether the described flow must brake for the given crossing.
bool mustBrake(const NBEdge *const possProhibitorFrom, const NBEdge *const possProhibitorTo, const NBEdge *const possProhibitedFrom, const NBEdge *const possProhibitedTo) const
Returns the information whether "prohibited" flow must let "prohibitor" flow pass.
void add(SUMOReal xoff, SUMOReal yoff, SUMOReal zoff)
bool needsCont(NBEdge *fromE, NBEdge *toE, NBEdge *otherFromE, NBEdge *otherToE, const NBEdge::Connection &c) const
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.
bool geometryLike() const
whether this is structurally similar to a geometry node
void invalidateOutgoingConnections()
SUMOReal distance(const Position &p) const
LinkState
The right-of-way state of a link between two lanes used when constructing a NBTrafficLightLogic, in MSLink and GNEInternalLane.
void removeTrafficLights()
Removes all references to traffic lights that control this tls.
EdgeVector * getEdgesThatApproach(NBEdge *currentOutgoing)
std::set< NBTrafficLightDefinition * > myTrafficLights
Storage for edges, including some functionality operating on multiple edges.
void bezier(int npts, SUMOReal b[], int cpts, SUMOReal p[])
std::string nextCrossing
the lane-id of the next crossing
void setCrossingTLIndices(unsigned int startIndex)
set tl indices of this nodes crossing starting at the given index
The link is a (hard) right direction.
PositionVector compute(bool leftHand)
Computes the shape of the assigned junction.
std::string toString(const T &t, std::streamsize accuracy=OUTPUT_ACCURACY)
const PositionVector & getShape() const
retrieve the junction shape
The link is a partial right direction.
static void compute(BresenhamCallBack *callBack, const unsigned int val1, const unsigned int val2)
NBEdge * getConnectionTo(NBNode *n) const
const std::vector< NBNode * > & getNodes() const
Returns the list of controlled nodes.
SUMOReal atan2Angle() const
virtual void removeNode(NBNode *node)
Removes the given node from the list of controlled nodes.
EdgeVector myIncomingEdges
Vector of incoming edges.
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.
std::vector< NBConnection > NBConnectionVector
Definition of a connection vector.
std::vector< std::pair< NBEdge *, NBEdge * > > getEdgesToJoin() const
bool intersects(const Line &l) const
int getJunctionPriority(const NBNode *const node) const
Returns the junction priority (normalised for the node currently build)
NBEdge * getPossiblySplittedOutgoing(const std::string &edgeid)
unsigned int removeSelfLoops(NBDistrictCont &dc, NBEdgeCont &ec, NBTrafficLightLogicCont &tc)
Removes edges which are both incoming and outgoing into this node.
void extrapolate(SUMOReal val)
EdgeVector myOutgoingEdges
Vector of outgoing edges.
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
NBEdge * myCurrentOutgoing
The approached current edge.
SUMOReal length() const
Returns the length.
void push_back(const PositionVector &p)
Appends all positions from the given vector.
static const int BACKWARD
std::string myID
The name of the object.
NBNode * getToNode() const
Returns the destination node of the edge.
void addTrafficLight(NBTrafficLightDefinition *tlDef)
Adds a traffic light to the list of traffic lights that control this node.
void extrapolateSecondBy(SUMOReal length)
bool isNearDistrict() const
bool myHaveCustomPoly
whether this nodes shape was set by the user
std::vector< int > getConnectionLanes(NBEdge *currentOutgoing) const
Returns the list of lanes that may be used to reach the given edge.
Position myPosition
The position the node lies at.
std::map< NBConnection, NBConnectionVector > NBConnectionProhibits
Definition of a container for connection block dependencies Includes a list of all connections which ...
void replaceOutgoing(NBEdge *which, NBEdge *by, unsigned int laneOff)
Replaces occurences of the first edge within the list of outgoing by the second Connections are remap...
~ApproachingDivider()
Destructor.
std::vector< WalkingArea > myWalkingAreas
Vector of walking areas.
LinkState getLinkState(const NBEdge *incoming, NBEdge *outgoing, int fromLane, bool mayDefinitelyPass, const std::string &tlID) const
SumoXMLNodeType
Numbers representing special SUMO-XML-attribute values for representing node- (junction-) types used ...
unsigned int buildCrossings()
bool isLeftHanded() const
Returns whether the built edges are left-handed.
Sorts outgoing before incoming edges.
void replaceInConnectionProhibitions(NBEdge *which, NBEdge *by, unsigned int whichLaneOff, unsigned int byLaneOff)
The link is controlled by a tls which is off and blinks, has to brake.
std::vector< NBEdge * > EdgeVector
std::string tlID
the traffic light id of the next crossing or ""
A definition of a pedestrian walking area.
EdgeVector * myApproaching
The list of edges that approach the current edge.
SUMOReal y() const
Returns the y-position.
A storage for options typed value containers)
void sub(SUMOReal x, SUMOReal y)
static const SUMOReal DEFAULT_CROSSING_WIDTH
default width of pedetrian crossings
void erase(NBDistrictCont &dc, NBEdge *edge)
Removes the given edge from the container (deleting it)
void replaceInConnections(NBEdge *which, NBEdge *by, unsigned int laneOff)
This is an uncontrolled, major link, may pass.
void mul(SUMOReal val)
Multiplies both positions with the given value.
std::deque< int > * spread(const std::vector< int > &approachingLanes, int dest) const
NBEdge * getTo() const
returns the to-edge (end of the connection)
The connection was computed.
bool crossingBetween(const NBEdge *e1, const NBEdge *e2) const
return true if the given edges are connected by a crossing
Represents a single node (junction) during network building.
bool removeFully(const std::string id)
Removes a logic definition (and all programs) from the dictionary.
Lane & getLaneStruct(unsigned int lane)
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.
Lanes to lanes - relationships are computed; no recheck is necessary/wished.
SUMOReal distanceTo2D(const Position &p2) const
returns the euclidean distance in the x-y-plane
int guessCrossings()
guess pedestrian crossings and return how many were guessed
A definition of a pedestrian crossing.
void move2side(SUMOReal amount)
bool insert(NBTrafficLightDefinition *logic, bool forceInsert=false)
Adds a logic definition to the dictionary.
NBEdge * getTurnDestination() const
void addSortedLinkFoes(const NBConnection &mayDrive, const NBConnection &mustStop)
Static storage of an output device and its base (abstract) implementation.
Computes lane-2-lane connections.
bool writeLogic(OutputDevice &into, const bool checkLaneFoes) const
static SUMOReal relAngle(SUMOReal angle1, SUMOReal angle2)
void push_back_noDoublePos(const Position &p)
#define SPLIT_CROSSING_WIDTH_THRESHOLD
void computeLogic(const NBEdgeCont &ec, OptionsCont &oc)
computes the node's type, logic and traffic light
SUMOReal getSpeed() const
Returns the speed allowed on this edge.
Position getPolygonCenter() const
Returns the arithmetic of all corner points.
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.
A traffic light logics which must be computed (only nodes/edges are given)
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 buildInnerEdges(bool buildCrossingsAndWalkingAreas)
build internal lanes, pedestrian crossings and walking areas
void invalidateTLS(NBTrafficLightLogicCont &tlCont)
causes the traffic light to be computed anew
std::string nextWalkingArea
the lane-id of the next walkingArea
void closePolygon()
ensures that the last position equals the first
Lanes to edges - relationships are computed/loaded.
NBNode(const std::string &id, const Position &position, SumoXMLNodeType type)
Constructor.
void append(const PositionVector &v)
Position intersectsAt(const Line &l) const
PositionVector getSubpart(SUMOReal beginOffset, SUMOReal endOffset) const
std::vector< std::string > prevSidewalks
the lane-id of the previous sidewalk lane or ""
std::vector< std::string > nextSidewalks
the lane-id of the next sidewalk lane or ""
static void nextCCW(const EdgeVector &edges, EdgeVector::const_iterator &from)
void reshiftPosition(SUMOReal xoff, SUMOReal yoff)
Applies an offset to the node.
SUMOReal width
This lane's width.
void remapRemoved(NBTrafficLightLogicCont &tc, NBEdge *removed, const EdgeVector &incoming, const EdgeVector &outgoing)
std::pair< unsigned int, unsigned int > getSizes() const
returns the number of the junction's lanes and the number of the junction's links in respect...
PositionVector shape
The polygonal shape.
#define UNCONTROLLED_CROSSING_SPEED_THRESHOLD
void replaceIncoming(const EdgeVector &which, NBEdge *const by)
Replaces incoming edges from the vector (sinks) by the given 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.
The link has no direction (is a dead end link)
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.