SUMO - Simulation of Urban MObility
NBEdgeCont.h
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2001-2017 German Aerospace Center (DLR) and others.
4 /****************************************************************************/
5 //
6 // This program and the accompanying materials
7 // are made available under the terms of the Eclipse Public License v2.0
8 // which accompanies this distribution, and is available at
9 // http://www.eclipse.org/legal/epl-v20.html
10 //
11 /****************************************************************************/
19 // Storage for edges, including some functionality operating on multiple edges
20 /****************************************************************************/
21 #ifndef NBEdgeCont_h
22 #define NBEdgeCont_h
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 <map>
35 #include <iostream>
36 #include <string>
37 #include <vector>
38 #include <set>
39 #include "NBCont.h"
44 
45 
46 // ===========================================================================
47 // class declarations
48 // ===========================================================================
49 class NBNodeCont;
50 class NBTypeCont;
51 class NBEdge;
52 class NBNode;
53 class OptionsCont;
54 class NBDistrictCont;
56 class OutputDevice;
57 
58 
59 // ===========================================================================
60 // class definitions
61 // ===========================================================================
66 class NBEdgeCont {
67 public:
72 
73 
75  ~NBEdgeCont();
76 
77 
86  void applyOptions(OptionsCont& oc);
87 
88 
90  void clear();
91 
92 
93 
94 
97 
111  bool insert(NBEdge* edge, bool ignorePrunning = false);
112 
113 
122  NBEdge* retrieve(const std::string& id, bool retrieveExtracted = false) const;
123 
124 
135  NBEdge* retrievePossiblySplit(const std::string& id, bool downstream) const;
136 
137 
150  NBEdge* retrievePossiblySplit(const std::string& id, const std::string& hint, bool incoming) const;
151 
152 
163  NBEdge* retrievePossiblySplit(const std::string& id, double pos) const;
164 
165 
172  void erase(NBDistrictCont& dc, NBEdge* edge);
173 
174 
184  void extract(NBDistrictCont& dc, NBEdge* edge, bool remember = false);
185 
186 
190  std::map<std::string, NBEdge*>::const_iterator begin() const {
191  return myEdges.begin();
192  }
193 
194 
198  std::map<std::string, NBEdge*>::const_iterator end() const {
199  return myEdges.end();
200  }
202 
203 
204 
207 
221  bool splitAt(NBDistrictCont& dc, NBEdge* edge, NBNode* node);
222 
223 
247  bool splitAt(NBDistrictCont& dc, NBEdge* edge, NBNode* node,
248  const std::string& firstEdgeName, const std::string& secondEdgeName,
249  int noLanesFirstEdge, int noLanesSecondEdge,
250  const double speed = -1., const int changedLeft = 0);
251 
252 
268  bool splitAt(NBDistrictCont& dc, NBEdge* edge, double edgepos, NBNode* node,
269  const std::string& firstEdgeName, const std::string& secondEdgeName,
270  int noLanesFirstEdge, int noLanesSecondEdge,
271  const double speed = -1., const int changedLeft = 0);
273 
274 
275 
278 
282  int size() const {
283  return (int) myEdges.size();
284  }
285 
286 
291  std::vector<std::string> getAllNames() const;
292 
293 
297  int getNoEdgeSplits() const {
298  return myEdgesSplit;
299  }
301 
302 
303 
306 
312 
313 
322  void splitGeometry(NBNodeCont& nc);
323 
324 
329  void reduceGeometries(const double minDist);
330 
331 
338  void checkGeometries(const double maxAngle, const double minRadius, bool fix);
340 
341 
342 
345 
354 
355 
364  void computeEdge2Edges(bool noLeftMovers);
365 
366 
374  void computeLanes2Edges();
375 
376 
384  void recheckLanes();
385 
386 
395  void appendTurnarounds(bool noTLSControlled);
396 
397 
404  void appendTurnarounds(const std::set<std::string>& ids, bool noTLSControlled);
405 
406 
415  void computeEdgeShapes();
416 
417 
426  void computeLaneShapes();
427 
428 
431  void clearControllingTLInformation() const;
432 
433 
442  NBTrafficLightLogicCont& tlc, EdgeVector edges);
443 
444 
447  void guessOpposites();
448 
449 
454  void recheckLaneSpread();
455 
457 
459  NBEdge* getOppositeByID(const std::string& edgeID) const;
460 
462  NBEdge* getByID(const std::string& edgeID) const;
463 
468  int guessRoundabouts();
469 
470 
474  bool wasIgnored(std::string id) const {
475  return myIgnoredEdges.count(id) != 0;
476  }
477 
479  void ignore(std::string id) {
480  myIgnoredEdges.insert(id);
481  }
482 
485  bool wasRemoved(std::string id) const {
486  return myExtractedEdges.count(id) != 0;
487  }
488 
491  void rename(NBEdge* edge, const std::string& newID);
492 
493 
494 
497 
511  void addPostProcessConnection(const std::string& from, int fromLane, const std::string& to, int toLane, bool mayDefinitelyPass,
512  bool keepClear, double contPos, double visibility, double speed,
513  const PositionVector& customShape,
514  bool warnOnly = false);
515 
516 
521 
523  void generateStreetSigns();
524 
526  int guessSidewalks(double width, double minSpeed, double maxSpeed, bool fromPermissions);
527 
528 
532  const std::set<EdgeSet> getRoundabouts() const;
533 
535  void addRoundabout(const EdgeSet& roundabout);
536 
538  void markRoundabouts();
539 
541  void patchRoundabouts(NBEdge* orig, NBEdge* part1, NBEdge* part2, std::set<EdgeSet>& roundabouts);
542 
544  bool ignoreFilterMatch(NBEdge* edge);
545 
547  int remapIDs(bool numericaIDs, bool reservedIDs);
548 
550  void checkOverlap(double threshold, double zThreshold) const;
551 
553  void checkGrade(double threshold) const;
554 
555 
562  EdgeVector getGeneratedFrom(const std::string& id) const;
563 
564 private:
566  static double formFactor(const EdgeVector& loopEdges);
567 
568 private:
571 
576  public:
584  PostProcessConnection(const std::string& from_, int fromLane_, const std::string& to_, int toLane_,
585  bool mayDefinitelyPass_, bool keepClear_, double contPos_, double visibility_, double speed_,
586  const PositionVector& customShape_,
587  bool warnOnly_ = false) :
588  from(from_), fromLane(fromLane_), to(to_), toLane(toLane_), mayDefinitelyPass(mayDefinitelyPass_), keepClear(keepClear_), contPos(contPos_),
589  visibility(visibility_),
590  speed(speed_),
591  customShape(customShape_),
592  warnOnly(warnOnly_) {
593  }
595  std::string from;
597  int fromLane;
599  std::string to;
601  int toLane;
605  bool keepClear;
607  double contPos;
609  double visibility;
611  double speed;
615  bool warnOnly;
616  };
617 
619  std::vector<PostProcessConnection> myConnections;
620 
621 
623  typedef std::map<std::string, NBEdge*> EdgeCont;
624 
626  EdgeCont myEdges;
627 
630 
632  std::set<std::string> myIgnoredEdges;
633 
636 
639 
642 
645 
647  std::set<std::string> myEdges2Keep;
648 
650  std::set<std::string> myEdges2Remove;
651 
654 
657 
659  std::set<std::string> myTypes2Keep;
660 
662  std::set<std::string> myTypes2Remove;
663 
666 
670 
672  std::set<EdgeSet> myRoundabouts;
674  std::set<EdgeSet> myGuessedRoundabouts;
675 
676 private:
678  NBEdgeCont(const NBEdgeCont& s);
679 
681  NBEdgeCont& operator=(const NBEdgeCont& s);
682 
683 };
684 
685 
686 #endif
687 
688 /****************************************************************************/
689 
~NBEdgeCont()
Destructor.
Definition: NBEdgeCont.cpp:71
NBEdge * getByID(const std::string &edgeID) const
Returns the edge with id if it exists.
Definition: NBEdgeCont.cpp:850
void sortOutgoingLanesConnections()
Sorts all lanes of all edges within the container by their direction.
Definition: NBEdgeCont.cpp:616
void markRoundabouts()
mark edge priorities and prohibit turn-arounds for all roundabout edges
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:901
void reduceGeometries(const double minDist)
Definition: NBEdgeCont.cpp:589
double contPos
custom position for internal junction on this connection
Definition: NBEdgeCont.h:607
A container for traffic light definitions and built programs.
int guessRoundabouts()
Determines which edges belong to roundabouts and increases their priority.
Definition: NBEdgeCont.cpp:943
bool myRemoveEdgesAfterJoining
Whether edges shall be joined first, then removed.
Definition: NBEdgeCont.h:644
NBEdge * getOppositeByID(const std::string &edgeID) const
Returns the edge with negated id if it exists.
Definition: NBEdgeCont.cpp:843
std::map< std::string, NBEdge * > EdgeCont
The type of the dictionary where an edge may be found by its id.
Definition: NBEdgeCont.h:623
int SVCPermissions
bitset where each bit declares whether a certain SVC may use this edge/lane
The representation of a single edge during network building.
Definition: NBEdge.h:70
void guessOpposites()
Sets opposite lane information for geometrically close edges.
Definition: NBEdgeCont.cpp:799
A container for districts.
void generateStreetSigns()
assigns street signs to edges based on toNode types
void rename(NBEdge *edge, const std::string &newID)
Renames the edge. Throws exception if newID already exists.
Definition: NBEdgeCont.cpp:403
bool splitAt(NBDistrictCont &dc, NBEdge *edge, NBNode *node)
Splits the edge at the position nearest to the given node.
Definition: NBEdgeCont.cpp:415
void recheckPostProcessConnections()
Try to set any stored connections.
Definition: NBEdgeCont.cpp:865
std::map< std::string, NBEdge * >::const_iterator end() const
Returns the pointer to the end of the stored edges.
Definition: NBEdgeCont.h:198
PositionVector customShape
custom shape for connection
Definition: NBEdgeCont.h:613
int getNoEdgeSplits() const
Returns the number of edge splits.
Definition: NBEdgeCont.h:297
void computeLanes2Edges()
Computes for each edge which lanes approach the next edges.
Definition: NBEdgeCont.cpp:632
std::vector< PostProcessConnection > myConnections
The list of connections to recheck.
Definition: NBEdgeCont.h:619
void checkGeometries(const double maxAngle, const double minRadius, bool fix)
Definition: NBEdgeCont.cpp:597
void checkOverlap(double threshold, double zThreshold) const
check whether edges overlap
void checkGrade(double threshold) const
check whether edges are to steep
PositionVector myPruningBoundary
Boundary within which an edge must be located in order to be kept.
Definition: NBEdgeCont.h:665
NBEdgeCont(NBTypeCont &tc)
Constructor.
Definition: NBEdgeCont.cpp:62
SVCPermissions myVehicleClasses2Keep
Set of vehicle types which must be allowed on edges in order to keep them.
Definition: NBEdgeCont.h:653
bool keepClear
Whether the connection may be passed without braking.
Definition: NBEdgeCont.h:605
double myEdgesMinSpeed
The minimum speed an edge may have in order to be kept (default: -1)
Definition: NBEdgeCont.h:641
std::map< std::string, NBEdge * >::const_iterator begin() const
Returns the pointer to the begin of the stored edges.
Definition: NBEdgeCont.h:190
std::set< NBEdge * > EdgeSet
container for unique edges
Definition: NBCont.h:50
void patchRoundabouts(NBEdge *orig, NBEdge *part1, NBEdge *part2, std::set< EdgeSet > &roundabouts)
fix roundabout information after splitting an edge
Definition: NBEdgeCont.cpp:532
double visibility
custom foe visiblity for connection
Definition: NBEdgeCont.h:609
bool insert(NBEdge *edge, bool ignorePrunning=false)
Adds an edge to the dictionary.
Definition: NBEdgeCont.cpp:157
NBEdge * retrievePossiblySplit(const std::string &id, bool downstream) const
Tries to retrieve an edge, even if it is splitted.
Definition: NBEdgeCont.cpp:286
void removeUnwishedEdges(NBDistrictCont &dc)
Removes unwished edges (not in keep-edges)
Definition: NBEdgeCont.cpp:561
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:391
A list of positions.
void applyOptions(OptionsCont &oc)
Initialises the storage by applying given options.
Definition: NBEdgeCont.cpp:77
bool mayDefinitelyPass
Whether the connection may be passed without braking.
Definition: NBEdgeCont.h:603
bool wasRemoved(std::string id) const
Returns whether the edge with the id was deleted explicitly.
Definition: NBEdgeCont.h:485
std::set< std::string > myEdges2Keep
Set of ids of edges which shall explicitly be kept.
Definition: NBEdgeCont.h:647
void computeEdge2Edges(bool noLeftMovers)
Computes for each edge the approached edges.
Definition: NBEdgeCont.cpp:624
void computeLaneShapes()
Computes the shapes of all lanes of all edges stored in the container.
Definition: NBEdgeCont.cpp:704
void clearControllingTLInformation() const
Clears information about controlling traffic lights for all connenections of all edges.
Definition: NBEdgeCont.cpp:608
static double formFactor(const EdgeVector &loopEdges)
compute the form factor for a loop of edges
Storage for edges, including some functionality operating on multiple edges.
Definition: NBEdgeCont.h:66
void splitGeometry(NBNodeCont &nc)
Splits edges into multiple if they have a complex geometry.
Definition: NBEdgeCont.cpp:578
EdgeCont myEdges
The instance of the dictionary (id->edge)
Definition: NBEdgeCont.h:626
bool warnOnly
whether a failure to set this connection is a warning or an error
Definition: NBEdgeCont.h:615
const std::set< EdgeSet > getRoundabouts() const
Returns the determined roundabouts.
void clear()
Deletes all edges.
Definition: NBEdgeCont.cpp:142
EdgeCont myExtractedEdges
The extracted nodes which are kept for reference.
Definition: NBEdgeCont.h:629
std::set< EdgeSet > myGuessedRoundabouts
Edges marked as belonging to a roundabout after guessing.
Definition: NBEdgeCont.h:674
std::set< EdgeSet > myRoundabouts
Edges marked as belonging to a roundabout by the user (each EdgeVector is a roundabout) ...
Definition: NBEdgeCont.h:672
void joinSameNodeConnectingEdges(NBDistrictCont &dc, NBTrafficLightLogicCont &tlc, EdgeVector edges)
Joins the given edges because they connect the same nodes.
Definition: NBEdgeCont.cpp:712
SVCPermissions myVehicleClasses2Remove
Set of vehicle types which need not be supported (edges which allow ONLY these are removed) ...
Definition: NBEdgeCont.h:656
std::string from
The id of the edge the connection starts at.
Definition: NBEdgeCont.h:595
std::set< std::string > myTypes2Keep
Set of edges types which shall be kept.
Definition: NBEdgeCont.h:659
int guessSidewalks(double width, double minSpeed, double maxSpeed, bool fromPermissions)
add sidwalks to edges within the given limits or permissions and return the number of edges affected ...
void appendTurnarounds(bool noTLSControlled)
Appends turnarounds to all edges stored in the container.
Definition: NBEdgeCont.cpp:680
PostProcessConnection(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 warnOnly_=false)
Constructor.
Definition: NBEdgeCont.h:584
std::vector< NBEdge * > EdgeVector
container for (sorted) edges
Definition: NBCont.h:40
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 warnOnly=false)
Adds a connection which could not be set during loading.
Definition: NBEdgeCont.cpp:857
NBEdge * retrieve(const std::string &id, bool retrieveExtracted=false) const
Returns the edge that has the given id.
Definition: NBEdgeCont.cpp:250
double speed
custom speed for connection
Definition: NBEdgeCont.h:611
bool myNeedGeoTransformedPruningBoundary
whether a geo transform has been applied to the pruning boundary
Definition: NBEdgeCont.h:668
int toLane
The number of the lane the connection ends at.
Definition: NBEdgeCont.h:601
int size() const
Returns the number of edges.
Definition: NBEdgeCont.h:282
A storage for options typed value containers)
Definition: OptionsCont.h:98
void erase(NBDistrictCont &dc, NBEdge *edge)
Removes the given edge from the container (deleting it)
Definition: NBEdgeCont.cpp:384
NBEdgeCont & operator=(const NBEdgeCont &s)
invalidated assignment operator
A structure representing a connection between two lanes.
Definition: NBEdgeCont.h:575
void computeEdgeShapes()
Computes the shapes of all edges stored in the container.
Definition: NBEdgeCont.cpp:696
void ignore(std::string id)
mark the given edge id as ignored
Definition: NBEdgeCont.h:479
Represents a single node (junction) during network building.
Definition: NBNode.h:74
NBTypeCont & myTypeCont
The network builder; used to obtain type information.
Definition: NBEdgeCont.h:570
std::string to
The id of the edge the connection ends at.
Definition: NBEdgeCont.h:599
void recheckLaneSpread()
Rechecks whether the lane spread is proper.
Definition: NBEdgeCont.cpp:829
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:70
std::set< std::string > myTypes2Remove
Set of edges types which shall be removed.
Definition: NBEdgeCont.h:662
bool wasIgnored(std::string id) const
Returns whether the edge with the id was ignored during parsing.
Definition: NBEdgeCont.h:474
void recheckLanes()
Rechecks whether all lanes have a successor for each of the stored edges.
Definition: NBEdgeCont.cpp:640
Container for nodes during the netbuilding process.
Definition: NBNodeCont.h:66
int fromLane
The number of the lane the connection starts at.
Definition: NBEdgeCont.h:597
std::set< std::string > myIgnoredEdges
The ids of ignored edges.
Definition: NBEdgeCont.h:632
void addRoundabout(const EdgeSet &roundabout)
add user specified roundabout
int remapIDs(bool numericaIDs, bool reservedIDs)
remap node IDs accoring to options –numerical-ids and –reserved-ids
std::vector< std::string > getAllNames() const
Returns all ids of known edges.
Definition: NBEdgeCont.cpp:550
bool ignoreFilterMatch(NBEdge *edge)
Returns true if this edge matches one of the removal criteria.
Definition: NBEdgeCont.cpp:178
A storage for available types of edges.
Definition: NBTypeCont.h:61
int myEdgesSplit
the number of splits of edges during the building
Definition: NBEdgeCont.h:635
std::set< std::string > myEdges2Remove
Set of ids of edges which shall explicitly be removed.
Definition: NBEdgeCont.h:650