46 #define DEBUGCOND (myJunction->getID() == "F")
67 myOutgoing(outgoing) {
72 myDone.reserve(variations);
73 for (
int i = 0; i < variations; i++) {
78 for (NBConnectionProhibits::const_iterator j = loadedProhibits.begin(); j != loadedProhibits.end(); j++) {
80 bool ok1 = prohibited.
check(ec);
95 for (NBConnectionVector::const_iterator k = prohibiting.begin(); k != prohibiting.end(); k++) {
97 bool ok2 = sprohibiting.
check(ec);
110 myDone[idx2][idx1] =
true;
111 myDone[idx1][idx2] =
true;
115 std::string pfID = prohibited.
getFrom() !=
nullptr ? prohibited.
getFrom()->
getID() :
"UNKNOWN";
116 std::string ptID = prohibited.
getTo() !=
nullptr ? prohibited.
getTo()->
getID() :
"UNKNOWN";
117 std::string bfID = sprohibiting.
getFrom() !=
nullptr ? sprohibiting.
getFrom()->
getID() :
"UNKNOWN";
118 std::string btID = sprohibiting.
getTo() !=
nullptr ? sprohibiting.
getTo()->
getID() :
"UNKNOWN";
119 WRITE_WARNING(
"could not prohibit " + pfID +
"->" + ptID +
" by " + bfID +
"->" + btID);
126 for (
int s1 = 0; s1 < variations; s1++) {
127 for (
int s2 = s1 + 1; s2 < variations; s2++) {
148 EdgeVector::const_iterator i, j;
164 EdgeVector::const_iterator pfrom = std::find(
myAll.begin(),
myAll.end(), from);
165 while (*pfrom != to) {
168 EdgeVector::const_iterator pto = std::find(
myAll.begin(),
myAll.end(), to);
169 while (*pto != from) {
182 EdgeVector::const_iterator pfrom = std::find(
myAll.begin(),
myAll.end(), from);
183 while (*pfrom != to) {
186 EdgeVector::const_iterator pto = std::find(
myAll.begin(),
myAll.end(), to);
187 while (*pto != from) {
202 if (to1 ==
nullptr || to2 ==
nullptr) {
208 if (idx1 < 0 || idx2 < 0) {
217 myDone[idx1][idx2] =
true;
218 myDone[idx2][idx1] =
true;
254 #ifdef DEBUG_SETBLOCKING
255 if (
DEBUGCOND) std::cout <<
"setBlocking"
256 <<
" 1:" << from1->
getID() <<
"->" << to1->
getID()
257 <<
" 2:" << from2->
getID() <<
"->" << to2->
getID() <<
"\n";
263 #ifdef DEBUG_SETBLOCKING
264 if (
DEBUGCOND) std::cout <<
"setBlocking"
265 <<
" 1:" << from1->
getID() <<
"->" << to1->
getID()
266 <<
" 2:" << from2->
getID() <<
"->" << to2->
getID()
267 <<
" p1=" << from1p <<
" p2=" << from2p <<
"\n";
271 if (from1p > from2p) {
275 if (from2p > from1p) {
285 #ifdef DEBUG_SETBLOCKING
286 if (
DEBUGCOND) std::cout <<
"setBlocking"
287 <<
" 1:" << from1->
getID() <<
"->" << to1->
getID()
288 <<
" 2:" << from2->
getID() <<
"->" << to2->
getID()
328 EdgeVector::const_iterator c1 = std::find(
myAll.begin(),
myAll.end(), from1);
331 while (*c1 != from1 && *c1 != from2) {
340 EdgeVector::const_iterator c2 = std::find(
myAll.begin(),
myAll.end(), from2);
343 while (*c2 != from2 && *c2 != from1) {
351 #ifdef DEBUG_SETBLOCKING
352 if (
DEBUGCOND) std::cout <<
"setBlocking"
353 <<
" 1:" << from1->
getID() <<
"->" << to1->
getID()
354 <<
" 2:" << from2->
getID() <<
"->" << to2->
getID()
362 EdgeVector::const_iterator p = std::find(
myAll.begin(),
myAll.end(), from);
366 if (p ==
myAll.begin()) {
376 assert(linkIndex >= 0);
377 assert(linkIndex < (
int)
myFoes.size());
384 assert(linkIndex >= 0);
396 for (
int i = 0; i <
numLinks; i++) {
399 if (padding && i < 10) {
418 EdgeVector::const_iterator i;
421 int noLanes = (*i)->getNumLanes();
422 for (
int k = 0; k < noLanes; k++) {
428 for (
auto c : crossings) {
437 int noLanesEdge1 = (*i11)->getNumLanes();
438 for (
int j1 = 0; j1 < noLanesEdge1; j1++) {
439 std::vector<NBEdge::Connection> el1 = (*i11)->getConnectionsFromLane(j1);
440 for (std::vector<NBEdge::Connection>::iterator i12 = el1.begin(); i12 != el1.end(); ++i12) {
441 int idx1 =
getIndex((*i11), (*i12).toEdge);
447 int noLanesEdge2 = (*i21)->getNumLanes();
448 for (
int j2 = 0; j2 < noLanesEdge2; j2++) {
449 std::vector<NBEdge::Connection> el2 = (*i21)->getConnectionsFromLane(j2);
450 for (std::vector<NBEdge::Connection>::iterator i22 = el2.begin(); i22 != el2.end(); i22++) {
451 int idx2 =
getIndex((*i21), (*i22).toEdge);
457 if ((*i11) == (*i21)) {
464 if (((*i12).tlID ==
"" && (*i22).tlID ==
"")
466 ((*i12).tlID !=
"" && (*i22).tlID !=
"")) {
472 if (!
foes(*i11, (*i12).toEdge, *i21, (*i22).toEdge)) {
477 if ((*i12).tlID !=
"") {
497 for (EdgeVector::const_iterator i =
myIncoming.begin();
499 int noLanesEdge = (*i)->getNumLanes();
500 for (
int j = 0; j < noLanesEdge; j++) {
501 int numConnections = (int)(*i)->getConnectionsFromLane(j).size();
502 noLinks += numConnections;
503 if (numConnections > 0) {
508 return std::make_pair(noLanes, noLinks);
514 const NBEdge*
const from2,
const NBEdge*
const to2)
const {
516 if (to1 ==
nullptr || to2 ==
nullptr) {
522 if (idx1 < 0 || idx2 < 0) {
533 const NBEdge*
const possProhibitedFrom,
const NBEdge*
const possProhibitedTo,
534 bool regardNonSignalisedLowerPriority)
const {
536 if (possProhibitorTo ==
nullptr || possProhibitedTo ==
nullptr) {
540 int possProhibitorIdx =
getIndex(possProhibitorFrom, possProhibitorTo);
541 int possProhibitedIdx =
getIndex(possProhibitedFrom, possProhibitedTo);
542 if (possProhibitorIdx < 0 || possProhibitedIdx < 0) {
548 if (!regardNonSignalisedLowerPriority) {
549 return myForbids[possProhibitorIdx][possProhibitedIdx];
552 if (!
myForbids[possProhibitorIdx][possProhibitedIdx]) {
565 assert(c.toEdge != 0);
567 const std::string
foes =
getFoesString(from, c.toEdge, fromLane, c.toLane, checkLaneFoes);
586 for (
int j = noLanes; j-- > 0;) {
588 int size = (int) connected.size();
589 for (
int k = size; k-- > 0;) {
590 const NBEdge* to = connected[k].toEdge;
592 for (EdgeVector::const_iterator it_e = crossing.
edges.begin(); it_e != crossing.
edges.end(); ++it_e) {
593 if ((*it_e) == from || (*it_e) == to) {
598 foes += foe ?
'1' :
'0';
616 const int toLane = c.
toLane;
624 for (std::vector<NBNode::Crossing*>::const_reverse_iterator i = crossings.rbegin(); i != crossings.rend(); i++) {
631 int noLanes = (*i)->getNumLanes();
632 for (
int j = noLanes; j-- > 0;) {
633 std::vector<NBEdge::Connection> connected = (*i)->getConnectionsFromLane(j);
634 int size = (int) connected.size();
635 for (
int k = size; k-- > 0;) {
638 }
else if ((*i) == from && fromLane == j) {
642 assert(connected[k].toEdge != 0);
643 const int idx2 =
getIndex(*i, connected[k].toEdge);
644 assert(k < (
int) connected.size());
648 #ifdef DEBUG_RESPONSE
650 std::cout <<
" c=" << queryCon.
getDescription(from) <<
" prohibitC=" << connected[k].getDescription(*i)
652 <<
" clf=" << checkLaneFoes
655 <<
" lc=" <<
laneConflict(from, to, toLane, *i, connected[k].toEdge, connected[k].toLane)
657 <<
" mc=" <<
mergeConflict(from, queryCon, *i, connected[k],
false)
664 const bool hasLaneConflict = (!(checkLaneFoes ||
checkLaneFoesByClass(queryCon, *i, connected[k])
666 ||
laneConflict(from, to, toLane, *i, connected[k].toEdge, connected[k].toLane));
667 if ((
myForbids[idx2][idx] && hasLaneConflict)
696 for (std::vector<NBNode::Crossing*>::const_reverse_iterator i = crossings.rbegin(); i != crossings.rend(); i++) {
698 for (EdgeVector::const_iterator it_e = (**i).edges.begin(); it_e != (**i).edges.end(); ++it_e) {
699 if ((*it_e) == from || (*it_e) == to) {
704 result +=
foes ?
'1' :
'0';
708 for (EdgeVector::const_reverse_iterator i =
myIncoming.rbegin();
711 for (
int j = (
int)(*i)->getNumLanes() - 1; j >= 0; --j) {
712 std::vector<NBEdge::Connection> connected = (*i)->getConnectionsFromLane(j);
713 int size = (int) connected.size();
714 for (
int k = size; k-- > 0;) {
715 const bool hasLaneConflict = (!(checkLaneFoes ||
checkLaneFoesByClass(queryCon, *i, connected[k])
717 ||
laneConflict(from, to, toLane, *i, connected[k].toEdge, connected[k].toLane));
718 if ((
foes(from, to, (*i), connected[k].toEdge) && hasLaneConflict)
720 ||
myJunction->
turnFoes(from, to, fromLane, *i, connected[k].toEdge, connected[k].fromLane, lefthand)
738 if (from == prohibitorFrom
800 if (shape.size() == 0 || otherShape.size() == 0) {
836 std::set<int> fromTargetLanes;
838 if (c.toEdge == con.
toEdge) {
839 fromTargetLanes.insert(c.toLane);
843 if (c.toEdge == con.
toEdge && fromTargetLanes.count(c.toLane) != 0) {
855 const NBEdge* prohibitorFrom,
const NBEdge* prohibitorTo,
int prohibitorToLane)
const {
856 if (to != prohibitorTo) {
871 return rightOfProhibitor ? toLane >= prohibitorToLane : toLane <= prohibitorToLane;
889 for (
int i = 0; i < variations; i++) {
891 for (
int j = 0; j < variations; j++) {
909 if (linkIndex >= 0 && (
int)
myResponse.size() > linkIndex) {
911 if (!includePedCrossings) {
914 if (response.find_first_of(
"1") == std::string::npos) {
929 for (
int idx1 = 0; idx1 <
numLinks(); idx1++) {
936 if (includePedCrossings) {
938 for (std::vector<NBNode::Crossing*>::const_reverse_iterator i = crossings.rbegin(); i != crossings.rend(); i++) {
948 const std::vector<NBEdge::Connection>& cons = from->
getConnections();
949 for (std::vector<NBEdge::Connection>::const_iterator i = cons.begin(); i != cons.end(); i++) {
951 from, (*i).toEdge, (*i).fromLane)) {
959 int noLanes = (*i)->getNumLanes();
960 for (
int j = noLanes; j-- > 0;) {
961 std::vector<NBEdge::Connection> connected = (*i)->getConnectionsFromLane(j);
962 const int size = (int) connected.size();
963 for (
int k = size; k-- > 0;) {
964 if ((*i) == from && fromLane != j
973 for (
int idx1 = 0; idx1 <
numLinks(); idx1++) {
988 if (crossing.
priority || mustYield) {
989 for (EdgeVector::const_iterator it_e = crossing.
edges.begin(); it_e != crossing.
edges.end(); ++it_e) {
991 if (((*it_e) == from && crossing.
priority) || (*it_e) == to) {
1002 const NBEdge*
const possProhibitedFrom,
const NBEdge*
const possProhibitedTo)
const {
1004 int idx1 =
getIndex(possProhibitorFrom, possProhibitorTo);
1005 int idx2 =
getIndex(possProhibitedFrom, possProhibitedTo);
1022 std::map<NBEdge*, int> incomingCount;
1024 std::map<NBEdge*, std::set<int> > approachedLanes;
1026 std::map<NBEdge*, EdgeVector> incomingEdges;
1028 const std::vector<NBEdge::Connection> connections = (*it_e)->getConnections();
1029 for (std::vector<NBEdge::Connection>::const_iterator it_c = connections.begin(); it_c != connections.end(); ++it_c) {
1030 incomingCount[it_c->toEdge]++;
1031 approachedLanes[it_c->toEdge].insert(it_c->toLane);
1032 incomingEdges[it_c->toEdge].push_back(*it_e);
1035 for (std::map<NBEdge*, int>::iterator it = incomingCount.begin(); it != incomingCount.end(); ++it) {
1038 if ((
int)approachedLanes[to].size() >= it->second) {
1041 for (EdgeVector::iterator it_e1 = incoming.begin(); it_e1 != incoming.end(); ++it_e1) {
1042 for (EdgeVector::iterator it_e2 = incoming.begin(); it_e2 != incoming.end(); ++it_e2) {