79 NodeCont::iterator i =
myNodes.find(
id);
85 const float pos[2] = {(float)position.
x(), (float)position.
y()};
93 std::string
id = node->
getID();
94 NodeCont::iterator i =
myNodes.find(
id);
107 NodeCont::const_iterator i =
myNodes.find(
id);
118 const float cmin[2] = {(float)(position.
x() - extOffset), (
float)(position.
y() - extOffset)};
119 const float cmax[2] = {(float)(position.
x() + extOffset), (
float)(position.
y() + extOffset)};
120 std::set<std::string> into;
123 for (std::set<std::string>::const_iterator i = into.begin(); i != into.end(); i++) {
167 for (NodeCont::iterator i =
myNodes.begin(); i !=
myNodes.end(); i++) {
168 no += (*i).second->removeSelfLoops(dc, ec, tc);
179 const double distanceThreshold = 7.;
180 const double lengthThreshold = 0.10;
182 for (NodeCont::iterator i =
myNodes.begin(); i !=
myNodes.end(); i++) {
184 std::map<NBNode*, EdgeVector> connectionCount;
185 const EdgeVector& outgoing = (*i).second->getOutgoingEdges();
186 for (EdgeVector::const_iterator j = outgoing.begin(); j != outgoing.end(); j++) {
187 connectionCount[(*j)->getToNode()].push_back(*j);
190 std::map<NBNode*, EdgeVector>::iterator k;
191 for (k = connectionCount.begin(); k != connectionCount.end(); k++) {
193 if ((*k).second.size() < 2) {
199 const NBEdge*
const first = ev.front();
200 EdgeVector::const_iterator jci;
201 for (jci = ev.begin() + 1; jci != ev.end(); ++jci) {
204 (relativeLengthDifference > lengthThreshold) ||
205 (fabs(first->
getSpeed() - (*jci)->getSpeed()) >= 0.01) ||
213 if (jci == ev.end()) {
224 const std::vector<std::string>& edgeNames = ec.
getAllNames();
225 for (std::vector<std::string>::const_iterator it = edgeNames.begin(); it != edgeNames.end(); ++it) {
234 if (outgoingEdges.size() != 1) {
239 if (incomingEdges.size() > 1) {
242 }
else if (incomingEdges.size() == 1) {
243 NBNode* fromNodeOfIncomingEdge = incomingEdges[0]->getFromNode();
244 NBNode* toNodeOfOutgoingEdge = outgoingEdges[0]->getToNode();
245 if (fromNodeOfIncomingEdge != toNodeOfOutgoingEdge) {
253 bool hasJunction =
false;
257 std::set<NBNode*> adjacentNodes;
265 adjacentNodes.clear();
266 for (EdgeVector::const_iterator itOfOutgoings = outgoingEdgesOfToNode.begin(); itOfOutgoings != outgoingEdgesOfToNode.end(); ++itOfOutgoings) {
267 if ((*itOfOutgoings)->getToNode() != from
268 && (*itOfOutgoings)->getToNode() != to
272 adjacentNodes.insert((*itOfOutgoings)->getToNode());
274 for (EdgeVector::const_iterator itOfIncomings = incomingEdgesOfToNode.begin(); itOfIncomings != incomingEdgesOfToNode.end(); ++itOfIncomings) {
275 adjacentNodes.insert((*itOfIncomings)->getFromNode());
277 adjacentNodes.erase(to);
278 if (adjacentNodes.size() > 2) {
281 }
while (!hasJunction && eOld != e);
283 std::string warningString =
"Removed a road without junctions: ";
284 for (EdgeVector::iterator roadIt = road.begin(); roadIt != road.end(); ++roadIt) {
285 if (roadIt == road.begin()) {
286 warningString += (*roadIt)->
getID();
288 warningString +=
", " + (*roadIt)->getID();
291 NBNode* fromNode = (*roadIt)->getFromNode();
292 NBNode* toNode = (*roadIt)->getToNode();
293 ec.
erase(dc, *roadIt);
311 std::vector<std::set<NBEdge*> > components;
312 std::set<NBEdge*> edgesLeft;
313 for (std::map<std::string, NBEdge*>::const_iterator edgeIt = ec.
begin(); edgeIt != ec.
end(); ++edgeIt) {
314 edgesLeft.insert(edgeIt->second);
317 std::set<NBEdge*> toRemove;
318 while (!edgesLeft.empty()) {
319 queue.push_back(*edgesLeft.begin());
320 std::set<NBEdge*> component;
321 while (!queue.empty()) {
322 NBEdge*
const e = queue.back();
325 std::vector<EdgeVector> edgeLists;
330 for (std::vector<EdgeVector>::const_iterator listIt = edgeLists.begin(); listIt != edgeLists.end(); ++listIt) {
331 for (EdgeVector::const_iterator edgeIt = listIt->begin(); edgeIt != listIt->end(); ++edgeIt) {
332 std::set<NBEdge*>::iterator leftIt = edgesLeft.find(*edgeIt);
333 if (leftIt != edgesLeft.end()) {
334 queue.push_back(*edgeIt);
335 edgesLeft.erase(leftIt);
340 std::vector<std::set<NBEdge*> >::iterator cIt;
341 for (cIt = components.begin(); cIt != components.end(); ++cIt) {
342 if (cIt->size() < component.size()) {
346 components.insert(cIt, component);
347 if ((
int)components.size() > numKeep) {
348 toRemove.insert(components.back().begin(), components.back().end());
349 components.pop_back();
352 for (std::set<NBEdge*>::iterator edgeIt = toRemove.begin(); edgeIt != toRemove.end(); ++edgeIt) {
353 NBNode*
const fromNode = (*edgeIt)->getFromNode();
354 NBNode*
const toNode = (*edgeIt)->getToNode();
355 ec.
erase(dc, *edgeIt);
369 bool removeGeometryNodes) {
371 std::set<std::string> edges2keep;
372 if (removeGeometryNodes) {
374 if (oc.
isSet(
"geometry.remove.keep-edges.input-file")) {
377 if (oc.
isSet(
"geometry.remove.keep-edges.explicit")) {
378 const std::vector<std::string> edges = oc.
getStringVector(
"geometry.remove.keep-edges.explicit");
379 edges2keep.insert(edges.begin(), edges.end());
383 std::vector<NBNode*> toRemove;
384 for (NodeCont::iterator i =
myNodes.begin(); i !=
myNodes.end(); i++) {
385 NBNode* current = (*i).second;
387 std::vector<std::pair<NBEdge*, NBEdge*> > toJoin;
394 if (removeGeometryNodes &&
mySplit.count(current) == 0) {
402 for (EdgeVector::const_iterator it_edge = current->
getEdges().begin(); it_edge != current->
getEdges().end(); ++it_edge) {
403 if (edges2keep.find((*it_edge)->getID()) != edges2keep.end()) {
417 for (std::vector<std::pair<NBEdge*, NBEdge*> >::iterator j = toJoin.begin(); j != toJoin.end(); j++) {
419 NBEdge* continuation = (*j).second;
420 begin->
append(continuation);
423 ec.
extract(dc, continuation,
true);
425 toRemove.push_back(current);
429 for (std::vector<NBNode*>::iterator j = toRemove.begin(); j != toRemove.end(); ++j) {
438 for (NodeCont::iterator i =
myNodes.begin(); i !=
myNodes.end(); i++) {
439 (*i).second->avoidOverlap();
446 std::set<NBNode*> visited;
447 for (NodeCont::const_iterator i =
myNodes.begin(); i !=
myNodes.end(); i++) {
448 std::vector<NodeAndDist> toProc;
449 if (visited.find((*i).second) != visited.end()) {
452 toProc.push_back(std::make_pair((*i).second, 0));
454 while (!toProc.empty()) {
456 NBNode* n = nodeAndDist.first;
457 double dist = nodeAndDist.second;
459 if (visited.find(n) != visited.end()) {
465 for (EdgeVector::const_iterator j = edges.begin(); j != edges.end(); ++j) {
476 if (visited.find(s) != visited.end()) {
483 toProc.push_back(std::make_pair(s, 0));
498 for (std::vector<std::string>::const_iterator it = ids.begin(); it != ids.end(); it++) {
502 WRITE_WARNING(
"Ignoring join exclusion for junction '" + *it +
"' since it already occured in a list of nodes to be joined");
503 }
else if (check &&
retrieve(*it) == 0) {
504 WRITE_WARNING(
"Ignoring join exclusion for unknown junction '" + *it +
"'");
515 for (std::set<std::string>::const_iterator it = cluster.begin(); it != cluster.end(); it++) {
517 WRITE_WARNING(
"Ignoring join-cluster because junction '" + *it +
"' was already excluded from joining");
519 }
else if (
myJoined.count(*it) > 0) {
520 WRITE_WARNING(
"Ignoring join-cluster because junction '" + *it +
"' already occured in another join-cluster");
535 std::set<NBNode*> cluster;
536 for (std::set<std::string>::iterator it_id = it->begin(); it_id != it->end(); it_id++) {
539 WRITE_WARNING(
"Ignoring unknown junction '" + *it_id +
"' while joining");
541 cluster.insert(node);
544 if (cluster.size() > 1) {
545 clusters.push_back(cluster);
550 return (
int)clusters.size();
559 for (NodeClusters::iterator i = cands.begin(); i != cands.end(); ++i) {
560 std::set<NBNode*> cluster = (*i);
562 for (std::set<NBNode*>::iterator j = cluster.begin(); j != cluster.end();) {
563 std::set<NBNode*>::iterator check = j;
566 cluster.erase(check);
570 bool pruneFringe =
true;
571 while (pruneFringe) {
573 for (std::set<NBNode*>::iterator j = cluster.begin(); j != cluster.end();) {
574 std::set<NBNode*>::iterator check = j;
581 NBNode* neighbor = (*it_edge)->getToNode();
582 if (cluster.count(neighbor) != 0) {
583 clusterDist =
MIN2(clusterDist, (*it_edge)->getLoadedLength());
587 NBNode* neighbor = (*it_edge)->getFromNode();
588 if (cluster.count(neighbor) != 0) {
589 clusterDist =
MIN2(clusterDist, (*it_edge)->getLoadedLength());
594 std::set<NBNode*> neighbors;
595 std::set<NBNode*> clusterNeigbors;
596 const double pedestrianFringeThreshold = 1.0;
598 NBNode* neighbor = (*it_edge)->getToNode();
599 if (cluster.count(neighbor) == 0) {
600 if ((*it_edge)->getPermissions() !=
SVC_PEDESTRIAN || clusterDist < pedestrianFringeThreshold) {
601 neighbors.insert(neighbor);
604 clusterNeigbors.insert(neighbor);
608 NBNode* neighbor = (*it_edge)->getFromNode();
609 if (cluster.count(neighbor) == 0) {
610 if ((*it_edge)->getPermissions() !=
SVC_PEDESTRIAN || clusterDist < pedestrianFringeThreshold) {
611 neighbors.insert(neighbor);
614 clusterNeigbors.insert(neighbor);
617 if (neighbors.size() <= 1 && clusterNeigbors.size() == 1) {
618 cluster.erase(check);
624 std::set<NBNode*> toRemove;
625 for (std::set<NBNode*>::iterator j = cluster.begin(); j != cluster.end(); ++j) {
628 for (EdgeVector::const_iterator it_edge = edges.begin(); it_edge != edges.end(); ++it_edge) {
637 for (std::set<NBNode*>::iterator j = toRemove.begin(); j != toRemove.end(); ++j) {
640 if (cluster.size() < 2) {
645 std::map<std::string, double> finalIncomingAngles;
646 std::map<std::string, double> finalOutgoingAngles;
647 std::vector<std::string> nodeIDs;
648 for (std::set<NBNode*>::const_iterator j = cluster.begin(); j != cluster.end(); ++j) {
649 nodeIDs.push_back((*j)->getID());
650 for (EdgeVector::const_iterator it_edge = (*j)->getIncomingEdges().begin(); it_edge != (*j)->getIncomingEdges().end(); ++it_edge) {
657 for (EdgeVector::const_iterator it_edge = (*j)->getOutgoingEdges().begin(); it_edge != (*j)->getOutgoingEdges().end(); ++it_edge) {
666 if (finalIncomingAngles.size() > 4) {
667 std::sort(nodeIDs.begin(), nodeIDs.end());
672 const double PARALLEL_INCOMING_THRESHOLD = 10.0;
673 bool foundParallel =
false;
674 for (std::map<std::string, double>::const_iterator j = finalIncomingAngles.begin(); j != finalIncomingAngles.end() && !foundParallel; ++j) {
675 std::map<std::string, double>::const_iterator k = j;
676 for (++k; k != finalIncomingAngles.end() && !foundParallel; ++k) {
677 if (fabs(j->second - k->second) < PARALLEL_INCOMING_THRESHOLD) {
679 + j->first +
"," + k->first +
")");
680 foundParallel =
true;
685 for (std::map<std::string, double>::const_iterator j = finalOutgoingAngles.begin(); j != finalOutgoingAngles.end() && !foundParallel; ++j) {
686 std::map<std::string, double>::const_iterator k = j;
687 for (++k; k != finalOutgoingAngles.end() && !foundParallel; ++k) {
688 if (fabs(j->second - k->second) < PARALLEL_INCOMING_THRESHOLD) {
690 + j->first +
"," + k->first +
")");
691 foundParallel =
true;
701 for (std::set<NBNode*>::iterator j = cluster.begin(); j != cluster.end(); ++j) {
703 std::set<NBNode*> newComp;
706 newComp.insert(current);
707 for (NodeClusters::iterator it_comp = components.begin(); it_comp != components.end();) {
708 NodeClusters::iterator check = it_comp;
710 bool connected =
false;
711 for (std::set<NBNode*>::iterator k = (*check).begin(); k != (*check).end(); ++k) {
712 if (current->
getConnectionTo(*k) != 0 || (*k)->getConnectionTo(current) != 0) {
714 newComp.insert((*check).begin(), (*check).end());
715 it_comp = components.erase(check);
725 components.push_back(newComp);
727 for (NodeClusters::iterator it_comp = components.begin(); it_comp != components.end(); ++it_comp) {
728 if ((*it_comp).size() > 1) {
730 clusters.push_back(*it_comp);
735 return (
int)clusters.size();
742 for (NodeClusters::iterator i = clusters.begin(); i != clusters.end(); ++i) {
743 std::set<NBNode*> cluster = *i;
744 assert(cluster.size() > 1);
761 throw ProcessError(
"Could not allocate tls '" +
id +
"'.");
765 std::set<NBEdge*> allEdges;
766 for (std::set<NBNode*>::const_iterator j = cluster.begin(); j != cluster.end(); ++j) {
768 allEdges.insert(edges.begin(), edges.end());
772 for (std::set<NBEdge*>::iterator j = allEdges.begin(); j != allEdges.end();) {
776 if (cluster.count(from) > 0 && cluster.count(to) > 0) {
777 for (std::set<NBEdge*>::iterator l = allEdges.begin(); l != allEdges.end(); ++l) {
790 for (std::set<NBEdge*>::iterator j = allEdges.begin(); j != allEdges.end(); ++j) {
793 const bool outgoing = cluster.count(e->
getFromNode()) > 0;
799 for (std::vector<NBEdge::Connection>::iterator k = conns.begin(); k != conns.end(); ++k) {
809 for (std::set<NBNode*>::const_iterator j = cluster.begin(); j != cluster.end(); ++j) {
818 std::set<std::string> ids;
819 for (std::set<NBNode*>::const_iterator j = cluster.begin(); j != cluster.end(); j++) {
820 ids.insert((*j)->getID());
831 std::vector<std::string> member_ids;
832 bool ambiguousType =
false;
833 for (std::set<NBNode*>::const_iterator j = cluster.begin(); j != cluster.end(); j++) {
834 member_ids.push_back((*j)->getID());
835 pos.
add((*j)->getPosition());
837 if ((*j)->isTLControlled()) {
840 type = (*(*j)->getControllingTLS().begin())->getType();
841 }
else if (type != (*(*j)->getControllingTLS().begin())->getType()) {
842 ambiguousType =
true;
847 pos.
mul(1.0 / cluster.size());
849 sort(member_ids.begin(), member_ids.end());
850 for (std::vector<std::string>::iterator j = member_ids.begin(); j != member_ids.end(); j++) {
851 id =
id +
"_" + (*j);
855 WRITE_WARNING(
"Ambiguous traffic light type for node cluster '" +
id +
"' set to '" +
toString(type) +
"'");
865 bool tooFast =
false;
867 std::set<NBEdge*> seen;
868 for (std::set<NBNode*>::const_iterator j = c.begin(); j != c.end(); ++j) {
870 for (EdgeVector::const_iterator k = edges.begin(); k != edges.end(); ++k) {
871 if (c.find((*k)->getFromNode()) != c.end() && c.find((*k)->getToNode()) != c.end()) {
874 if ((*j)->hasIncoming(*k)) {
876 f += (double)(*k)->getNumLanes() * (*k)->getLaneSpeed(0);
880 if ((*k)->getLaneSpeed(0) * 3.6 > 79) {
885 return !tooFast && f >= 150. / 3.6 && c.size() != 0;
892 std::vector<NBNode*> ncontrolled;
893 if (oc.
isSet(
"tls.unset")) {
894 std::vector<std::string> notTLControlledNodes = oc.
getStringVector(
"tls.unset");
895 for (std::vector<std::string>::const_iterator i = notTLControlledNodes.begin(); i != notTLControlledNodes.end(); ++i) {
898 throw ProcessError(
" The junction '" + *i +
"' to set as not-controlled is not known.");
901 for (std::set<NBTrafficLightDefinition*>::const_iterator j = tls.begin(); j != tls.end(); ++j) {
905 ncontrolled.push_back(n);
912 if (oc.
exists(
"tls.taz-nodes") && oc.
getBool(
"tls.taz-nodes")) {
913 for (NodeCont::iterator i =
myNodes.begin(); i !=
myNodes.end(); i++) {
914 NBNode* cur = (*i).second;
915 if (cur->
isNearDistrict() && find(ncontrolled.begin(), ncontrolled.end(), cur) == ncontrolled.end()) {
923 if (oc.
exists(
"tls.guess-signals") && oc.
getBool(
"tls.guess-signals")) {
925 const double signalDist = oc.
getFloat(
"tls.guess-signals.dist");
926 for (std::map<std::string, NBNode*>::const_iterator i =
myNodes.begin(); i !=
myNodes.end(); ++i) {
927 NBNode* node = (*i).second;
930 for (EdgeVector::const_iterator it_o = outgoing.begin(); it_o != outgoing.end(); ++it_o) {
931 (*it_o)->setSignalOffset((*it_o)->getLength());
936 for (std::map<std::string, NBNode*>::const_iterator i =
myNodes.begin(); i !=
myNodes.end(); ++i) {
938 if (find(ncontrolled.begin(), ncontrolled.end(), node) != ncontrolled.end()) {
944 std::vector<NBNode*> signals;
946 for (EdgeVector::const_iterator it_i = incoming.begin(); it_i != incoming.end(); ++it_i) {
947 const NBEdge* inEdge = *it_i;
958 for (EdgeVector::const_iterator it_i = outgoing.begin(); it_i != outgoing.end(); ++it_i) {
959 const NBEdge* outEdge = *it_i;
962 signals.push_back(cand);
966 for (std::vector<NBNode*>::iterator j = signals.begin(); j != signals.end(); ++j) {
969 for (std::set<NBTrafficLightDefinition*>::iterator k = tls.begin(); k != tls.end(); ++k) {
987 if (!oc.
getBool(
"tls.guess")) {
994 std::vector<std::set<NBNode*> > cands;
997 for (std::vector<std::set<NBNode*> >::iterator i = cands.begin(); i != cands.end();) {
998 std::set<NBNode*>& c = (*i);
1001 for (std::set<NBNode*>::iterator j = c.begin(); j != c.end();) {
1002 if ((*j)->isTLControlled() || find(ncontrolled.begin(), ncontrolled.end(), *j) != ncontrolled.end()) {
1017 for (std::vector<std::set<NBNode*> >::iterator i = cands.begin(); i != cands.end(); ++i) {
1018 std::vector<NBNode*> nodes;
1019 for (std::set<NBNode*>::iterator j = (*i).begin(); j != (*i).end(); j++) {
1020 nodes.push_back(*j);
1022 std::string
id =
"joinedG_" +
toString(index++);
1024 if (!tlc.
insert(tlDef)) {
1034 for (NodeCont::iterator i =
myNodes.begin(); i !=
myNodes.end(); i++) {
1035 NBNode* cur = (*i).second;
1041 if (find(ncontrolled.begin(), ncontrolled.end(), cur) != ncontrolled.end()) {
1044 std::set<NBNode*> c;
1056 std::vector<std::set<NBNode*> > cands;
1059 for (std::vector<std::set<NBNode*> >::iterator i = cands.begin(); i != cands.end(); ++i) {
1060 std::set<NBNode*>& c = (*i);
1061 for (std::set<NBNode*>::iterator j = c.begin(); j != c.end();) {
1062 if (!(*j)->isTLControlled()) {
1074 std::string dummyId;
1077 for (std::set<NBNode*>::iterator j = c.begin(); j != c.end(); ++j) {
1078 std::set<NBTrafficLightDefinition*> tls = (*j)->getControllingTLS();
1079 (*j)->removeTrafficLights();
1080 for (std::set<NBTrafficLightDefinition*>::iterator k = tls.begin(); k != tls.end(); ++k) {
1084 std::string
id =
"joinedS_" +
toString(index++);
1085 std::vector<NBNode*> nodes;
1086 for (std::set<NBNode*>::iterator j = c.begin(); j != c.end(); j++) {
1087 nodes.push_back(*j);
1090 if (!tlc.
insert(tlDef)) {
1107 if (!tlc.
insert(tlDef)) {
1109 WRITE_WARNING(
"Building a tl-logic for junction '" +
id +
"' twice is not possible.");
1119 for (NodeCont::iterator i =
myNodes.begin(); i !=
myNodes.end(); i++) {
1120 (*i).second->computeLanes2Lanes();
1128 for (NodeCont::iterator i =
myNodes.begin(); i !=
myNodes.end(); i++) {
1129 (*i).second->computeLogic(ec, oc);
1136 for (NodeCont::iterator i =
myNodes.begin(); i !=
myNodes.end(); i++) {
1137 delete((*i).second);
1150 std::string freeID =
"SUMOGenerated" + toString<int>(counter);
1155 freeID =
"SUMOGenerated" + toString<int>(counter);
1163 for (NodeCont::iterator i =
myNodes.begin(); i !=
myNodes.end(); i++) {
1164 (*i).second->computeNodeShape(mismatchThreshold);
1171 int numUnregulatedJunctions = 0;
1172 int numDeadEndJunctions = 0;
1173 int numPriorityJunctions = 0;
1174 int numRightBeforeLeftJunctions = 0;
1175 int numAllWayStopJunctions = 0;
1176 int numZipperJunctions = 0;
1177 int numRailSignals = 0;
1178 for (NodeCont::const_iterator i =
myNodes.begin(); i !=
myNodes.end(); i++) {
1179 switch ((*i).second->getType()) {
1182 ++numUnregulatedJunctions;
1185 ++numDeadEndJunctions;
1192 ++numPriorityJunctions;
1195 ++numRightBeforeLeftJunctions;
1198 ++numAllWayStopJunctions;
1201 ++numZipperJunctions;
1204 ++numRightBeforeLeftJunctions;
1217 if (numDeadEndJunctions > 0) {
1222 if (numAllWayStopJunctions > 0) {
1225 if (numZipperJunctions > 0) {
1228 if (numRailSignals > 0) {
1234 std::vector<std::string>
1236 std::vector<std::string> ret;
1237 for (NodeCont::const_iterator i =
myNodes.begin(); i !=
myNodes.end(); ++i) {
1238 ret.push_back((*i).first);
1246 if (
myNodes.count(newID) != 0) {
1247 throw ProcessError(
"Attempt to rename node using existing id '" + newID +
"'");
1257 for (NodeCont::const_iterator i =
myNodes.begin(); i !=
myNodes.end(); ++i) {
1258 NBNode* node = i->second;
1265 for (EdgeVector::const_iterator it_o = outgoing.begin(); it_o != outgoing.end(); ++it_o) {
1266 (*it_o)->setSignalOffset((*it_o)->getLength());
1269 for (std::set<NBTrafficLightDefinition*>::const_iterator it = tldefs.begin(); it != tldefs.end(); ++it) {
1283 std::set<std::string> reserve;
1286 avoid.insert(avoid.end(), reserve.begin(), reserve.end());
1289 std::set<NBNode*, Named::ComparatorIdLess> toChange;
1290 for (NodeCont::iterator it =
myNodes.begin(); it !=
myNodes.end(); it++) {
1295 toChange.insert(it->second);
1298 if (reservedIDs && reserve.count(it->first) > 0) {
1299 toChange.insert(it->second);
1302 for (std::set<NBNode*, Named::ComparatorIdLess>::iterator it = toChange.begin(); it != toChange.end(); ++it) {
1308 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.
void joinSimilarEdges(NBDistrictCont &dc, NBEdgeCont &ec, NBTrafficLightLogicCont &tlc)
Joins edges connecting the same nodes.
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) ...
const EdgeVector & getIncomingEdges() const
Returns this node's incoming edges (The edges which yield in this node)
void removeSelfLoops(NBDistrictCont &dc, NBEdgeCont &ec, NBTrafficLightLogicCont &tc)
Removes self-loop edges (edges where the source and the destination node are the same) ...
std::vector< std::string > getAllNames() const
Returns all ids of known edges.
void addJoinExclusion(const std::vector< std::string > &ids, bool check=false)
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.
double getAngleAtNode(const NBNode *const node) const
Returns the angle of the edge's geometry at the given node.
int removeUnwishedNodes(NBDistrictCont &dc, NBEdgeCont &ec, NBTrafficLightLogicCont &tlc, bool removeGeometryNodes)
Removes "unwished" nodes.
void removeIsolatedRoads(NBDistrictCont &dc, NBEdgeCont &ec)
Removes sequences of edges that are not connected with a junction. Simple roads without junctions som...
bool isNearEnough2BeJoined2(NBEdge *e, double threshold) const
Check if edge is near enought to be joined to another edge.
double getLoadedLength() const
Returns the length was set explicitly or the computed length if it wasn't set.
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.
bool isTLControlled() const
Returns whether this node is controlled by any tls.
double getFloat(const std::string &name) const
Returns the double-value of the named option (only for Option_Float)
double x() const
Returns the x-position.
std::vector< std::set< std::string > > myJoinedClusters
sets of node ids which were joined
bool getBool(const std::string &name) const
Returns the boolean-value of the named option (only for Option_Bool)
The representation of a single edge during network building.
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
A container for districts.
The base class for traffic light logic definitions.
double getSignalOffset() const
Returns the offset of a traffic signal from the end of this edge.
int joinLoadedClusters(NBDistrictCont &dc, NBEdgeCont &ec, NBTrafficLightLogicCont &tlc)
Joins loaded junction clusters (see NIXMLNodesHandler)
NamedRTree myRTree
node positions for faster lookup
double getSpeed() const
Returns the speed allowed on this edge.
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.
bool connectionsDone
Whether connection information for this lane is already completed.
void avoidOverlap()
fix overlap
bool checkIsRemovable() const
check if node is removable
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...
bool hasIncoming(const NBEdge *const e) const
Returns whether the given edge ends at this node.
#define WRITE_WARNING(msg)
static OptionsCont & getOptions()
Retrieves the options.
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.
std::string getString(const std::string &name) const
Returns the string-value of the named option (only for Option_String)
const EdgeVector & getOutgoingEdges() const
Returns this node's outgoing edges (The edges which start at this node)
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.
const Position & getPosition() const
void generateNodeClusters(double maxDist, NodeClusters &into) const
Builds node clusters.
std::map< std::string, NBEdge * >::const_iterator end() const
Returns the pointer to the end of the stored edges.
std::string getNext()
Returns the next id.
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 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.
A point in 2D or 3D with translation and scaling methods.
std::pair< NBNode *, double > NodeAndDist
double y() const
Returns the y-position.
bool geometryLike() const
whether this is structurally similar to a geometry node
int getNumLanes() const
Returns the number of lanes.
void removeTrafficLights()
Removes all references to traffic lights that control this tls.
const EdgeVector & getEdges() const
Returns all edges which participate in this node (Edges that start or end at this node) ...
Storage for edges, including some functionality operating on multiple edges.
void computeNodeShapes(double mismatchThreshold=-1)
Compute the junction shape for this node.
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.
int joinJunctions(double maxDist, NBDistrictCont &dc, NBEdgeCont &ec, NBTrafficLightLogicCont &tlc)
Joins junctions that are very close together.
std::vector< std::string > getAllNames() const
get all node names
The connection was given by the user.
NBEdge * getConnectionTo(NBNode *n) const
get connection to certain node
bool shouldBeTLSControlled(const std::set< NBNode * > &c) const
Returns whethe 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.
std::vector< std::pair< NBEdge *, NBEdge * > > getEdgesToJoin() const
get edges to join
void joinSameNodeConnectingEdges(NBDistrictCont &dc, NBTrafficLightLogicCont &tlc, EdgeVector edges)
Joins the given edges because they connect the same nodes.
std::map< std::string, NBEdge * >::const_iterator begin() const
Returns the pointer to the begin of the stored edges.
SVCPermissions getPermissions(int lane=-1) const
get the union of allowed classes over all lanes or for a specific lane
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.
NBNode * getToNode() const
Returns the destination node of the edge.
double getLength() const
Returns the computed length of the edge.
bool isNearDistrict() const
if node is near district
void setID(const std::string &newID)
resets the id
NBEdge * retrieve(const std::string &id, bool retrieveExtracted=false) const
Returns the edge that has the given id.
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
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...
std::vector< NBEdge * > EdgeVector
container for (sorted) edges
void analyzeCluster(std::set< NBNode * > cluster, std::string &id, Position &pos, bool &hasTLS, TrafficLightType &type)
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
void append(NBEdge *continuation)
append another edge
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)
Adds a connection between the specified this edge's lane and an approached one.
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 ...
Represents a single node (junction) during network building.
T get(const std::string &str) const
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
NBNode * retrieve(const std::string &id) const
Returns the node with the given name.
void mul(double val)
Multiplies both positions with the given value.
void printBuiltNodesStatistics() const
Prints statistics about built nodes.
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)
bool extract(NBNode *node, bool remember=false)
Removes the given node but does not delete it.
int Search(const float a_min[2], const float a_max[2], const Named::StoringVisitor &c) const
Find all within search rectangle.
#define WRITE_MESSAGE(msg)
bool erase(NBNode *node)
Removes the given node, deleting it.
const std::vector< Connection > & getConnections() const
Returns the connections.
std::map< std::string, NBNode * >::const_iterator begin() const
Returns the pointer to the begin of the stored nodes.
bool exists(const std::string &name) const
Returns the information whether the named option is known.
bool isSet(const std::string &name, bool failOnNonExistant=true) const
Returns the information whether the named option is set.
void registerJoinedCluster(const std::set< NBNode * > &cluster)
gets all joined clusters (see doc for myClusters2Join)
NBNode * getFromNode() const
Returns the origin 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.