61#define MAX_SLIPLANE_LENGTH 1000
72#define DEBUGNODEID2 ""
74#define DEBUGCOND(obj) ((obj) != 0 && ((obj)->getID() == DEBUGNODEID || (obj)->getID() == DEBUGNODEID2))
90 NodeCont::iterator i =
myNodes.find(
id);
96 const float pos[2] = {(float)position.
x(), (float)position.
y()};
104 std::string
id =
node->getID();
105 NodeCont::iterator i =
myNodes.find(
id);
110 const float pos[2] = {(float)
node->getPosition().x(), (float)
node->getPosition().y()};
118 NodeCont::const_iterator i =
myNodes.find(
id);
128 std::vector<NBNode*> result;
129 const double extOffset = offset + POSITION_EPS;
130 const float cmin[2] = {(float)(position.
x() - extOffset), (
float)(position.
y() - extOffset)};
131 const float cmax[2] = {(float)(position.
x() + extOffset), (
float)(position.
y() + extOffset)};
132 std::set<const Named*> into;
135 for (
const Named* namedNode : into) {
137 if (fabs(
node->getPosition().x() - position.
x()) <= offset
139 fabs(
node->getPosition().y() - position.
y()) <= offset) {
140 result.push_back(
node);
160 NodeCont::iterator i =
myNodes.find(
node->getID());
167 node->removeTrafficLights();
179 for (NodeCont::iterator i =
myNodes.begin(); i !=
myNodes.end(); i++) {
180 no += (*i).second->removeSelfLoops(dc, ec, tc);
192 const double distanceThreshold = 7.;
193 const double lengthThreshold = 0.10;
195 for (NodeCont::iterator i =
myNodes.begin(); i !=
myNodes.end(); i++) {
197 std::map<NBNode*, EdgeVector> connectionCount;
198 const EdgeVector& outgoing = (*i).second->getOutgoingEdges();
199 for (EdgeVector::const_iterator j = outgoing.begin(); j != outgoing.end(); j++) {
200 connectionCount[(*j)->getToNode()].push_back(*j);
203 std::map<NBNode*, EdgeVector>::iterator k;
204 for (k = connectionCount.begin(); k != connectionCount.end(); k++) {
206 if ((*k).second.size() < 2) {
212 const NBEdge*
const first = ev.front();
213 EdgeVector::const_iterator jci;
214 for (jci = ev.begin() + 1; jci != ev.end(); ++jci) {
217 (relativeLengthDifference > lengthThreshold) ||
218 (fabs(first->
getSpeed() - (*jci)->getSpeed()) >= 0.01) ||
226 if (jci == ev.end()) {
227 if (removeDuplicates) {
228 for (
int ei = 1; ei < (int)ev.size(); ei++) {
242 int numRemovedEdges = 0;
244 const std::vector<std::string>& edgeNames = ec.
getAllNames();
245 for (std::vector<std::string>::const_iterator it = edgeNames.begin(); it != edgeNames.end(); ++it) {
254 if (outgoingEdges.size() != 1) {
259 if (incomingEdges.size() > 1) {
262 }
else if (incomingEdges.size() == 1) {
263 NBNode* fromNodeOfIncomingEdge = incomingEdges[0]->getFromNode();
264 NBNode* toNodeOfOutgoingEdge = outgoingEdges[0]->getToNode();
265 if (fromNodeOfIncomingEdge != toNodeOfOutgoingEdge) {
273 bool hasJunction =
false;
285 adjacentNodes.clear();
286 for (EdgeVector::const_iterator itOfOutgoings = outgoingEdgesOfToNode.begin(); itOfOutgoings != outgoingEdgesOfToNode.end(); ++itOfOutgoings) {
287 if ((*itOfOutgoings)->getToNode() != from
288 && (*itOfOutgoings)->getToNode() != to
292 adjacentNodes.insert((*itOfOutgoings)->getToNode());
294 for (EdgeVector::const_iterator itOfIncomings = incomingEdgesOfToNode.begin(); itOfIncomings != incomingEdgesOfToNode.end(); ++itOfIncomings) {
295 adjacentNodes.insert((*itOfIncomings)->getFromNode());
297 adjacentNodes.erase(to);
298 if (adjacentNodes.size() > 2) {
301 }
while (!hasJunction && eOld != e);
303 std::string warningString;
304 for (EdgeVector::iterator roadIt = road.begin(); roadIt != road.end(); ++roadIt) {
305 if (roadIt == road.begin()) {
306 warningString += (*roadIt)->
getID();
308 warningString +=
"," + (*roadIt)->getID();
311 NBNode* fromNode = (*roadIt)->getFromNode();
312 NBNode* toNode = (*roadIt)->getToNode();
313 ec.
erase(dc, *roadIt);
327 return numRemovedEdges;
334 std::vector<std::set<NBEdge*> > components;
336 std::set<std::string> edgesLeft;
337 for (std::map<std::string, NBEdge*>::const_iterator edgeIt = ec.
begin(); edgeIt != ec.
end(); ++edgeIt) {
338 edgesLeft.insert(edgeIt->first);
341 std::set<NBEdge*> toRemove;
342 int foundComponents = 0;
344 while (!edgesLeft.empty()) {
345 queue.push_back(ec.
getByID(*edgesLeft.begin()));
346 std::set<NBEdge*> component;
347 while (!queue.empty()) {
348 NBEdge*
const e = queue.back();
351 std::vector<EdgeVector> edgeLists;
356 for (std::vector<EdgeVector>::const_iterator listIt = edgeLists.begin(); listIt != edgeLists.end(); ++listIt) {
357 for (EdgeVector::const_iterator edgeIt = listIt->begin(); edgeIt != listIt->end(); ++edgeIt) {
358 std::set<std::string>::iterator leftIt = edgesLeft.find((*edgeIt)->getID());
359 if (leftIt != edgesLeft.end()) {
360 queue.push_back(*edgeIt);
361 edgesLeft.erase(leftIt);
367 std::vector<std::set<NBEdge*> >::iterator cIt;
368 for (cIt = components.begin(); cIt != components.end(); ++cIt) {
369 if (cIt->size() < component.size()) {
373 components.insert(cIt, component);
374 if ((
int)components.size() > numKeep) {
375 bool recheck =
false;
377 for (
NBEdge* e : components.back()) {
387 toRemove.insert(components.back().begin(), components.back().end());
390 std::vector<std::string> edgeIDs;
391 for (
NBEdge* e : components.back()) {
392 edgeIDs.push_back(e->getID());
396 components.pop_back();
400 for (
NBEdge* e : toRemove) {
401 NBNode*
const fromNode = e->getFromNode();
402 NBNode*
const toNode = e->getToNode();
411 if (foundComponents > 1) {
414 return (
int)toRemove.size();
420 std::set<std::string> stopEdges;
421 for (
const auto& item : sc.
getStops()) {
422 stopEdges.insert(item.second->getEdgeId());
428 for (
const std::string& edgeID : component) {
429 if (stopEdges.count(edgeID) != 0) {
436 for (
const std::string& edgeID : component) {
445 for (
NBEdge* e : toRemove) {
446 NBNode*
const fromNode = e->getFromNode();
447 NBNode*
const toNode = e->getToNode();
457 if (numRemoved > 0) {
460 return (
int)toRemove.size();
469 bool removeGeometryNodes) {
472 std::set<std::string> edges2keep;
473 if (removeGeometryNodes) {
474 if (oc.
isSet(
"geometry.remove.keep-edges.input-file")) {
477 if (oc.
isSet(
"geometry.remove.keep-edges.explicit")) {
478 const std::vector<std::string> edges = oc.
getStringVector(
"geometry.remove.keep-edges.explicit");
479 edges2keep.insert(edges.begin(), edges.end());
484 if (oc.
exists(
"geometry.remove.keep-ptstops") && oc.
getBool(
"geometry.remove.keep-ptstops")) {
489 std::map<NBEdge*, std::set<NBTrafficLightDefinition*> > tlsLookup;
490 for (
auto it = ec.
begin(); it != ec.
end(); it++) {
497 const bool outputRemoved = oc.
getBool(
"output.removed-nodes");
498 std::vector<NBNode*> toRemove;
499 for (
const auto& i :
myNodes) {
500 NBNode*
const current = i.second;
507 if (edges2keep.find(it_edge->getID()) != edges2keep.end()) {
517 for (
const std::pair<NBEdge*, NBEdge*>& j : current->
getEdgesToJoin()) {
519 NBEdge*
const continuation = j.second;
522 auto itTL = tlsLookup.find(continuation);
523 if (itTL != tlsLookup.end()) {
525 tls->replaceRemoved(continuation, -1,
begin, -1,
true);
527 tlsLookup[
begin] = itTL->second;
531 ec.
extract(dc, continuation,
true);
536 toRemove.push_back(current);
539 for (
NBNode* n : toRemove) {
542 return (
int)toRemove.size();
548 for (NodeCont::iterator i =
myNodes.begin(); i !=
myNodes.end(); i++) {
549 (*i).second->avoidOverlap();
557 std::set<NBNode*> visited;
558 for (
const auto& i :
myNodes) {
559 if (visited.count(i.second) > 0) {
562 std::vector<NodeAndDist> toProc;
563 toProc.emplace_back(i.second, 0.);
565 while (!toProc.empty()) {
566 NBNode*
const n = toProc.back().first;
567 const double dist = toProc.back().second;
569 if (visited.count(n) > 0) {
573 bool pureRail =
true;
574 bool railAndPeds =
true;
592 const double length = e->getLoadedLength();
593#ifdef DEBUG_JOINJUNCTIONS
595 std::cout <<
"generateNodeClusters: consider s=" << s->
getID()
596 <<
" clusterNode=" << n->
getID() <<
" edge=" << e->getID() <<
" dist=" << dist <<
" length=" << length <<
" with cluster " <<
joinNamedToString(c,
' ') <<
"\n";
600 bool railAndPeds2 =
true;
603 railAndPeds2 =
false;
614 const bool joinPedCrossings = bothCrossing && e->getPermissions() ==
SVC_PEDESTRIAN;
616 !joinPedCrossings && (
619 || (length > 3 * POSITION_EPS
622#ifdef DEBUG_JOINJUNCTIONS
633 bool foundRail =
false;
636 if ((e2->getPermissions() & railNoTram) != 0) {
649 if (visited.find(s) != visited.end()) {
652 if (length + dist < maxDist) {
657 const double fullLength = e->getGeometry().length2D();
658 const double length2 = bothCrossing || hasTLS || trueGeomLike ? length : fullLength;
659 toProc.emplace_back(s, dist + length2);
661 toProc.emplace_back(s, 0.);
669#ifdef DEBUG_JOINJUNCTIONS
682 if ((e->getPermissions() & ~ignored) != 0) {
683 allowedIn.push_back(e);
687 if ((e->getPermissions() & ~ignored) != 0) {
688 allowedOut.push_back(e);
691 if (allowedIn.size() > 0 && allowedOut.size() > 0) {
701 for (
const std::string& nodeID : ids) {
705 WRITE_WARNINGF(
TL(
"Ignoring join exclusion for junction '%' since it already occurred in a list of nodes to be joined."), nodeID);
715 std::string result = base;
718 result = base + sep +
toString(i++);
728 maxIds = (int)cluster.size();
730 if ((
int)cluster.size() > maxIds) {
731 auto clusterIt = cluster.begin();
732 std::string result = prefix + *clusterIt;
733 for (
int i = 1; i < maxIds; i++) {
735 result +=
"_" + *clusterIt;
737 return result +
"_#" +
toString((
int)cluster.size() - maxIds) +
"more";
747 for (std::string nodeID : cluster) {
749 WRITE_WARNINGF(
TL(
"Ignoring join-cluster because junction '%' was already excluded from joining."), nodeID);
751 }
else if (
myJoined.count(nodeID) > 0) {
752 WRITE_WARNINGF(
TL(
"Ignoring join-cluster because junction '%' already occurred in another join-cluster."), nodeID);
756 join.cluster.insert(nodeID);
758 WRITE_ERRORF(
TL(
"Unknown junction '%' in join-cluster."), nodeID);
762 if (join.cluster.size() > 1) {
763 myJoined.insert(join.cluster.begin(), join.cluster.end());
766 WRITE_WARNINGF(
TL(
"Ignoring join-cluster '%' because it has size '%'."),
node->getID(), join.cluster.size());
777 for (std::string nodeID : item.cluster) {
779 if (
node ==
nullptr) {
782 cluster.insert(
node);
785 if (cluster.size() > 1) {
786 joinNodeCluster(cluster, dc, ec, tlc, item.node, item.resetConnections);
798#ifdef DEBUG_JOINJUNCTIONS
799 std::cout <<
"joinJunctions...\n";
803 std::map<const NBNode*, std::vector<NBNode*> > ptStopEnds;
805 for (
const auto& stopIt : sc.
getStops()) {
807 if (edge !=
nullptr) {
812 for (
NodeSet& cluster : cands) {
813#ifdef DEBUG_JOINJUNCTIONS
815 for (
NBNode* n : cluster) {
822 for (NodeSet::iterator j = cluster.begin(); j != cluster.end();) {
823 NodeSet::iterator check = j;
826 cluster.erase(check);
832 if (cluster.size() < 2) {
837 if (cluster.size() < 2) {
838 WRITE_WARNINGF(
TL(
"Not joining junctions % (%)."), origCluster,
"slip lane");
842 NBNode* tryRemove =
nullptr;
844 std::string origReason;
846 bool feasible =
feasibleCluster(cluster, ptStopEnds, maxDist, origReason, tryRemove);
847 if (feasible && ((
int)cluster.size() -
pruneLongEdges(cluster, maxDist,
true) < 2)) {
848 origReason =
"long edge";
852#ifdef DEBUG_JOINJUNCTIONS
854 std::cout <<
" try to reduce to 4-circle nodes=" <<
joinNamedToString(cluster,
',') <<
"\n";
858 feasible =
feasibleCluster(cluster, ptStopEnds, maxDist, reason, tryRemove);
860 WRITE_WARNINGF(
TL(
"Reducing junction cluster % (%)."), origCluster, origReason);
865#ifdef DEBUG_JOINJUNCTIONS
867 std::cout <<
" try to reduce to 2-circle nodes=" <<
joinNamedToString(cluster,
',') <<
"\n";
871 feasible =
feasibleCluster(cluster, ptStopEnds, maxDist, reason, tryRemove);
873 WRITE_WARNINGF(
TL(
"Reducing junction cluster % (%)."), origCluster, origReason);
877 while (!feasible && tryRemove !=
nullptr) {
878 cluster.erase(tryRemove);
881 feasible =
feasibleCluster(cluster, ptStopEnds, maxDist, reason, tryRemove);
883 WRITE_WARNINGF(
TL(
"Reducing junction cluster % (%)."), origCluster, origReason);
886 if (cluster.size() < 2) {
887 WRITE_WARNINGF(
TL(
"Not joining junctions % (%)."), origCluster,
"after reduction");
892 if (cluster.size() < 2) {
893 WRITE_WARNINGF(
TL(
"Not joining junctions % (%)."), origCluster,
"long edge");
899 if (cluster.size() < 2) {
900 WRITE_WARNINGF(
TL(
"Not joining junctions % (%)."), origCluster,
"long edge");
904 if (cluster.size() < 2) {
905 WRITE_WARNINGF(
TL(
"Not joining junctions % (%)."), origCluster,
"slip lane");
909 feasible =
feasibleCluster(cluster, ptStopEnds, maxDist, origReason, tryRemove);
911 WRITE_WARNINGF(
TL(
"Not joining junctions % (%)."), origCluster, origReason);
917 for (
NBNode* current : cluster) {
921 newComp.insert(current);
922 for (NodeClusters::iterator it_comp = components.begin(); it_comp != components.end();) {
923 NodeClusters::iterator check = it_comp;
925 bool connected =
false;
926 for (
NBNode* k : *check) {
927 if (current->getConnectionTo(k) !=
nullptr || k->getConnectionTo(current) !=
nullptr) {
929 newComp.insert((*check).begin(), (*check).end());
930 it_comp = components.erase(check);
940 components.push_back(newComp);
942 for (NodeClusters::iterator it_comp = components.begin(); it_comp != components.end(); ++it_comp) {
943 if ((*it_comp).size() > 1) {
945 clusters.push_back(*it_comp);
948#ifdef DEBUG_JOINJUNCTIONS
953 return (
int)clusters.size();
959#ifdef DEBUG_JOINJUNCTIONS
960 std::cout <<
"joinSameJunctions...\n";
962 std::set<NBNode*> checked;
971 for (
NBNode* n2 : nearby) {
976 if (cluster.size() > 1) {
977 checked.insert(cluster.begin(), cluster.end());
978 clusters.push_back(cluster);
982 return (
int)clusters.size();
987#ifdef DEBUG_JOINJUNCTIONS
994 bool pruneFringe =
true;
995 bool pruneNoisyFringe =
false;
998 while (pruneFringe) {
1000 for (NodeSet::iterator j = cluster.begin(); j != cluster.end();) {
1001 NodeSet::iterator check = j;
1006 double clusterDist = std::numeric_limits<double>::max();
1007 bool touchingCluster =
false;
1009 NBNode* neighbor = (*it_edge)->getToNode();
1010 if (cluster.count(neighbor) != 0) {
1011 clusterDist =
MIN2(clusterDist, (*it_edge)->getLoadedLength());
1016 NBNode* neighbor = (*it_edge)->getFromNode();
1017 if (cluster.count(neighbor) != 0) {
1018 clusterDist =
MIN2(clusterDist, (*it_edge)->getLoadedLength());
1024 std::set<NBNode*> outsideNeighbors;
1025 std::set<NBNode*> clusterNeighbors;
1026 const double pedestrianFringeThreshold = 0.3;
1028 NBNode* neighbor = e->getFromNode() == n ? e->getToNode() : e->getFromNode();
1029 if (cluster.count(neighbor) == 0) {
1032 || (clusterDist <= pedestrianFringeThreshold
1033 && (!pruneNoisyFringe
1037 || cluster.size() == 2))
1038 || touchingCluster) {
1039 outsideNeighbors.insert(neighbor);
1042 clusterNeighbors.insert(neighbor);
1045#ifdef DEBUG_JOINJUNCTIONS
1047 <<
" clusterDist=" << clusterDist
1048 <<
" cd<th=" << (clusterDist <= pedestrianFringeThreshold)
1049 <<
" touching=" << touchingCluster
1055 if (clusterNeighbors.size() == 0
1056 || (outsideNeighbors.size() <= 1
1057 && clusterNeighbors.size() == 1
1059 cluster.erase(check);
1061#ifdef DEBUG_JOINJUNCTIONS
1063 std::cout <<
" pruned n=" << n->
getID() <<
"\n";
1066 }
else if (outsideNeighbors.size() <= 1 && clusterNeighbors.size() == 1) {
1067 geometryLikeTLS.insert(n);
1070 if (!pruneFringe && !pruneNoisyFringe) {
1073 pruneNoisyFringe =
true;
1077 if (remove2TLS && geometryLikeTLS.size() == cluster.size()) {
1085 for (
const NBNode* n1 : cluster) {
1086 for (
const NBNode* n2 : cluster) {
1087 result =
MAX2(result, n1->getPosition().distanceTo2D(n2->getPosition()));
1095 std::set<NBNode*> toRemove;
1096 int maxPassengerLanes = 0;
1097 for (
NBNode* n : cluster) {
1098 for (
NBEdge* edge : n->getEdges()) {
1099 maxPassengerLanes =
MAX2(maxPassengerLanes, edge->getNumLanesThatAllow(
SVC_PASSENGER));
1102 for (
NBNode* n : cluster) {
1103 for (
NBEdge* edge : n->getOutgoingEdges()) {
1107 std::vector<NBNode*> passed;
1110 NBNode* to = edge->getToNode();
1111 while (cluster.count(to) != 0) {
1113 bool goStraight = (std::find(passed.begin(), passed.end(), to) == passed.end()
1118 passed.push_back(to);
1121 if (cur !=
nullptr) {
1132#ifdef DEBUG_JOINJUNCTIONS
1134 std::cout <<
"check edge length " << edge->getID() <<
" (" << length <<
", passed=" << passed.size() <<
", max=" << longThreshold <<
")\n";
1137 if (length > longThreshold) {
1141 const bool keepStart =
getClusterNeighbors(passed.back(), longThreshold, cluster).size() == 1;
1142 const bool keepEnd = !keepStart &&
getClusterNeighbors(n, longThreshold, cluster).size() == 1;
1143#ifdef DEBUG_JOINJUNCTIONS
1145 std::cout <<
"node=" << n->getID() <<
" long edge " << edge->getID() <<
" (" << length <<
", passed=" <<
toString(passed) <<
", max=" << longThreshold <<
") keepStart=" << keepStart <<
" keepEnd=" << keepEnd <<
"\n";
1151 toRemove.insert(passed.begin(), passed.end() - 1);
1153 toRemove.insert(passed.back());
1160 for (std::set<NBNode*>::iterator j = toRemove.begin(); j != toRemove.end(); ++j) {
1164 return (
int)toRemove.size();
1172 if (e->getLength() > longThreshold) {
1175 NBNode* neighbor = e->getFromNode() == n ? e->getToNode() : e->getFromNode();
1176 if (cluster.count(neighbor) != 0) {
1177 result.insert(neighbor);
1186#ifdef DEBUG_JOINJUNCTIONS
1188 std::cout <<
"pruning slip-lanes at cluster=" <<
joinNamedToString(cluster,
' ') <<
"\n";
1192 if (cluster.size() <= 2) {
1196 for (
NBNode* n : cluster) {
1202#ifdef DEBUG_JOINJUNCTIONS
1204 std::cout <<
" candidate slip-lane start=" << n->
getID() <<
" outgoing=" <<
toString(outgoing) <<
"\n";
1207 for (
NBEdge* contEdge : outgoing) {
1211 double slipLength = contEdge->getLength();
1212 NBNode* cont = contEdge->getToNode();
1216 if (cands.count(cont) != 0) {
1220#ifdef DEBUG_JOINJUNCTIONS
1222 std::cout <<
" candidate slip-lane cont=" << cont->
getID() <<
"\n";
1229#ifdef DEBUG_JOINJUNCTIONS
1231 std::cout <<
" candidate slip-lane end=" << cont->
getID() <<
" slipLength=" << slipLength <<
"\n";
1238 const NBEdge*
const otherEdge = (contEdge == outgoing.front() ? outgoing.back() : outgoing.front());
1241 std::vector<NodeAndDist> toProc;
1244 while (!toProc.empty()) {
1246 NBNode* cont2 = nodeAndDist.first;
1247 double dist = nodeAndDist.second;
1248#ifdef DEBUG_JOINJUNCTIONS
1250 std::cout <<
" search alternative cont2=" << cont2->
getID() <<
" dist=" << dist <<
"\n";
1254 if (visited.find(cont2) != visited.end()) {
1257 visited.insert(cont2);
1258 if (cont2 == cont) {
1263 const double dist2 = dist + e->getLength();
1264 if (dist2 < slipLength * 2 && (e->getPermissions() &
SVC_PASSENGER) != 0) {
1265 toProc.push_back(std::make_pair(e->getToNode(), dist2));
1272 toRemove.insert(cands.begin(), cands.end());
1273#ifdef DEBUG_JOINJUNCTIONS
1275 std::cout <<
" found slip-lane with nodes=" <<
joinNamedToString(cands,
' ') <<
"\n";
1288#ifdef DEBUG_JOINJUNCTIONS
1290 std::cout <<
" candidate slip-lane end=" << n->getID() <<
" incoming=" <<
toString(incoming) <<
"\n";
1293 for (
NBEdge* contEdge : incoming) {
1297 double slipLength = contEdge->getLength();
1298 NBNode* cont = contEdge->getFromNode();
1302 if (cands.count(cont) != 0) {
1306#ifdef DEBUG_JOINJUNCTIONS
1308 std::cout <<
" candidate slip-lane cont=" << cont->
getID() <<
"\n";
1315#ifdef DEBUG_JOINJUNCTIONS
1317 std::cout <<
" candidate slip-lane start=" << cont->
getID() <<
" slipLength=" << slipLength <<
"\n";
1324 const NBEdge*
const otherEdge = (contEdge == incoming.front() ? incoming.back() : incoming.front());
1327 std::vector<NodeAndDist> toProc;
1330 while (!toProc.empty()) {
1332 NBNode* cont2 = nodeAndDist.first;
1333 double dist = nodeAndDist.second;
1334#ifdef DEBUG_JOINJUNCTIONS
1336 std::cout <<
" search alternative cont2=" << cont2->
getID() <<
" dist=" << dist <<
"\n";
1340 if (visited.find(cont2) != visited.end()) {
1343 visited.insert(cont2);
1344 if (cont2 == cont) {
1349 const double dist2 = dist + e->getLength();
1350 if (dist2 < slipLength * 2 && (e->getPermissions() &
SVC_PASSENGER) != 0) {
1351 toProc.push_back(std::make_pair(e->getFromNode(), dist2));
1358 toRemove.insert(cands.begin(), cands.end());
1359#ifdef DEBUG_JOINJUNCTIONS
1361 std::cout <<
" found slip-lane start with nodes=" <<
joinNamedToString(cands,
' ') <<
"\n";
1373 for (
NBNode* n : toRemove) {
1374 numRemoved += (int)cluster.erase(n);
1376 if (numRemoved > 0) {
1377#ifdef DEBUG_JOINJUNCTIONS
1379 std::cout <<
" removed " << numRemoved <<
" nodes from cluster: " <<
joinNamedToString(toRemove,
' ') <<
"\n";
1397 if (inPE.size() == 1 && outPE.size() == 2) {
1398 outgoing.insert(outgoing.begin(), outPE.begin(), outPE.end());
1399 inAngle = inPE.front()->getAngleAtNode(n);
1401 }
else if (inPE.size() >= 2 && outPE.size() == 3) {
1404 const double inRelAngle = fabs(
NBHelpers::relAngle(inPE.front()->getAngleAtNode(n), inPE.back()->getAngleAtNode(n)));
1406 if (inRelAngle < 135) {
1409 for (
NBEdge* in : inPE) {
1412 for (
NBEdge* out : outPE) {
1413 const double outRelAngle = fabs(
NBHelpers::relAngle(in->getAngleAtNode(n), out->getAngleAtNode(n)));
1414 if (outRelAngle <= 45) {
1415 straight.push_back(out);
1416 }
else if (outRelAngle >= 135) {
1420 if (straight.size() == 2 && numReverse == 1) {
1421 outgoing.insert(outgoing.begin(), straight.begin(), straight.end());
1422 inAngle = in->getAngleAtNode(n);
1435 if (inPE.size() == 2 && outPE.size() == 1) {
1436 incoming.insert(incoming.begin(), inPE.begin(), inPE.end());
1437 outAngle = outPE.front()->getAngleAtNode(n);
1439 }
else if (inPE.size() == 3 && outPE.size() >= 2) {
1442 const double outRelAngle = fabs(
NBHelpers::relAngle(outPE.front()->getAngleAtNode(n), outPE.back()->getAngleAtNode(n)));
1444 if (outRelAngle < 135) {
1447 for (
NBEdge* out : outPE) {
1450 for (
NBEdge* in : inPE) {
1451 const double inRelAngle = fabs(
NBHelpers::relAngle(in->getAngleAtNode(n), out->getAngleAtNode(n)));
1452 if (inRelAngle <= 45) {
1453 straight.push_back(in);
1454 }
else if (inRelAngle >= 135) {
1458 if (straight.size() == 2 && numReverse == 1) {
1459 incoming.insert(incoming.begin(), straight.begin(), straight.end());
1460 outAngle = out->getAngleAtNode(n);
1470 double maxDist, std::string& reason,
NBNode*& tryRemove)
const {
1473 std::map<NBEdge*, double, ComparatorIdLess> finalIncomingAngles;
1474 std::map<NBEdge*, double, ComparatorIdLess> finalOutgoingAngles;
1475 for (
NBNode* n : cluster) {
1476 for (EdgeVector::const_iterator it_edge = n->getIncomingEdges().begin(); it_edge != n->getIncomingEdges().end(); ++it_edge) {
1483 for (EdgeVector::const_iterator it_edge = n->getOutgoingEdges().begin(); it_edge != n->getOutgoingEdges().end(); ++it_edge) {
1492#ifdef DEBUG_JOINJUNCTIONS
1493 for (
NBNode* n : cluster) {
1502 if (finalIncomingAngles.size() > 5) {
1503 reason =
toString(finalIncomingAngles.size()) +
" incoming edges";
1508 const double PARALLEL_THRESHOLD_SAME_NODE = PARALLEL_THRESHOLD_DIFF_NODE / 3;
1509 bool foundParallel =
false;
1510 for (
auto j = finalIncomingAngles.begin(); j != finalIncomingAngles.end() && !foundParallel; ++j) {
1512 for (++k; k != finalIncomingAngles.end() && !foundParallel; ++k) {
1513 const double angleDiff = fabs(j->second - k->second);
1514 if (angleDiff < PARALLEL_THRESHOLD_DIFF_NODE) {
1519#ifdef DEBUG_JOINJUNCTIONS
1521 std::cout <<
" angleDiff=" << angleDiff <<
" shapeDist=" << edgeDist <<
"\n";
1524 if (angleDiff >= PARALLEL_THRESHOLD_SAME_NODE && (
1526 || (edgeDist < maxDist)))) {
1529 reason =
"parallel incoming " + e1->
getID() +
"," + e2->
getID();
1544 for (
auto j = finalOutgoingAngles.begin(); j != finalOutgoingAngles.end() && !foundParallel; ++j) {
1546 for (++k; k != finalOutgoingAngles.end() && !foundParallel; ++k) {
1547 const double angleDiff = fabs(j->second - k->second);
1548 if (angleDiff < PARALLEL_THRESHOLD_DIFF_NODE) {
1553#ifdef DEBUG_JOINJUNCTIONS
1555 std::cout <<
" angleDiff=" << angleDiff <<
" shapeDist=" << edgeDist <<
"\n";
1558 if (angleDiff >= PARALLEL_THRESHOLD_SAME_NODE && (
1560 || (edgeDist < maxDist)))) {
1563 reason =
"parallel outgoing " + e1->
getID() +
"," + e2->
getID();
1578 bool hasTLS =
false;
1579 for (
NBNode* n : cluster) {
1580 if (n->isTLControlled() || n->hadSignal()) {
1583 const auto& stopEnds = ptStopEnds.find(n);
1584 if (stopEnds != ptStopEnds.end()) {
1585 for (
NBNode*
const to : stopEnds->second) {
1586 if (cluster.count(to) != 0) {
1587 reason =
"it contains a pt stop edge";
1594 if (cluster.size() > 2) {
1596 double maxLength = -1;
1597 NBEdge* maxEdge =
nullptr;
1598 for (
NBNode* n1 : cluster) {
1599 for (
NBNode* n2 : cluster) {
1600 NBEdge* e1 = n1->getConnectionTo(n2);
1601 NBEdge* e2 = n2->getConnectionTo(n1);
1612#ifdef DEBUG_JOINJUNCTIONS
1613 for (
NBNode* n : cluster) {
1615 std::cout <<
"feasible hasTLS=" << hasTLS <<
" maxLength=" << maxLength <<
" maxEdge=" << maxEdge->
getID() <<
"\n";
1619 if (!hasTLS && maxLength > 5) {
1621 std::vector<NBNode*> toCheck;
1622 std::set<NBNode*> visited;
1623 toCheck.push_back(maxEdge->
getToNode());
1624 bool foundCircle =
false;
1625 while (!toCheck.empty()) {
1626 NBNode* n = toCheck.back();
1635 NBNode* cand = e->getFromNode() == n ? e->getToNode() : e->getFromNode();
1636 if (visited.count(cand) == 0 && cluster.count(cand) != 0) {
1637 toCheck.push_back(cand);
1643 reason =
"not compact (maxEdge=" + maxEdge->
getID() +
" length=" +
toString(maxLength) +
")";
1649 if (cluster.size() >= 2) {
1654 int edgesWithin = 0;
1655 for (
NBNode* n : cluster) {
1656 bool foundOutsideIncoming =
false;
1657 for (
NBEdge* e : n->getIncomingEdges()) {
1658 if (cluster.count(e->getFromNode()) == 0) {
1660 outsideIncoming.push_back(e);
1661 foundOutsideIncoming =
true;
1666 if (foundOutsideIncoming) {
1669 bool foundOutsideOutgoing =
false;
1670 for (
NBEdge* e : n->getOutgoingEdges()) {
1671 if (cluster.count(e->getToNode()) == 0) {
1673 outsideOutgoing.push_back(e);
1674 foundOutsideOutgoing =
true;
1677 if (foundOutsideOutgoing) {
1682 if (entryNodes < 2) {
1683 reason =
"only 1 entry node";
1686 if (exitNodes < 2) {
1687 reason =
"only 1 exit node";
1690 if (cluster.size() == 2) {
1691 if (edgesWithin == 1 && outsideIncoming.size() < 3 && outsideOutgoing.size() < 3) {
1692 reason =
"only 1 edge within and no cross-traffic";
1711 std::cout <<
"reduceToCircle cs=" << circleSize <<
" cands=" <<
toString(cands,
',') <<
" startNodes=" <<
joinNamedToString(startNodes,
',') <<
"\n";
1713 assert(circleSize >= 2);
1714 if ((
int)cands.size() == circleSize) {
1715 if (cands.back()->getConnectionTo(cands.front()) !=
nullptr) {
1718 candCluster.insert(cands.begin(), cands.end());
1720 bool feasible = (int)candCluster.size() == circleSize;
1723 cluster.insert(cands.begin(), cands.end());
1730 if ((
int)cluster.size() <= circleSize || startNodes.size() == 0) {
1733 std::cout <<
" abort\n";
1737 if (cands.size() == 0) {
1743 if (
reduceToCircle(cluster, circleSize, startNodes, maxDist, cands)) {
1752 singleStart.insert(cands.back());
1755 std::vector<NBNode*> cands2(cands);
1757 if (
reduceToCircle(cluster, circleSize, startNodes, maxDist, cands2)) {
1763 std::cout <<
" abort2\n";
1771 double minDist = std::numeric_limits<double>::max();
1772 NBEdge* result =
nullptr;
1773 for (
NBNode* n : startNodes) {
1774 for (
NBEdge* e : n->getOutgoingEdges()) {
1775 NBNode* neigh = e->getToNode();
1776 if (cluster.count(neigh) != 0 && std::find(exclude.begin(), exclude.end(), neigh) == exclude.end()) {
1779 if (dist < minDist) {
1793 for (
NodeSet cluster : clusters) {
1802 assert(cluster.size() > 1);
1803 std::string
id =
"cluster_";
1809 std::set<NBEdge*, ComparatorIdLess> allEdges;
1810 for (
NBNode* n : cluster) {
1812 allEdges.insert(edges.begin(), edges.end());
1815 std::set<NBEdge*, ComparatorIdLess> clusterIncoming;
1816 std::set<NBEdge*, ComparatorIdLess> inside;
1817 for (
NBEdge* e : allEdges) {
1818 if (cluster.count(e->getToNode()) > 0) {
1819 if (cluster.count(e->getFromNode()) > 0) {
1826 clusterIncoming.insert(e);
1830#ifdef DEBUG_JOINJUNCTIONS_CONNECTIONS
1832 <<
" resetConnections=" << resetConnections <<
"\n"
1837 NBNode* newNode =
nullptr;
1838 if (predefined !=
nullptr) {
1839 newNode = predefined;
1848 std::string tlID = id;
1849 if (predefined !=
nullptr) {
1851 nodeType = predefined->
getType();
1865 newNode->
reinit(pos, nodeType);
1871 if (!tlc.
insert(tlDef)) {
1879 std::map<NBEdge*, EdgeSet> reachable;
1880 std::map<std::pair<NBEdge*, NBEdge*>,
SVCPermissions> conPermissions;
1882 for (
NBEdge*
const e : clusterIncoming) {
1886 while (open.size() > 0) {
1887 NBEdge*
const cur = open.back();
1889#ifdef DEBUG_JOINJUNCTIONS_CONNECTIONS
1890 std::cout <<
"e=" << e->getID() <<
" cur=" << cur->
getID() <<
" open=" <<
toString(open) <<
"\n";
1891 std::cout <<
"e=" << e->getID() <<
" cur=" << cur->
getID() <<
" open=" <<
toString(open) <<
"\n";
1895 if (cluster.count(cur->
getToNode()) == 0) {
1903 if (allEdges.count(out) != 0) {
1905 if (seen.count(out) == 0 || (~conPermissions[ {e, out}] & p) != 0) {
1907 open.push_back(out);
1908 conPermissions[ {e, out}] |= p;
1909#ifdef DEBUG_JOINJUNCTIONS_CONNECTIONS
1918 for (
const auto& con : cons) {
1919 if (con.toEdge !=
nullptr && allEdges.count(con.toEdge) != 0) {
1922 p &= con.permissions;
1924 if (seen.count(con.toEdge) == 0 || (~conPermissions[ {e, con.toEdge}] & p) != 0) {
1925 open.push_back(con.toEdge);
1926 conPermissions[ {e, con.toEdge}] |= p;
1934 for (
NBEdge* reached : seen) {
1936 if (inside.count(reached) == 0) {
1941 reachable[e].insert(reached);
1942 const SVCPermissions pDefault = e->getPermissions() & reached->getPermissions();
1943 if (conPermissions[ {e, reached}] != pDefault) {
1944 specialPermissions.insert(e);
1945#ifdef DEBUG_JOINJUNCTIONS_CONNECTIONS
1946 std::cout <<
"e=" << e->getID() <<
" out=" << reached->getID() <<
" special=" <<
getVehicleClassNames(conPermissions[ {e, reached}]) <<
"\n";
1951#ifdef DEBUG_JOINJUNCTIONS_CONNECTIONS
1952 std::cout <<
" reachable e=" << e->getID() <<
" seen=" <<
toString(seen) <<
" reachable=" <<
toString(reachable[e]) <<
"\n";
1960 for (
NBEdge* e : inside) {
1961 for (
NBEdge* e2 : allEdges) {
1963 e2->replaceInConnections(e, e->getConnections());
1971 for (
NBEdge* e : allEdges) {
1972 const bool outgoing = cluster.count(e->getFromNode()) > 0;
1973 NBNode* from = outgoing ? newNode : e->getFromNode();
1974 NBNode* to = outgoing ? e->getToNode() : newNode;
1977 e->
setParameter(
"origFrom", e->getFromNode()->getID());
1979 e->setParameter(
"origTo", e->getToNode()->getID());
1982 if (e->getTurnSignTarget() !=
"") {
1983 for (
NBNode* n : cluster) {
1984 if (e->getTurnSignTarget() == n->getID()) {
1985 e->setTurnSignTarget(to->
getID());
1990 e->reinitNodes(from, to);
1993 std::vector<NBEdge::Connection> conns = e->getConnections();
1994 for (std::vector<NBEdge::Connection>::iterator k = conns.begin(); k != conns.end(); ++k) {
1995 if ((*k).toEdge ==
nullptr) {
2000 if ((*k).fromLane >= 0 && (*k).fromLane < e->getNumLanes() && e->getLaneStruct((*k).fromLane).connectionsDone) {
2003#ifdef DEBUG_JOINJUNCTIONS_CONNECTIONS
2004 std::cout <<
" e=" << e->getID() <<
" declareConnectionsAsLoaded\n";
2009 if (!resetConnections) {
2014 if (reachable[in].count(out) == 0) {
2017 in->removeFromConnections(out, -1, -1,
true,
false,
true);
2021 }
else if (specialPermissions.count(in) != 0) {
2022 SVCPermissions pDefault = in->getPermissions() & out->getPermissions();
2023 SVCPermissions p = conPermissions[ {in, out}] == 0 ? pDefault : conPermissions[ {in, out}];
2024 in->addEdge2EdgeConnection(out,
true, p == pDefault ?
SVC_UNSPECIFIED : p);
2031 in->invalidateConnections(
true);
2037 for (
NBNode* n : cluster) {
2045 std::set<std::string> ids;
2046 for (
NBNode* n : cluster) {
2047 ids.insert(n->getID());
2070 bool ambiguousType =
false;
2071 for (
NBNode* j : cluster) {
2072 pos.
add(j->getPosition());
2074 if (j->isTLControlled()) {
2077 type = (*j->getControllingTLS().begin())->getType();
2078 }
else if (type != (*j->getControllingTLS().begin())->getType()) {
2079 ambiguousType =
true;
2085 nodeType = otherType;
2086 }
else if (nodeType != otherType) {
2098 pos.
mul(1. / (
double)cluster.size());
2099 if (ambiguousType) {
2109 bool tooFast =
false;
2110 double laneSpeedSum = 0;
2111 std::set<NBEdge*> seen;
2113 for (
const NBEdge* e : j->getEdges()) {
2114 if (c.find(e->getFromNode()) != c.end() && c.find(e->getToNode()) != c.end()) {
2118 if (j->hasIncoming(e)) {
2119 if (recheck && !j->hasConflict(e)) {
2124 laneSpeedSum += (double)e->getNumLanes() * e->getLaneSpeed(0);
2126 if (e->getLaneSpeed(0) * 3.6 > 79) {
2132 return !tooFast && laneSpeedSum >= laneSpeedThreshold && c.size() != 0;
2144 nonPedIncoming.push_back(e);
2149 nonPedOutgoing.push_back(e);
2152 if (!
node->geometryLike(nonPedIncoming, nonPedOutgoing)) {
2168 if (
node->isTLControlled()) {
2174 const std::string tlID = tl->
getID();
2175 if (tlID !=
node->getID()
2191 const double laneSpeedThreshold = oc.
getFloat(
"tls.guess.threshold");
2192 if (oc.
isSet(
"tls.unset")) {
2193 std::vector<std::string> notTLControlledNodes = oc.
getStringVector(
"tls.unset");
2194 for (std::vector<std::string>::const_iterator i = notTLControlledNodes.begin(); i != notTLControlledNodes.end(); ++i) {
2197 throw ProcessError(
TLF(
" The junction '%' to set as not-controlled is not known.", *i));
2200 for (std::set<NBTrafficLightDefinition*>::const_iterator j = tls.begin(); j != tls.end(); ++j) {
2201 (*j)->removeNode(n);
2211 if (oc.
exists(
"tls.taz-nodes") && oc.
getBool(
"tls.taz-nodes")) {
2212 for (NodeCont::iterator i =
myNodes.begin(); i !=
myNodes.end(); i++) {
2213 NBNode* cur = (*i).second;
2222 if (oc.
exists(
"tls.guess-signals") && oc.
getBool(
"tls.guess-signals")) {
2224 const double signalDist = oc.
getFloat(
"tls.guess-signals.dist");
2225 for (
const auto& item :
myNodes) {
2227 if (
node->isTLControlled() && (
node->getIncomingEdges().size() == 1 ||
node->geometryLike())) {
2228#ifdef DEBUG_GUESSSIGNALS
2230 std::cout <<
" propagate TLS from " <<
node->
getID() <<
" downstream\n";
2233 for (
NBEdge* edge :
node->getOutgoingEdges()) {
2236 edge->setSignalPosition(
node->getPosition(),
node);
2241 std::set<NBEdge*> seen;
2242 std::set<NBEdge*> check;
2243 for (
const auto& item :
myNodes) {
2244 for (
NBEdge* edge : item.second->getOutgoingEdges()) {
2248#ifdef DEBUG_GUESSSIGNALS
2249 if (
DEBUGCOND(edge->getSignalNode()) ||
true) {
2250 std::cout <<
" primary signalPosition edge=" << edge->getID() <<
" pos=" << edge->getSignalPosition() <<
"\n";
2257 while (check.size() > 0) {
2258 NBEdge*
const edge = *check.begin();
2259 check.erase(check.begin());
2264 if (seen.count(outEdge) == 0) {
2266#ifdef DEBUG_GUESSSIGNALS
2268 std::cout <<
" setSignalPosition edge=" << outEdge->
getID() <<
" pos=" << edge->
getSignalPosition() <<
"\n";
2271 check.insert(outEdge);
2278 const int slack = oc.
getInt(
"tls.guess-signals.slack");
2279 for (std::map<std::string, NBNode*>::const_iterator i =
myNodes.begin(); i !=
myNodes.end(); ++i) {
2286 if (!
node->isTLControlled() && incoming.size() > 1 && !
node->geometryLike()
2289 std::vector<const NBNode*> signals;
2290 int foundSignals = 0;
2291 int missingSignals = 0;
2293 for (EdgeVector::const_iterator it_i = incoming.begin(); it_i != incoming.end(); ++it_i) {
2294 const NBEdge* inEdge = *it_i;
2297#ifdef DEBUG_GUESSSIGNALS
2299 std::cout <<
" noTLS, edge=" << inEdge->
getID() <<
"\n";
2303 if (missingSignals > slack) {
2312 int foundSignalsAtDist = 0;
2313 if (foundSignals > 1 && missingSignals <= slack && missingSignals < foundSignals) {
2314 node->updateSurroundingGeometry();
2317 for (EdgeVector::const_iterator it_i = incoming.begin(); it_i != incoming.end(); ++it_i) {
2318 const NBEdge* inEdge = *it_i;
2321#ifdef DEBUG_GUESSSIGNALS
2327 if (missingSignals > slack) {
2332 foundSignalsAtDist++;
2335 if (signal !=
nullptr) {
2336 signals.push_back(signal);
2341 for (
const NBEdge* outEdge : outgoing) {
2342 NBNode* cand = outEdge->getToNode();
2344#ifdef DEBUG_GUESSSIGNALS
2346 std::cout <<
" node=" <<
node->
getID() <<
" outEdge=" << outEdge->getID() <<
" signalNode=" << cand->
getID() <<
" len=" << outEdge->getLength() <<
"\n";
2349 signals.push_back(cand);
2353 if (foundSignalsAtDist > 1 && missingSignals <= slack && missingSignals < foundSignalsAtDist) {
2354 for (
const NBNode* s : signals) {
2355 std::set<NBTrafficLightDefinition*> tls = s->getControllingTLS();
2357 for (std::set<NBTrafficLightDefinition*>::iterator k = tls.begin(); k != tls.end(); ++k) {
2364 if (!tlc.
insert(tlDef)) {
2376 if (oc.
getBool(
"tls.guess.joining")) {
2381 for (NodeClusters::iterator i = cands.begin(); i != cands.end();) {
2385 for (NodeSet::iterator j = c.begin(); j != c.end();) {
2386 if ((*j)->isTLControlled() ||
myUnsetTLS.count(*j) != 0) {
2401 for (
auto nodeSet : cands) {
2402 std::vector<NBNode*> nodes;
2404 nodes.push_back(
node);
2409 if (!tlc.
insert(tlDef)) {
2419 if (oc.
getBool(
"tls.guess")) {
2420 for (NodeCont::iterator i =
myNodes.begin(); i !=
myNodes.end(); i++) {
2421 NBNode* cur = (*i).second;
2444 std::set<NBTrafficLightDefinition*> recompute;
2447 const std::set<NBTrafficLightDefinition*>& tlDefs =
node->getControllingTLS();
2448 recompute.insert(tlDefs.begin(), tlDefs.end());
2449 node->removeTrafficLights(
true);
2450 for (
NBEdge* edge :
node->getIncomingEdges()) {
2451 edge->clearControllingTLInformation();
2456 if (def->getNodes().size() == 0) {
2459 def->setParticipantsInformation();
2460 def->setTLControllingInformation();
2469 if (!
node->isTLControlled()) {
2472 if ((*
node->getControllingTLS().begin())->getNodes().size() != 1) {
2485 for (
const auto& item :
myNodes) {
2486 item.second->computeKeepClear();
2494 for (
const std::string& tlsID : excludeList) {
2495 if (!tlc.
exist(tlsID,
false)) {
2496 WRITE_WARNINGF(
"Unknown tls ID '%' in option tls.join-exclude", tlsID);
2499 std::set<std::string> exclude(excludeList.begin(), excludeList.end());
2503 for (NodeSet::iterator j = c.begin(); j != c.end();) {
2504 if (!(*j)->isTLControlled() || exclude.count((*(*j)->getControllingTLS().begin())->getID()) != 0) {
2515 bool dummySetTL =
false;
2516 std::string
id =
"joinedS_";
2521 std::set<NBTrafficLightDefinition*> tls = j->getControllingTLS();
2522 j->removeTrafficLights();
2527 std::vector<NBNode*> nodes;
2532 if (!tlc.
insert(tlDef)) {
2549 if (!tlc.
insert(tlDef)) {
2551 WRITE_WARNINGF(
TL(
"Building a tl-logic for junction '%' twice is not possible."),
id);
2561 for (NodeCont::iterator i =
myNodes.begin(); i !=
myNodes.end(); i++) {
2562 (*i).second->computeLanes2Lanes();
2570 for (NodeCont::iterator i =
myNodes.begin(); i !=
myNodes.end(); i++) {
2571 (*i).second->computeLogic(ec);
2578 std::set<NBNode*> roundaboutNodes;
2579 const bool checkLaneFoesAll = oc.
getBool(
"check-lane-foes.all");
2580 const bool checkLaneFoesRoundabout = !checkLaneFoesAll && oc.
getBool(
"check-lane-foes.roundabout");
2581 if (checkLaneFoesRoundabout) {
2583 for (std::set<EdgeSet>::const_iterator i = roundabouts.begin(); i != roundabouts.end(); ++i) {
2584 for (EdgeSet::const_iterator j = (*i).begin(); j != (*i).end(); ++j) {
2585 roundaboutNodes.insert((*j)->getToNode());
2589 for (NodeCont::iterator i =
myNodes.begin(); i !=
myNodes.end(); i++) {
2590 const bool checkLaneFoes = checkLaneFoesAll || (checkLaneFoesRoundabout && roundaboutNodes.count((*i).second) > 0);
2591 (*i).second->computeLogic2(checkLaneFoes);
2598 for (NodeCont::iterator i =
myNodes.begin(); i !=
myNodes.end(); i++) {
2599 delete ((*i).second);
2612 std::string freeID =
"SUMOGenerated" + toString<int>(counter);
2614 while (
retrieve(freeID) !=
nullptr) {
2617 freeID =
"SUMOGenerated" + toString<int>(counter);
2625 for (NodeCont::iterator i =
myNodes.begin(); i !=
myNodes.end(); i++) {
2626 (*i).second->computeNodeShape(mismatchThreshold);
2633 WRITE_MESSAGE(
TL(
"-----------------------------------------------------"));
2636 int numUnregulatedJunctions = 0;
2637 int numDeadEndJunctions = 0;
2638 int numTrafficLightJunctions = 0;
2639 int numPriorityJunctions = 0;
2640 int numRightBeforeLeftJunctions = 0;
2641 int numLeftBeforeRightJunctions = 0;
2642 int numAllWayStopJunctions = 0;
2643 int numZipperJunctions = 0;
2644 int numDistrictJunctions = 0;
2645 int numRailCrossing = 0;
2646 int numRailSignals = 0;
2647 for (NodeCont::const_iterator i =
myNodes.begin(); i !=
myNodes.end(); i++) {
2648 switch ((*i).second->getType()) {
2650 ++numUnregulatedJunctions;
2653 ++numDeadEndJunctions;
2658 ++numTrafficLightJunctions;
2662 ++numPriorityJunctions;
2665 ++numRightBeforeLeftJunctions;
2668 ++numLeftBeforeRightJunctions;
2671 ++numAllWayStopJunctions;
2674 ++numZipperJunctions;
2677 ++numDistrictJunctions;
2694 if (numDeadEndJunctions > 0) {
2699 if (numLeftBeforeRightJunctions > 0) {
2702 if (numTrafficLightJunctions > 0) {
2705 if (numAllWayStopJunctions > 0) {
2708 if (numZipperJunctions > 0) {
2711 if (numRailCrossing > 0) {
2714 if (numRailSignals > 0) {
2717 if (numDistrictJunctions > 0) {
2725 WRITE_MESSAGE(
TL(
"-----------------------------------------------------"));
2729std::vector<std::string>
2731 std::vector<std::string> ret;
2732 for (NodeCont::const_iterator i =
myNodes.begin(); i !=
myNodes.end(); ++i) {
2733 ret.push_back((*i).first);
2742 const auto nodeContainerCopy =
myNodes;
2744 for (
const auto&
node : nodeContainerCopy) {
2745 node.second->setID(prefix +
node.second->getID());
2753 if (
myNodes.count(newID) != 0) {
2754 throw ProcessError(
TLF(
"Attempt to rename node using existing id '%'", newID));
2764 for (NodeCont::const_iterator i =
myNodes.begin(); i !=
myNodes.end(); ++i) {
2766 if (
node->isTLControlled() && (!geometryLike ||
node->geometryLike())) {
2769 if (geometryLike && (*tldefs.begin())->getNodes().size() > 1) {
2773 if (
node->getCrossings().size() > 0) {
2778 for (
NBEdge* edge :
node->getOutgoingEdges()) {
2779 edge->setSignalPosition(
node->getPosition(),
nullptr);
2780#ifdef DEBUG_GUESSSIGNALS
2781 std::cout <<
" discard-simple " <<
node->getID() <<
" edge=" << edge->getID() <<
" pos=" << edge->getSignalPosition() <<
"\n";
2784 for (std::set<NBTrafficLightDefinition*>::const_iterator it = tldefs.begin(); it != tldefs.end(); ++it) {
2786 node->removeTrafficLight(tlDef);
2790 node->reinit(
node->getPosition(), newType);
2810 if (!numericaIDs && !reservedIDs && prefix ==
"" && !startGiven) {
2813 std::vector<std::string> avoid;
2819 std::set<std::string> reserve;
2823 avoid.insert(avoid.end(), reserve.begin(), reserve.end());
2827 for (NodeCont::iterator it =
myNodes.begin(); it !=
myNodes.end(); it++) {
2829 toChange.insert(it->second);
2836 toChange.insert(it->second);
2839 if (reservedIDs && reserve.count(it->first) > 0) {
2840 toChange.insert(it->second);
2843 std::set<std::string> keep;
2847 for (
auto it = toChange.begin(); it != toChange.end();) {
2848 if (keep.count((*it)->getID()) != 0) {
2849 it = toChange.erase(it++);
2869 if (prefix.empty()) {
2870 return (
int)toChange.size();
2875 for (
auto item : oldNodes) {
2877 rename(item.second, prefix + item.first);
2880 tlc.
rename(tlDef, prefix + tlDef->getID());
2898 for (
const auto& item :
myNodes) {
2901 paretoCheck(item.second, bottomRightFront, 1, -1);
2902 paretoCheck(item.second, bottomLeftFront, -1, -1);
2905 front.insert(topRightFront.begin(), topRightFront.end());
2906 front.insert(topLeftFront.begin(), topLeftFront.end());
2907 front.insert(bottomRightFront.begin(), bottomRightFront.end());
2908 front.insert(bottomLeftFront.begin(), bottomLeftFront.end());
2910 for (
NBNode* n : front) {
2911 const int in = (int)n->getIncomingEdges().size();
2912 const int out = (int)n->getOutgoingEdges().size();
2913 if ((in <= 1 && out <= 1) &&
2914 (in == 0 || out == 0
2915 || n->getIncomingEdges().front()->isTurningDirectionAt(n->getOutgoingEdges().front()))) {
2922 for (
const auto& item :
myNodes) {
2924 if (front.count(n) != 0) {
2927 if (n->
getEdges().size() == 1 && n->
getEdges().front()->getSpeed() > speedThreshold) {
2938 const double x =
node->getPosition().x() * xSign;
2939 const double y =
node->getPosition().y() * ySign;
2940 std::vector<NBNode*> dominated;
2942 const double x2 =
fn->getPosition().x() * xSign;
2943 const double y2 =
fn->getPosition().y() * ySign;
2944 if (x2 >= x && y2 >= y) {
2946 }
else if (x2 <= x && y2 <= y) {
2947 dominated.push_back(
fn);
2950 frontier.insert(
node);
2951 for (
NBNode* r : dominated) {
2959 for (
const auto& item :
myNodes) {
2962 bool hasNEMA =
false;
2980 bool hadShapes =
false;
2981 for (
const auto& item :
myNodes) {
2982 if (item.second->getShape().size() > 0 && !item.second->hasCustomShape()) {
2984 item.second->resetShape();
#define WRITE_WARNINGF(...)
#define WRITE_MESSAGEF(...)
#define WRITE_ERRORF(...)
#define WRITE_MESSAGE(msg)
#define WRITE_WARNING(msg)
std::set< NBNode *, ComparatorIdLess > NodeSet
std::set< NBEdge * > EdgeSet
container for unique edges
std::vector< NBEdge * > EdgeVector
container for (sorted) edges
#define MAX_SLIPLANE_LENGTH
bool isForVulnerableModes(SVCPermissions permissions)
Returns whether an edge with the given permissions allows only vulnerable road users.
bool isRailway(SVCPermissions permissions)
Returns whether an edge with the given permissions is a (exclusive) railway edge.
const SVCPermissions SVC_UNSPECIFIED
permissions not specified
bool isWaterway(SVCPermissions permissions)
Returns whether an edge with the given permissions is a waterway edge.
const std::string & getVehicleClassNames(SVCPermissions permissions, bool expand)
Returns the ids of the given classes, divided using a ' '.
long long int SVCPermissions
bitset where each bit declares whether a certain SVC may use this edge/lane
@ SVC_RAIL_CLASSES
classes which drive on tracks
@ SVC_PASSENGER
vehicle is a passenger car (a "normal" car)
@ SVC_DELIVERY
vehicle is a small delivery vehicle
@ SVC_TRAM
vehicle is a light rail
@ SVC_PEDESTRIAN
pedestrian
const std::string SUMO_PARAM_ORIGID
SumoXMLNodeType
Numbers representing special SUMO-XML-attribute values for representing node- (junction-) types used ...
@ TRAFFIC_LIGHT_RIGHT_ON_RED
@ TRAFFIC_LIGHT_NOJUNCTION
bool gDebugFlag1
global utility flags for debugging
const double SUMO_const_laneWidth
std::string joinNamedToString(const std::set< T *, C > &ns, const T_BETWEEN &between)
std::string joinToString(const std::vector< T > &v, const T_BETWEEN &between, std::streamsize accuracy=gPrecision)
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
static methods for processing the coordinates conversion for the current net
const Boundary & getOrigBoundary() const
Returns the original boundary.
static GeoConvHelper & getProcessing()
the coordinate transformation to use for input conversion and processing
const Position getOffsetBase() const
Returns the network base.
const Boundary & getConvBoundary() const
Returns the converted boundary.
std::string getNext()
Returns the next id.
A container for districts.
A class representing a single district.
Storage for edges, including some functionality operating on multiple edges.
NBEdge * getByID(const std::string &edgeID) const
Returns the edge with id if it exists.
const std::set< EdgeSet > getRoundabouts() const
Returns the determined roundabouts.
std::map< std::string, NBEdge * >::const_iterator begin() const
Returns the pointer to the begin of the stored edges.
void extract(NBDistrictCont &dc, NBEdge *edge, bool remember=false)
Removes the given edge from the container like erase but does not delete it.
void erase(NBDistrictCont &dc, NBEdge *edge)
Removes the given edge from the container (deleting it)
NBEdge * retrieve(const std::string &id, bool retrieveExtracted=false) const
Returns the edge that has the given id.
std::map< std::string, NBEdge * >::const_iterator end() const
Returns the pointer to the end of the stored edges.
bool hasPostProcessConnection(const std::string &from, const std::string &to="")
add post process connections
void removeRoundaboutEdges(const EdgeSet &toRemove)
remove edges from all stored roundabouts
void joinSameNodeConnectingEdges(NBDistrictCont &dc, NBTrafficLightLogicCont &tlc, EdgeVector edges)
Joins the given edges because they connect the same nodes.
std::vector< std::string > getAllNames() const
Returns all ids of known edges.
The representation of a single edge during network building.
double getLength() const
Returns the computed length of the edge.
SVCPermissions getPermissions(int lane=-1) const
get the union of allowed classes over all lanes or for a specific lane
const std::vector< Connection > & getConnections() const
Returns the connections.
const Position & getSignalPosition() const
Returns the position of a traffic signal on this edge.
double getLoadedLength() const
Returns the length was set explicitly or the computed length if it wasn't set.
NBNode * getToNode() const
Returns the destination node of the edge.
static EdgeVector filterByPermissions(const EdgeVector &edges, SVCPermissions permissions)
return only those edges that permit at least one of the give permissions
EdgeBuildingStep getStep() const
The building step of this edge.
NBEdge * getStraightContinuation(SVCPermissions permissions) const
return the straightest follower edge for the given permissions or nullptr (never returns turn-arounds...
bool isNearEnough2BeJoined2(NBEdge *e, double threshold) const
Check if edge is near enough to be joined to another edge.
@ INIT
The edge has been loaded, nothing is computed yet.
double getSpeed() const
Returns the speed allowed on this edge.
const std::string & getID() const
static const double UNSPECIFIED_SIGNAL_OFFSET
unspecified signal offset
const NBNode * getSignalNode() const
Returns the node that (possibly) represents a traffic signal controlling at the end of this edge.
int getNumLanesThatAllow(SVCPermissions permissions, bool allPermissions=true) const
@ USER
The connection was given by the user.
NBNode * getFromNode() const
Returns the origin node of the edge.
double getAngleAtNode(const NBNode *const node) const
Returns the angle of the edge's geometry at the given node.
double getSignalOffset() const
Returns the offset of a traffic signal from the end of this edge.
int getPriority() const
Returns the priority of the edge.
const PositionVector & getLaneShape(int i) const
Returns the shape of the nth lane.
void append(NBEdge *continuation)
append another edge
static void loadPrefixedIDsFomFile(const std::string &file, const std::string prefix, std::set< std::string > &into)
Add prefixed ids defined in file.
static double relAngle(double angle1, double angle2)
computes the relative angle between the two angles
static void loadEdgesFromFile(const std::string &file, std::set< std::string > &into)
Add edge ids defined in file (either ID or edge:ID per line) into the given set.
void clear()
deletes all nodes
std::set< std::string > myJoinExclusions
set of node ids which should not be joined
std::vector< std::vector< std::string > > myRailComponents
network components that must be removed if not connected to the road network via stop access
static double getDiameter(const NodeSet &cluster)
compute the maximum distance between any two cluster nodes
NamedRTree myRTree
node positions for faster lookup
void avoidOverlap()
fix overlap
int removeRailComponents(NBDistrictCont &dc, NBEdgeCont &ec, NBPTStopCont &sc)
bool onlyCrossings(const NodeSet &c) const
check whether the set of nodes only contains pedestrian crossings
std::string createClusterId(const NodeSet &cluster, const std::string &prefix="cluster_")
generate id from cluster node ids
std::map< std::string, NBNode * >::const_iterator begin() const
Returns the pointer to the begin of the stored nodes.
void recheckGuessedTLS(NBTrafficLightLogicCont &tlc)
recheck myGuessedTLS after node logics are computed
std::vector< NodeSet > NodeClusters
Definition of a node cluster container.
void computeKeepClear()
compute keepClear status for all connections
std::vector< NBNode * > retrieveByPos(const Position &position, const double offset=0.) const
Returns the node with the given coordinates.
NodeCont myNodes
The map of names to nodes.
bool reduceToCircle(NodeSet &cluster, int circleSize, NodeSet startNodes, double maxDist, std::vector< NBNode * > cands=std::vector< NBNode * >()) const
try to find a joinable subset (recursively)
void registerJoinedCluster(const NodeSet &cluster)
gets all joined clusters (see doc for myClusters2Join)
std::string getFreeID()
generates a new node ID
int removeSelfLoops(NBDistrictCont &dc, NBEdgeCont &ec, NBTrafficLightLogicCont &tc)
Removes self-loop edges (edges where the source and the destination node are the same)
bool recheckTLSThreshold(NBNode *node)
check whether a specific guessed tls should keep its type
void paretoCheck(NBNode *node, NodeSet &frontier, int xSign, int ySign)
update pareto frontier with the given node
bool maybeSlipLaneStart(const NBNode *n, EdgeVector &outgoing, double &inAngle) const
check whether the given node maybe the start of a slip lane
void addJoinExclusion(const std::vector< std::string > &ids)
bool erase(NBNode *node)
Removes the given node, deleting it.
int joinLoadedClusters(NBDistrictCont &dc, NBEdgeCont &ec, NBTrafficLightLogicCont &tlc)
Joins loaded junction clusters (see NIXMLNodesHandler)
static bool geometryLikeForClass(const NBNode *n, SVCPermissions permissions)
check whether the node is geometryLike when only considering edges that support the given permissions
void applyConditionalDefaults()
apply default values after loading
void pruneSlipLaneNodes(NodeSet &cluster, double maxDist) const
remove nodes that form a slip lane from cluster
int remapIDs(bool numericaIDs, bool reservedIDs, bool keptIDs, const std::string &prefix, NBTrafficLightLogicCont &tlc)
remap node IDs according to options –numerical-ids and –reserved-ids
bool insert(const std::string &id, const Position &position, NBDistrict *district=0)
Inserts a node into the map.
std::set< const NBNode * > myUnsetTLS
nodes that are excluded from tls-guessing
NBNode * retrieve(const std::string &id) const
Returns the node with the given name.
NodeCont myExtractedNodes
The extracted nodes which are kept for reference.
void joinTLS(NBTrafficLightLogicCont &tlc, double maxdist)
Builds clusters of tls-controlled junctions and joins the control if possible.
int removeUnwishedNodes(NBDistrictCont &dc, NBEdgeCont &ec, NBTrafficLightLogicCont &tlc, NBPTStopCont &sc, NBPTLineCont &lc, NBParkingCont &pc, bool removeGeometryNodes)
Removes "unwished" nodes.
std::vector< JoinCluster > myClusters2Join
loaded sets of node ids to join (cleared after use)
bool extract(NBNode *node, bool remember=false)
Removes the given node but does not delete it.
void pruneClusterFringe(NodeSet &cluster, double maxDist, bool remove2TLS=false) const
remove geometry-like fringe nodes from cluster
int removeComponents(NBDistrictCont &dc, NBEdgeCont &ec, const int numKeep, bool hasPTStops)
Checks the network for weak connectivity and removes all but the largest components....
std::vector< std::string > getAllNames() const
get all node names
void computeLogics2(const NBEdgeCont &ec, OptionsCont &oc)
compute right-of-way logic for all lane-to-lane connections
bool shouldBeTLSControlled(const NodeSet &c, double laneSpeedThreshold, bool recheck=false) const
Returns whether the given node cluster should be controlled by a tls.
void rename(NBNode *node, const std::string &newID)
Renames the node. Throws exception if newID already exists.
void joinSimilarEdges(NBDistrictCont &dc, NBEdgeCont &ec, NBTrafficLightLogicCont &tlc, bool removeDuplicates)
Joins edges connecting the same nodes.
int removeIsolatedRoads(NBDistrictCont &dc, NBEdgeCont &ec)
Removes sequences of edges that are not connected with a junction. Simple roads without junctions som...
void joinNodeClusters(NodeClusters clusters, NBDistrictCont &dc, NBEdgeCont &ec, NBTrafficLightLogicCont &tlc, bool resetConnections=false)
joins the given node clusters
void discardRailSignals()
discards rail signals
void addPrefix(const std::string &prefix)
add prefix to all nodes
void printBuiltNodesStatistics() const
Prints statistics about built nodes.
void setAsTLControlled(NBNode *node, NBTrafficLightLogicCont &tlc, TrafficLightType type, std::string id="")
Sets the given node as being controlled by a tls.
std::set< const NBNode * > mySplit
nodes that were created when splitting an edge
static NodeSet getClusterNeighbors(const NBNode *n, double longThreshold, NodeSet &cluster)
return all cluster neighbors for the given node
void computeLogics(const NBEdgeCont &ec)
build the list of outgoing edges and lanes
void joinNodeCluster(NodeSet clusters, NBDistrictCont &dc, NBEdgeCont &ec, NBTrafficLightLogicCont &tlc, NBNode *predefined=nullptr, bool resetConnections=false)
void unregisterJoinedCluster(const std::set< std::string > &cluster)
remove cluster from list (on netedit-undo)
void generateNodeClusters(double maxDist, NodeClusters &into) const
Builds node clusters.
static bool isSlipLaneContinuation(const NBNode *cont)
whether the given node may continue a slip lane
void computeNodeShapes(double mismatchThreshold=-1)
Compute the junction shape for this node.
std::vector< std::set< std::string > > myJoinedClusters
sets of node ids which were joined
NBEdge * shortestEdge(const NodeSet &cluster, const NodeSet &startNodes, const std::vector< NBNode * > &exclude) const
find closest neighbor for building circle
std::pair< NBNode *, double > NodeAndDist
void guessTLs(OptionsCont &oc, NBTrafficLightLogicCont &tlc)
Guesses which junctions or junction clusters shall be controlled by tls.
bool feasibleCluster(const NodeSet &cluster, const std::map< const NBNode *, std::vector< NBNode * > > &ptStopEnds, double maxDist, std::string &reason, NBNode *&tryRemove) const
determine whether the cluster is not too complex for joining
int joinSameJunctions(NBDistrictCont &dc, NBEdgeCont &ec, NBTrafficLightLogicCont &tlc, double maxDist)
Joins junctions with similar coordinates regardless of topology.
int guessFringe()
guess and mark fringe nodes
int joinJunctions(double maxDist, NBDistrictCont &dc, NBEdgeCont &ec, NBTrafficLightLogicCont &tlc, NBPTStopCont &sc)
Joins junctions that are very close together.
void computeLanes2Lanes()
divides the incoming lanes on outgoing lanes
void addCluster2Join(const std::set< std::string > &cluster, NBNode *node, const bool resetConnections=false)
add ids of nodes which shall be joined into a single node
void discardTrafficLights(NBTrafficLightLogicCont &tlc, bool geometryLike)
std::set< NBNode *, ComparatorIdLess > myGuessedTLS
nodes that received a traffic light due to guessing (–tls.guess)
std::set< std::string > myJoined
ids found in loaded join clusters used for error checking
void analyzeCluster(NodeSet cluster, std::string &id, Position &pos, bool &hasTLS, TrafficLightType &type, SumoXMLNodeType &nodeType)
std::string createUnusedID(const std::string &base, const std::string &sep)
if base is an existing node id, find a unused id of the form base + sep + INT
bool customTLID(const NodeSet &c) const
check whether the set of nodes contains traffic lights with custom id
bool resetNodeShapes()
reset all node shapes
static int pruneLongEdges(NodeSet &cluster, double maxDist, const bool dryRun=false)
avoid removal of long edges when joining junction clusters
bool maybeSlipLaneEnd(const NBNode *n, EdgeVector &incoming, double &outAngle) const
check whether the given node maybe the end of a slip lane
Represents a single node (junction) during network building.
bool hasIncoming(const NBEdge *const e) const
Returns whether the given edge ends at this node.
RightOfWay getRightOfWay() const
Returns hint on how to compute right of way.
const std::set< NBTrafficLightDefinition * > & getControllingTLS() const
Returns the traffic lights that were assigned to this node (The set of tls that control this node)
void reinit(const Position &position, SumoXMLNodeType type, bool updateEdgeGeometries=false)
Resets initial values.
SumoXMLNodeType getType() const
Returns the type of this node.
void setRightOfWay(RightOfWay rightOfWay)
set method for computing right-of-way
static bool isTrafficLight(SumoXMLNodeType type)
return whether the given type is a traffic light
const EdgeVector & getIncomingEdges() const
Returns this node's incoming edges (The edges which yield in this node)
std::vector< std::pair< NBEdge *, NBEdge * > > getEdgesToJoin() const
get edges to join
const EdgeVector & getOutgoingEdges() const
Returns this node's outgoing edges (The edges which start at this node)
void removeTrafficLights(bool setAsPriority=false)
Removes all references to traffic lights that control this tls.
void replaceIncoming(NBEdge *which, NBEdge *by, int laneOff)
Replaces occurrences of the first edge within the list of incoming by the second Connections are rema...
EdgeVector getPassengerEdges(bool incoming) const
return edges that permit passengers (either incoming or outgoing)
const Position & getPosition() const
const EdgeVector & getEdges() const
Returns all edges which participate in this node (Edges that start or end at this node)
bool checkIsRemovable() const
check if node is removable
void setFringeType(FringeType fringeType)
set fringe type
bool geometryLike() const
whether this is structurally similar to a geometry node
bool isNearDistrict() const
@chech if node is near district
bool isTLControlled() const
Returns whether this node is controlled by any tls.
static bool isRailwayNode(const NBNode *n)
whether the given node only has rail edges
A traffic light logics which must be computed (only nodes/edges are given)
void replaceEdge(const std::string &edgeID, const EdgeVector &replacement)
replace the edge with the given edge list in all lines
Container for public transport stops during the net building process.
void replaceEdge(const std::string &edgeID, const std::vector< NBEdge * > &replacement)
replace the edge with the closes edge on the given edge list in all stops
const std::map< std::string, std::shared_ptr< NBPTStop > > & getStops() const
Returns an unmodifiable reference to the stored pt stops.
void addEdges2Keep(const OptionsCont &oc, std::set< std::string > &into)
add edges that must be kept
void addEdges2Keep(const OptionsCont &oc, std::set< std::string > &into)
add edges that must be kept
The base class for traffic light logic definitions.
const std::vector< NBNode * > & getNodes() const
Returns the list of controlled nodes.
A container for traffic light definitions and built programs.
bool exist(const std::string &newID, bool requireComputed=true) const
check if exists a definition with the given ID
void rename(NBTrafficLightDefinition *tlDef, const std::string &newID)
rename traffic light
bool computeSingleLogic(OptionsCont &oc, NBTrafficLightDefinition *def)
Computes a specific traffic light logic (using by netedit)
bool removeFully(const std::string id)
Removes a logic definition (and all programs) from the dictionary.
bool insert(NBTrafficLightDefinition *logic, bool forceInsert=false)
Adds a logic definition to the dictionary.
void extract(NBTrafficLightDefinition *definition)
Extracts a traffic light definition from myDefinitions but keeps it in myExtracted for eventual * del...
Allows to store the object; used as context while traveling the rtree in TraCI.
Base class for objects which have an id.
const std::string & getID() const
Returns the id.
void Remove(const float a_min[2], const float a_max[2], Named *const &a_data)
Remove entry.
void Insert(const float a_min[2], const float a_max[2], Named *const &a_data)
Insert entry.
int Search(const float a_min[2], const float a_max[2], const Named::StoringVisitor &c) const
Find all within search rectangle.
A storage for options typed value containers)
bool isSet(const std::string &name, bool failOnNonExistant=true) const
Returns the information whether the named option is set.
double getFloat(const std::string &name) const
Returns the double-value of the named option (only for Option_Float)
int getInt(const std::string &name) const
Returns the int-value of the named option (only for Option_Integer)
std::string getString(const std::string &name) const
Returns the string-value of the named option (only for Option_String)
bool isDefault(const std::string &name) const
Returns the information whether the named option has still the default value.
bool exists(const std::string &name) const
Returns the information whether the named option is known.
bool getBool(const std::string &name) const
Returns the boolean-value of the named option (only for Option_Bool)
const StringVector & getStringVector(const std::string &name) const
Returns the list of string-value of the named option (only for Option_StringVector)
static OptionsCont & getOptions()
Retrieves the options.
virtual void setParameter(const std::string &key, const std::string &value)
Sets a parameter.
A point in 2D or 3D with translation and scaling methods.
void setx(double x)
set position x
static const Position INVALID
used to indicate that a position is valid
double distanceTo2D(const Position &p2) const
returns the euclidean distance in the x-y-plane
double x() const
Returns the x-position.
void add(const Position &pos)
Adds the given position to this one.
void setz(double z)
set position z
void mul(double val)
Multiplies position with the given value.
double z() const
Returns the z-position.
void sety(double y)
set position y
double y() const
Returns the y-position.
static StringBijection< TrafficLightType > TrafficLightTypes
traffic light types
T get(const std::string &str) const
get key
static long long int toLong(const std::string &sData)
converts a string into the long value described by it by calling the char-type converter,...
static bool startsWith(const std::string &str, const std::string prefix)
Checks whether a given string starts with the prefix.