61 #ifdef CHECK_MEMORY_LEAKS
63 #endif // CHECK_MEMORY_LEAKS
72 myVehicleClasses2Keep(0),
73 myVehicleClasses2Remove(0),
74 myNeedGeoTransformedPrunningBoundary(false)
89 if (oc.
isSet(
"keep-edges.explicit")) {
90 const std::vector<std::string> edges = oc.
getStringVector(
"keep-edges.explicit");
93 if (oc.
isSet(
"remove-edges.explicit")) {
94 const std::vector<std::string> edges = oc.
getStringVector(
"remove-edges.explicit");
97 if (oc.
exists(
"keep-edges.by-vclass") && oc.
isSet(
"keep-edges.by-vclass")) {
98 const std::vector<std::string> classes = oc.
getStringVector(
"keep-edges.by-vclass");
99 for (std::vector<std::string>::const_iterator i = classes.begin(); i != classes.end(); ++i) {
103 if (oc.
exists(
"remove-edges.by-vclass") && oc.
isSet(
"remove-edges.by-vclass")) {
104 const std::vector<std::string> classes = oc.
getStringVector(
"remove-edges.by-vclass");
105 for (std::vector<std::string>::const_iterator i = classes.begin(); i != classes.end(); ++i) {
109 if (oc.
exists(
"keep-edges.by-type") && oc.
isSet(
"keep-edges.by-type")) {
110 const std::vector<std::string> types = oc.
getStringVector(
"keep-edges.by-type");
113 if (oc.
exists(
"remove-edges.by-type") && oc.
isSet(
"remove-edges.by-type")) {
114 const std::vector<std::string> types = oc.
getStringVector(
"remove-edges.by-type");
118 if (oc.
isSet(
"keep-edges.in-boundary") || oc.
isSet(
"keep-edges.in-geo-boundary")) {
120 "keep-edges.in-boundary" :
"keep-edges.in-geo-boundary");
122 std::vector<SUMOReal> poly;
123 for (std::vector<std::string>::iterator i = polyS.begin(); i != polyS.end(); ++i) {
126 if (poly.size() < 4) {
127 throw ProcessError(
"Invalid boundary: need at least 2 coordinates");
128 }
else if (poly.size() % 2 != 0) {
129 throw ProcessError(
"Invalid boundary: malformed coordinate");
130 }
else if (poly.size() == 4) {
137 for (std::vector<SUMOReal>::iterator j = poly.begin(); j != poly.end();) {
150 for (EdgeCont::iterator i =
myEdges.begin(); i !=
myEdges.end(); i++) {
178 if (oc.
exists(
"dismiss-vclasses") && oc.
getBool(
"dismiss-vclasses")) {
236 WRITE_ERROR(
"Cannot prune edges using a geo-boundary because no projection has been loaded");
252 EdgeCont::const_iterator i =
myEdges.find(
id);
254 if (retrieveExtracted) {
271 while (candidates->size() == 1) {
272 const std::string& nextID = candidates->front()->getID();
273 if (nextID.find(
id) != 0 || nextID.size() <=
id.size() + 1 || (nextID[
id.size()] !=
'.' && nextID[
id.size()] !=
'-')) {
276 edge = candidates->front();
297 hints.push_back(hintedge);
300 for (EdgeVector::iterator i = hints.begin(); i != hints.end(); i++) {
302 for (EdgeVector::iterator j = candidates.begin(); j != candidates.end(); j++) {
303 NBEdge* poss_searched = (*j);
305 ? poss_searched->
myTo : poss_searched->
myFrom;
308 if (find(cont.begin(), cont.end(), hintedge) != cont.end()) {
309 return poss_searched;
324 size_t maxLength = 0;
325 std::string tid =
id +
"[";
326 for (EdgeCont::const_iterator i =
myEdges.begin(); i !=
myEdges.end(); ++i) {
327 if ((*i).first.find(tid) == 0) {
328 maxLength =
MAX2(maxLength, (*i).first.length());
333 std::vector<std::string> names;
334 names.push_back(
id +
"[1]");
335 names.push_back(
id +
"[0]");
336 while (names.size() > 0) {
338 std::string cid = names.back();
344 if (cid.length() + 3 < maxLength) {
345 names.push_back(cid +
"[1]");
346 names.push_back(cid +
"[0]");
383 if (
myEdges.count(newID) != 0) {
384 throw ProcessError(
"Attempt to rename edge using existing id '" + newID +
"'");
402 const std::string& firstEdgeName,
403 const std::string& secondEdgeName,
404 unsigned int noLanesFirstEdge,
unsigned int noLanesSecondEdge) {
415 return splitAt(dc, edge, pos, node, firstEdgeName, secondEdgeName,
416 noLanesFirstEdge, noLanesSecondEdge);
423 const std::string& firstEdgeName,
424 const std::string& secondEdgeName,
425 unsigned int noLanesFirstEdge,
unsigned int noLanesSecondEdge) {
427 std::pair<PositionVector, PositionVector> geoms =
430 geoms.first.pop_back();
435 geoms.second.pop_front();
443 for (
unsigned int i = 0; i < noLanesFirstEdge && i < edge->
getNumLanes(); i++) {
450 for (
unsigned int i = 0; i < noLanesSecondEdge && i < edge->
getNumLanes(); i++) {
464 if (noLanesFirstEdge == noLanesSecondEdge - 1) {
465 for (
unsigned int i = 0; i < one->
getNumLanes(); i++) {
499 std::vector<std::string>
501 std::vector<std::string> ret;
502 for (EdgeCont::const_iterator i =
myEdges.begin(); i !=
myEdges.end(); ++i) {
503 ret.push_back((*i).first);
513 for (EdgeCont::iterator i =
myEdges.begin(); i !=
myEdges.end(); ++i) {
514 NBEdge* edge = (*i).second;
518 toRemove.push_back(edge);
521 for (EdgeVector::iterator j = toRemove.begin(); j != toRemove.end(); ++j) {
529 for (EdgeCont::iterator i =
myEdges.begin(); i !=
myEdges.end(); ++i) {
530 if ((*i).second->getGeometry().size() < 3) {
533 (*i).second->splitGeometry(*
this, nc);
540 for (EdgeCont::iterator i =
myEdges.begin(); i !=
myEdges.end(); ++i) {
541 (*i).second->reduceGeometry(minDist);
548 if (maxAngle > 0 || minRadius > 0) {
549 for (EdgeCont::iterator i =
myEdges.begin(); i !=
myEdges.end(); ++i) {
550 (*i).second->checkGeometry(maxAngle, minRadius, fix);
559 for (EdgeCont::const_iterator i =
myEdges.begin(); i !=
myEdges.end(); i++) {
560 (*i).second->clearControllingTLInformation();
567 for (EdgeCont::iterator i =
myEdges.begin(); i !=
myEdges.end(); i++) {
568 (*i).second->sortOutgoingConnectionsByAngle();
575 for (EdgeCont::iterator i =
myEdges.begin(); i !=
myEdges.end(); i++) {
576 (*i).second->computeEdge2Edges(noLeftMovers);
583 for (EdgeCont::iterator i =
myEdges.begin(); i !=
myEdges.end(); i++) {
584 (*i).second->computeLanes2Edges();
591 for (EdgeCont::iterator i =
myEdges.begin(); i !=
myEdges.end(); i++) {
592 (*i).second->recheckLanes();
599 for (EdgeCont::iterator i =
myEdges.begin(); i !=
myEdges.end(); i++) {
600 (*i).second->appendTurnaround(noTLSControlled);
607 for (std::set<std::string>::const_iterator it = ids.begin(); it != ids.end(); it++) {
608 myEdges[*it]->appendTurnaround(noTLSControlled);
615 for (EdgeCont::iterator i =
myEdges.begin(); i !=
myEdges.end(); i++) {
616 (*i).second->computeEdgeShape();
623 for (EdgeCont::iterator i =
myEdges.begin(); i !=
myEdges.end(); ++i) {
624 (*i).second->computeLaneShapes();
639 unsigned int nolanes = 0;
645 NBEdge* tpledge = *(edges.begin());
646 NBNode* from = tpledge->getFromNode();
647 NBNode* to = tpledge->getToNode();
648 EdgeVector::const_iterator i;
649 for (i = edges.begin(); i != edges.end(); i++) {
651 assert((*i)->getFromNode() == from);
652 assert((*i)->getToNode() == to);
654 nolanes += (*i)->getNumLanes();
656 if (i != edges.begin()) {
661 speed += (*i)->getSpeed();
663 priority =
MAX2(priority, (*i)->getPriority());
665 speed /= edges.size();
669 NBEdge* newEdge =
new NBEdge(
id, from, to,
"", speed, nolanes, priority,
671 tpledge->getStreetName(), tpledge->myLaneSpreadFunction);
679 for (i = edges.begin(); i != edges.end(); i++) {
681 for (EdgeVector::iterator j = ev.begin(); j != ev.end(); j++) {
686 unsigned int currLane = 0;
687 for (i = edges.begin(); i != edges.end(); i++) {
689 currLane += (*i)->getNumLanes();
693 for (i = edges.begin(); i != edges.end(); i++) {
694 unsigned int noLanes = (*i)->getNumLanes();
695 for (
unsigned int j = 0; j < noLanes; j++, currLane++) {
701 for (i = edges.begin(); i != edges.end(); i++) {
709 for (EdgeCont::iterator i =
myEdges.begin(); i !=
myEdges.end(); ++i) {
710 std::string oppositeID;
711 if ((*i).first[0] ==
'-') {
712 oppositeID = (*i).first.substr(1);
714 oppositeID =
"-" + (*i).first;
739 if (from != 0 && to != 0) {
741 WRITE_WARNING(
"Could not insert connection between '" + (*i).from +
"' and '" + (*i).to +
"' after build.");
747 for (EdgeCont::iterator it =
myEdges.begin(); it !=
myEdges.end(); ++it) {
748 NBEdge* edge = it->second;
751 std::vector<NBEdge::Connection> connections = edge->
getConnections();
752 for (std::vector<NBEdge::Connection>::iterator it_con = connections.begin(); it_con != connections.end(); ++it_con) {
766 size_t len =
id.length();
768 for (EdgeCont::const_iterator i =
myEdges.begin(); i !=
myEdges.end(); ++i) {
769 std::string curr = (*i).first;
772 if (curr.length() <= len) {
777 if (curr.substr(0, len) ==
id && curr[len] ==
'[') {
778 ret.push_back((*i).second);
782 size_t pos = curr.find(
id);
784 if (pos == std::string::npos) {
789 if (curr[pos - 1] !=
']' && curr[pos - 1] !=
'+') {
794 if (pos +
id.length() < curr.length()) {
795 if (curr[pos +
id.length()] !=
'[' && curr[pos +
id.length()] !=
'+') {
800 ret.push_back((*i).second);
809 std::set<NBEdge*> candidates;
810 for (EdgeCont::const_iterator i =
myEdges.begin(); i !=
myEdges.end(); ++i) {
814 candidates.insert(e);
819 std::set<NBEdge*> visited;
820 for (std::set<NBEdge*>::const_iterator i = candidates.begin(); i != candidates.end(); ++i) {
827 if (visited.count(e) > 0) {
831 loopEdges.push_back(e);
836 if (edges.size() < 2) {
845 EdgeVector::const_iterator me = find(edges.begin(), edges.end(), e);
854 EdgeVector::const_iterator loopClosed = find(loopEdges.begin(), loopEdges.end(), left);
855 const size_t loopSize = loopEdges.end() - loopClosed;
860 }
else if (loopSize < loopEdges.size()) {
862 EdgeVector(loopEdges.begin() + (loopEdges.size() - loopSize), loopEdges.end()).swap(loopEdges);
866 for (EdgeVector::const_iterator j = loopEdges.begin(); j != loopEdges.end(); ++j) {
867 if ((*j)->getToNode()->getEdges().size() > 2) {
871 if (attachments < 3) {
876 if (visited.count(left) > 0) {
880 loopEdges.push_back(left);
886 std::set<NBEdge*> loopEdgesSet(loopEdges.begin(), loopEdges.end());
887 for (std::set<NBEdge*>::const_iterator j = loopEdgesSet.begin(); j != loopEdgesSet.end(); ++j) {
889 NBNode* node = (*j)->getToNode();
891 for (EdgeVector::const_iterator k = incoming.begin(); k != incoming.end(); ++k) {
893 if (loopEdgesSet.count(inEdge) > 0) {
902 (*j)->setJunctionPriority(node, 1000);
905 marked.push_back(loopEdges);
913 for (EdgeCont::iterator i =
myEdges.begin(); i !=
myEdges.end(); ++i) {