SUMO - Simulation of Urban MObility
NBEdgeCont.cpp
Go to the documentation of this file.
1 /****************************************************************************/
10 // Storage for edges, including some functionality operating on multiple edges
11 /****************************************************************************/
12 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
13 // Copyright (C) 2001-2015 DLR (http://www.dlr.de/) and contributors
14 /****************************************************************************/
15 //
16 // This file is part of SUMO.
17 // SUMO is free software: you can redistribute it and/or modify
18 // it under the terms of the GNU General Public License as published by
19 // the Free Software Foundation, either version 3 of the License, or
20 // (at your option) any later version.
21 //
22 /****************************************************************************/
23 
24 
25 // ===========================================================================
26 // included modules
27 // ===========================================================================
28 #ifdef _MSC_VER
29 #include <windows_config.h>
30 #else
31 #include <config.h>
32 #endif
33 
34 #include <vector>
35 #include <string>
36 #include <cassert>
37 #include <algorithm>
38 #include <utils/geom/Boundary.h>
39 #include <utils/geom/GeomHelper.h>
42 #include <utils/common/ToString.h>
45 #include "NBNetBuilder.h"
46 #include "NBEdgeCont.h"
47 #include "NBNodeCont.h"
48 #include "NBHelpers.h"
49 #include "NBCont.h"
51 #include "NBDistrictCont.h"
52 #include <cmath>
53 #include "NBTypeCont.h"
57 
58 #ifdef CHECK_MEMORY_LEAKS
59 #include <foreign/nvwa/debug_new.h>
60 #endif // CHECK_MEMORY_LEAKS
61 
62 
63 // ===========================================================================
64 // method definitions
65 // ===========================================================================
67  myTypeCont(tc),
68  myEdgesSplit(0),
69  myVehicleClasses2Keep(0),
70  myVehicleClasses2Remove(0),
71  myNeedGeoTransformedPrunningBoundary(false)
72 {}
73 
74 
76  clear();
77 }
78 
79 
80 void
82  // set edges dismiss/accept options
83  myEdgesMinSpeed = oc.isSet("keep-edges.min-speed") ? oc.getFloat("keep-edges.min-speed") : -1;
84  myRemoveEdgesAfterJoining = oc.exists("keep-edges.postload") && oc.getBool("keep-edges.postload");
85  // we possibly have to load the edges to keep/remove
86  if (oc.isSet("keep-edges.input-file")) {
87  NBHelpers::loadEdgesFromFile(oc.getString("keep-edges.input-file"), myEdges2Keep);
88  }
89  if (oc.isSet("remove-edges.input-file")) {
90  NBHelpers::loadEdgesFromFile(oc.getString("remove-edges.input-file"), myEdges2Remove);
91  }
92  if (oc.isSet("keep-edges.explicit")) {
93  const std::vector<std::string> edges = oc.getStringVector("keep-edges.explicit");
94  myEdges2Keep.insert(edges.begin(), edges.end());
95  }
96  if (oc.isSet("remove-edges.explicit")) {
97  const std::vector<std::string> edges = oc.getStringVector("remove-edges.explicit");
98  myEdges2Remove.insert(edges.begin(), edges.end());
99  }
100  if (oc.exists("keep-edges.by-vclass") && oc.isSet("keep-edges.by-vclass")) {
101  myVehicleClasses2Keep = parseVehicleClasses(oc.getStringVector("keep-edges.by-vclass"));
102  }
103  if (oc.exists("remove-edges.by-vclass") && oc.isSet("remove-edges.by-vclass")) {
104  myVehicleClasses2Remove = parseVehicleClasses(oc.getStringVector("remove-edges.by-vclass"));
105  }
106  if (oc.exists("keep-edges.by-type") && oc.isSet("keep-edges.by-type")) {
107  const std::vector<std::string> types = oc.getStringVector("keep-edges.by-type");
108  myTypes2Keep.insert(types.begin(), types.end());
109  }
110  if (oc.exists("remove-edges.by-type") && oc.isSet("remove-edges.by-type")) {
111  const std::vector<std::string> types = oc.getStringVector("remove-edges.by-type");
112  myTypes2Remove.insert(types.begin(), types.end());
113  }
114 
115  if (oc.isSet("keep-edges.in-boundary") || oc.isSet("keep-edges.in-geo-boundary")) {
116  std::vector<std::string> polyS = oc.getStringVector(oc.isSet("keep-edges.in-boundary") ?
117  "keep-edges.in-boundary" : "keep-edges.in-geo-boundary");
118  // !!! throw something if length<4 || length%2!=0?
119  std::vector<SUMOReal> poly;
120  for (std::vector<std::string>::iterator i = polyS.begin(); i != polyS.end(); ++i) {
121  poly.push_back(TplConvert::_2SUMOReal((*i).c_str())); // !!! may throw something anyhow...
122  }
123  if (poly.size() < 4) {
124  throw ProcessError("Invalid boundary: need at least 2 coordinates");
125  } else if (poly.size() % 2 != 0) {
126  throw ProcessError("Invalid boundary: malformed coordinate");
127  } else if (poly.size() == 4) {
128  // prunning boundary (box)
129  myPrunningBoundary.push_back(Position(poly[0], poly[1]));
130  myPrunningBoundary.push_back(Position(poly[2], poly[1]));
131  myPrunningBoundary.push_back(Position(poly[2], poly[3]));
132  myPrunningBoundary.push_back(Position(poly[0], poly[3]));
133  } else {
134  for (std::vector<SUMOReal>::iterator j = poly.begin(); j != poly.end();) {
135  SUMOReal x = *j++;
136  SUMOReal y = *j++;
137  myPrunningBoundary.push_back(Position(x, y));
138  }
139  }
140  myNeedGeoTransformedPrunningBoundary = oc.isSet("keep-edges.in-geo-boundary");
141  }
142 }
143 
144 
145 void
147  for (EdgeCont::iterator i = myEdges.begin(); i != myEdges.end(); i++) {
148  delete((*i).second);
149  }
150  myEdges.clear();
151  for (EdgeCont::iterator i = myExtractedEdges.begin(); i != myExtractedEdges.end(); i++) {
152  delete((*i).second);
153  }
154  myExtractedEdges.clear();
155 }
156 
157 
158 
159 // ----- edge access methods
160 bool
161 NBEdgeCont::insert(NBEdge* edge, bool ignorePrunning) {
162  if (myEdges.count(edge->getID())) {
163  return false;
164  }
165  if (!ignorePrunning && ignoreFilterMatch(edge)) {
166  edge->getFromNode()->removeEdge(edge);
167  edge->getToNode()->removeEdge(edge);
168  myIgnoredEdges.insert(edge->getID());
169  delete edge;
170  } else {
172  if (oc.exists("dismiss-vclasses") && oc.getBool("dismiss-vclasses")) {
174  }
175  myEdges[edge->getID()] = edge;
176  }
177  return true;
178 }
179 
180 
181 bool
183  // remove edges which allow a speed below a set one (set using "keep-edges.min-speed")
184  if (edge->getSpeed() < myEdgesMinSpeed) {
185  return true;
186  }
187  // check whether the edge is a named edge to keep
188  if (!myRemoveEdgesAfterJoining && myEdges2Keep.size() != 0) {
189  if (find(myEdges2Keep.begin(), myEdges2Keep.end(), edge->getID()) == myEdges2Keep.end()) {
190  return true;
191  }
192  }
193  // check whether the edge is a named edge to remove
194  if (myEdges2Remove.size() != 0) {
195  if (find(myEdges2Remove.begin(), myEdges2Remove.end(), edge->getID()) != myEdges2Remove.end()) {
196  return true;
197  }
198  }
199  // check whether the edge shall be removed because it does not allow any of the wished classes
200  if (myVehicleClasses2Keep != 0 && (myVehicleClasses2Keep & edge->getPermissions()) == 0) {
201  return true;
202  }
203  // check whether the edge shall be removed due to allowing unwished classes only
205  return true;
206  }
207  // check whether the edge shall be removed because it does not have one of the requested types
208  if (myTypes2Keep.size() != 0) {
209  if (myTypes2Keep.count(edge->getTypeID()) == 0) {
210  return true;
211  }
212  }
213  // check whether the edge shall be removed because it has one of the forbidden types
214  if (myTypes2Remove.size() != 0) {
215  if (myTypes2Remove.count(edge->getTypeID()) > 0) {
216  return true;
217  }
218  }
219  // check whether the edge is within the prunning boundary
220  if (myPrunningBoundary.size() != 0) {
224  } else if (GeoConvHelper::getLoaded().usingGeoProjection()) {
225  // XXX what if input file with different projections are loaded?
226  for (int i = 0; i < (int) myPrunningBoundary.size(); i++) {
228  }
229  } else {
230  WRITE_ERROR("Cannot prune edges using a geo-boundary because no projection has been loaded");
231  }
233  }
235  return true;
236  }
237  }
239  return true;
240  }
241  return false;
242 }
243 
244 
245 NBEdge*
246 NBEdgeCont::retrieve(const std::string& id, bool retrieveExtracted) const {
247  EdgeCont::const_iterator i = myEdges.find(id);
248  if (i == myEdges.end()) {
249  if (retrieveExtracted) {
250  i = myExtractedEdges.find(id);
251  if (i == myExtractedEdges.end()) {
252  return 0;
253  }
254  } else {
255  return 0;
256  }
257  }
258  return (*i).second;
259 }
260 
261 // FIXME: This can't work
262 /*
263 NBEdge*
264 NBEdgeCont::retrievePossiblySplit(const std::string& id, bool downstream) const {
265  NBEdge* edge = retrieve(id);
266  if (edge == 0) {
267  return 0;
268  }
269  const EdgeVector* candidates = downstream ? &edge->getToNode()->getOutgoingEdges() : &edge->getFromNode()->getIncomingEdges();
270  while (candidates->size() == 1) {
271  const std::string& nextID = candidates->front()->getID();
272  if (nextID.find(id) != 0 || nextID.size() <= id.size() + 1 || (nextID[id.size()] != '.' && nextID[id.size()] != '-')) {
273  break;
274  }
275  edge = candidates->front();
276  candidates = downstream ? &edge->getToNode()->getOutgoingEdges() : &edge->getFromNode()->getIncomingEdges();
277  }
278  return edge;
279 }*/
280 
281 NBEdge*
282 NBEdgeCont::retrievePossiblySplit(const std::string& id, bool downstream) const {
283  NBEdge* edge = retrieve(id);
284  if (edge != 0) {
285  return edge;
286  }
287  // NOTE: (TODO) for multiply split edges (e.g. 15[0][0]) one could try recursion
288  if ((retrieve(id + "[0]") != 0) && (retrieve(id + "[1]") != 0)) {
289  // Edge was split during the netbuilding process
290  if (downstream == true) {
291  return retrieve(id + "[1]");
292  } else {
293  return retrieve(id + "[0]");
294  }
295  }
296  return edge;
297 }
298 
299 
300 NBEdge*
301 NBEdgeCont::retrievePossiblySplit(const std::string& id, const std::string& hint, bool incoming) const {
302  // try to retrieve using the given name (iterative)
303  NBEdge* edge = retrieve(id);
304  if (edge != 0) {
305  return edge;
306  }
307  // now, we did not find it; we have to look over all possibilities
308  EdgeVector hints;
309  // check whether at least the hint was not splitted
310  NBEdge* hintedge = retrieve(hint);
311  if (hintedge == 0) {
312  hints = getGeneratedFrom(hint);
313  } else {
314  hints.push_back(hintedge);
315  }
316  EdgeVector candidates = getGeneratedFrom(id);
317  for (EdgeVector::iterator i = hints.begin(); i != hints.end(); i++) {
318  NBEdge* hintedge = (*i);
319  for (EdgeVector::iterator j = candidates.begin(); j != candidates.end(); j++) {
320  NBEdge* poss_searched = (*j);
321  NBNode* node = incoming
322  ? poss_searched->myTo : poss_searched->myFrom;
323  const EdgeVector& cont = incoming
324  ? node->getOutgoingEdges() : node->getIncomingEdges();
325  if (find(cont.begin(), cont.end(), hintedge) != cont.end()) {
326  return poss_searched;
327  }
328  }
329  }
330  return 0;
331 }
332 
333 
334 NBEdge*
335 NBEdgeCont::retrievePossiblySplit(const std::string& id, SUMOReal pos) const {
336  // check whether the edge was not split, yet
337  NBEdge* edge = retrieve(id);
338  if (edge != 0) {
339  return edge;
340  }
341  size_t maxLength = 0;
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, (*i).first.length());
346  }
347  }
348  // find the part of the edge which matches the position
349  SUMOReal seen = 0;
350  std::vector<std::string> names;
351  names.push_back(id + "[1]");
352  names.push_back(id + "[0]");
353  while (names.size() > 0) {
354  // retrieve the first subelement (to follow)
355  std::string cid = names.back();
356  names.pop_back();
357  edge = retrieve(cid);
358  // The edge was splitted; check its subparts within the
359  // next step
360  if (edge == 0) {
361  if (cid.length() + 3 < maxLength) {
362  names.push_back(cid + "[1]");
363  names.push_back(cid + "[0]");
364  }
365  }
366  // an edge with the name was found,
367  // check whether the position lies within it
368  else {
369  seen += edge->getLength();
370  if (seen >= pos) {
371  return edge;
372  }
373  }
374  }
375  return 0;
376 }
377 
378 
379 void
381  extract(dc, edge);
382  delete edge;
383 }
384 
385 
386 void
387 NBEdgeCont::extract(NBDistrictCont& dc, NBEdge* edge, bool remember) {
388  if (remember) {
389  myExtractedEdges[edge->getID()] = edge;
390  }
391  myEdges.erase(edge->getID());
392  edge->myFrom->removeEdge(edge);
393  edge->myTo->removeEdge(edge);
394  dc.removeFromSinksAndSources(edge);
395 }
396 
397 
398 void
399 NBEdgeCont::rename(NBEdge* edge, const std::string& newID) {
400  if (myEdges.count(newID) != 0) {
401  throw ProcessError("Attempt to rename edge using existing id '" + newID + "'");
402  }
403  myEdges.erase(edge->getID());
404  edge->setID(newID);
405  myEdges[newID] = edge;
406 }
407 
408 
409 // ----- explicit edge manipulation methods
410 bool
412  return splitAt(dc, edge, node, edge->getID() + "[0]", edge->getID() + "[1]",
413  (unsigned int) edge->myLanes.size(), (unsigned int) edge->myLanes.size());
414 }
415 
416 
417 bool
419  const std::string& firstEdgeName,
420  const std::string& secondEdgeName,
421  unsigned int noLanesFirstEdge, unsigned int noLanesSecondEdge,
422  const SUMOReal speed,
423  const int changedLeft) {
424  SUMOReal pos;
425  pos = edge->getGeometry().nearest_offset_to_point2D(node->getPosition());
426  if (pos <= 0) {
428  edge->myFrom->getPosition(), edge->myTo->getPosition(),
429  node->getPosition());
430  }
431  if (pos <= 0 || pos + POSITION_EPS > edge->getGeometry().length()) {
432  return false;
433  }
434  return splitAt(dc, edge, pos, node, firstEdgeName, secondEdgeName,
435  noLanesFirstEdge, noLanesSecondEdge, speed, changedLeft);
436 }
437 
438 
439 bool
441  NBEdge* edge, SUMOReal pos, NBNode* node,
442  const std::string& firstEdgeName,
443  const std::string& secondEdgeName,
444  unsigned int noLanesFirstEdge, unsigned int noLanesSecondEdge,
445  const SUMOReal speed,
446  const int changedLeft
447  ) {
448  // there must be at least some overlap between first and second edge
449  assert(changedLeft > -((int)noLanesFirstEdge));
450  assert(changedLeft < (int)noLanesSecondEdge);
451 
452  // build the new edges' geometries
453  std::pair<PositionVector, PositionVector> geoms =
454  edge->getGeometry().splitAt(pos);
455  if (geoms.first[-1] != node->getPosition()) {
456  geoms.first.pop_back();
457  geoms.first.push_back(node->getPosition());
458  }
459 
460  if (geoms.second[0] != node->getPosition()) {
461  geoms.second[0] = node->getPosition();
462  }
463  // build and insert the edges
464  NBEdge* one = new NBEdge(firstEdgeName, edge->myFrom, node, edge, geoms.first, noLanesFirstEdge);
465  NBEdge* two = new NBEdge(secondEdgeName, node, edge->myTo, edge, geoms.second, noLanesSecondEdge);
466  two->copyConnectionsFrom(edge);
467  if (speed != -1.) {
468  two->setSpeed(-1, speed);
469  }
470  // replace information about this edge within the nodes
471  edge->myFrom->replaceOutgoing(edge, one, 0);
472  edge->myTo->replaceIncoming(edge, two, 0);
473  // the edge is now occuring twice in both nodes...
474  // clean up
475  edge->myFrom->removeDoubleEdges();
476  edge->myTo->removeDoubleEdges();
477  // add connections from the first to the second edge
478  // there will be as many connections as there are lanes on the second edge
479  // by default lanes will be added / discontinued on the right side
480  // (appropriate for highway on-/off-ramps)
481  const int offset = (int)one->getNumLanes() - (int)two->getNumLanes() + changedLeft;
482  for (int i2 = 0; i2 < (int)two->getNumLanes(); i2++) {
483  const int i1 = MIN2(MAX2((int)0, i2 + offset), (int)one->getNumLanes());
484  if (!one->addLane2LaneConnection(i1, two, i2, NBEdge::L2L_COMPUTED)) {
485  throw ProcessError("Could not set connection!");
486  }
487  }
489  if (find(myEdges2Keep.begin(), myEdges2Keep.end(), edge->getID()) != myEdges2Keep.end()) {
490  myEdges2Keep.insert(one->getID());
491  myEdges2Keep.insert(two->getID());
492  }
493  if (find(myEdges2Remove.begin(), myEdges2Remove.end(), edge->getID()) != myEdges2Remove.end()) {
494  myEdges2Remove.insert(one->getID());
495  myEdges2Remove.insert(two->getID());
496  }
497  }
498  // erase the splitted edge
499  erase(dc, edge);
500  insert(one, true);
501  insert(two, true);
502  myEdgesSplit++;
503  return true;
504 }
505 
506 
507 
508 // ----- container access methods
509 std::vector<std::string>
511  std::vector<std::string> ret;
512  for (EdgeCont::const_iterator i = myEdges.begin(); i != myEdges.end(); ++i) {
513  ret.push_back((*i).first);
514  }
515  return ret;
516 }
517 
518 
519 // ----- Adapting the input
520 void
522  EdgeVector toRemove;
523  for (EdgeCont::iterator i = myEdges.begin(); i != myEdges.end(); ++i) {
524  NBEdge* edge = (*i).second;
525  if (!myEdges2Keep.count(edge->getID())) {
526  edge->getFromNode()->removeEdge(edge);
527  edge->getToNode()->removeEdge(edge);
528  toRemove.push_back(edge);
529  }
530  }
531  for (EdgeVector::iterator j = toRemove.begin(); j != toRemove.end(); ++j) {
532  erase(dc, *j);
533  }
534 }
535 
536 
537 void
539  for (EdgeCont::iterator i = myEdges.begin(); i != myEdges.end(); ++i) {
540  if ((*i).second->getGeometry().size() < 3) {
541  continue;
542  }
543  (*i).second->splitGeometry(*this, nc);
544  }
545 }
546 
547 
548 void
550  for (EdgeCont::iterator i = myEdges.begin(); i != myEdges.end(); ++i) {
551  (*i).second->reduceGeometry(minDist);
552  }
553 }
554 
555 
556 void
557 NBEdgeCont::checkGeometries(const SUMOReal maxAngle, const SUMOReal minRadius, bool fix) {
558  if (maxAngle > 0 || minRadius > 0) {
559  for (EdgeCont::iterator i = myEdges.begin(); i != myEdges.end(); ++i) {
560  (*i).second->checkGeometry(maxAngle, minRadius, fix);
561  }
562  }
563 }
564 
565 
566 // ----- processing methods
567 void
569  for (EdgeCont::const_iterator i = myEdges.begin(); i != myEdges.end(); i++) {
570  (*i).second->clearControllingTLInformation();
571  }
572 }
573 
574 
575 void
577  for (EdgeCont::iterator i = myEdges.begin(); i != myEdges.end(); i++) {
578  (*i).second->sortOutgoingConnectionsByAngle();
579  }
580 }
581 
582 
583 void
584 NBEdgeCont::computeEdge2Edges(bool noLeftMovers) {
585  for (EdgeCont::iterator i = myEdges.begin(); i != myEdges.end(); i++) {
586  (*i).second->computeEdge2Edges(noLeftMovers);
587  }
588 }
589 
590 
591 void
593  for (EdgeCont::iterator i = myEdges.begin(); i != myEdges.end(); i++) {
594  (*i).second->computeLanes2Edges();
595  }
596 }
597 
598 
599 void
601  for (EdgeCont::iterator i = myEdges.begin(); i != myEdges.end(); i++) {
602  (*i).second->recheckLanes();
603  }
604 }
605 
606 
607 void
608 NBEdgeCont::appendTurnarounds(bool noTLSControlled) {
609  for (EdgeCont::iterator i = myEdges.begin(); i != myEdges.end(); i++) {
610  (*i).second->appendTurnaround(noTLSControlled);
611  }
612 }
613 
614 
615 void
616 NBEdgeCont::appendTurnarounds(const std::set<std::string>& ids, bool noTLSControlled) {
617  for (std::set<std::string>::const_iterator it = ids.begin(); it != ids.end(); it++) {
618  myEdges[*it]->appendTurnaround(noTLSControlled);
619  }
620 }
621 
622 
623 void
625  for (EdgeCont::iterator i = myEdges.begin(); i != myEdges.end(); i++) {
626  (*i).second->computeEdgeShape();
627  }
628 }
629 
630 
631 void
633  for (EdgeCont::iterator i = myEdges.begin(); i != myEdges.end(); ++i) {
634  (*i).second->computeLaneShapes();
635  }
636 }
637 
638 
639 void
642  EdgeVector edges) {
643  // !!! Attention!
644  // No merging of the geometry to come is being done
645  // The connections are moved from one edge to another within
646  // the replacement where the edge is a node's incoming edge.
647 
648  // count the number of lanes, the speed and the id
649  unsigned int nolanes = 0;
650  SUMOReal speed = 0;
651  int priority = 0;
652  std::string id;
653  sort(edges.begin(), edges.end(), NBContHelper::same_connection_edge_sorter());
654  // retrieve the connected nodes
655  NBEdge* tpledge = *(edges.begin());
656  NBNode* from = tpledge->getFromNode();
657  NBNode* to = tpledge->getToNode();
658  EdgeVector::const_iterator i;
659  for (i = edges.begin(); i != edges.end(); i++) {
660  // some assertions
661  assert((*i)->getFromNode() == from);
662  assert((*i)->getToNode() == to);
663  // ad the number of lanes the current edge has
664  nolanes += (*i)->getNumLanes();
665  // build the id
666  if (i != edges.begin()) {
667  id += "+";
668  }
669  id += (*i)->getID();
670  // compute the speed
671  speed += (*i)->getSpeed();
672  // build the priority
673  priority = MAX2(priority, (*i)->getPriority());
674  }
675  speed /= edges.size();
676  // build the new edge
677  NBEdge* newEdge = new NBEdge(id, from, to, "", speed, nolanes, priority,
679  tpledge->getStreetName(), tpledge->myLaneSpreadFunction);
680  // copy lane attributes
681  int laneIndex = 0;
682  for (i = edges.begin(); i != edges.end(); ++i) {
683  const std::vector<NBEdge::Lane>& lanes = (*i)->getLanes();
684  for (int j = 0; j < (int)lanes.size(); ++j) {
685  newEdge->setPermissions(lanes[j].permissions, laneIndex);
686  newEdge->setLaneWidth(laneIndex, lanes[j].width);
687  newEdge->setEndOffset(laneIndex, lanes[j].endOffset);
688  laneIndex++;
689  }
690  }
691  insert(newEdge, true);
692  // replace old edge by current within the nodes
693  // and delete the old
694  from->replaceOutgoing(edges, newEdge);
695  to->replaceIncoming(edges, newEdge);
696  // patch connections
697  // add edge2edge-information
698  for (i = edges.begin(); i != edges.end(); i++) {
699  EdgeVector ev = (*i)->getConnectedEdges();
700  for (EdgeVector::iterator j = ev.begin(); j != ev.end(); j++) {
701  newEdge->addEdge2EdgeConnection(*j);
702  }
703  }
704  // copy outgoing connections to the new edge
705  unsigned int currLane = 0;
706  for (i = edges.begin(); i != edges.end(); i++) {
707  newEdge->moveOutgoingConnectionsFrom(*i, currLane);
708  currLane += (*i)->getNumLanes();
709  }
710  // patch tl-information
711  currLane = 0;
712  for (i = edges.begin(); i != edges.end(); i++) {
713  unsigned int noLanes = (*i)->getNumLanes();
714  for (unsigned int j = 0; j < noLanes; j++, currLane++) {
715  // replace in traffic lights
716  tlc.replaceRemoved(*i, j, newEdge, currLane);
717  }
718  }
719  // delete joined edges
720  for (i = edges.begin(); i != edges.end(); i++) {
721  extract(dc, *i, true);
722  }
723 }
724 
725 
726 void
728  for (EdgeCont::iterator i = myEdges.begin(); i != myEdges.end(); ++i) {
729  std::string oppositeID;
730  if ((*i).first[0] == '-') {
731  oppositeID = (*i).first.substr(1);
732  } else {
733  oppositeID = "-" + (*i).first;
734  }
735  if (myEdges.find(oppositeID) != myEdges.end()) {
736  (*i).second->setLaneSpreadFunction(LANESPREAD_RIGHT);
737  myEdges.find(oppositeID)->second->setLaneSpreadFunction(LANESPREAD_RIGHT);
738  } else {
739  (*i).second->setLaneSpreadFunction(LANESPREAD_CENTER);
740  }
741  }
742 }
743 
744 
745 
746 // ----- other
747 void
748 NBEdgeCont::addPostProcessConnection(const std::string& from, int fromLane, const std::string& to, int toLane, bool mayDefinitelyPass, bool keepClear, SUMOReal contPos) {
749  myConnections.push_back(PostProcessConnection(from, fromLane, to, toLane, mayDefinitelyPass, keepClear, contPos));
750 }
751 
752 
753 void
755  for (std::vector<PostProcessConnection>::const_iterator i = myConnections.begin(); i != myConnections.end(); ++i) {
756  NBEdge* from = retrievePossiblySplit((*i).from, true);
757  NBEdge* to = retrievePossiblySplit((*i).to, false);
758  if (from != 0 && to != 0) {
759  if (!from->addLane2LaneConnection((*i).fromLane, to, (*i).toLane, NBEdge::L2L_USER, false, (*i).mayDefinitelyPass, (*i).keepClear, (*i).contPos)) {
760  WRITE_WARNING("Could not insert connection between '" + (*i).from + "' and '" + (*i).to + "' after build.");
761  }
762  }
763  }
764  // during loading we also kept some ambiguous connections in hope they might be valid after processing
765  // we need to make sure that all invalid connections are removed now
766  for (EdgeCont::iterator it = myEdges.begin(); it != myEdges.end(); ++it) {
767  NBEdge* edge = it->second;
768  NBNode* to = edge->getToNode();
769  // make a copy because we may delete connections
770  std::vector<NBEdge::Connection> connections = edge->getConnections();
771  for (std::vector<NBEdge::Connection>::iterator it_con = connections.begin(); it_con != connections.end(); ++it_con) {
772  NBEdge::Connection& c = *it_con;
773  if (c.toEdge != 0 && c.toEdge->getFromNode() != to) {
774  WRITE_WARNING("Found and removed invalid connection from edge '" + edge->getID() +
775  "' to edge '" + c.toEdge->getID() + "' via junction '" + to->getID() + "'.");
776  edge->removeFromConnections(c.toEdge);
777  }
778  }
779  }
780 }
781 
782 
784 NBEdgeCont::getGeneratedFrom(const std::string& id) const {
785  size_t len = id.length();
786  EdgeVector ret;
787  for (EdgeCont::const_iterator i = myEdges.begin(); i != myEdges.end(); ++i) {
788  std::string curr = (*i).first;
789  // the next check makes it possibly faster - we don not have
790  // to compare the names
791  if (curr.length() <= len) {
792  continue;
793  }
794  // the name must be the same as the given id but something
795  // beginning with a '[' must be appended to it
796  if (curr.substr(0, len) == id && curr[len] == '[') {
797  ret.push_back((*i).second);
798  continue;
799  }
800  // ok, maybe the edge is a compound made during joining of edges
801  size_t pos = curr.find(id);
802  // surely not
803  if (pos == std::string::npos) {
804  continue;
805  }
806  // check leading char
807  if (pos > 0) {
808  if (curr[pos - 1] != ']' && curr[pos - 1] != '+') {
809  // actually, this is another id
810  continue;
811  }
812  }
813  if (pos + id.length() < curr.length()) {
814  if (curr[pos + id.length()] != '[' && curr[pos + id.length()] != '+') {
815  // actually, this is another id
816  continue;
817  }
818  }
819  ret.push_back((*i).second);
820  }
821  return ret;
822 }
823 
824 
825 int
827  myGuessedRoundabouts.clear();
828  std::set<NBEdge*> loadedRoundaboutEdges;
829  for (std::set<EdgeSet>::const_iterator it = myRoundabouts.begin(); it != myRoundabouts.end(); ++it) {
830  loadedRoundaboutEdges.insert(it->begin(), it->end());
831  }
832  // step 1: keep only those edges which have no turnarounds and which are not
833  // part of a loaded roundabout
834  std::set<NBEdge*> candidates;
835  for (EdgeCont::const_iterator i = myEdges.begin(); i != myEdges.end(); ++i) {
836  NBEdge* e = (*i).second;
837  NBNode* const to = e->getToNode();
838  if (e->getTurnDestination() == 0 && to->getConnectionTo(e->getFromNode()) == 0 && loadedRoundaboutEdges.count(e) == 0) {
839  candidates.insert(e);
840  }
841  }
842 
843  // step 2:
844  std::set<NBEdge*> visited;
845  for (std::set<NBEdge*>::const_iterator i = candidates.begin(); i != candidates.end(); ++i) {
846  EdgeVector loopEdges;
847  // start with a random edge (this doesn't have to be a roundabout edge)
848  // loop over connected edges (using always the leftmost one)
849  // and keep the list in loopEdges
850  // continue until we loop back onto a loopEdges and extract the loop
851  NBEdge* e = (*i);
852  if (visited.count(e) > 0) {
853  // already seen
854  continue;
855  }
856  loopEdges.push_back(e);
857  bool doLoop = true;
858  do {
859  visited.insert(e);
860  const EdgeVector& edges = e->getToNode()->getEdges();
861  if (edges.size() < 2) {
862  doLoop = false;
863  break;
864  }
865  if (e->getTurnDestination() != 0 || e->getToNode()->getConnectionTo(e->getFromNode()) != 0) {
866  // do not follow turn-arounds while in a (tentative) loop
867  doLoop = false;
868  break;
869  }
870  EdgeVector::const_iterator me = find(edges.begin(), edges.end(), e);
871  NBContHelper::nextCW(edges, me);
872  NBEdge* left = *me;
873  SUMOReal angle = fabs(NBHelpers::relAngle(e->getAngleAtNode(e->getToNode()), left->getAngleAtNode(e->getToNode())));
874  if (angle >= 90) {
875  // roundabouts do not have sharp turns (or they wouldn't be called 'round')
876  doLoop = false;
877  break;
878  }
879  EdgeVector::const_iterator loopClosed = find(loopEdges.begin(), loopEdges.end(), left);
880  const size_t loopSize = loopEdges.end() - loopClosed;
881  if (loopSize > 0) {
882  // loop found
883  if (loopSize < 3) {
884  doLoop = false; // need at least 3 edges for a roundabout
885  } else if (loopSize < loopEdges.size()) {
886  // remove initial edges not belonging to the loop
887  EdgeVector(loopEdges.begin() + (loopEdges.size() - loopSize), loopEdges.end()).swap(loopEdges);
888  }
889  // count attachments to the outside. need at least 3 or a roundabout doesn't make much sense
890  int attachments = 0;
891  for (EdgeVector::const_iterator j = loopEdges.begin(); j != loopEdges.end(); ++j) {
892  if ((*j)->getToNode()->getEdges().size() > 2) {
893  attachments++;
894  }
895  }
896  if (attachments < 3) {
897  doLoop = false;
898  }
899  break;
900  }
901  if (visited.count(left) > 0) {
902  doLoop = false;
903  } else {
904  // keep going
905  loopEdges.push_back(left);
906  e = left;
907  }
908  } while (doLoop);
909  if (doLoop) {
910  // check form factor to avoid elongated shapes (circle: 1, square: ~0.79)
911  if (formFactor(loopEdges) > 0.6) {
912  // collected edges are marked in markRoundabouts
913  myGuessedRoundabouts.insert(EdgeSet(loopEdges.begin(), loopEdges.end()));
914  }
915  }
916  }
917  return (int)myGuessedRoundabouts.size();
918 }
919 
920 
921 SUMOReal
923  PositionVector points;
924  for (EdgeVector::const_iterator it = loopEdges.begin(); it != loopEdges.end(); ++it) {
925  points.append((*it)->getGeometry());
926  }
927  SUMOReal circumference = points.length2D();
928  return 4 * M_PI * points.area() / (circumference * circumference);
929 }
930 
931 
932 const std::set<EdgeSet>
934  std::set<EdgeSet> result = myRoundabouts;
935  result.insert(myGuessedRoundabouts.begin(), myGuessedRoundabouts.end());
936  return result;
937 }
938 
939 
940 void
941 NBEdgeCont::addRoundabout(const EdgeSet& roundabout) {
942  if (find(myRoundabouts.begin(), myRoundabouts.end(), roundabout) != myRoundabouts.end()) {
943  WRITE_WARNING("Ignoring duplicate roundabout: " + toString(roundabout));
944  } else {
945  myRoundabouts.insert(roundabout);
946  }
947 }
948 
949 
950 void
952  const std::set<EdgeSet> roundabouts = getRoundabouts();
953  for (std::set<EdgeSet>::const_iterator it = roundabouts.begin(); it != roundabouts.end(); ++it) {
954  const EdgeSet roundaboutSet = *it;
955  for (std::set<NBEdge*>::const_iterator j = roundaboutSet.begin(); j != roundaboutSet.end(); ++j) {
956  // disable turnarounds on incoming edges
957  NBNode* node = (*j)->getToNode();
958  const EdgeVector& incoming = node->getIncomingEdges();
959  for (EdgeVector::const_iterator k = incoming.begin(); k != incoming.end(); ++k) {
960  NBEdge* inEdge = *k;
961  if (roundaboutSet.count(inEdge) > 0) {
962  continue;
963  }
964  if ((inEdge)->getStep() >= NBEdge::LANES2LANES_USER) {
965  continue;
966  }
967  inEdge->removeFromConnections(inEdge->getTurnDestination(), -1);
968  }
969  // let the connections to succeeding roundabout edge have a higher priority
970  (*j)->setJunctionPriority(node, 1000);
971  node->setRoundabout();
972  }
973  }
974 }
975 
976 void
978  for (EdgeCont::iterator i = myEdges.begin(); i != myEdges.end(); ++i) {
979  NBEdge* e = i->second;
980  // is this a "real" junction?
981  // XXX nyi
982  //continue
983  const SUMOReal offset = MAX2((SUMOReal)0, e->getLength() - 3);
984  switch (e->getToNode()->getType()) {
985  case NODETYPE_PRIORITY:
986  // yield or major?
987  if (e->getJunctionPriority(e->getToNode()) > 0) {
989  } else {
991  }
992  break;
994  // yield or major?
995  if (e->getJunctionPriority(e->getToNode()) > 0) {
997  } else {
999  }
1000  break;
1001  case NODETYPE_ALLWAY_STOP:
1003  break;
1006  break;
1007  default:
1008  break;
1009  }
1010  }
1011 }
1012 
1013 
1014 int
1015 NBEdgeCont::guessSidewalks(SUMOReal width, SUMOReal minSpeed, SUMOReal maxSpeed, bool fromPermissions) {
1016  int sidewalksCreated = 0;
1017  const std::vector<std::string> edges = OptionsCont::getOptions().getStringVector("sidewalks.guess.exclude");
1018  std::set<std::string> exclude(edges.begin(), edges.end());
1019  for (EdgeCont::iterator it = myEdges.begin(); it != myEdges.end(); it++) {
1020  NBEdge* edge = it->second;
1021  if (// not excluded
1022  exclude.count(edge->getID()) == 0
1023  // does not yet have a sidewalk
1024  && edge->getPermissions(0) != SVC_PEDESTRIAN
1025  && (
1026  // guess.from-permissions
1027  (fromPermissions && (edge->getPermissions() & SVC_PEDESTRIAN) != 0)
1028  // guess from speed
1029  || (!fromPermissions && edge->getSpeed() > minSpeed && edge->getSpeed() <= maxSpeed)
1030  )) {
1031  edge->addSidewalk(width);
1032  sidewalksCreated += 1;
1033  }
1034  }
1035  return sidewalksCreated;
1036 }
1037 
1038 
1039 /****************************************************************************/
~NBEdgeCont()
Destructor.
Definition: NBEdgeCont.cpp:75
int guessSidewalks(SUMOReal width, SUMOReal minSpeed, SUMOReal maxSpeed, bool fromPermissions)
add sidwalks to edges within the given limits or permissions and return the number of edges affected ...
std::vector< Lane > myLanes
Lane information.
Definition: NBEdge.h:1315
void replaceIncoming(NBEdge *which, NBEdge *by, unsigned int laneOff)
Replaces occurences of the first edge within the list of incoming by the second Connections are remap...
Definition: NBNode.cpp:993
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&#39;s incoming edges.
Definition: NBNode.h:240
const std::string & getTypeID() const
Definition: NBEdge.h:905
A structure which describes a connection between edges or lanes.
Definition: NBEdge.h:148
void sortOutgoingLanesConnections()
Sorts all lanes of all edges within the container by their direction.
Definition: NBEdgeCont.cpp:576
void markRoundabouts()
mark edge priorities and prohibit turn-arounds for all roundabout edges
Definition: NBEdgeCont.cpp:951
void setRoundabout()
update the type of this node as a roundabout
Definition: NBNode.cpp:2383
NBEdge * retrievePossiblySplit(const std::string &id, bool downstream) const
Tries to retrieve an edge, even if it is splitted.
Definition: NBEdgeCont.cpp:282
static const SUMOReal UNSPECIFIED_WIDTH
unspecified lane width
Definition: NBEdge.h:201
A class representing a single street sign.
Definition: NBSign.h:51
bool x2cartesian_const(Position &from) const
Converts the given coordinate into a cartesian using the previous initialisation. ...
is a pedestrian
SUMOReal nearest_offset_to_point2D(const Position &p, bool perpendicular=true) const
std::vector< std::string > getAllNames() const
Returns all ids of known edges.
Definition: NBEdgeCont.cpp:510
static bool transformCoordinates(Position &from, bool includeInBoundary=true, GeoConvHelper *from_srs=0)
transforms loaded coordinates handles projections, offsets (using GeoConvHelper) and import of height...
void addSign(NBSign sign)
Definition: NBEdge.h:1092
NBEdge * toEdge
The edge the connections yields in.
Definition: NBEdge.h:164
NBNode * myTo
Definition: NBEdge.h:1264
const std::set< EdgeSet > getRoundabouts() const
Returns the determined roundabouts.
Definition: NBEdgeCont.cpp:933
static SUMOReal _2SUMOReal(const E *const data)
Definition: TplConvert.h:242
bool myNeedGeoTransformedPrunningBoundary
whether a geo transform has been applied to the pruning boundary
Definition: NBEdgeCont.h:620
#define M_PI
Definition: angles.h:37
A container for traffic light definitions and built programs.
int guessRoundabouts()
Determines which edges belong to roundabouts and increases their priority.
Definition: NBEdgeCont.cpp:826
void setLaneWidth(int lane, SUMOReal width)
set lane specific width (negative lane implies set for all lanes)
Definition: NBEdge.cpp:2263
bool myRemoveEdgesAfterJoining
Whether edges shall be joined first, then removed.
Definition: NBEdgeCont.h:596
void setSpeed(int lane, SUMOReal speed)
set lane specific speed (negative lane implies set for all lanes)
Definition: NBEdge.cpp:2318
const std::vector< NBEdge::Lane > & getLanes() const
Returns the lane definitions.
Definition: NBEdge.h:500
void moveOutgoingConnectionsFrom(NBEdge *e, unsigned int laneOff)
Definition: NBEdge.cpp:1861
void addSidewalk(SUMOReal width)
add a pedestrian sidewalk of the given width and shift existing connctions
Definition: NBEdge.cpp:2447
static GeoConvHelper & getProcessing()
the coordinate transformation to use for input conversion and processing
Definition: GeoConvHelper.h:98
void removeEdge(NBEdge *edge, bool removeFromConnections=true)
Removes edge from this node and optionally removes connections as well.
Definition: NBNode.cpp:1173
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.
Definition: NBEdge.h:70
bool addLane2LaneConnection(unsigned int fromLane, NBEdge *dest, unsigned int toLane, Lane2LaneInfoType type, bool mayUseSameDestination=false, bool mayDefinitelyPass=false, bool keepClear=true, SUMOReal contPos=UNSPECIFIED_CONTPOS)
Adds a connection between the specified this edge&#39;s lane and an approached one.
Definition: NBEdge.cpp:675
A container for districts.
static GeoConvHelper & getLoaded()
the coordinate transformation that was loaded fron an input file
void removeDoubleEdges()
Definition: NBNode.cpp:1061
T MAX2(T a, T b)
Definition: StdDefs.h:79
void clearControllingTLInformation() const
Clears information about controlling traffic lights for all connenections of all edges.
Definition: NBEdgeCont.cpp:568
void setPermissions(SVCPermissions permissions, int lane=-1)
set allowed/disallowed classes for the given lane or for all lanes if -1 is given ...
Definition: NBEdge.cpp:2334
void generateStreetSigns()
assigns street signs to edges based on toNode types
Definition: NBEdgeCont.cpp:977
void rename(NBEdge *edge, const std::string &newID)
Renames the edge. Throws exception if newID already exists.
Definition: NBEdgeCont.cpp:399
bool splitAt(NBDistrictCont &dc, NBEdge *edge, NBNode *node)
Splits the edge at the position nearest to the given node.
Definition: NBEdgeCont.cpp:411
void recheckPostProcessConnections()
Try to set any stored connections.
Definition: NBEdgeCont.cpp:754
SUMOReal getFloat(const std::string &name) const
Returns the SUMOReal-value of the named option (only for Option_Float)
static void nextCW(const EdgeVector &edges, EdgeVector::const_iterator &from)
unsigned int myEdgesSplit
the number of splits of edges during the building
Definition: NBEdgeCont.h:587
static const SUMOReal UNSPECIFIED_OFFSET
unspecified lane offset
Definition: NBEdge.h:203
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. ...
Definition: NBHelpers.cpp:97
void computeLanes2Edges()
Computes for each edge which lanes approach the next edges.
Definition: NBEdgeCont.cpp:592
std::vector< PostProcessConnection > myConnections
The list of connections to recheck.
Definition: NBEdgeCont.h:571
#define WRITE_WARNING(msg)
Definition: MsgHandler.h:200
static OptionsCont & getOptions()
Retrieves the options.
Definition: OptionsCont.cpp:69
void checkGeometries(const SUMOReal maxAngle, const SUMOReal minRadius, bool fix)
Definition: NBEdgeCont.cpp:557
NBEdgeCont(NBTypeCont &tc)
Constructor.
Definition: NBEdgeCont.cpp:66
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&#39;s outgoing edges.
Definition: NBNode.h:248
const std::string & getID() const
Returns the id.
Definition: Named.h:65
SUMOReal length2D() const
Returns the length.
bool addEdge2EdgeConnection(NBEdge *dest)
Adds a connection to another edge.
Definition: NBEdge.cpp:651
bool overlapsWith(const AbstractPoly &poly, SUMOReal offset=0) const
Returns whether the boundary overlaps with the given polygon.
Definition: Boundary.cpp:156
SVCPermissions myVehicleClasses2Keep
Set of vehicle types which must be allowed on edges in order to keep them.
Definition: NBEdgeCont.h:605
const Position & getPosition() const
Returns the position of this node.
Definition: NBNode.h:228
void reduceGeometries(const SUMOReal minDist)
Definition: NBEdgeCont.cpp:549
Lanes to lanes - relationships are loaded; no recheck is necessary/wished.
Definition: NBEdge.h:102
std::set< NBEdge * > EdgeSet
Definition: NBCont.h:51
bool usingGeoProjection() const
Returns whether a transformation from geo to metric coordinates will be performed.
bool insert(NBEdge *edge, bool ignorePrunning=false)
Adds an edge to the dictionary.
Definition: NBEdgeCont.cpp:161
void removeUnwishedEdges(NBDistrictCont &dc)
Removes unwished edges (not in keep-edges)
Definition: NBEdgeCont.cpp:521
void extract(NBDistrictCont &dc, NBEdge *edge, bool remember=false)
Removes the given edge from the container like erase but does not delete it.
Definition: NBEdgeCont.cpp:387
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:46
A list of positions.
void applyOptions(OptionsCont &oc)
Initialises the storage by applying given options.
Definition: NBEdgeCont.cpp:81
unsigned int getNumLanes() const
Returns the number of lanes.
Definition: NBEdge.h:345
std::set< std::string > myEdges2Keep
Set of ids of edges which shall explicitly be kept.
Definition: NBEdgeCont.h:599
SumoXMLNodeType getType() const
Returns the type of this node.
Definition: NBNode.h:265
void computeEdge2Edges(bool noLeftMovers)
Computes for each edge the approached edges.
Definition: NBEdgeCont.cpp:584
void computeLaneShapes()
Computes the shapes of all lanes of all edges stored in the container.
Definition: NBEdgeCont.cpp:632
const EdgeVector & getEdges() const
Returns all edges which participate in this node.
Definition: NBNode.h:256
T MIN2(T a, T b)
Definition: StdDefs.h:73
void splitGeometry(NBNodeCont &nc)
Splits edges into multiple if they have a complex geometry.
Definition: NBEdgeCont.cpp:538
EdgeCont myEdges
The instance of the dictionary (id->edge)
Definition: NBEdgeCont.h:578
#define POSITION_EPS
Definition: config.h:188
SVCPermissions parseVehicleClasses(const std::string &allowedS)
Parses the given definition of allowed vehicle classes into the given containers Deprecated classes g...
void clear()
Deletes all edges.
Definition: NBEdgeCont.cpp:146
EdgeCont myExtractedEdges
The extracted nodes which are kept for reference.
Definition: NBEdgeCont.h:581
bool knows(const std::string &type) const
Returns whether the named type is in the container.
Definition: NBTypeCont.cpp:75
std::string toString(const T &t, std::streamsize accuracy=OUTPUT_ACCURACY)
Definition: ToString.h:53
The connection was given by the user.
Definition: NBEdge.h:113
std::set< EdgeSet > myGuessedRoundabouts
Edges marked as belonging to a roundabout after guessing.
Definition: NBEdgeCont.h:626
void removeFromConnections(NBEdge *toEdge, int fromLane=-1, int toLane=-1, bool tryLater=false)
Removes the specified connection(s)
Definition: NBEdge.cpp:916
std::set< EdgeSet > myRoundabouts
Edges marked as belonging to a roundabout by the user (each EdgeVector is a roundabout) ...
Definition: NBEdgeCont.h:624
NBEdge * getConnectionTo(NBNode *n) const
Definition: NBNode.cpp:1614
int getJunctionPriority(const NBNode *const node) const
Returns the junction priority (normalised for the node currently build)
Definition: NBEdge.cpp:1261
void joinSameNodeConnectingEdges(NBDistrictCont &dc, NBTrafficLightLogicCont &tlc, EdgeVector edges)
Joins the given edges because they connect the same nodes.
Definition: NBEdgeCont.cpp:640
static SUMOReal formFactor(const EdgeVector &loopEdges)
compute the form factor for a loop of edges
Definition: NBEdgeCont.cpp:922
std::pair< PositionVector, PositionVector > splitAt(SUMOReal where) const
Returns the two lists made when this list vector is splitted at the given point.
SVCPermissions myVehicleClasses2Remove
Set of vehicle types which need not be supported (edges which allow ONLY these are removed) ...
Definition: NBEdgeCont.h:608
#define WRITE_ERROR(msg)
Definition: MsgHandler.h:205
SVCPermissions getPermissions(int lane=-1) const
get the union of allowed classes over all lanes or for a specific lane
Definition: NBEdge.cpp:2362
PositionVector myPrunningBoundary
Boundary within which an edge must be located in order to be kept.
Definition: NBEdgeCont.h:617
SUMOReal length() const
Returns the length.
std::set< std::string > myTypes2Keep
Set of edges types which shall be kept.
Definition: NBEdgeCont.h:611
Boundary & grow(SUMOReal by)
extends the boundary by the given amount
Definition: Boundary.cpp:201
NBNode * getToNode() const
Returns the destination node of the edge.
Definition: NBEdge.h:369
SUMOReal myEdgesMinSpeed
The minimum speed an edge may have in order to be kept (default: -1)
Definition: NBEdgeCont.h:593
void setID(const std::string &newID)
resets the id
Definition: Named.h:73
void replaceOutgoing(NBEdge *which, NBEdge *by, unsigned int laneOff)
Replaces occurences of the first edge within the list of outgoing by the second Connections are remap...
Definition: NBNode.cpp:957
NBEdge * retrieve(const std::string &id, bool retrieveExtracted=false) const
Returns the edge that has the given id.
Definition: NBEdgeCont.cpp:246
void appendTurnarounds(bool noTLSControlled)
Appends turnarounds to all edges stored in the container.
Definition: NBEdgeCont.cpp:608
std::vector< NBEdge * > EdgeVector
Definition: NBCont.h:41
bool getShallBeDiscarded(const std::string &type) const
Returns the information whether edges of this type shall be discarded.
Definition: NBTypeCont.cpp:199
const PositionVector & getGeometry() const
Returns the geometry of the edge.
Definition: NBEdge.h:521
A storage for options typed value containers)
Definition: OptionsCont.h:108
static SUMOReal nearest_offset_on_line_to_point2D(const Position &lineStart, const Position &lineEnd, const Position &p, bool perpendicular=true)
Definition: GeomHelper.cpp:100
void erase(NBDistrictCont &dc, NBEdge *edge)
Removes the given edge from the container (deleting it)
Definition: NBEdgeCont.cpp:380
A structure representing a connection between two lanes.
Definition: NBEdgeCont.h:542
void computeEdgeShapes()
Computes the shapes of all edges stored in the container.
Definition: NBEdgeCont.cpp:624
The connection was computed.
Definition: NBEdge.h:111
Represents a single node (junction) during network building.
Definition: NBNode.h:74
void dismissVehicleClassInformation()
Definition: NBEdge.cpp:2383
NBTypeCont & myTypeCont
The network builder; used to obtain type information.
Definition: NBEdgeCont.h:537
void recheckLaneSpread()
Rechecks whether the lane spread is proper.
Definition: NBEdgeCont.cpp:727
void setEndOffset(int lane, SUMOReal offset)
set lane specific end-offset (negative lane implies set for all lanes)
Definition: NBEdge.cpp:2302
#define SUMOReal
Definition: config.h:214
static SUMOReal relAngle(SUMOReal angle1, SUMOReal angle2)
Definition: NBHelpers.cpp:56
void removeFromSinksAndSources(NBEdge *const e)
Removes the given edge from the lists of sources and sinks in all stored districts.
std::set< std::string > myTypes2Remove
Set of edges types which shall be removed.
Definition: NBEdgeCont.h:614
void recheckLanes()
Rechecks whether all lanes have a successor for each of the stored edges.
Definition: NBEdgeCont.cpp:600
SUMOReal getSpeed() const
Returns the speed allowed on this edge.
Definition: NBEdge.h:429
Container for nodes during the netbuilding process.
Definition: NBNodeCont.h:64
std::set< std::string > myIgnoredEdges
The ids of ignored edges.
Definition: NBEdgeCont.h:584
EdgeVector getGeneratedFrom(const std::string &id) const
Returns the edges which have been built by splitting the edge of the given id.
Definition: NBEdgeCont.cpp:784
void replaceRemoved(NBEdge *removed, int removedLane, NBEdge *by, int byLane)
Replaces occurences of the removed edge/lane in all definitions by the given edge.
SUMOReal area() const
Returns the area (0 for non-closed)
void addRoundabout(const EdgeSet &roundabout)
add user specified roundabout
Definition: NBEdgeCont.cpp:941
void addPostProcessConnection(const std::string &from, int fromLane, const std::string &to, int toLane, bool mayDefinitelyPass, bool keepClear, SUMOReal contPos)
Adds a connection which could not be set during loading.
Definition: NBEdgeCont.cpp:748
Boundary getBoxBoundary() const
Returns a boundary enclosing this list of lines.
const std::vector< Connection > & getConnections() const
Returns the connections.
Definition: NBEdge.h:761
NBNode * myFrom
The source and the destination node.
Definition: NBEdge.h:1264
NBEdge * getTurnDestination(bool possibleDestination=false) const
Definition: NBEdge.cpp:2126
bool exists(const std::string &name) const
Returns the information whether the named option is known.
void append(const PositionVector &v, SUMOReal sameThreshold=2.0)
void copyConnectionsFrom(NBEdge *src)
Definition: NBEdge.cpp:1024
bool ignoreFilterMatch(NBEdge *edge)
Returns true if this edge matches one of the removal criteria.
Definition: NBEdgeCont.cpp:182
A storage for available types of edges.
Definition: NBTypeCont.h:62
SUMOReal getLength() const
Returns the computed length of the edge.
Definition: NBEdge.h:404
bool isSet(const std::string &name, bool failOnNonExistant=true) const
Returns the information whether the named option is set.
SUMOReal getAngleAtNode(const NBNode *const node) const
Returns the angle of the edge&#39;s geometry at the given node.
Definition: NBEdge.cpp:1281
std::set< std::string > myEdges2Remove
Set of ids of edges which shall explicitly be removed.
Definition: NBEdgeCont.h:602
NBNode * getFromNode() const
Returns the origin node of the edge.
Definition: NBEdge.h:361