Eclipse 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-2019 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, bool noGeometryLike);
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 uncontrolled,
544  bool warnOnly);
545 
546  bool hasPostProcessConnection(const std::string& from, const std::string& to = "");
547 
548 
553 
555  void generateStreetSigns();
556 
558  int guessSpecialLanes(SUMOVehicleClass svc, double width, double minSpeed, double maxSpeed, bool fromPermissions, const std::string& excludeOpt);
559 
560 
564  const std::set<EdgeSet> getRoundabouts() const;
565 
567  void addRoundabout(const EdgeSet& roundabout);
568 
570  void removeRoundabout(const NBNode* node);
571 
573  void markRoundabouts();
574 
576  void patchRoundabouts(NBEdge* orig, NBEdge* part1, NBEdge* part2, std::set<EdgeSet>& roundabouts);
577 
579  bool ignoreFilterMatch(NBEdge* edge);
580 
582  int remapIDs(bool numericaIDs, bool reservedIDs, const std::string& prefix, NBPTStopCont& sc);
583 
585  void checkOverlap(double threshold, double zThreshold) const;
586 
588  void checkGrade(double threshold) const;
589 
590 
597  EdgeVector getGeneratedFrom(const std::string& id) const;
598 
600  int joinLanes(SVCPermissions perms);
601 
603  EdgeVector getAllEdges() const;
605 
606 private:
608  static double formFactor(const EdgeVector& loopEdges);
609 
610 private:
613 
618  public:
626  PostProcessConnection(const std::string& from_, int fromLane_, const std::string& to_, int toLane_,
627  bool mayDefinitelyPass_, bool keepClear_, double contPos_, double visibility_, double speed_,
628  const PositionVector& customShape_,
629  bool uncontrolled_,
630  bool warnOnly_) :
631  from(from_), fromLane(fromLane_), to(to_), toLane(toLane_), mayDefinitelyPass(mayDefinitelyPass_), keepClear(keepClear_), contPos(contPos_),
632  visibility(visibility_),
633  speed(speed_),
634  customShape(customShape_),
635  uncontrolled(uncontrolled_),
636  warnOnly(warnOnly_) {
637  }
639  std::string from;
641  int fromLane;
643  std::string to;
645  int toLane;
649  bool keepClear;
651  double contPos;
653  double visibility;
655  double speed;
661  bool warnOnly;
662  };
663 
665  std::map<std::string, std::vector<PostProcessConnection> > myConnections;
666 
667 
669  typedef std::map<std::string, NBEdge*> EdgeCont;
670 
672  EdgeCont myEdges;
673 
676 
678  std::set<std::string> myIgnoredEdges;
679 
682 
685 
688 
691 
693  std::set<std::string> myEdges2Keep;
694 
696  std::set<std::string> myEdges2Remove;
697 
700 
703 
705  std::set<std::string> myTypes2Keep;
706 
708  std::set<std::string> myTypes2Remove;
709 
712 
716 
718  std::set<EdgeSet> myRoundabouts;
720  std::set<EdgeSet> myGuessedRoundabouts;
721 
725  class split_sorter {
726  public:
728  explicit split_sorter() { }
729 
731  int operator()(const Split& e1, const Split& e2) const {
732  return e1.pos < e2.pos;
733  }
734  };
735 
736 
737 private:
739  NBEdgeCont(const NBEdgeCont& s);
740 
742  NBEdgeCont& operator=(const NBEdgeCont& s);
743 
744 };
745 
746 
747 #endif
748 
749 /****************************************************************************/
750 
~NBEdgeCont()
Destructor.
Definition: NBEdgeCont.cpp:66
std::map< std::string, std::vector< PostProcessConnection > > myConnections
The list of connections to recheck.
Definition: NBEdgeCont.h:665
split_sorter()
Constructor.
Definition: NBEdgeCont.h:728
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:754
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 reduceGeometries(const double minDist)
Definition: NBEdgeCont.cpp:727
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types...
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:651
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:690
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:669
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:86
void guessOpposites()
Sets opposite lane information for geometrically close edges.
Definition: NBEdgeCont.cpp:958
void removeRoundabout(const NBNode *node)
remove roundabout that contains the given node
bool uncontrolled
whether this connection shall not be controlled by a traffic light
Definition: NBEdgeCont.h:659
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::vector< NBRouterEdge * > RouterEdgeVector
Definition: NBCont.h:43
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:657
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:770
void checkGeometries(const double maxAngle, const double minRadius, bool fix)
Definition: NBEdgeCont.cpp:735
void checkOverlap(double threshold, double zThreshold) const
check whether edges overlap
int joinLanes(SVCPermissions perms)
join adjacent lanes with the given permissions
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:711
double pos
The position of this change.
Definition: NBEdgeCont.h:211
NBEdgeCont(NBTypeCont &tc)
Constructor.
Definition: NBEdgeCont.cpp:57
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 ...
RouterEdgeVector getAllRouterEdges() const
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:699
bool keepClear
Whether the connection may be passed without braking.
Definition: NBEdgeCont.h:649
int operator()(const Split &e1, const Split &e2) const
Comparing operator.
Definition: NBEdgeCont.h:731
double myEdgesMinSpeed
The minimum speed an edge may have in order to be kept (default: -1)
Definition: NBEdgeCont.h:687
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:50
void patchRoundabouts(NBEdge *orig, NBEdge *part1, NBEdge *part2, std::set< EdgeSet > &roundabouts)
fix roundabout information after splitting an edge
Definition: NBEdgeCont.cpp:670
double visibility
custom foe visiblity for connection
Definition: NBEdgeCont.h:653
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:699
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)
Adds a connection which could not be set during loading.
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:647
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:693
void computeEdge2Edges(bool noLeftMovers)
Computes for each edge the approached edges.
Definition: NBEdgeCont.cpp:762
void computeLaneShapes()
Computes the shapes of all lanes of all edges stored in the container.
Definition: NBEdgeCont.cpp:863
void clearControllingTLInformation() const
Clears information about controlling traffic lights for all connenections of all edges.
Definition: NBEdgeCont.cpp:746
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:716
EdgeCont myEdges
The instance of the dictionary (id->edge)
Definition: NBEdgeCont.h:672
bool warnOnly
whether a failure to set this connection is a warning or an error
Definition: NBEdgeCont.h:661
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:675
std::set< EdgeSet > myGuessedRoundabouts
Edges marked as belonging to a roundabout after guessing.
Definition: NBEdgeCont.h:720
std::set< EdgeSet > myRoundabouts
Edges marked as belonging to a roundabout by the user (each EdgeVector is a roundabout) ...
Definition: NBEdgeCont.h:718
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 uncontrolled_, bool warnOnly_)
Constructor.
Definition: NBEdgeCont.h:626
void joinSameNodeConnectingEdges(NBDistrictCont &dc, NBTrafficLightLogicCont &tlc, EdgeVector edges)
Joins the given edges because they connect the same nodes.
Definition: NBEdgeCont.cpp:871
SVCPermissions myVehicleClasses2Remove
Set of vehicle types which need not be supported (edges which allow ONLY these are removed) ...
Definition: NBEdgeCont.h:702
std::string from
The id of the edge the connection starts at.
Definition: NBEdgeCont.h:639
std::set< std::string > myTypes2Keep
Set of edges types which shall be kept.
Definition: NBEdgeCont.h:705
EdgeVector getAllEdges() const
return all edges
std::vector< NBEdge * > EdgeVector
container for (sorted) edges
Definition: NBCont.h:35
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:655
bool myNeedGeoTransformedPruningBoundary
whether a geo transform has been applied to the pruning boundary
Definition: NBEdgeCont.h:714
int toLane
The number of the lane the connection ends at.
Definition: NBEdgeCont.h:645
int size() const
Returns the number of edges.
Definition: NBEdgeCont.h:306
A storage for options typed value containers)
Definition: OptionsCont.h:90
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:617
double speed
The speed after this change.
Definition: NBEdgeCont.h:213
Sorts splits by their position (increasing)
Definition: NBEdgeCont.h:725
void appendRailwayTurnarounds(const NBPTStopCont &sc)
Appends turnarounds to all bidiRail edges with stops.
Definition: NBEdgeCont.cpp:834
void ignore(std::string id)
mark the given edge id as ignored
Definition: NBEdgeCont.h:508
bool hasPostProcessConnection(const std::string &from, const std::string &to="")
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:612
std::string to
The id of the edge the connection ends at.
Definition: NBEdgeCont.h:643
void recheckLaneSpread()
Rechecks whether the lane spread is proper.
Definition: NBEdgeCont.cpp:988
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:855
std::set< std::string > myTypes2Remove
Set of edges types which shall be removed.
Definition: NBEdgeCont.h:708
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:778
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:641
std::set< std::string > myIgnoredEdges
The ids of ignored edges.
Definition: NBEdgeCont.h:678
void addRoundabout(const EdgeSet &roundabout)
add user specified roundabout
std::vector< std::string > getAllNames() const
Returns all ids of known edges.
Definition: NBEdgeCont.cpp:688
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
void appendTurnarounds(bool noTLSControlled, bool onlyDeadends, bool noGeometryLike)
Appends turnarounds to all edges stored in the container.
Definition: NBEdgeCont.cpp:818
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:681
std::set< std::string > myEdges2Remove
Set of ids of edges which shall explicitly be removed.
Definition: NBEdgeCont.h:696