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-2018 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials
5 // are made available under the terms of the Eclipse Public License v2.0
6 // which accompanies this distribution, and is available at
7 // http://www.eclipse.org/legal/epl-v20.html
8 // SPDX-License-Identifier: EPL-2.0
9 /****************************************************************************/
17 // Storage for edges, including some functionality operating on multiple edges
18 /****************************************************************************/
19 #ifndef NBEdgeCont_h
20 #define NBEdgeCont_h
21 
22 
23 // ===========================================================================
24 // included modules
25 // ===========================================================================
26 #include <config.h>
27 
28 #include <map>
29 #include <iostream>
30 #include <string>
31 #include <vector>
32 #include <set>
33 #include "NBCont.h"
38 
39 
40 // ===========================================================================
41 // class declarations
42 // ===========================================================================
43 class OptionsCont;
44 class OutputDevice;
45 class NBNodeCont;
46 class NBTypeCont;
47 class NBEdge;
48 class NBNode;
49 class NBDistrictCont;
51 class NBPTStopCont;
52 
53 
54 // ===========================================================================
55 // class definitions
56 // ===========================================================================
61 class NBEdgeCont {
62 public:
67 
68 
70  ~NBEdgeCont();
71 
72 
81  void applyOptions(OptionsCont& oc);
82 
83 
85  void clear();
86 
87 
88 
89 
92 
106  bool insert(NBEdge* edge, bool ignorePrunning = false);
107 
108 
117  NBEdge* retrieve(const std::string& id, bool retrieveExtracted = false) const;
118 
119 
130  NBEdge* retrievePossiblySplit(const std::string& id, bool downstream) const;
131 
132 
145  NBEdge* retrievePossiblySplit(const std::string& id, const std::string& hint, bool incoming) const;
146 
147 
158  NBEdge* retrievePossiblySplit(const std::string& id, double pos) const;
159 
160 
167  void erase(NBDistrictCont& dc, NBEdge* edge);
168 
169 
179  void extract(NBDistrictCont& dc, NBEdge* edge, bool remember = false);
180 
181 
185  std::map<std::string, NBEdge*>::const_iterator begin() const {
186  return myEdges.begin();
187  }
188 
189 
193  std::map<std::string, NBEdge*>::const_iterator end() const {
194  return myEdges.end();
195  }
197 
198 
199 
202 
206  struct Split {
207  Split() : offset(0), offsetFactor(1) {}
209  std::vector<int> lanes;
211  double pos;
213  double speed;
217  std::string idBefore;
219  std::string idAfter;
221  std::string nameID;
223  double offset;
226  };
227 
228  void processSplits(NBEdge* e, std::vector<Split> splits,
230 
231 
245  bool splitAt(NBDistrictCont& dc, NBEdge* edge, NBNode* node);
246 
247 
271  bool splitAt(NBDistrictCont& dc, NBEdge* edge, NBNode* node,
272  const std::string& firstEdgeName, const std::string& secondEdgeName,
273  int noLanesFirstEdge, int noLanesSecondEdge,
274  const double speed = -1., const int changedLeft = 0);
275 
276 
292  bool splitAt(NBDistrictCont& dc, NBEdge* edge, double edgepos, NBNode* node,
293  const std::string& firstEdgeName, const std::string& secondEdgeName,
294  int noLanesFirstEdge, int noLanesSecondEdge,
295  const double speed = -1., const int changedLeft = 0);
297 
298 
299 
302 
306  int size() const {
307  return (int) myEdges.size();
308  }
309 
310 
315  std::vector<std::string> getAllNames() const;
316 
317 
321  int getNoEdgeSplits() const {
322  return myEdgesSplit;
323  }
325 
326 
327 
330 
336 
337 
346  void splitGeometry(NBNodeCont& nc);
347 
348 
353  void reduceGeometries(const double minDist);
354 
355 
362  void checkGeometries(const double maxAngle, const double minRadius, bool fix);
364 
365 
366 
369 
378 
379 
388  void computeEdge2Edges(bool noLeftMovers);
389 
390 
398  void computeLanes2Edges();
399 
400 
408  void recheckLanes();
409 
410 
420  void appendTurnarounds(bool noTLSControlled, bool onlyDeadends);
421 
422 
429  void appendTurnarounds(const std::set<std::string>& ids, bool noTLSControlled);
430 
433  void appendRailwayTurnarounds(const NBPTStopCont& sc);
434 
435 
444  void computeEdgeShapes(double smoothElevationThreshold=-1);
445 
446 
455  void computeLaneShapes();
456 
457 
460  void clearControllingTLInformation() const;
461 
462 
471  NBTrafficLightLogicCont& tlc, EdgeVector edges);
472 
473 
476  void guessOpposites();
477 
478 
483  void recheckLaneSpread();
484 
486 
488  NBEdge* getOppositeByID(const std::string& edgeID) const;
489 
491  NBEdge* getByID(const std::string& edgeID) const;
492 
497  int guessRoundabouts();
498 
499 
503  bool wasIgnored(std::string id) const {
504  return myIgnoredEdges.count(id) != 0;
505  }
506 
508  void ignore(std::string id) {
509  myIgnoredEdges.insert(id);
510  }
511 
514  bool wasRemoved(std::string id) const {
515  return myExtractedEdges.count(id) != 0;
516  }
517 
520  void rename(NBEdge* edge, const std::string& newID);
521 
522 
523 
526 
540  void addPostProcessConnection(const std::string& from, int fromLane, const std::string& to, int toLane, bool mayDefinitelyPass,
541  bool keepClear, double contPos, double visibility, double speed,
542  const PositionVector& customShape,
543  bool warnOnly = false);
544 
545 
550 
552  void generateStreetSigns();
553 
555  int guessSidewalks(double width, double minSpeed, double maxSpeed, bool fromPermissions);
556 
557 
561  const std::set<EdgeSet> getRoundabouts() const;
562 
564  void addRoundabout(const EdgeSet& roundabout);
565 
567  void markRoundabouts();
568 
570  void patchRoundabouts(NBEdge* orig, NBEdge* part1, NBEdge* part2, std::set<EdgeSet>& roundabouts);
571 
573  bool ignoreFilterMatch(NBEdge* edge);
574 
576  int remapIDs(bool numericaIDs, bool reservedIDs, const std::string& prefix, NBPTStopCont& sc);
577 
579  void checkOverlap(double threshold, double zThreshold) const;
580 
582  void checkGrade(double threshold) const;
583 
584 
591  EdgeVector getGeneratedFrom(const std::string& id) const;
592 
594  EdgeVector getAllEdges() const;
595 
596 private:
598  static double formFactor(const EdgeVector& loopEdges);
599 
600 private:
603 
608  public:
616  PostProcessConnection(const std::string& from_, int fromLane_, const std::string& to_, int toLane_,
617  bool mayDefinitelyPass_, bool keepClear_, double contPos_, double visibility_, double speed_,
618  const PositionVector& customShape_,
619  bool warnOnly_ = false) :
620  from(from_), fromLane(fromLane_), to(to_), toLane(toLane_), mayDefinitelyPass(mayDefinitelyPass_), keepClear(keepClear_), contPos(contPos_),
621  visibility(visibility_),
622  speed(speed_),
623  customShape(customShape_),
624  warnOnly(warnOnly_) {
625  }
627  std::string from;
629  int fromLane;
631  std::string to;
633  int toLane;
637  bool keepClear;
639  double contPos;
641  double visibility;
643  double speed;
647  bool warnOnly;
648  };
649 
651  std::vector<PostProcessConnection> myConnections;
652 
653 
655  typedef std::map<std::string, NBEdge*> EdgeCont;
656 
658  EdgeCont myEdges;
659 
662 
664  std::set<std::string> myIgnoredEdges;
665 
668 
671 
674 
677 
679  std::set<std::string> myEdges2Keep;
680 
682  std::set<std::string> myEdges2Remove;
683 
686 
689 
691  std::set<std::string> myTypes2Keep;
692 
694  std::set<std::string> myTypes2Remove;
695 
698 
702 
704  std::set<EdgeSet> myRoundabouts;
706  std::set<EdgeSet> myGuessedRoundabouts;
707 
711  class split_sorter {
712  public:
714  explicit split_sorter() { }
715 
717  int operator()(const Split& e1, const Split& e2) const {
718  return e1.pos < e2.pos;
719  }
720  };
721 
722 
723 private:
725  NBEdgeCont(const NBEdgeCont& s);
726 
728  NBEdgeCont& operator=(const NBEdgeCont& s);
729 
730 };
731 
732 
733 #endif
734 
735 /****************************************************************************/
736 
~NBEdgeCont()
Destructor.
Definition: NBEdgeCont.cpp:66
split_sorter()
Constructor.
Definition: NBEdgeCont.h:714
NBEdge * getByID(const std::string &edgeID) const
Returns the edge with id if it exists.
void sortOutgoingLanesConnections()
Sorts all lanes of all edges within the container by their direction.
Definition: NBEdgeCont.cpp:757
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.
void appendTurnarounds(bool noTLSControlled, bool onlyDeadends)
Appends turnarounds to all edges stored in the container.
Definition: NBEdgeCont.cpp:821
void reduceGeometries(const double minDist)
Definition: NBEdgeCont.cpp:730
A structure which describes changes of lane number or speed along the road.
Definition: NBEdgeCont.h:206
double contPos
custom position for internal junction on this connection
Definition: NBEdgeCont.h:639
A container for traffic light definitions and built programs.
int guessRoundabouts()
Determines which edges belong to roundabouts and increases their priority.
bool myRemoveEdgesAfterJoining
Whether edges shall be joined first, then removed.
Definition: NBEdgeCont.h:676
NBEdge * getOppositeByID(const std::string &edgeID) const
Returns the edge with negated id if it exists.
std::string nameID
the default node id
Definition: NBEdgeCont.h:221
std::map< std::string, NBEdge * > EdgeCont
The type of the dictionary where an edge may be found by its id.
Definition: NBEdgeCont.h:655
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:65
void guessOpposites()
Sets opposite lane information for geometrically close edges.
Definition: NBEdgeCont.cpp:961
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:398
bool splitAt(NBDistrictCont &dc, NBEdge *edge, NBNode *node)
Splits the edge at the position nearest to the given node.
Definition: NBEdgeCont.cpp:556
void recheckPostProcessConnections()
Try to set any stored connections.
std::string idAfter
The id for the edge after the split.
Definition: NBEdgeCont.h:219
std::map< std::string, NBEdge * >::const_iterator end() const
Returns the pointer to the end of the stored edges.
Definition: NBEdgeCont.h:193
PositionVector customShape
custom shape for connection
Definition: NBEdgeCont.h:645
int getNoEdgeSplits() const
Returns the number of edge splits.
Definition: NBEdgeCont.h:321
void computeLanes2Edges()
Computes for each edge which lanes approach the next edges.
Definition: NBEdgeCont.cpp:773
std::vector< PostProcessConnection > myConnections
The list of connections to recheck.
Definition: NBEdgeCont.h:651
void checkGeometries(const double maxAngle, const double minRadius, bool fix)
Definition: NBEdgeCont.cpp:738
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:697
double pos
The position of this change.
Definition: NBEdgeCont.h:211
NBEdgeCont(NBTypeCont &tc)
Constructor.
Definition: NBEdgeCont.cpp:57
NBNode * node
The new node that is created for this split.
Definition: NBEdgeCont.h:215
SVCPermissions myVehicleClasses2Keep
Set of vehicle types which must be allowed on edges in order to keep them.
Definition: NBEdgeCont.h:685
bool keepClear
Whether the connection may be passed without braking.
Definition: NBEdgeCont.h:637
int operator()(const Split &e1, const Split &e2) const
Comparing operator.
Definition: NBEdgeCont.h:717
double myEdgesMinSpeed
The minimum speed an edge may have in order to be kept (default: -1)
Definition: NBEdgeCont.h:673
std::map< std::string, NBEdge * >::const_iterator begin() const
Returns the pointer to the begin of the stored edges.
Definition: NBEdgeCont.h:185
std::set< NBEdge * > EdgeSet
container for unique edges
Definition: NBCont.h:46
void patchRoundabouts(NBEdge *orig, NBEdge *part1, NBEdge *part2, std::set< EdgeSet > &roundabouts)
fix roundabout information after splitting an edge
Definition: NBEdgeCont.cpp:673
double visibility
custom foe visiblity for connection
Definition: NBEdgeCont.h:641
bool insert(NBEdge *edge, bool ignorePrunning=false)
Adds an edge to the dictionary.
Definition: NBEdgeCont.cpp:152
NBEdge * retrievePossiblySplit(const std::string &id, bool downstream) const
Tries to retrieve an edge, even if it is splitted.
Definition: NBEdgeCont.cpp:281
int offsetFactor
direction in which to apply the offset (used by netgenerate for lefthand networks) ...
Definition: NBEdgeCont.h:225
void removeUnwishedEdges(NBDistrictCont &dc)
Removes unwished edges (not in keep-edges)
Definition: NBEdgeCont.cpp:702
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:386
A list of positions.
void applyOptions(OptionsCont &oc)
Initialises the storage by applying given options.
Definition: NBEdgeCont.cpp:72
bool mayDefinitelyPass
Whether the connection may be passed without braking.
Definition: NBEdgeCont.h:635
bool wasRemoved(std::string id) const
Returns whether the edge with the id was deleted explicitly.
Definition: NBEdgeCont.h:514
std::set< std::string > myEdges2Keep
Set of ids of edges which shall explicitly be kept.
Definition: NBEdgeCont.h:679
void computeEdge2Edges(bool noLeftMovers)
Computes for each edge the approached edges.
Definition: NBEdgeCont.cpp:765
void computeLaneShapes()
Computes the shapes of all lanes of all edges stored in the container.
Definition: NBEdgeCont.cpp:866
void clearControllingTLInformation() const
Clears information about controlling traffic lights for all connenections of all edges.
Definition: NBEdgeCont.cpp:749
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:61
void processSplits(NBEdge *e, std::vector< Split > splits, NBNodeCont &nc, NBDistrictCont &dc, NBTrafficLightLogicCont &tlc)
Definition: NBEdgeCont.cpp:411
void splitGeometry(NBNodeCont &nc)
Splits edges into multiple if they have a complex geometry.
Definition: NBEdgeCont.cpp:719
EdgeCont myEdges
The instance of the dictionary (id->edge)
Definition: NBEdgeCont.h:658
bool warnOnly
whether a failure to set this connection is a warning or an error
Definition: NBEdgeCont.h:647
const std::set< EdgeSet > getRoundabouts() const
Returns the determined roundabouts.
std::vector< int > lanes
The lanes after this change.
Definition: NBEdgeCont.h:209
void clear()
Deletes all edges.
Definition: NBEdgeCont.cpp:137
EdgeCont myExtractedEdges
The extracted nodes which are kept for reference.
Definition: NBEdgeCont.h:661
std::set< EdgeSet > myGuessedRoundabouts
Edges marked as belonging to a roundabout after guessing.
Definition: NBEdgeCont.h:706
std::set< EdgeSet > myRoundabouts
Edges marked as belonging to a roundabout by the user (each EdgeVector is a roundabout) ...
Definition: NBEdgeCont.h:704
void joinSameNodeConnectingEdges(NBDistrictCont &dc, NBTrafficLightLogicCont &tlc, EdgeVector edges)
Joins the given edges because they connect the same nodes.
Definition: NBEdgeCont.cpp:874
SVCPermissions myVehicleClasses2Remove
Set of vehicle types which need not be supported (edges which allow ONLY these are removed) ...
Definition: NBEdgeCont.h:688
std::string from
The id of the edge the connection starts at.
Definition: NBEdgeCont.h:627
std::set< std::string > myTypes2Keep
Set of edges types which shall be kept.
Definition: NBEdgeCont.h:691
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 ...
EdgeVector getAllEdges() const
return all edges
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:616
std::vector< NBEdge * > EdgeVector
container for (sorted) edges
Definition: NBCont.h:34
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.
NBEdge * retrieve(const std::string &id, bool retrieveExtracted=false) const
Returns the edge that has the given id.
Definition: NBEdgeCont.cpp:245
double speed
custom speed for connection
Definition: NBEdgeCont.h:643
bool myNeedGeoTransformedPruningBoundary
whether a geo transform has been applied to the pruning boundary
Definition: NBEdgeCont.h:700
int toLane
The number of the lane the connection ends at.
Definition: NBEdgeCont.h:633
int size() const
Returns the number of edges.
Definition: NBEdgeCont.h:306
A storage for options typed value containers)
Definition: OptionsCont.h:92
void erase(NBDistrictCont &dc, NBEdge *edge)
Removes the given edge from the container (deleting it)
Definition: NBEdgeCont.cpp:379
NBEdgeCont & operator=(const NBEdgeCont &s)
invalidated assignment operator
A structure representing a connection between two lanes.
Definition: NBEdgeCont.h:607
double speed
The speed after this change.
Definition: NBEdgeCont.h:213
Sorts splits by their position (increasing)
Definition: NBEdgeCont.h:711
void appendRailwayTurnarounds(const NBPTStopCont &sc)
Appends turnarounds to all bidiRail edges with stops.
Definition: NBEdgeCont.cpp:837
void ignore(std::string id)
mark the given edge id as ignored
Definition: NBEdgeCont.h:508
Represents a single node (junction) during network building.
Definition: NBNode.h:68
NBTypeCont & myTypeCont
The network builder; used to obtain type information.
Definition: NBEdgeCont.h:602
std::string to
The id of the edge the connection ends at.
Definition: NBEdgeCont.h:631
void recheckLaneSpread()
Rechecks whether the lane spread is proper.
Definition: NBEdgeCont.cpp:991
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:64
void computeEdgeShapes(double smoothElevationThreshold=-1)
Computes the shapes of all edges stored in the container.
Definition: NBEdgeCont.cpp:858
std::set< std::string > myTypes2Remove
Set of edges types which shall be removed.
Definition: NBEdgeCont.h:694
bool wasIgnored(std::string id) const
Returns whether the edge with the id was ignored during parsing.
Definition: NBEdgeCont.h:503
void recheckLanes()
Rechecks whether all lanes have a successor for each of the stored edges.
Definition: NBEdgeCont.cpp:781
Container for nodes during the netbuilding process.
Definition: NBNodeCont.h:60
int fromLane
The number of the lane the connection starts at.
Definition: NBEdgeCont.h:629
std::set< std::string > myIgnoredEdges
The ids of ignored edges.
Definition: NBEdgeCont.h:664
void addRoundabout(const EdgeSet &roundabout)
add user specified roundabout
std::vector< std::string > getAllNames() const
Returns all ids of known edges.
Definition: NBEdgeCont.cpp:691
int remapIDs(bool numericaIDs, bool reservedIDs, const std::string &prefix, NBPTStopCont &sc)
remap node IDs accoring to options –numerical-ids and –reserved-ids
std::string idBefore
The id for the edge before the split.
Definition: NBEdgeCont.h:217
bool ignoreFilterMatch(NBEdge *edge)
Returns true if this edge matches one of the removal criteria.
Definition: NBEdgeCont.cpp:173
A storage for available types of edges.
Definition: NBTypeCont.h:55
double offset
lateral offset to edge geometry
Definition: NBEdgeCont.h:223
int myEdgesSplit
the number of splits of edges during the building
Definition: NBEdgeCont.h:667
std::set< std::string > myEdges2Remove
Set of ids of edges which shall explicitly be removed.
Definition: NBEdgeCont.h:682