 |
Eclipse SUMO - Simulation of Urban MObility
|
Go to the documentation of this file.
53 #define DEBUG_EDGE_ID "301241681#2"
61 myVehicleClasses2Keep(0),
62 myVehicleClasses2Remove(0),
63 myNeedGeoTransformedPruningBoundary(false) {
78 if (oc.
isSet(
"keep-edges.input-file")) {
81 if (oc.
isSet(
"remove-edges.input-file")) {
84 if (oc.
isSet(
"keep-edges.explicit")) {
85 const std::vector<std::string> edges = oc.
getStringVector(
"keep-edges.explicit");
88 if (oc.
isSet(
"remove-edges.explicit")) {
89 const std::vector<std::string> edges = oc.
getStringVector(
"remove-edges.explicit");
92 if (oc.
exists(
"keep-edges.by-vclass") && oc.
isSet(
"keep-edges.by-vclass")) {
95 if (oc.
exists(
"remove-edges.by-vclass") && oc.
isSet(
"remove-edges.by-vclass")) {
98 if (oc.
exists(
"keep-edges.by-type") && oc.
isSet(
"keep-edges.by-type")) {
99 const std::vector<std::string> types = oc.
getStringVector(
"keep-edges.by-type");
102 if (oc.
exists(
"remove-edges.by-type") && oc.
isSet(
"remove-edges.by-type")) {
103 const std::vector<std::string> types = oc.
getStringVector(
"remove-edges.by-type");
107 if (oc.
isSet(
"keep-edges.in-boundary") || oc.
isSet(
"keep-edges.in-geo-boundary")) {
109 "keep-edges.in-boundary" :
"keep-edges.in-geo-boundary");
111 std::vector<double> poly;
112 for (std::vector<std::string>::iterator i = polyS.begin(); i != polyS.end(); ++i) {
115 if (poly.size() < 4) {
116 throw ProcessError(
"Invalid boundary: need at least 2 coordinates");
117 }
else if (poly.size() % 2 != 0) {
118 throw ProcessError(
"Invalid boundary: malformed coordinate");
119 }
else if (poly.size() == 4) {
126 for (std::vector<double>::iterator j = poly.begin(); j != poly.end();) {
139 for (EdgeCont::iterator i =
myEdges.begin(); i !=
myEdges.end(); i++) {
140 delete ((*i).second);
144 delete ((*i).second);
164 if (oc.
exists(
"dismiss-vclasses") && oc.
getBool(
"dismiss-vclasses")) {
230 WRITE_ERROR(
"Cannot prune edges using a geo-boundary because no projection has been loaded");
247 EdgeCont::const_iterator i =
myEdges.find(
id);
249 if (retrieveExtracted) {
284 if (edge !=
nullptr) {
288 if ((
retrieve(
id +
"[0]") !=
nullptr) && (
retrieve(
id +
"[1]") !=
nullptr)) {
290 if (downstream ==
true) {
304 if (edge !=
nullptr) {
311 if (hintedge ==
nullptr) {
314 hints.push_back(hintedge);
317 for (EdgeVector::iterator i = hints.begin(); i != hints.end(); i++) {
319 for (EdgeVector::iterator j = candidates.begin(); j != candidates.end(); j++) {
320 NBEdge* poss_searched = (*j);
322 ? poss_searched->
myTo : poss_searched->
myFrom;
325 if (find(cont.begin(), cont.end(), hintedge) != cont.end()) {
326 return poss_searched;
338 if (edge !=
nullptr) {
342 std::string tid =
id +
"[";
343 for (EdgeCont::const_iterator i =
myEdges.begin(); i !=
myEdges.end(); ++i) {
344 if ((*i).first.find(tid) == 0) {
345 maxLength =
MAX2(maxLength, (
int)(*i).first.length());
350 std::vector<std::string> names;
351 names.push_back(
id +
"[1]");
352 names.push_back(
id +
"[0]");
353 while (names.size() > 0) {
355 std::string cid = names.back();
360 if (edge ==
nullptr) {
361 if ((
int)cid.length() + 3 < maxLength) {
362 names.push_back(cid +
"[1]");
363 names.push_back(cid +
"[0]");
400 if (
myEdges.count(newID) != 0) {
401 throw ProcessError(
"Attempt to rename edge using existing id '" + newID +
"'");
414 if (splits.size() == 0) {
417 const std::string origID = e->
getID();
418 std::vector<Split>::iterator i;
422 for (i = splits.begin(); i != splits.end(); ++i) {
423 sort((*i).lanes.begin(), (*i).lanes.end());
424 noLanesMax =
MAX2(noLanesMax, (
int)(*i).lanes.size());
427 std::vector<int> currLanes;
429 currLanes.push_back(l);
431 if (e->
getNumLanes() != (
int)splits.back().lanes.size()) {
439 std::string firstID =
"";
441 for (i = splits.begin(); i != splits.end(); ++i) {
442 const Split& exp = *i;
443 assert(exp.
lanes.size() != 0);
456 WRITE_WARNING(
"Error on parsing a split (edge '" + origID +
"').");
459 std::vector<int> newLanes = exp.
lanes;
465 int rightMostP = currLanes[0];
466 int rightMostN = newLanes[0];
467 for (
int l = 0; l < (int) rightMostP - (
int) rightMostN; ++l) {
471 int leftMostP = currLanes.back();
472 int leftMostN = newLanes.back();
473 for (
int l = 0; l < (int) leftMostN - (
int) leftMostP; ++l) {
477 for (
int l = 0; l < noLanesMax; ++l) {
478 if (find(currLanes.begin(), currLanes.end(), l) == currLanes.end()) {
481 if (find(newLanes.begin(), newLanes.end(), l) == newLanes.end()) {
492 in->invalidateConnections(
true);
497 currLanes = newLanes;
498 }
else if (exp.
pos == 0) {
500 if (laneCountDiff < 0) {
505 currLanes = exp.
lanes;
515 if (splits.front().pos != 0) {
519 for (
int lane = 0; lane < (int)e->
getNumLanes(); ++lane) {
520 start.
lanes.push_back(lane);
522 start.
offset = splits.front().offset;
524 splits.insert(splits.begin(), start);
528 for (; i != splits.end(); ++i) {
529 int maxLeft = (*i).lanes.back();
530 double offset = (*i).offset;
531 if (maxLeft < noLanesMax) {
538 int maxRight = (*i).lanes.front();
565 const std::string& firstEdgeName,
566 const std::string& secondEdgeName,
567 int noLanesFirstEdge,
int noLanesSecondEdge,
569 const int changedLeft) {
580 return splitAt(dc, edge, pos, node, firstEdgeName, secondEdgeName,
581 noLanesFirstEdge, noLanesSecondEdge, speed, changedLeft);
588 const std::string& firstEdgeName,
589 const std::string& secondEdgeName,
590 int noLanesFirstEdge,
int noLanesSecondEdge,
592 const int changedLeft
595 assert(changedLeft > -((
int)noLanesFirstEdge));
596 assert(changedLeft < (
int)noLanesSecondEdge);
599 std::pair<PositionVector, PositionVector> geoms =
602 NBEdge* one =
new NBEdge(firstEdgeName, edge->
myFrom, node, edge, geoms.first, noLanesFirstEdge);
603 NBEdge* two =
new NBEdge(secondEdgeName, node, edge->
myTo, edge, geoms.second, noLanesSecondEdge);
606 if (firstEdgeName != origID) {
609 if (secondEdgeName != origID) {
622 for (std::set<NBTrafficLightDefinition*>::iterator i = fromTLS.begin(); i != fromTLS.end(); ++i) {
623 (*i)->replaceRemoved(edge, -1, one, -1);
626 for (std::set<NBTrafficLightDefinition*>::iterator i = toTLS.begin(); i != toTLS.end(); ++i) {
627 (*i)->replaceRemoved(edge, -1, two, -1);
638 for (
int i2 = 0; i2 < (int)two->
getNumLanes(); i2++) {
657 const std::string oldID = edge->
getID();
660 WRITE_ERROR(
"Could not insert edge '" + one->
getID() +
"' before split of edge '" + oldID +
"'");
663 WRITE_ERROR(
"Could not insert edge '" + two->
getID() +
"' after split of edge '" + oldID +
"'");
672 std::set<EdgeSet> addLater;
673 for (std::set<EdgeSet>::iterator it = roundabouts.begin(); it != roundabouts.end(); ++it) {
675 if (roundaboutSet.count(orig) > 0) {
676 roundaboutSet.erase(orig);
677 roundaboutSet.insert(part1);
678 roundaboutSet.insert(part2);
680 addLater.insert(roundaboutSet);
683 roundabouts.insert(addLater.begin(), addLater.end());
688 std::vector<std::string>
690 std::vector<std::string> ret;
691 for (EdgeCont::const_iterator i =
myEdges.begin(); i !=
myEdges.end(); ++i) {
692 ret.push_back((*i).first);
702 for (EdgeCont::iterator i =
myEdges.begin(); i !=
myEdges.end(); ++i) {
703 NBEdge* edge = (*i).second;
707 toRemove.push_back(edge);
710 for (EdgeVector::iterator j = toRemove.begin(); j != toRemove.end(); ++j) {
720 for (
auto& item : edges) {
721 NBEdge* edge = item.second;
726 const std::string
id = edge->
getID();
728 for (
int i = 1; i < (int)geom.size() - 1; i++) {
729 offset += geom[i - 1].distanceTo(geom[i]);
730 std::string nodeID =
id +
"." +
toString((
int)offset);
731 if (!nc.
insert(nodeID, geom[i])) {
745 for (EdgeCont::iterator i =
myEdges.begin(); i !=
myEdges.end(); ++i) {
746 (*i).second->reduceGeometry(minDist);
753 if (maxAngle > 0 || minRadius > 0) {
758 item.second->checkGeometry(maxAngle, minRadius, fix || (fixRailways &&
isRailway(item.second->getPermissions())), silent);
767 for (EdgeCont::const_iterator i =
myEdges.begin(); i !=
myEdges.end(); i++) {
768 (*i).second->clearControllingTLInformation();
775 for (EdgeCont::iterator i =
myEdges.begin(); i !=
myEdges.end(); i++) {
776 (*i).second->sortOutgoingConnectionsByAngle();
783 for (EdgeCont::iterator i =
myEdges.begin(); i !=
myEdges.end(); i++) {
784 (*i).second->computeEdge2Edges(noLeftMovers);
791 for (EdgeCont::iterator i =
myEdges.begin(); i !=
myEdges.end(); i++) {
792 (*i).second->computeLanes2Edges();
800 for (EdgeCont::iterator i =
myEdges.begin(); i !=
myEdges.end(); i++) {
805 const std::string& oppositeID = edge->
getLanes().back().oppositeID;
806 if (oppositeID !=
"" && oppositeID !=
"-") {
807 NBEdge* oppEdge =
retrieve(oppositeID.substr(0, oppositeID.rfind(
"_")));
809 WRITE_WARNING(
"Removing unknown opposite lane '" + oppositeID +
"' for edge '" + edge->
getID() +
"'.");
814 if (fixOppositeLengths) {
828 WRITE_ERROR(
"Opposite lane '" + oppositeID +
"' does not connect the same nodes as edge '" + edge->
getID() +
"'!");
839 for (EdgeCont::iterator i =
myEdges.begin(); i !=
myEdges.end(); i++) {
840 (*i).second->appendTurnaround(noTLSControlled, onlyDeadends, noGeometryLike,
true);
847 for (std::set<std::string>::const_iterator it = ids.begin(); it != ids.end(); it++) {
848 myEdges[*it]->appendTurnaround(noTLSControlled,
false,
false,
false);
855 std::set<std::string> stopEdgeIDs;
856 for (
auto& stopItem : sc.
getStops()) {
857 stopEdgeIDs.insert(stopItem.second->getEdgeId());
860 NBEdge* edge = item.second;
862 && (stopEdgeIDs.count(item.first) > 0 ||
876 for (EdgeCont::iterator i =
myEdges.begin(); i !=
myEdges.end(); i++) {
877 (*i).second->computeEdgeShape(smoothElevationThreshold);
880 for (EdgeCont::iterator i =
myEdges.begin(); i !=
myEdges.end(); i++) {
882 const std::string& oppositeID = edge->
getLanes().back().oppositeID;
883 if (oppositeID !=
"" && oppositeID !=
"-") {
884 NBEdge* oppEdge =
retrieve(oppositeID.substr(0, oppositeID.rfind(
"_")));
900 for (EdgeCont::iterator i =
myEdges.begin(); i !=
myEdges.end(); ++i) {
901 (*i).second->computeLaneShapes();
922 NBEdge* tpledge = *(edges.begin());
925 EdgeVector::const_iterator i;
926 for (i = edges.begin(); i != edges.end(); i++) {
928 assert((*i)->getFromNode() == from);
929 assert((*i)->getToNode() == to);
931 nolanes += (*i)->getNumLanes();
933 if (i != edges.begin()) {
938 speed += (*i)->getSpeed();
940 priority =
MAX2(priority, (*i)->getPriority());
942 speed /= edges.size();
944 NBEdge* newEdge =
new NBEdge(
id, from, to,
"", speed, nolanes, priority,
949 for (i = edges.begin(); i != edges.end(); ++i) {
950 const std::vector<NBEdge::Lane>& lanes = (*i)->getLanes();
951 for (
int j = 0; j < (int)lanes.size(); ++j) {
965 for (i = edges.begin(); i != edges.end(); i++) {
967 for (EdgeVector::iterator j = ev.begin(); j != ev.end(); j++) {
973 for (i = edges.begin(); i != edges.end(); i++) {
975 currLane += (*i)->getNumLanes();
979 for (i = edges.begin(); i != edges.end(); i++) {
980 int noLanes = (*i)->getNumLanes();
981 for (
int j = 0; j < noLanes; j++, currLane++) {
987 for (i = edges.begin(); i != edges.end(); i++) {
996 const double distanceThreshold = 7;
997 for (EdgeCont::iterator i =
myEdges.begin(); i !=
myEdges.end(); ++i) {
1003 NBEdge* opposite =
nullptr;
1006 if ((*j)->getToNode() == edge->
getFromNode() && !(*j)->getLanes().empty()) {
1008 if (distance < distanceThreshold) {
1014 if (opposite !=
nullptr) {
1025 for (EdgeCont::iterator i =
myEdges.begin(); i !=
myEdges.end(); ++i) {
1027 if (opposite !=
nullptr) {
1039 const std::string oppositeID = edgeID[0] ==
'-' ? edgeID.substr(1) :
"-" + edgeID;
1040 EdgeCont::const_iterator it =
myEdges.find(oppositeID);
1046 EdgeCont::const_iterator it =
myEdges.find(edgeID);
1053 bool keepClear,
double contPos,
double visibility,
double speed,
1055 myConnections[from].push_back(
PostProcessConnection(from, fromLane, to, toLane, mayDefinitelyPass, keepClear, contPos, visibility, speed, customShape, uncontrolled, warnOnly, permissions));
1080 for (std::vector<PostProcessConnection>::const_iterator i = item.second.begin(); i != item.second.end(); ++i) {
1083 if (from ==
nullptr || to ==
nullptr ||
1085 (*i).keepClear, (*i).contPos, (*i).visibility, (*i).speed, (*i).customShape, (*i).uncontrolled)) {
1086 const std::string msg =
"Could not insert connection between '" + (*i).from +
"' and '" + (*i).to +
"' after build.";
1087 if (warnOnly || (*i).warnOnly) {
1097 for (EdgeCont::iterator it =
myEdges.begin(); it !=
myEdges.end(); ++it) {
1098 NBEdge* edge = it->second;
1101 std::vector<NBEdge::Connection> connections = edge->
getConnections();
1102 for (std::vector<NBEdge::Connection>::iterator it_con = connections.begin(); it_con != connections.end(); ++it_con) {
1106 "' to edge '" + c.
toEdge->
getID() +
"' via junction '" + to->
getID() +
"'.");
1116 int len = (int)
id.length();
1118 for (EdgeCont::const_iterator i =
myEdges.begin(); i !=
myEdges.end(); ++i) {
1119 std::string curr = (*i).first;
1122 if ((
int)curr.length() <= len) {
1127 if (curr.substr(0, len) ==
id && curr[len] ==
'[') {
1128 ret.push_back((*i).second);
1132 std::string::size_type pos = curr.find(
id);
1134 if (pos == std::string::npos) {
1139 if (curr[pos - 1] !=
']' && curr[pos - 1] !=
'+') {
1144 if (pos +
id.length() < curr.length()) {
1145 if (curr[pos +
id.length()] !=
'[' && curr[pos +
id.length()] !=
'+') {
1150 ret.push_back((*i).second);
1159 std::set<NBEdge*> loadedRoundaboutEdges;
1161 loadedRoundaboutEdges.insert(it->begin(), it->end());
1165 std::set<NBEdge*> candidates;
1167 for (EdgeCont::const_iterator i =
myEdges.begin(); i !=
myEdges.end(); ++i) {
1172 && loadedRoundaboutEdges.count(e) == 0
1174 candidates.insert(e);
1179 std::set<NBEdge*> visited;
1180 for (std::set<NBEdge*>::const_iterator i = candidates.begin(); i != candidates.end(); ++i) {
1187 if (visited.count(e) > 0) {
1191 loopEdges.push_back(e);
1193 #ifdef DEBUG_GUESS_ROUNDABOUT
1197 #ifdef DEBUG_GUESS_ROUNDABOUT
1199 std::cout <<
" e=" << e->
getID() <<
" loopEdges=" <<
toString(loopEdges) <<
"\n";
1207 #ifdef DEBUG_GUESS_ROUNDABOUT
1209 std::cout <<
" rbl\n";
1215 if (edges.size() < 2) {
1217 #ifdef DEBUG_GUESS_ROUNDABOUT
1219 std::cout <<
" deadend\n";
1228 #ifdef DEBUG_GUESS_ROUNDABOUT
1230 std::cout <<
" turn\n";
1236 EdgeVector::const_iterator me = std::find(edges.begin(), edges.end(), e);
1246 #ifdef DEBUG_GUESS_ROUNDABOUT
1248 std::cout <<
" noContinuation\n";
1258 #ifdef DEBUG_GUESS_ROUNDABOUT
1260 std::cout <<
" angle=" << angle <<
" nextAngle=" << nextAngle <<
"\n";
1274 #ifdef DEBUG_GUESS_ROUNDABOUT
1276 std::cout <<
" angle=" << angle <<
"\n";
1282 EdgeVector::const_iterator loopClosed = std::find(loopEdges.begin(), loopEdges.end(), left);
1283 const int loopSize = (int)(loopEdges.end() - loopClosed);
1288 }
else if (loopSize < (
int)loopEdges.size()) {
1290 EdgeVector(loopEdges.begin() + (loopEdges.size() - loopSize), loopEdges.end()).swap(loopEdges);
1293 int attachments = 0;
1294 for (EdgeVector::const_iterator j = loopEdges.begin(); j != loopEdges.end(); ++j) {
1295 if ((*j)->getToNode()->getEdges().size() > 2) {
1299 if (attachments < 3) {
1301 #ifdef DEBUG_GUESS_ROUNDABOUT
1303 std::cout <<
" attachments=" << attachments <<
"\n";
1310 if (visited.count(left) > 0) {
1314 loopEdges.push_back(left);
1318 #ifdef DEBUG_GUESS_ROUNDABOUT
1336 for (EdgeVector::const_iterator it = loopEdges.begin(); it != loopEdges.end(); ++it) {
1337 points.
append((*it)->getGeometry());
1339 double circumference = points.
length2D();
1340 return 4 *
M_PI * points.
area() / (circumference * circumference);
1344 const std::set<EdgeSet>
1354 if (roundabout.size() > 0) {
1367 if (e->getToNode() == node) {
1379 for (
NBEdge*
const edge : roundaboutSet) {
1381 NBNode*
const node = edge->getToNode();
1383 if (roundaboutSet.count(inEdge) > 0) {
1389 if (inEdge->getTurnDestination() !=
nullptr) {
1390 inEdge->removeFromConnections(inEdge->getTurnDestination(), -1);
1404 for (EdgeCont::iterator i =
myEdges.begin(); i !=
myEdges.end(); ++i) {
1444 int lanesCreated = 0;
1445 std::vector<std::string> edges;
1446 if (excludeOpt !=
"") {
1449 std::set<std::string> exclude(edges.begin(), edges.end());
1450 for (EdgeCont::iterator it =
myEdges.begin(); it !=
myEdges.end(); it++) {
1451 NBEdge* edge = it->second;
1453 exclude.count(edge->
getID()) == 0
1460 || (!fromPermissions && edge->
getSpeed() > minSpeed && edge->
getSpeed() <= maxSpeed)
1466 return lanesCreated;
1473 std::set<std::string> reserve;
1476 avoid.insert(avoid.end(), reserve.begin(), reserve.end());
1479 std::set<NBEdge*, ComparatorIdLess> toChange;
1480 for (EdgeCont::iterator it =
myEdges.begin(); it !=
myEdges.end(); it++) {
1485 toChange.insert(it->second);
1488 if (reservedIDs && reserve.count(it->first) > 0) {
1489 toChange.insert(it->second);
1493 std::map<std::string, std::vector<NBPTStop*> > stopsOnEdge;
1494 for (
const auto& item : sc.
getStops()) {
1495 stopsOnEdge[item.second->getEdgeId()].push_back(item.second);
1499 for (std::set<NBEdge*, ComparatorIdLess>::iterator it = toChange.begin(); it != toChange.end(); ++it) {
1501 const std::string origID = edge->
getID();
1508 for (
NBPTStop* stop : stopsOnEdge[origID]) {
1509 stop->setEdgeId(prefix + edge->
getID(), *
this);
1512 if (prefix.empty()) {
1513 return (
int)toChange.size();
1518 for (
auto item : oldEdges) {
1520 rename(item.second, prefix + item.first);
1531 for (EdgeCont::const_iterator it =
myEdges.begin(); it !=
myEdges.end(); it++) {
1532 const NBEdge* e1 = it->second;
1538 for (EdgeCont::const_iterator it2 = it; it2 !=
myEdges.end(); it2++) {
1539 const NBEdge* e2 = it2->second;
1548 const double overlap = outline1.
getOverlapWith(outline2, zThreshold);
1549 if (overlap > threshold) {
1560 for (EdgeCont::const_iterator it =
myEdges.begin(); it !=
myEdges.end(); it++) {
1561 const NBEdge* edge = it->second;
1562 for (
int i = 0; i < (int)edge->
getNumLanes(); i++) {
1565 if (maxJump > 0.01) {
1567 }
else if (grade > threshold) {
1572 const std::vector<NBEdge::Connection>& connections = edge->
getConnections();
1573 for (std::vector<NBEdge::Connection>::const_iterator it_con = connections.begin(); it_con != connections.end(); ++it_con) {
1577 if (maxJump > 0.01) {
1579 }
else if (grade > threshold) {
1589 int affectedEdges = 0;
1591 if (item.second->joinLanes(perms)) {
1595 return affectedEdges;
1602 item.second->setNumericalID((
int)result.size());
1603 result.push_back(item.second);
Sorts splits by their position (increasing)
bool isSet(const std::string &name, bool failOnNonExistant=true) const
Returns the information whether the named option is set.
static const double UNSPECIFIED_OFFSET
unspecified lane offset
@ SVC_PEDESTRIAN
pedestrian
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types.
NBEdge * toEdge
The edge the connections yields in.
void setOrigID(const std::string origID)
set origID for all lanes
NBTypeCont & myTypeCont
The network builder; used to obtain type information.
std::set< std::string > myIgnoredEdges
The ids of ignored edges.
int offsetFactor
direction in which to apply the offset (used by netgenerate for lefthand networks)
NBEdge * retrieve(const std::string &id, bool retrieveExtracted=false) const
Returns the edge that has the given id.
@ SIGN_TYPE_RIGHT_BEFORE_LEFT
#define WRITE_WARNING(msg)
void replaceOutgoing(NBEdge *which, NBEdge *by, int laneOff)
Replaces occurences of the first edge within the list of outgoing by the second Connections are remap...
double myEdgesMinSpeed
The minimum speed an edge may have in order to be kept (default: -1)
void addPostProcessConnection(const std::string &from, int fromLane, const std::string &to, int toLane, bool mayDefinitelyPass, bool keepClear, double contPos, double visibility, double speed, const PositionVector &customShape, bool uncontrolled, bool warnOnly, SVCPermissions permissions=SVC_UNSPECIFIED)
Adds a connection which could not be set during loading.
EdgeCont myExtractedEdges
The extracted nodes which are kept for reference.
LaneSpreadFunction myLaneSpreadFunction
The information about how to spread the lanes.
bool x2cartesian_const(Position &from) const
Converts the given coordinate into a cartesian using the previous initialisation.
A container for traffic light definitions and built programs.
void erase(NBDistrictCont &dc, NBEdge *edge)
Removes the given edge from the container (deleting it)
bool hasRestrictedLane(SUMOVehicleClass vclass) const
returns whether any lane already allows the given vclass exclusively
A class representing a single street sign.
NBEdge * getOppositeByID(const std::string &edgeID) const
Returns the edge with negated id if it exists.
void markAsSplit(const NBNode *node)
mark a node as being created form a split
NBEdge * getConnectionTo(NBNode *n) const
get connection to certain node
static double toDouble(const std::string &sData)
converts a string into the double value described by it by calling the char-type converter
std::vector< NBEdge * > EdgeVector
container for (sorted) edges
void copyConnectionsFrom(NBEdge *src)
copy connections from antoher edge
bool insert(const std::string &id, const Position &position, NBDistrict *district=0)
Inserts a node into the map.
void applyOptions(OptionsCont &oc)
Initialises the storage by applying given options.
void checkGrade(double threshold) const
check whether edges are to steep
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)
static GeoConvHelper & getProcessing()
the coordinate transformation to use for input conversion and processing
bool isBidiRail(bool ignoreSpread=false) const
whether this edge is part of a bidirectional railway
bool addEdge2EdgeConnection(NBEdge *dest)
Adds a connection to another edge.
void processSplits(NBEdge *e, std::vector< Split > splits, NBNodeCont &nc, NBDistrictCont &dc, NBTrafficLightLogicCont &tlc)
static bool transformCoordinates(PositionVector &from, bool includeInBoundary=true, GeoConvHelper *from_srs=0)
bool exists(const std::string &name) const
Returns the information whether the named option is known.
void computeLaneShapes()
Computes the shapes of all lanes of all edges stored in the container.
std::map< std::string, std::vector< PostProcessConnection > > myConnections
The list of connections to recheck.
bool getBool(const std::string &name) const
Returns the boolean-value of the named option (only for Option_Bool)
void patchRoundabouts(NBEdge *orig, NBEdge *part1, NBEdge *part2, std::set< EdgeSet > &roundabouts)
fix roundabout information after splitting an edge
static OptionsCont & getOptions()
Retrieves the options.
SumoXMLNodeType getType() const
Returns the type of this node.
NBEdge * getByID(const std::string &edgeID) const
Returns the edge with id if it exists.
bool insert(NBEdge *edge, bool ignorePrunning=false)
Adds an edge to the dictionary.
double length() const
Returns the length.
double offset
lateral offset to edge geometry
static GeoConvHelper & getLoaded()
the coordinate transformation that was loaded fron an input file
const double SUMO_const_laneWidthAndOffset
void setPermissions(SVCPermissions permissions, int lane=-1)
set allowed/disallowed classes for the given lane or for all lanes if -1 is given
SVCPermissions getPermissions(int lane=-1) const
get the union of allowed classes over all lanes or for a specific lane
void setLoadedLength(double val)
set loaded length
void setLaneSpreadFunction(LaneSpreadFunction spread)
(Re)sets how the lanes lateral offset shall be computed
static double nearest_offset_on_line_to_point2D(const Position &lineStart, const Position &lineEnd, const Position &p, bool perpendicular=true)
double speed
The speed after this change.
void markRoundabouts()
mark edge priorities and prohibit turn-arounds for all roundabout edges
@ L2L_USER
The connection was given by the user.
const double SUMO_const_halfLaneAndOffset
bool knows(const std::string &type) const
Returns whether the named type is in the container.
std::set< std::string > myTypes2Remove
Set of edges types which shall be removed.
A container for districts.
bool splitAt(NBDistrictCont &dc, NBEdge *edge, NBNode *node)
Splits the edge at the position nearest to the given node.
bool ignoreFilterMatch(NBEdge *edge)
Returns true if this edge matches one of the removal criteria.
std::vector< NBRouterEdge * > RouterEdgeVector
int remapIDs(bool numericaIDs, bool reservedIDs, const std::string &prefix, NBPTStopCont &sc)
remap node IDs accoring to options –numerical-ids and –reserved-ids
Boundary getBoxBoundary() const
Returns a boundary enclosing this list of lines.
static double relAngle(double angle1, double angle2)
computes the relative angle between the two angles
Container for nodes during the netbuilding process.
const double SUMO_const_haltingSpeed
the speed threshold at which vehicles are considered as halting
const std::string getParameter(const std::string &key, const std::string &defaultValue="") const
Returns the value for a given key.
The representation of a single edge during network building.
const StringVector & getStringVector(const std::string &name) const
Returns the list of string-value of the named option (only for Option_StringVector)
SVCPermissions myVehicleClasses2Keep
Set of vehicle types which must be allowed on edges in order to keep them.
EdgeVector getGeneratedFrom(const std::string &id) const
Returns the edges which have been built by splitting the edge of the given id.
SVCPermissions parseVehicleClasses(const std::string &allowedS)
Parses the given definition of allowed vehicle classes into the given containers Deprecated classes g...
void joinSameNodeConnectingEdges(NBDistrictCont &dc, NBTrafficLightLogicCont &tlc, EdgeVector edges)
Joins the given edges because they connect the same nodes.
const Position & getPosition() const
void setEndOffset(int lane, double offset)
set lane specific end-offset (negative lane implies set for all lanes)
void dismissVehicleClassInformation()
dimiss vehicle class information
double nearest_offset_to_point2D(const Position &p, bool perpendicular=true) const
return the nearest offest to point 2D
void invalidateConnections(bool reallowSetting=false)
invalidate current connections of edge
static void loadPrefixedIDsFomFile(const std::string &file, const std::string prefix, std::set< std::string > &into)
Add prefixed ids defined in file.
NBNode * myFrom
The source and the destination node.
EdgeCont myEdges
The instance of the dictionary (id->edge)
void computeLanes2Edges()
Computes for each edge which lanes approach the next edges.
NBNode * getToNode() const
Returns the destination node of the edge.
bool setConnection(int lane, NBEdge *destEdge, int destLane, 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, const bool uncontrolled=UNSPECIFIED_CONNECTION_UNCONTROLLED, SVCPermissions permissions=SVC_UNSPECIFIED)
Adds a connection to a certain lane of a certain edge.
PositionVector viaShape
shape of via
void decLaneNo(int by)
decrement lane
void checkOverlap(double threshold, double zThreshold) const
check whether edges overlap
const PositionVector & getGeometry() const
Returns the geometry of the edge.
std::set< std::string > myEdges2Remove
Set of ids of edges which shall explicitly be removed.
bool isForbidden(SVCPermissions permissions)
Returns whether an edge with the given permission is a forbidden edge.
NBNode * node
The new node that is created for this split.
void generateStreetSigns()
assigns street signs to edges based on toNode types
int SVCPermissions
bitset where each bit declares whether a certain SVC may use this edge/lane
double getOverlapWith(const PositionVector &poly, double zThreshold) const
Returns the maximum overlaps between this and the given polygon (when not separated by at least zThre...
bool hasPostProcessConnection(const std::string &from, const std::string &to="")
bool typeWasGuessed() const
return whether a priority road turns at this node
std::map< std::string, NBEdge * > EdgeCont
The type of the dictionary where an edge may be found by its id.
static const double UNSPECIFIED_CONTPOS
unspecified internal junction position
std::string getDescription(const NBEdge *parent) const
get string describing this connection
int guessRoundabouts()
Determines which edges belong to roundabouts and increases their priority.
SumoXMLNodeType
Numbers representing special SUMO-XML-attribute values for representing node- (junction-) types used ...
std::string getLaneID(int lane) const
get lane ID
bool recheckLanes()
recheck whether all lanes within the edge are all right and optimises the connections once again
std::set< NBEdge * > EdgeSet
container for unique edges
const std::string SUMO_PARAM_ORIGID
PositionVector shape
shape of Connection
void moveOutgoingConnectionsFrom(NBEdge *e, int laneOff)
move outgoing connection
A class that stores a 2D geometrical boundary.
std::set< std::string > myTypes2Keep
Set of edges types which shall be kept.
std::vector< int > lanes
The lanes after this change.
void recheckPostProcessConnections()
Try to set any stored connections.
int getNumLanes() const
Returns the number of lanes.
void setRoundabout()
update the type of this node as a roundabout
@ L2L_COMPUTED
The connection was computed.
void clear()
Deletes all edges.
NBEdge * retrievePossiblySplit(const std::string &id, bool downstream) const
Tries to retrieve an edge, even if it is splitted.
bool isRailway(SVCPermissions permissions)
Returns whether an edge with the given permission is a railway edge.
void setSpeed(int lane, double speed)
set lane specific speed (negative lane implies set for all lanes)
A point in 2D or 3D with translation and scaling methods.
void append(const PositionVector &v, double sameThreshold=2.0)
double getTotalWidth() const
Returns the combined width of all lanes of this edge.
bool myNeedGeoTransformedPruningBoundary
whether a geo transform has been applied to the pruning boundary
void removeUnwishedEdges(NBDistrictCont &dc)
Removes unwished edges (not in keep-edges)
void recheckLanes()
Rechecks whether all lanes have a successor for each of the stored edges.
A storage for options typed value containers)
bool getShallBeDiscarded(const std::string &type) const
Returns the information whether edges of this type shall be discarded.
const EdgeVector & getEdges() const
Returns all edges which participate in this node (Edges that start or end at this node)
Lane & getLaneStruct(int lane)
static const double UNSPECIFIED_VISIBILITY_DISTANCE
unspecified foe visibility for connections
static bool startsWith(const std::string &str, const std::string prefix)
Checks whether a given string starts with the prefix.
void splitGeometry(NBDistrictCont &dc, NBNodeCont &nc)
Splits edges into multiple if they have a complex geometry.
double length2D() const
Returns the length.
void appendTurnarounds(bool noTLSControlled, bool onlyDeadends, bool noGeometryLike)
Appends turnarounds to all edges stored in the container.
PositionVector myPruningBoundary
Boundary within which an edge must be located in order to be kept.
void removeFromConnections(NBEdge *toEdge, int fromLane=-1, int toLane=-1, bool tryLater=false, const bool adaptToLaneRemoval=false, const bool keepPossibleTurns=false)
Removes the specified connection(s)
@ L2L_VALIDATED
The connection was computed and validated.
double pos
The position of this change.
@ NODETYPE_RIGHT_BEFORE_LEFT
void removeEdge(NBEdge *edge, bool removeFromConnections=true)
Removes edge from this node and optionally removes connections as well.
std::pair< PositionVector, PositionVector > splitAt(double where, bool use2D=false) const
Returns the two lists made when this list vector is splitted at the given point.
EdgeVector getAllEdges() const
return all edges
NBNode * retrieve(const std::string &id) const
Returns the node with the given name.
const std::vector< NBEdge::Lane > & getLanes() const
Returns the lane definitions.
const std::string & getStreetName() const
Returns the street name of this edge.
void appendRailwayTurnarounds(const NBPTStopCont &sc)
Appends turnarounds to all bidiRail edges with stops.
double getLoadedLength() const
Returns the length was set explicitly or the computed length if it wasn't set.
std::vector< std::string > getAllNames() const
Returns all ids of known edges.
double getFloat(const std::string &name) const
Returns the double-value of the named option (only for Option_Float)
double getLength() const
Returns the computed length of the edge.
const PositionVector & getLaneShape(int i) const
Returns the shape of the nth lane.
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
double getMaxGrade(double &maxJump) const
void sortOutgoingLanesConnections()
Sorts all lanes of all edges within the container by their direction.
const std::map< std::string, NBPTStop * > & getStops() const
void reduceGeometries(const double minDist)
std::set< std::string > myEdges2Keep
Set of ids of edges which shall explicitly be kept.
void rename(NBEdge *edge, const std::string &newID)
Renames the edge. Throws exception if newID already exists.
int getJunctionPriority(const NBNode *const node) const
Returns the junction priority (normalised for the node currently build)
void setLaneWidth(int lane, double width)
set lane specific width (negative lane implies set for all lanes)
A storage for available types of edges.
std::set< EdgeSet > myRoundabouts
Edges marked as belonging to a roundabout by the user (each EdgeVector is a roundabout)
double getSpeed() const
Returns the speed allowed on this edge.
const std::set< NBTrafficLightDefinition * > & getControllingTLS() const
Returns the traffic lights that were assigned to this node (The set of tls that control this node)
An (internal) definition of a single lane of an edge.
void addSign(NBSign sign)
add Sign
const SVCPermissions SVCAll
all VClasses are allowed
A structure representing a connection between two lanes.
NBEdgeCont(NBTypeCont &tc)
Constructor.
const EdgeVector & getIncomingEdges() const
Returns this node's incoming edges (The edges which yield in this node)
std::string oppositeID
An opposite lane ID, if given.
int guessSpecialLanes(SUMOVehicleClass svc, double width, double minSpeed, double maxSpeed, bool fromPermissions, const std::string &excludeOpt)
add sidwalks to edges within the given limits or permissions and return the number of edges affected
std::vector< double > distances(const PositionVector &s, bool perpendicular=false) const
distances of all my points to s and all of s points to myself
void extract(NBDistrictCont &dc, NBEdge *edge, bool remember=false)
Removes the given edge from the container like erase but does not delete it.
void recheckLaneSpread()
Rechecks whether the lane spread is proper.
static double formFactor(const EdgeVector &loopEdges)
compute the form factor for a loop of edges
std::vector< Lane > myLanes
Lane information.
std::string getNext()
Returns the next id.
std::string idAfter
The id for the edge after the split.
bool isSimpleContinuation(bool checkLaneNumbers=true, bool checkWidth=false) const
check if node is a simple continuation
static const double UNSPECIFIED_WIDTH
unspecified lane width
void removeDoubleEdges()
remove duble edges
void computeEdgeShapes(double smoothElevationThreshold=-1)
Computes the shapes of all edges stored in the container.
int myEdgesSplit
the number of splits of edges during the building
double getFinalLength() const
get length that will be assigned to the lanes in the final network
const std::string & getTypeID() const
get ID of type
static void nextCW(const EdgeVector &edges, EdgeVector::const_iterator &from)
int joinLanes(SVCPermissions perms)
join adjacent lanes with the given permissions
void addRoundabout(const EdgeSet &roundabout)
add user specified roundabout
bool gDebugFlag1
global utility flags for debugging
void addRestrictedLane(double width, SUMOVehicleClass vclass)
add a lane of the given width, restricted to the given class and shift existing connections
void removeFromSinksAndSources(NBEdge *const e)
Removes the given edge from the lists of sources and sinks in all stored districts.
static T maxValue(const std::vector< T > &v)
Boundary & grow(double by)
extends the boundary by the given amount
SVCPermissions myVehicleClasses2Remove
Set of vehicle types which need not be supported (edges which allow ONLY these are removed)
void invalidateTLS(NBTrafficLightLogicCont &tlCont, bool removedConnections, bool addedConnections)
causes the traffic light to be computed anew
void removeRoundabout(const NBNode *node)
remove roundabout that contains the given node
void incLaneNo(int by)
increment lane
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,...
PositionVector shape
The lane's shape.
void guessOpposites()
Sets opposite lane information for geometrically close edges.
void checkGeometries(const double maxAngle, const double minRadius, bool fix, bool fixRailways, bool silent=false)
Represents a single node (junction) during network building.
bool isSidewalk(SVCPermissions permissions)
Returns whether an edge with the given permission is a sidewalk.
void computeEdge2Edges(bool noLeftMovers)
Computes for each edge the approached edges.
The representation of a single pt stop.
A structure which describes a connection between edges or lanes.
bool myRemoveEdgesAfterJoining
Whether edges shall be joined first, then removed.
double area() const
Returns the area (0 for non-closed)
A structure which describes changes of lane number or speed along the road.
const std::string & getID() const
Returns the id.
double getAngleAtNode(const NBNode *const node) const
Returns the angle of the edge's geometry at the given node.
void setAverageLengthWithOpposite(double val)
patch average lane length in regard to the opposite edge
std::string idBefore
The id for the edge before the split.
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, const bool uncontrolled=UNSPECIFIED_CONNECTION_UNCONTROLLED, SVCPermissions=SVC_UNSPECIFIED)
Adds a connection between the specified this edge's lane and an approached one.
const std::vector< Connection > & getConnections() const
Returns the connections.
NBNode * getFromNode() const
Returns the origin node of the edge.
std::set< EdgeSet > myGuessedRoundabouts
Edges marked as belonging to a roundabout after guessing.
const std::set< EdgeSet > getRoundabouts() const
Returns the determined roundabouts.
PositionVector getCCWBoundaryLine(const NBNode &n) const
get the outer boundary of this edge when going counter-clock-wise around the given node
void replaceRemoved(NBEdge *removed, int removedLane, NBEdge *by, int byLane)
Replaces occurences of the removed edge/lane in all definitions by the given edge.
void setGeometry(const PositionVector &g, bool inner=false)
(Re)sets the edge's geometry
void move2side(double amount, double maxExtension=100)
move position vector to side using certain ammount
@ LANES2LANES_USER
Lanes to lanes - relationships are loaded; no recheck is necessary/wished.
void setID(const std::string &newID)
resets the id
RouterEdgeVector getAllRouterEdges() const
LaneSpreadFunction getLaneSpreadFunction() const
Returns how this edge's lanes' lateral offset is computed.
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::string nameID
the default node id
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.
bool overlapsWith(const AbstractPoly &poly, double offset=0) const
Returns whether the boundary overlaps with the given polygon.
NBEdge * getTurnDestination(bool possibleDestination=false) const
void clearControllingTLInformation() const
Clears information about controlling traffic lights for all connenections of all edges.
const std::string & getID() const