81 NodeCont::iterator i =
myNodes.find(
id);
87 const float pos[2] = {(float)position.
x(), (float)position.
y()};
95 std::string
id = node->
getID();
96 NodeCont::iterator i =
myNodes.find(
id);
109 NodeCont::const_iterator i =
myNodes.find(
id);
120 const float cmin[2] = {(float)(position.
x() - extOffset), (
float)(position.
y() - extOffset)};
121 const float cmax[2] = {(float)(position.
x() + extOffset), (
float)(position.
y() + extOffset)};
122 std::set<std::string> into;
125 for (std::set<std::string>::const_iterator i = into.begin(); i != into.end(); i++) {
169 for (NodeCont::iterator i =
myNodes.begin(); i !=
myNodes.end(); i++) {
170 no += (*i).second->removeSelfLoops(dc, ec, tc);
181 const double distanceThreshold = 7.;
182 const double lengthThreshold = 0.10;
184 for (NodeCont::iterator i =
myNodes.begin(); i !=
myNodes.end(); i++) {
186 std::map<NBNode*, EdgeVector> connectionCount;
187 const EdgeVector& outgoing = (*i).second->getOutgoingEdges();
188 for (EdgeVector::const_iterator j = outgoing.begin(); j != outgoing.end(); j++) {
189 connectionCount[(*j)->getToNode()].push_back(*j);
192 std::map<NBNode*, EdgeVector>::iterator k;
193 for (k = connectionCount.begin(); k != connectionCount.end(); k++) {
195 if ((*k).second.size() < 2) {
201 const NBEdge*
const first = ev.front();
202 EdgeVector::const_iterator jci;
203 for (jci = ev.begin() + 1; jci != ev.end(); ++jci) {
206 (relativeLengthDifference > lengthThreshold) ||
207 (fabs(first->
getSpeed() - (*jci)->getSpeed()) >= 0.01) ||
215 if (jci == ev.end()) {
226 const std::vector<std::string>& edgeNames = ec.
getAllNames();
227 for (std::vector<std::string>::const_iterator it = edgeNames.begin(); it != edgeNames.end(); ++it) {
236 if (outgoingEdges.size() != 1) {
241 if (incomingEdges.size() > 1) {
244 }
else if (incomingEdges.size() == 1) {
245 NBNode* fromNodeOfIncomingEdge = incomingEdges[0]->getFromNode();
246 NBNode* toNodeOfOutgoingEdge = outgoingEdges[0]->getToNode();
247 if (fromNodeOfIncomingEdge != toNodeOfOutgoingEdge) {
255 bool hasJunction =
false;
259 std::set<NBNode*> adjacentNodes;
267 adjacentNodes.clear();
268 for (EdgeVector::const_iterator itOfOutgoings = outgoingEdgesOfToNode.begin(); itOfOutgoings != outgoingEdgesOfToNode.end(); ++itOfOutgoings) {
269 if ((*itOfOutgoings)->getToNode() != from
270 && (*itOfOutgoings)->getToNode() != to
274 adjacentNodes.insert((*itOfOutgoings)->getToNode());
276 for (EdgeVector::const_iterator itOfIncomings = incomingEdgesOfToNode.begin(); itOfIncomings != incomingEdgesOfToNode.end(); ++itOfIncomings) {
277 adjacentNodes.insert((*itOfIncomings)->getFromNode());
279 adjacentNodes.erase(to);
280 if (adjacentNodes.size() > 2) {
283 }
while (!hasJunction && eOld != e);
285 std::string warningString =
"Removed a road without junctions: ";
286 for (EdgeVector::iterator roadIt = road.begin(); roadIt != road.end(); ++roadIt) {
287 if (roadIt == road.begin()) {
288 warningString += (*roadIt)->
getID();
290 warningString +=
", " + (*roadIt)->getID();
293 NBNode* fromNode = (*roadIt)->getFromNode();
294 NBNode* toNode = (*roadIt)->getToNode();
295 ec.
erase(dc, *roadIt);
313 std::vector<std::set<NBEdge*> > components;
314 std::set<NBEdge*> edgesLeft;
315 for (std::map<std::string, NBEdge*>::const_iterator edgeIt = ec.
begin(); edgeIt != ec.
end(); ++edgeIt) {
316 edgesLeft.insert(edgeIt->second);
319 std::set<NBEdge*> toRemove;
320 while (!edgesLeft.empty()) {
321 queue.push_back(*edgesLeft.begin());
322 std::set<NBEdge*> component;
323 while (!queue.empty()) {
324 NBEdge*
const e = queue.back();
327 std::vector<EdgeVector> edgeLists;
332 for (std::vector<EdgeVector>::const_iterator listIt = edgeLists.begin(); listIt != edgeLists.end(); ++listIt) {
333 for (EdgeVector::const_iterator edgeIt = listIt->begin(); edgeIt != listIt->end(); ++edgeIt) {
334 std::set<NBEdge*>::iterator leftIt = edgesLeft.find(*edgeIt);
335 if (leftIt != edgesLeft.end()) {
336 queue.push_back(*edgeIt);
337 edgesLeft.erase(leftIt);
342 std::vector<std::set<NBEdge*> >::iterator cIt;
343 for (cIt = components.begin(); cIt != components.end(); ++cIt) {
344 if (cIt->size() < component.size()) {
348 components.insert(cIt, component);
349 if ((
int)components.size() > numKeep) {
350 toRemove.insert(components.back().begin(), components.back().end());
351 components.pop_back();
354 for (std::set<NBEdge*>::iterator edgeIt = toRemove.begin(); edgeIt != toRemove.end(); ++edgeIt) {
355 NBNode*
const fromNode = (*edgeIt)->getFromNode();
356 NBNode*
const toNode = (*edgeIt)->getToNode();
357 ec.
erase(dc, *edgeIt);
372 bool removeGeometryNodes) {
374 std::set<std::string> edges2keep;
375 if (removeGeometryNodes) {
377 if (oc.
isSet(
"geometry.remove.keep-edges.input-file")) {
380 if (oc.
isSet(
"geometry.remove.keep-edges.explicit")) {
381 const std::vector<std::string> edges = oc.
getStringVector(
"geometry.remove.keep-edges.explicit");
382 edges2keep.insert(edges.begin(), edges.end());
389 std::vector<NBNode*> toRemove;
390 for (NodeCont::iterator i =
myNodes.begin(); i !=
myNodes.end(); i++) {
391 NBNode* current = (*i).second;
393 std::vector<std::pair<NBEdge*, NBEdge*> > toJoin;
400 if (removeGeometryNodes &&
mySplit.count(current) == 0) {
408 for (EdgeVector::const_iterator it_edge = current->
getEdges().begin(); it_edge != current->
getEdges().end(); ++it_edge) {
409 if (edges2keep.find((*it_edge)->getID()) != edges2keep.end()) {
423 for (std::vector<std::pair<NBEdge*, NBEdge*> >::iterator j = toJoin.begin(); j != toJoin.end(); j++) {
425 NBEdge* continuation = (*j).second;
426 begin->
append(continuation);
429 ec.
extract(dc, continuation,
true);
431 toRemove.push_back(current);
435 for (std::vector<NBNode*>::iterator j = toRemove.begin(); j != toRemove.end(); ++j) {
444 for (NodeCont::iterator i =
myNodes.begin(); i !=
myNodes.end(); i++) {
445 (*i).second->avoidOverlap();
452 std::set<NBNode*> visited;
453 for (NodeCont::const_iterator i =
myNodes.begin(); i !=
myNodes.end(); i++) {
454 std::vector<NodeAndDist> toProc;
455 if (visited.find((*i).second) != visited.end()) {
458 toProc.push_back(std::make_pair((*i).second, 0));
460 while (!toProc.empty()) {
462 NBNode* n = nodeAndDist.first;
463 double dist = nodeAndDist.second;
465 if (visited.find(n) != visited.end()) {
471 for (EdgeVector::const_iterator j = edges.begin(); j != edges.end(); ++j) {
482 if (visited.find(s) != visited.end()) {
489 toProc.push_back(std::make_pair(s, 0));
504 for (std::vector<std::string>::const_iterator it = ids.begin(); it != ids.end(); it++) {
508 WRITE_WARNING(
"Ignoring join exclusion for junction '" + *it +
"' since it already occured in a list of nodes to be joined");
509 }
else if (check &&
retrieve(*it) == 0) {
510 WRITE_WARNING(
"Ignoring join exclusion for unknown junction '" + *it +
"'");
521 for (std::set<std::string>::const_iterator it = cluster.begin(); it != cluster.end(); it++) {
523 WRITE_WARNING(
"Ignoring join-cluster because junction '" + *it +
"' was already excluded from joining");
525 }
else if (
myJoined.count(*it) > 0) {
526 WRITE_WARNING(
"Ignoring join-cluster because junction '" + *it +
"' already occured in another join-cluster");
541 std::set<NBNode*> cluster;
542 for (std::set<std::string>::iterator it_id = it->begin(); it_id != it->end(); it_id++) {
545 WRITE_WARNING(
"Ignoring unknown junction '" + *it_id +
"' while joining");
547 cluster.insert(node);
550 if (cluster.size() > 1) {
551 clusters.push_back(cluster);
556 return (
int)clusters.size();
565 for (NodeClusters::iterator i = cands.begin(); i != cands.end(); ++i) {
566 std::set<NBNode*> cluster = (*i);
568 for (std::set<NBNode*>::iterator j = cluster.begin(); j != cluster.end();) {
569 std::set<NBNode*>::iterator check = j;
572 cluster.erase(check);
576 bool pruneFringe =
true;
577 while (pruneFringe) {
579 for (std::set<NBNode*>::iterator j = cluster.begin(); j != cluster.end();) {
580 std::set<NBNode*>::iterator check = j;
585 double clusterDist = std::numeric_limits<double>::max();
587 NBNode* neighbor = (*it_edge)->getToNode();
588 if (cluster.count(neighbor) != 0) {
589 clusterDist =
MIN2(clusterDist, (*it_edge)->getLoadedLength());
593 NBNode* neighbor = (*it_edge)->getFromNode();
594 if (cluster.count(neighbor) != 0) {
595 clusterDist =
MIN2(clusterDist, (*it_edge)->getLoadedLength());
600 std::set<NBNode*> neighbors;
601 std::set<NBNode*> clusterNeigbors;
602 const double pedestrianFringeThreshold = 1.0;
604 NBNode* neighbor = (*it_edge)->getToNode();
605 if (cluster.count(neighbor) == 0) {
606 if ((*it_edge)->getPermissions() !=
SVC_PEDESTRIAN || clusterDist < pedestrianFringeThreshold) {
607 neighbors.insert(neighbor);
610 clusterNeigbors.insert(neighbor);
614 NBNode* neighbor = (*it_edge)->getFromNode();
615 if (cluster.count(neighbor) == 0) {
616 if ((*it_edge)->getPermissions() !=
SVC_PEDESTRIAN || clusterDist < pedestrianFringeThreshold) {
617 neighbors.insert(neighbor);
620 clusterNeigbors.insert(neighbor);
623 if (neighbors.size() <= 1 && clusterNeigbors.size() == 1) {
624 cluster.erase(check);
630 std::set<NBNode*> toRemove;
631 for (std::set<NBNode*>::iterator j = cluster.begin(); j != cluster.end(); ++j) {
634 for (EdgeVector::const_iterator it_edge = edges.begin(); it_edge != edges.end(); ++it_edge) {
643 for (std::set<NBNode*>::iterator j = toRemove.begin(); j != toRemove.end(); ++j) {
646 if (cluster.size() < 2) {
651 std::map<std::string, double> finalIncomingAngles;
652 std::map<std::string, double> finalOutgoingAngles;
653 std::vector<std::string> nodeIDs;
654 for (std::set<NBNode*>::const_iterator j = cluster.begin(); j != cluster.end(); ++j) {
655 nodeIDs.push_back((*j)->getID());
656 for (EdgeVector::const_iterator it_edge = (*j)->getIncomingEdges().begin(); it_edge != (*j)->getIncomingEdges().end(); ++it_edge) {
663 for (EdgeVector::const_iterator it_edge = (*j)->getOutgoingEdges().begin(); it_edge != (*j)->getOutgoingEdges().end(); ++it_edge) {
672 if (finalIncomingAngles.size() > 4) {
673 std::sort(nodeIDs.begin(), nodeIDs.end());
678 const double PARALLEL_INCOMING_THRESHOLD = 10.0;
679 bool foundParallel =
false;
680 for (std::map<std::string, double>::const_iterator j = finalIncomingAngles.begin(); j != finalIncomingAngles.end() && !foundParallel; ++j) {
681 std::map<std::string, double>::const_iterator k = j;
682 for (++k; k != finalIncomingAngles.end() && !foundParallel; ++k) {
683 if (fabs(j->second - k->second) < PARALLEL_INCOMING_THRESHOLD) {
685 + j->first +
"," + k->first +
")");
686 foundParallel =
true;
691 for (std::map<std::string, double>::const_iterator j = finalOutgoingAngles.begin(); j != finalOutgoingAngles.end() && !foundParallel; ++j) {
692 std::map<std::string, double>::const_iterator k = j;
693 for (++k; k != finalOutgoingAngles.end() && !foundParallel; ++k) {
694 if (fabs(j->second - k->second) < PARALLEL_INCOMING_THRESHOLD) {
696 + j->first +
"," + k->first +
")");
697 foundParallel =
true;
706 bool foundStop =
false;
707 for (
auto it = sc.
begin(); it != sc.
end(); it++) {
709 if (edge != 0 && cluster.count(edge->
getFromNode()) != 0 && cluster.count(edge->
getToNode()) != 0) {
721 for (std::set<NBNode*>::iterator j = cluster.begin(); j != cluster.end(); ++j) {
723 std::set<NBNode*> newComp;
726 newComp.insert(current);
727 for (NodeClusters::iterator it_comp = components.begin(); it_comp != components.end();) {
728 NodeClusters::iterator check = it_comp;
730 bool connected =
false;
731 for (std::set<NBNode*>::iterator k = (*check).begin(); k != (*check).end(); ++k) {
732 if (current->
getConnectionTo(*k) != 0 || (*k)->getConnectionTo(current) != 0) {
734 newComp.insert((*check).begin(), (*check).end());
735 it_comp = components.erase(check);
745 components.push_back(newComp);
747 for (NodeClusters::iterator it_comp = components.begin(); it_comp != components.end(); ++it_comp) {
748 if ((*it_comp).size() > 1) {
750 clusters.push_back(*it_comp);
755 return (
int)clusters.size();
762 for (NodeClusters::iterator i = clusters.begin(); i != clusters.end(); ++i) {
763 std::set<NBNode*> cluster = *i;
764 assert(cluster.size() > 1);
781 throw ProcessError(
"Could not allocate tls '" +
id +
"'.");
785 std::set<NBEdge*> allEdges;
786 for (std::set<NBNode*>::const_iterator j = cluster.begin(); j != cluster.end(); ++j) {
788 allEdges.insert(edges.begin(), edges.end());
792 for (std::set<NBEdge*>::iterator j = allEdges.begin(); j != allEdges.end();) {
796 if (cluster.count(from) > 0 && cluster.count(to) > 0) {
797 for (std::set<NBEdge*>::iterator l = allEdges.begin(); l != allEdges.end(); ++l) {
810 for (std::set<NBEdge*>::iterator j = allEdges.begin(); j != allEdges.end(); ++j) {
813 const bool outgoing = cluster.count(e->
getFromNode()) > 0;
819 for (std::vector<NBEdge::Connection>::iterator k = conns.begin(); k != conns.end(); ++k) {
829 for (std::set<NBNode*>::const_iterator j = cluster.begin(); j != cluster.end(); ++j) {
838 std::set<std::string> ids;
839 for (std::set<NBNode*>::const_iterator j = cluster.begin(); j != cluster.end(); j++) {
840 ids.insert((*j)->getID());
851 std::vector<std::string> member_ids;
852 bool ambiguousType =
false;
853 for (std::set<NBNode*>::const_iterator j = cluster.begin(); j != cluster.end(); j++) {
854 member_ids.push_back((*j)->getID());
855 pos.
add((*j)->getPosition());
857 if ((*j)->isTLControlled()) {
860 type = (*(*j)->getControllingTLS().begin())->getType();
861 }
else if (type != (*(*j)->getControllingTLS().begin())->getType()) {
862 ambiguousType =
true;
867 pos.
mul(1.0 / cluster.size());
869 sort(member_ids.begin(), member_ids.end());
870 for (std::vector<std::string>::iterator j = member_ids.begin(); j != member_ids.end(); j++) {
871 id =
id +
"_" + (*j);
875 WRITE_WARNING(
"Ambiguous traffic light type for node cluster '" +
id +
"' set to '" +
toString(type) +
"'");
885 bool tooFast =
false;
887 std::set<NBEdge*> seen;
888 for (std::set<NBNode*>::const_iterator j = c.begin(); j != c.end(); ++j) {
890 for (EdgeVector::const_iterator k = edges.begin(); k != edges.end(); ++k) {
891 if (c.find((*k)->getFromNode()) != c.end() && c.find((*k)->getToNode()) != c.end()) {
894 if ((*j)->hasIncoming(*k)) {
896 f += (double)(*k)->getNumLanes() * (*k)->getLaneSpeed(0);
900 if ((*k)->getLaneSpeed(0) * 3.6 > 79) {
905 return !tooFast && f >= 150. / 3.6 && c.size() != 0;
912 std::vector<NBNode*> ncontrolled;
913 if (oc.
isSet(
"tls.unset")) {
914 std::vector<std::string> notTLControlledNodes = oc.
getStringVector(
"tls.unset");
915 for (std::vector<std::string>::const_iterator i = notTLControlledNodes.begin(); i != notTLControlledNodes.end(); ++i) {
918 throw ProcessError(
" The junction '" + *i +
"' to set as not-controlled is not known.");
921 for (std::set<NBTrafficLightDefinition*>::const_iterator j = tls.begin(); j != tls.end(); ++j) {
925 ncontrolled.push_back(n);
932 if (oc.
exists(
"tls.taz-nodes") && oc.
getBool(
"tls.taz-nodes")) {
933 for (NodeCont::iterator i =
myNodes.begin(); i !=
myNodes.end(); i++) {
934 NBNode* cur = (*i).second;
935 if (cur->
isNearDistrict() && find(ncontrolled.begin(), ncontrolled.end(), cur) == ncontrolled.end()) {
943 if (oc.
exists(
"tls.guess-signals") && oc.
getBool(
"tls.guess-signals")) {
945 const double signalDist = oc.
getFloat(
"tls.guess-signals.dist");
946 for (std::map<std::string, NBNode*>::const_iterator i =
myNodes.begin(); i !=
myNodes.end(); ++i) {
947 NBNode* node = (*i).second;
950 for (EdgeVector::const_iterator it_o = outgoing.begin(); it_o != outgoing.end(); ++it_o) {
951 (*it_o)->setSignalOffset((*it_o)->getLength());
956 for (std::map<std::string, NBNode*>::const_iterator i =
myNodes.begin(); i !=
myNodes.end(); ++i) {
958 if (find(ncontrolled.begin(), ncontrolled.end(), node) != ncontrolled.end()) {
964 std::vector<NBNode*> signals;
966 for (EdgeVector::const_iterator it_i = incoming.begin(); it_i != incoming.end(); ++it_i) {
967 const NBEdge* inEdge = *it_i;
978 for (EdgeVector::const_iterator it_i = outgoing.begin(); it_i != outgoing.end(); ++it_i) {
979 const NBEdge* outEdge = *it_i;
982 signals.push_back(cand);
986 for (std::vector<NBNode*>::iterator j = signals.begin(); j != signals.end(); ++j) {
989 for (std::set<NBTrafficLightDefinition*>::iterator k = tls.begin(); k != tls.end(); ++k) {
1007 if (!oc.
getBool(
"tls.guess")) {
1014 std::vector<std::set<NBNode*> > cands;
1017 for (std::vector<std::set<NBNode*> >::iterator i = cands.begin(); i != cands.end();) {
1018 std::set<NBNode*>& c = (*i);
1021 for (std::set<NBNode*>::iterator j = c.begin(); j != c.end();) {
1022 if ((*j)->isTLControlled() || find(ncontrolled.begin(), ncontrolled.end(), *j) != ncontrolled.end()) {
1037 for (std::vector<std::set<NBNode*> >::iterator i = cands.begin(); i != cands.end(); ++i) {
1038 std::vector<NBNode*> nodes;
1039 for (std::set<NBNode*>::iterator j = (*i).begin(); j != (*i).end(); j++) {
1040 nodes.push_back(*j);
1042 std::string
id =
"joinedG_" +
toString(index++);
1044 if (!tlc.
insert(tlDef)) {
1054 for (NodeCont::iterator i =
myNodes.begin(); i !=
myNodes.end(); i++) {
1055 NBNode* cur = (*i).second;
1061 if (find(ncontrolled.begin(), ncontrolled.end(), cur) != ncontrolled.end()) {
1064 std::set<NBNode*> c;
1076 std::vector<std::set<NBNode*> > cands;
1079 for (std::vector<std::set<NBNode*> >::iterator i = cands.begin(); i != cands.end(); ++i) {
1080 std::set<NBNode*>& c = (*i);
1081 for (std::set<NBNode*>::iterator j = c.begin(); j != c.end();) {
1082 if (!(*j)->isTLControlled()) {
1094 std::string dummyId;
1097 for (std::set<NBNode*>::iterator j = c.begin(); j != c.end(); ++j) {
1098 std::set<NBTrafficLightDefinition*> tls = (*j)->getControllingTLS();
1099 (*j)->removeTrafficLights();
1100 for (std::set<NBTrafficLightDefinition*>::iterator k = tls.begin(); k != tls.end(); ++k) {
1104 std::string
id =
"joinedS_" +
toString(index++);
1105 std::vector<NBNode*> nodes;
1106 for (std::set<NBNode*>::iterator j = c.begin(); j != c.end(); j++) {
1107 nodes.push_back(*j);
1110 if (!tlc.
insert(tlDef)) {
1127 if (!tlc.
insert(tlDef)) {
1129 WRITE_WARNING(
"Building a tl-logic for junction '" +
id +
"' twice is not possible.");
1139 for (NodeCont::iterator i =
myNodes.begin(); i !=
myNodes.end(); i++) {
1140 (*i).second->computeLanes2Lanes();
1148 for (NodeCont::iterator i =
myNodes.begin(); i !=
myNodes.end(); i++) {
1149 (*i).second->computeLogic(ec, oc);
1156 for (NodeCont::iterator i =
myNodes.begin(); i !=
myNodes.end(); i++) {
1157 delete((*i).second);
1170 std::string freeID =
"SUMOGenerated" + toString<int>(counter);
1175 freeID =
"SUMOGenerated" + toString<int>(counter);
1183 for (NodeCont::iterator i =
myNodes.begin(); i !=
myNodes.end(); i++) {
1184 (*i).second->computeNodeShape(mismatchThreshold);
1191 int numUnregulatedJunctions = 0;
1192 int numDeadEndJunctions = 0;
1193 int numPriorityJunctions = 0;
1194 int numRightBeforeLeftJunctions = 0;
1195 int numAllWayStopJunctions = 0;
1196 int numZipperJunctions = 0;
1197 int numRailSignals = 0;
1198 for (NodeCont::const_iterator i =
myNodes.begin(); i !=
myNodes.end(); i++) {
1199 switch ((*i).second->getType()) {
1202 ++numUnregulatedJunctions;
1205 ++numDeadEndJunctions;
1212 ++numPriorityJunctions;
1215 ++numRightBeforeLeftJunctions;
1218 ++numAllWayStopJunctions;
1221 ++numZipperJunctions;
1224 ++numRightBeforeLeftJunctions;
1237 if (numDeadEndJunctions > 0) {
1242 if (numAllWayStopJunctions > 0) {
1245 if (numZipperJunctions > 0) {
1248 if (numRailSignals > 0) {
1254 std::vector<std::string>
1256 std::vector<std::string> ret;
1257 for (NodeCont::const_iterator i =
myNodes.begin(); i !=
myNodes.end(); ++i) {
1258 ret.push_back((*i).first);
1266 if (
myNodes.count(newID) != 0) {
1267 throw ProcessError(
"Attempt to rename node using existing id '" + newID +
"'");
1277 for (NodeCont::const_iterator i =
myNodes.begin(); i !=
myNodes.end(); ++i) {
1278 NBNode* node = i->second;
1285 for (EdgeVector::const_iterator it_o = outgoing.begin(); it_o != outgoing.end(); ++it_o) {
1286 (*it_o)->setSignalOffset((*it_o)->getLength());
1289 for (std::set<NBTrafficLightDefinition*>::const_iterator it = tldefs.begin(); it != tldefs.end(); ++it) {
1303 std::set<std::string> reserve;
1306 avoid.insert(avoid.end(), reserve.begin(), reserve.end());
1309 std::set<NBNode*, ComparatorIdLess> toChange;
1310 for (NodeCont::iterator it =
myNodes.begin(); it !=
myNodes.end(); it++) {
1315 toChange.insert(it->second);
1318 if (reservedIDs && reserve.count(it->first) > 0) {
1319 toChange.insert(it->second);
1323 for (std::set<NBNode*, ComparatorIdLess>::iterator it = toChange.begin(); it != toChange.end(); ++it) {
1332 return (
int)toChange.size();
std::string getFreeID()
generates a new node ID
std::set< std::string > myJoinExclusions
set of node ids which should not be joined
NodeCont myNodes
The map of names to nodes.
void Insert(const float a_min[2], const float a_max[2], Named *const &a_data)
Insert entry.
NBNode * retrieve(const std::string &id) const
Returns the node with the given name.
void joinSimilarEdges(NBDistrictCont &dc, NBEdgeCont &ec, NBTrafficLightLogicCont &tlc)
Joins edges connecting the same nodes.
double getLength() const
Returns the computed length of the edge.
void removeSelfLoops(NBDistrictCont &dc, NBEdgeCont &ec, NBTrafficLightLogicCont &tc)
Removes self-loop edges (edges where the source and the destination node are the same) ...
void registerJoinedCluster(const std::set< NBNode *> &cluster)
gets all joined clusters (see doc for myClusters2Join)
void addEdges2Keep(const OptionsCont &oc, std::set< std::string > &into)
add edges that must be kept
std::map< std::string, NBNode * >::const_iterator begin() const
Returns the pointer to the begin of the stored nodes.
void addJoinExclusion(const std::vector< std::string > &ids, bool check=false)
int removeUnwishedNodes(NBDistrictCont &dc, NBEdgeCont &ec, NBTrafficLightLogicCont &tlc, NBPTStopCont &sc, NBPTLineCont &lc, NBParkingCont &pc, bool removeGeometryNodes)
Removes "unwished" nodes.
static void loadPrefixedIDsFomFile(const std::string &file, const std::string prefix, std::set< std::string > &into)
Add prefixed ids defined in file.
void add(const Position &pos)
Adds the given position to this one.
void addEdges2Keep(const OptionsCont &oc, std::set< std::string > &into)
add edges that must be kept
void removeIsolatedRoads(NBDistrictCont &dc, NBEdgeCont &ec)
Removes sequences of edges that are not connected with a junction. Simple roads without junctions som...
A container for traffic light definitions and built programs.
void joinTLS(NBTrafficLightLogicCont &tlc, double maxdist)
Builds clusters of tls-controlled junctions and joins the control if possible.
void reinit(const Position &position, SumoXMLNodeType type, bool updateEdgeGeometries=false)
Resets initial values.
double getSignalOffset() const
Returns the offset of a traffic signal from the end of this edge.
std::vector< std::set< std::string > > myJoinedClusters
sets of node ids which were joined
double y() const
Returns the y-position.
The representation of a single edge during network building.
void reinitNodes(NBNode *from, NBNode *to)
Resets nodes but keeps all other values the same (used when joining)
static const double UNSPECIFIED_SIGNAL_OFFSET
unspecified signal offset
double x() const
Returns the x-position.
A container for districts.
The base class for traffic light logic definitions.
int joinLoadedClusters(NBDistrictCont &dc, NBEdgeCont &ec, NBTrafficLightLogicCont &tlc)
Joins loaded junction clusters (see NIXMLNodesHandler)
NamedRTree myRTree
node positions for faster lookup
static long long int _str2long(const std::string &sData)
converts a string into the long value described by it by calling the char-type converter, which
void guessTLs(OptionsCont &oc, NBTrafficLightLogicCont &tlc)
Guesses which junctions or junction clusters shall be controlled by tls.
std::map< std::string, NBEdge * >::const_iterator end() const
Returns the pointer to the end of the stored edges.
bool getBool(const std::string &name) const
Returns the boolean-value of the named option (only for Option_Bool)
bool connectionsDone
Whether connection information for this lane is already completed.
void avoidOverlap()
fix overlap
const std::string & getID() const
Returns the id.
Lane & getLaneStruct(int lane)
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 removeTrafficLight(NBTrafficLightDefinition *tlDef)
Removes the given traffic light from this node.
void extract(NBTrafficLightDefinition *definition)
Extracts a traffic light definition from myDefinitions but keeps it in myExtracted for eventual * del...
#define WRITE_WARNING(msg)
static OptionsCont & getOptions()
Retrieves the options.
const EdgeVector & getOutgoingEdges() const
Returns this node's outgoing edges (The edges which start at this node)
The edge has been loaded, nothing is computed yet.
void computeLogics(const NBEdgeCont &ec, OptionsCont &oc)
build the list of outgoing edges and lanes
A class representing a single district.
NBEdge * getConnectionTo(NBNode *n) const
get connection to certain node
bool isSet(const std::string &name, bool failOnNonExistant=true) const
Returns the information whether the named option is set.
void Remove(const float a_min[2], const float a_max[2], Named *const &a_data)
Remove entry.
bool isTLControlled() const
Returns whether this node is controlled by any tls.
int joinJunctions(double maxDist, NBDistrictCont &dc, NBEdgeCont &ec, NBTrafficLightLogicCont &tlc, NBPTStopCont &sc)
Joins junctions that are very close together.
bool shouldBeTLSControlled(const std::set< NBNode *> &c) const
Returns whethe the given node cluster should be controlled by a tls.
std::map< std::string, NBPTStop * >::const_iterator begin() const
Returns the pointer to the begin of the stored pt stops.
std::map< std::string, NBEdge * >::const_iterator begin() const
Returns the pointer to the begin of the stored edges.
std::string getNext()
Returns the next id.
void computeLanes2Lanes()
divides the incoming lanes on outgoing lanes
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
static StringBijection< TrafficLightType > TrafficLightTypes
traffic light types
void extract(NBDistrictCont &dc, NBEdge *edge, bool remember=false)
Removes the given edge from the container like erase but does not delete it.
int getNumLanes() const
Returns the number of lanes.
A point in 2D or 3D with translation and scaling methods.
std::pair< NBNode *, double > NodeAndDist
void generateNodeClusters(double maxDist, NodeClusters &into) const
Builds node clusters.
T get(const std::string &str) const
std::string getString(const std::string &name) const
Returns the string-value of the named option (only for Option_String)
const EdgeVector & getEdges() const
Returns all edges which participate in this node (Edges that start or end at this node) ...
bool exists(const std::string &name) const
Returns the information whether the named option is known.
void removeTrafficLights()
Removes all references to traffic lights that control this tls.
bool geometryLike() const
whether this is structurally similar to a geometry node
Storage for edges, including some functionality operating on multiple edges.
std::vector< std::string > getStringVector(const std::string &name) const
Returns the list of string-vector-value of the named option (only for Option_String) ...
void computeNodeShapes(double mismatchThreshold=-1)
Compute the junction shape for this node.
double getAngleAtNode(const NBNode *const node) const
Returns the angle of the edge's geometry at the given node.
void setParameter(const std::string &key, const std::string &value)
Sets a parameter.
void joinNodeClusters(NodeClusters clusters, NBDistrictCont &dc, NBEdgeCont &ec, NBTrafficLightLogicCont &tlc)
joins the given node clusters
std::set< NBNode * > myExtractedNodes
The extracted nodes which are kept for reference.
The connection was given by the user.
void addEdges2Keep(const OptionsCont &oc, std::set< std::string > &into)
add edges that must be kept
void analyzeCluster(std::set< NBNode *> cluster, std::string &id, Position &pos, bool &hasTLS, TrafficLightType &type)
int Search(const float a_min[2], const float a_max[2], const Named::StoringVisitor &c) const
Find all within search rectangle.
std::map< std::string, NBPTStop * >::const_iterator end() const
Returns the pointer to the end of the stored pt stops.
double getFloat(const std::string &name) const
Returns the double-value of the named option (only for Option_Float)
SVCPermissions getPermissions(int lane=-1) const
get the union of allowed classes over all lanes or for a specific lane
void rename(NBNode *node, const std::string &newID)
Renames the node. Throws exception if newID already exists.
bool hasIncoming(const NBEdge *const e) const
Returns whether the given edge ends at this node.
void joinSameNodeConnectingEdges(NBDistrictCont &dc, NBTrafficLightLogicCont &tlc, EdgeVector edges)
Joins the given edges because they connect the same nodes.
double getSpeed() const
Returns the speed allowed on this edge.
void setAsTLControlled(NBNode *node, NBTrafficLightLogicCont &tlc, TrafficLightType type, std::string id="")
Sets the given node as being controlled by a tls.
Allows to store the object; used as context while traveling the rtree in TraCI.
std::vector< std::string > getAllNames() const
get all node names
void setID(const std::string &newID)
resets the id
bool addLane2LaneConnection(int fromLane, NBEdge *dest, int toLane, Lane2LaneInfoType type, bool mayUseSameDestination=false, bool mayDefinitelyPass=false, bool keepClear=true, double contPos=UNSPECIFIED_CONTPOS, double visibility=UNSPECIFIED_VISIBILITY_DISTANCE, double speed=UNSPECIFIED_SPEED, const PositionVector &customShape=PositionVector::EMPTY)
Adds a connection between the specified this edge's lane and an approached one.
void addCluster2Join(std::set< std::string > cluster)
add ids of nodes which shall be joined into a single node
int remapIDs(bool numericaIDs, bool reservedIDs)
remap node IDs accoring to options –numerical-ids and –reserved-ids
const EdgeVector & getIncomingEdges() const
Returns this node's incoming edges (The edges which yield in this node)
const std::vector< Connection > & getConnections() const
Returns the connections.
void replaceIncoming(NBEdge *which, NBEdge *by, int laneOff)
Replaces occurences of the first edge within the list of incoming by the second Connections are remap...
bool isNearDistrict() const
if node is near district
const std::set< NBTrafficLightDefinition * > & getControllingTLS() const
Returns the traffic lights that were assigned to this node (The set of tls that control this node) ...
std::vector< NBEdge * > EdgeVector
container for (sorted) edges
NBEdge * retrieve(const std::string &id, bool retrieveExtracted=false) const
Returns the edge that has the given id.
std::set< std::string > myJoined
ids found in loaded join clusters used for error checking
A storage for options typed value containers)
std::vector< std::set< NBNode * > > NodeClusters
Definition of a node cluster container.
std::string joinToStringSorting(const std::vector< T > &v, const T_BETWEEN &between, std::streamsize accuracy=gPrecision)
void erase(NBDistrictCont &dc, NBEdge *edge)
Removes the given edge from the container (deleting it)
bool insert(const std::string &id, const Position &position, NBDistrict *district=0)
Inserts a node into the map.
void clear()
deletes all nodes
const std::string SUMO_PARAM_ORIGID
void append(NBEdge *continuation)
append another edge
std::vector< std::set< std::string > > myClusters2Join
loaded sets of node ids to join (cleared after use)
void discardTrafficLights(NBTrafficLightLogicCont &tlc, bool geometryLike, bool guessSignals)
void declareConnectionsAsLoaded(EdgeBuildingStep step=LANES2LANES_USER)
declares connections as fully loaded. This is needed to avoid recomputing connections if an edge has ...
const Position & getPosition() const
Represents a single node (junction) during network building.
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.
std::set< const NBNode * > mySplit
nodes that were created when splitting an edge
void printBuiltNodesStatistics() const
Prints statistics about built nodes.
NBNode * getFromNode() const
Returns the origin node of the edge.
void mul(double val)
Multiplies both positions with the given value.
void replaceRemoved(NBEdge *removed, int removedLane, NBEdge *by, int byLane)
Replaces occurences of the removed edge/lane in all definitions by the given edge.
A traffic light logics which must be computed (only nodes/edges are given)
double getLoadedLength() const
Returns the length was set explicitly or the computed length if it wasn't set.
bool extract(NBNode *node, bool remember=false)
Removes the given node but does not delete it.
#define WRITE_MESSAGE(msg)
bool erase(NBNode *node)
Removes the given node, deleting it.
bool checkIsRemovable() const
check if node is removable
std::vector< std::string > getAllNames() const
Returns all ids of known edges.
std::vector< std::pair< NBEdge *, NBEdge * > > getEdgesToJoin() const
get edges to join
bool isNearEnough2BeJoined2(NBEdge *e, double threshold) const
Check if edge is near enought to be joined to another edge.
NBNode * getToNode() const
Returns the destination node of the edge.
void removeComponents(NBDistrictCont &dc, NBEdgeCont &ec, const int numKeep)
Checks the network for weak connectivity and removes all but the largest components. The connectivity check is done regardless of edge direction and vclass.