61 #ifdef CHECK_MEMORY_LEAKS
63 #endif // CHECK_MEMORY_LEAKS
71 myVehicleClasses2Keep(0),
72 myVehicleClasses2Remove(0),
88 if (oc.
isSet(
"keep-edges.explicit")) {
89 const std::vector<std::string> edges = oc.
getStringVector(
"keep-edges.explicit");
92 if (oc.
isSet(
"remove-edges.explicit")) {
93 const std::vector<std::string> edges = oc.
getStringVector(
"remove-edges.explicit");
96 if (oc.
exists(
"keep-edges.by-vclass") && oc.
isSet(
"keep-edges.by-vclass")) {
97 const std::vector<std::string> classes = oc.
getStringVector(
"keep-edges.by-vclass");
98 for (std::vector<std::string>::const_iterator i = classes.begin(); i != classes.end(); ++i) {
102 if (oc.
exists(
"remove-edges.by-vclass") && oc.
isSet(
"remove-edges.by-vclass")) {
103 const std::vector<std::string> classes = oc.
getStringVector(
"remove-edges.by-vclass");
104 for (std::vector<std::string>::const_iterator i = classes.begin(); i != classes.end(); ++i) {
108 if (oc.
exists(
"keep-edges.by-type") && oc.
isSet(
"keep-edges.by-type")) {
109 const std::vector<std::string> types = oc.
getStringVector(
"keep-edges.by-type");
112 if (oc.
exists(
"remove-edges.by-type") && oc.
isSet(
"remove-edges.by-type")) {
113 const std::vector<std::string> types = oc.
getStringVector(
"remove-edges.by-type");
117 if (oc.
isSet(
"keep-edges.in-boundary") || oc.
isSet(
"keep-edges.in-geo-boundary")) {
119 "keep-edges.in-boundary" :
"keep-edges.in-geo-boundary");
121 std::vector<SUMOReal> poly;
122 for (std::vector<std::string>::iterator i = polyS.begin(); i != polyS.end(); ++i) {
125 if (poly.size() < 4) {
126 throw ProcessError(
"Invalid boundary: need at least 2 coordinates");
127 }
else if (poly.size() % 2 != 0) {
128 throw ProcessError(
"Invalid boundary: malformed coordinate");
129 }
else if (poly.size() == 4) {
136 for (std::vector<SUMOReal>::iterator j = poly.begin(); j != poly.end();) {
142 if (oc.
isSet(
"keep-edges.in-geo-boundary")) {
151 for (EdgeCont::iterator i =
myEdges.begin(); i !=
myEdges.end(); i++) {
179 if (oc.
exists(
"dismiss-vclasses") && oc.
getBool(
"dismiss-vclasses")) {
241 EdgeCont::const_iterator i =
myEdges.find(
id);
243 if (retrieveExtracted) {
270 hints.push_back(hintedge);
273 for (EdgeVector::iterator i = hints.begin(); i != hints.end(); i++) {
275 for (EdgeVector::iterator j = candidates.begin(); j != candidates.end(); j++) {
276 NBEdge* poss_searched = (*j);
278 ? poss_searched->
myTo : poss_searched->
myFrom;
281 if (find(cont.begin(), cont.end(), hintedge) != cont.end()) {
282 return poss_searched;
297 size_t maxLength = 0;
298 std::string tid =
id +
"[";
299 for (EdgeCont::const_iterator i =
myEdges.begin(); i !=
myEdges.end(); ++i) {
300 if ((*i).first.find(tid) == 0) {
301 maxLength =
MAX2(maxLength, (*i).first.length());
306 std::vector<std::string> names;
307 names.push_back(
id +
"[1]");
308 names.push_back(
id +
"[0]");
309 while (names.size() > 0) {
311 std::string cid = names.back();
317 if (cid.length() + 3 < maxLength) {
318 names.push_back(cid +
"[1]");
319 names.push_back(cid +
"[0]");
356 if (
myEdges.count(newID) != 0) {
357 throw ProcessError(
"Attempt to rename edge using existing id '" + newID +
"'");
375 const std::string& firstEdgeName,
376 const std::string& secondEdgeName,
377 unsigned int noLanesFirstEdge,
unsigned int noLanesSecondEdge) {
388 return splitAt(dc, edge, pos, node, firstEdgeName, secondEdgeName,
389 noLanesFirstEdge, noLanesSecondEdge);
396 const std::string& firstEdgeName,
397 const std::string& secondEdgeName,
398 unsigned int noLanesFirstEdge,
unsigned int noLanesSecondEdge) {
400 std::pair<PositionVector, PositionVector> geoms =
403 geoms.first.pop_back();
408 geoms.second.pop_front();
416 for (
unsigned int i = 0; i < noLanesFirstEdge && i < edge->
getNumLanes(); i++) {
423 for (
unsigned int i = 0; i < noLanesSecondEdge && i < edge->
getNumLanes(); i++) {
437 if (noLanesFirstEdge == noLanesSecondEdge - 1) {
438 for (
unsigned int i = 0; i < one->
getNumLanes(); i++) {
472 std::vector<std::string>
474 std::vector<std::string> ret;
475 for (EdgeCont::const_iterator i =
myEdges.begin(); i !=
myEdges.end(); ++i) {
476 ret.push_back((*i).first);
486 for (EdgeCont::iterator i =
myEdges.begin(); i !=
myEdges.end(); ++i) {
487 NBEdge* edge = (*i).second;
491 toRemove.push_back(edge);
494 for (EdgeVector::iterator j = toRemove.begin(); j != toRemove.end(); ++j) {
502 for (EdgeCont::iterator i =
myEdges.begin(); i !=
myEdges.end(); ++i) {
503 if ((*i).second->getGeometry().size() < 3) {
506 (*i).second->splitGeometry(*
this, nc);
513 for (EdgeCont::iterator i =
myEdges.begin(); i !=
myEdges.end(); ++i) {
514 (*i).second->reduceGeometry(minDist);
521 if (maxAngle > 0 || minRadius > 0) {
522 for (EdgeCont::iterator i =
myEdges.begin(); i !=
myEdges.end(); ++i) {
523 (*i).second->checkGeometry(maxAngle, minRadius, fix);
532 for (EdgeCont::const_iterator i =
myEdges.begin(); i !=
myEdges.end(); i++) {
533 (*i).second->clearControllingTLInformation();
540 for (EdgeCont::iterator i =
myEdges.begin(); i !=
myEdges.end(); i++) {
541 (*i).second->sortOutgoingConnectionsByAngle();
548 for (EdgeCont::iterator i =
myEdges.begin(); i !=
myEdges.end(); i++) {
549 (*i).second->computeEdge2Edges(noLeftMovers);
556 for (EdgeCont::iterator i =
myEdges.begin(); i !=
myEdges.end(); i++) {
557 (*i).second->computeLanes2Edges();
564 for (EdgeCont::iterator i =
myEdges.begin(); i !=
myEdges.end(); i++) {
565 (*i).second->recheckLanes();
572 for (EdgeCont::iterator i =
myEdges.begin(); i !=
myEdges.end(); i++) {
573 (*i).second->appendTurnaround(noTLSControlled);
580 for (std::set<std::string>::const_iterator it = ids.begin(); it != ids.end(); it++) {
581 myEdges[*it]->appendTurnaround(noTLSControlled);
588 for (EdgeCont::iterator i =
myEdges.begin(); i !=
myEdges.end(); i++) {
589 (*i).second->computeEdgeShape();
596 for (EdgeCont::iterator i =
myEdges.begin(); i !=
myEdges.end(); ++i) {
597 (*i).second->computeLaneShapes();
612 unsigned int nolanes = 0;
618 NBEdge* tpledge = *(edges.begin());
619 NBNode* from = tpledge->getFromNode();
620 NBNode* to = tpledge->getToNode();
621 EdgeVector::const_iterator i;
622 for (i = edges.begin(); i != edges.end(); i++) {
624 assert((*i)->getFromNode() == from);
625 assert((*i)->getToNode() == to);
627 nolanes += (*i)->getNumLanes();
629 if (i != edges.begin()) {
634 speed += (*i)->getSpeed();
636 priority =
MAX2(priority, (*i)->getPriority());
638 speed /= edges.size();
642 NBEdge* newEdge =
new NBEdge(
id, from, to,
"", speed, nolanes, priority,
644 tpledge->getStreetName(), tpledge->myLaneSpreadFunction);
652 for (i = edges.begin(); i != edges.end(); i++) {
654 for (EdgeVector::iterator j = ev.begin(); j != ev.end(); j++) {
659 unsigned int currLane = 0;
660 for (i = edges.begin(); i != edges.end(); i++) {
662 currLane += (*i)->getNumLanes();
666 for (i = edges.begin(); i != edges.end(); i++) {
667 unsigned int noLanes = (*i)->getNumLanes();
668 for (
unsigned int j = 0; j < noLanes; j++, currLane++) {
674 for (i = edges.begin(); i != edges.end(); i++) {
682 for (EdgeCont::iterator i =
myEdges.begin(); i !=
myEdges.end(); ++i) {
683 std::string oppositeID;
684 if ((*i).first[0] ==
'-') {
685 oppositeID = (*i).first.substr(1);
687 oppositeID =
"-" + (*i).first;
712 if (from != 0 && to != 0) {
714 WRITE_WARNING(
"Could not insert connection between '" + (*i).from +
"' and '" + (*i).to +
"' after build.");
720 for (EdgeCont::iterator it =
myEdges.begin(); it !=
myEdges.end(); ++it) {
721 NBEdge* edge = it->second;
724 std::vector<NBEdge::Connection> connections = edge->
getConnections();
725 for (std::vector<NBEdge::Connection>::iterator it_con = connections.begin(); it_con != connections.end(); ++it_con) {
739 size_t len =
id.length();
741 for (EdgeCont::const_iterator i =
myEdges.begin(); i !=
myEdges.end(); ++i) {
742 std::string curr = (*i).first;
745 if (curr.length() <= len) {
750 if (curr.substr(0, len) ==
id && curr[len] ==
'[') {
751 ret.push_back((*i).second);
755 size_t pos = curr.find(
id);
757 if (pos == std::string::npos) {
762 if (curr[pos - 1] !=
']' && curr[pos - 1] !=
'+') {
767 if (pos +
id.length() < curr.length()) {
768 if (curr[pos +
id.length()] !=
'[' && curr[pos +
id.length()] !=
'+') {
773 ret.push_back((*i).second);
782 std::set<NBEdge*> candidates;
783 for (EdgeCont::const_iterator i =
myEdges.begin(); i !=
myEdges.end(); ++i) {
787 candidates.insert(e);
792 std::set<NBEdge*> visited;
793 for (std::set<NBEdge*>::const_iterator i = candidates.begin(); i != candidates.end(); ++i) {
800 if (visited.count(e) > 0) {
804 loopEdges.push_back(e);
809 if (edges.size() < 2) {
818 EdgeVector::const_iterator me = find(edges.begin(), edges.end(), e);
827 EdgeVector::const_iterator loopClosed = find(loopEdges.begin(), loopEdges.end(), left);
828 const size_t loopSize = loopEdges.end() - loopClosed;
833 }
else if (loopSize < loopEdges.size()) {
835 EdgeVector(loopEdges.begin() + (loopEdges.size() - loopSize), loopEdges.end()).swap(loopEdges);
839 for (EdgeVector::const_iterator j = loopEdges.begin(); j != loopEdges.end(); ++j) {
840 if ((*j)->getToNode()->getEdges().size() > 2) {
844 if (attachments < 3) {
849 if (visited.count(left) > 0) {
853 loopEdges.push_back(left);
859 std::set<NBEdge*> loopEdgesSet(loopEdges.begin(), loopEdges.end());
860 for (std::set<NBEdge*>::const_iterator j = loopEdgesSet.begin(); j != loopEdgesSet.end(); ++j) {
862 NBNode* node = (*j)->getToNode();
864 for (EdgeVector::const_iterator k = incoming.begin(); k != incoming.end(); ++k) {
866 if (loopEdgesSet.count(inEdge) > 0) {
875 (*j)->setJunctionPriority(node, 1000);
877 marked.push_back(loopEdges);
885 for (EdgeCont::iterator i =
myEdges.begin(); i !=
myEdges.end(); ++i) {