45 #define DEBUGCOND (myJunction->getID() == "F")
66 myOutgoing(outgoing) {
71 myDone.reserve(variations);
72 for (
int i = 0; i < variations; i++) {
77 for (NBConnectionProhibits::const_iterator j = loadedProhibits.begin(); j != loadedProhibits.end(); j++) {
79 bool ok1 = prohibited.
check(ec);
94 for (NBConnectionVector::const_iterator k = prohibiting.begin(); k != prohibiting.end(); k++) {
96 bool ok2 = sprohibiting.
check(ec);
109 myDone[idx2][idx1] =
true;
110 myDone[idx1][idx2] =
true;
114 std::string pfID = prohibited.
getFrom() !=
nullptr ? prohibited.
getFrom()->
getID() :
"UNKNOWN";
115 std::string ptID = prohibited.
getTo() !=
nullptr ? prohibited.
getTo()->
getID() :
"UNKNOWN";
116 std::string bfID = sprohibiting.
getFrom() !=
nullptr ? sprohibiting.
getFrom()->
getID() :
"UNKNOWN";
117 std::string btID = sprohibiting.
getTo() !=
nullptr ? sprohibiting.
getTo()->
getID() :
"UNKNOWN";
118 WRITE_WARNING(
"could not prohibit " + pfID +
"->" + ptID +
" by " + bfID +
"->" + btID);
125 for (
int s1 = 0; s1 < variations; s1++) {
126 for (
int s2 = s1 + 1; s2 < variations; s2++) {
147 EdgeVector::const_iterator i, j;
163 EdgeVector::const_iterator pfrom = std::find(
myAll.begin(),
myAll.end(), from);
164 while (*pfrom != to) {
167 EdgeVector::const_iterator pto = std::find(
myAll.begin(),
myAll.end(), to);
168 while (*pto != from) {
181 EdgeVector::const_iterator pfrom = std::find(
myAll.begin(),
myAll.end(), from);
182 while (*pfrom != to) {
185 EdgeVector::const_iterator pto = std::find(
myAll.begin(),
myAll.end(), to);
186 while (*pto != from) {
201 if (to1 ==
nullptr || to2 ==
nullptr) {
207 if (idx1 < 0 || idx2 < 0) {
216 myDone[idx1][idx2] =
true;
217 myDone[idx2][idx1] =
true;
253 #ifdef DEBUG_SETBLOCKING
254 if (
DEBUGCOND) std::cout <<
"setBlocking"
255 <<
" 1:" << from1->
getID() <<
"->" << to1->
getID()
256 <<
" 2:" << from2->
getID() <<
"->" << to2->
getID() <<
"\n";
262 #ifdef DEBUG_SETBLOCKING
263 if (
DEBUGCOND) std::cout <<
"setBlocking"
264 <<
" 1:" << from1->
getID() <<
"->" << to1->
getID()
265 <<
" 2:" << from2->
getID() <<
"->" << to2->
getID()
266 <<
" p1=" << from1p <<
" p2=" << from2p <<
"\n";
270 if (from1p > from2p) {
274 if (from2p > from1p) {
284 #ifdef DEBUG_SETBLOCKING
285 if (
DEBUGCOND) std::cout <<
"setBlocking"
286 <<
" 1:" << from1->
getID() <<
"->" << to1->
getID()
287 <<
" 2:" << from2->
getID() <<
"->" << to2->
getID()
327 EdgeVector::const_iterator c1 = std::find(
myAll.begin(),
myAll.end(), from1);
330 while (*c1 != from1 && *c1 != from2) {
339 EdgeVector::const_iterator c2 = std::find(
myAll.begin(),
myAll.end(), from2);
342 while (*c2 != from2 && *c2 != from1) {
350 #ifdef DEBUG_SETBLOCKING
351 if (
DEBUGCOND) std::cout <<
"setBlocking"
352 <<
" 1:" << from1->
getID() <<
"->" << to1->
getID()
353 <<
" 2:" << from2->
getID() <<
"->" << to2->
getID()
361 EdgeVector::const_iterator p = std::find(
myAll.begin(),
myAll.end(), from);
365 if (p ==
myAll.begin()) {
375 assert(linkIndex >= 0);
376 assert(linkIndex < (
int)
myFoes.size());
383 assert(linkIndex >= 0);
395 for (
int i = 0; i <
numLinks; i++) {
398 if (padding && i < 10) {
417 EdgeVector::const_iterator i;
420 int noLanes = (*i)->getNumLanes();
421 for (
int k = 0; k < noLanes; k++) {
427 for (
auto c : crossings) {
436 int noLanesEdge1 = (*i11)->getNumLanes();
437 for (
int j1 = 0; j1 < noLanesEdge1; j1++) {
438 std::vector<NBEdge::Connection> el1 = (*i11)->getConnectionsFromLane(j1);
439 for (std::vector<NBEdge::Connection>::iterator i12 = el1.begin(); i12 != el1.end(); ++i12) {
440 int idx1 =
getIndex((*i11), (*i12).toEdge);
446 int noLanesEdge2 = (*i21)->getNumLanes();
447 for (
int j2 = 0; j2 < noLanesEdge2; j2++) {
448 std::vector<NBEdge::Connection> el2 = (*i21)->getConnectionsFromLane(j2);
449 for (std::vector<NBEdge::Connection>::iterator i22 = el2.begin(); i22 != el2.end(); i22++) {
450 int idx2 =
getIndex((*i21), (*i22).toEdge);
456 if ((*i11) == (*i21)) {
463 if (((*i12).tlID ==
"" && (*i22).tlID ==
"")
465 ((*i12).tlID !=
"" && (*i22).tlID !=
"")) {
471 if (!
foes(*i11, (*i12).toEdge, *i21, (*i22).toEdge)) {
476 if ((*i12).tlID !=
"") {
496 for (EdgeVector::const_iterator i =
myIncoming.begin();
498 int noLanesEdge = (*i)->getNumLanes();
499 for (
int j = 0; j < noLanesEdge; j++) {
500 int numConnections = (int)(*i)->getConnectionsFromLane(j).size();
501 noLinks += numConnections;
502 if (numConnections > 0) {
507 return std::make_pair(noLanes, noLinks);
513 const NBEdge*
const from2,
const NBEdge*
const to2)
const {
515 if (to1 ==
nullptr || to2 ==
nullptr) {
521 if (idx1 < 0 || idx2 < 0) {
532 const NBEdge*
const possProhibitedFrom,
const NBEdge*
const possProhibitedTo,
533 bool regardNonSignalisedLowerPriority)
const {
535 if (possProhibitorTo ==
nullptr || possProhibitedTo ==
nullptr) {
539 int possProhibitorIdx =
getIndex(possProhibitorFrom, possProhibitorTo);
540 int possProhibitedIdx =
getIndex(possProhibitedFrom, possProhibitedTo);
541 if (possProhibitorIdx < 0 || possProhibitedIdx < 0) {
547 if (!regardNonSignalisedLowerPriority) {
548 return myForbids[possProhibitorIdx][possProhibitedIdx];
551 if (!
myForbids[possProhibitorIdx][possProhibitedIdx]) {
564 assert(c.toEdge != 0);
566 const std::string
foes =
getFoesString(from, c.toEdge, fromLane, c.toLane, checkLaneFoes);
585 for (
int j = noLanes; j-- > 0;) {
587 int size = (int) connected.size();
588 for (
int k = size; k-- > 0;) {
589 const NBEdge* to = connected[k].toEdge;
591 for (EdgeVector::const_iterator it_e = crossing.
edges.begin(); it_e != crossing.
edges.end(); ++it_e) {
592 if ((*it_e) == from || (*it_e) == to) {
597 foes += foe ?
'1' :
'0';
615 const int toLane = c.
toLane;
623 for (std::vector<NBNode::Crossing*>::const_reverse_iterator i = crossings.rbegin(); i != crossings.rend(); i++) {
630 int noLanes = (*i)->getNumLanes();
631 for (
int j = noLanes; j-- > 0;) {
632 std::vector<NBEdge::Connection> connected = (*i)->getConnectionsFromLane(j);
633 int size = (int) connected.size();
634 for (
int k = size; k-- > 0;) {
637 }
else if ((*i) == from && fromLane == j) {
641 assert(connected[k].toEdge != 0);
642 const int idx2 =
getIndex(*i, connected[k].toEdge);
643 assert(k < (
int) connected.size());
647 #ifdef DEBUG_RESPONSE
649 std::cout <<
" c=" << queryCon.
getDescription(from) <<
" prohibitC=" << connected[k].getDescription(*i)
651 <<
" clf=" << checkLaneFoes
654 <<
" lc=" <<
laneConflict(from, to, toLane, *i, connected[k].toEdge, connected[k].toLane)
656 <<
" mc=" <<
mergeConflict(from, queryCon, *i, connected[k],
false)
663 const bool hasLaneConflict = (!(checkLaneFoes ||
checkLaneFoesByClass(queryCon, *i, connected[k])
665 ||
laneConflict(from, to, toLane, *i, connected[k].toEdge, connected[k].toLane));
666 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) {