SUMO - Simulation of Urban MObility
NBEdgeCont.h
Go to the documentation of this file.
1 /****************************************************************************/
9 // Storage for edges, including some functionality operating on multiple edges
10 /****************************************************************************/
11 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
12 // Copyright (C) 2001-2016 DLR (http://www.dlr.de/) and contributors
13 /****************************************************************************/
14 //
15 // This file is part of SUMO.
16 // SUMO is free software: you can redistribute it and/or modify
17 // it under the terms of the GNU General Public License as published by
18 // the Free Software Foundation, either version 3 of the License, or
19 // (at your option) any later version.
20 //
21 /****************************************************************************/
22 #ifndef NBEdgeCont_h
23 #define NBEdgeCont_h
24 
25 
26 // ===========================================================================
27 // included modules
28 // ===========================================================================
29 #ifdef _MSC_VER
30 #include <windows_config.h>
31 #else
32 #include <config.h>
33 #endif
34 
35 #include <map>
36 #include <iostream>
37 #include <string>
38 #include <vector>
39 #include <set>
40 #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, SUMOReal 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  unsigned int noLanesFirstEdge, unsigned int noLanesSecondEdge,
250  const SUMOReal speed = -1., const int changedLeft = 0);
251 
252 
268  bool splitAt(NBDistrictCont& dc, NBEdge* edge, SUMOReal edgepos, NBNode* node,
269  const std::string& firstEdgeName, const std::string& secondEdgeName,
270  unsigned int noLanesFirstEdge, unsigned int noLanesSecondEdge,
271  const SUMOReal speed = -1., const int changedLeft = 0);
273 
274 
275 
278 
282  unsigned int size() const {
283  return (unsigned int) myEdges.size();
284  }
285 
286 
291  std::vector<std::string> getAllNames() const;
292 
293 
297  unsigned int getNoEdgeSplits() const {
298  return myEdgesSplit;
299  }
301 
302 
303 
306 
312 
313 
322  void splitGeometry(NBNodeCont& nc);
323 
324 
329  void reduceGeometries(const SUMOReal minDist);
330 
331 
338  void checkGeometries(const SUMOReal maxAngle, const SUMOReal 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 
449  void recheckLaneSpread();
451 
452 
453 
458  int guessRoundabouts();
459 
460 
464  bool wasIgnored(std::string id) const {
465  return myIgnoredEdges.count(id) != 0;
466  }
467 
468 
471  bool wasRemoved(std::string id) const {
472  return myExtractedEdges.count(id) != 0;
473  }
474 
477  void rename(NBEdge* edge, const std::string& newID);
478 
479 
480 
483 
493  void addPostProcessConnection(const std::string& from, int fromLane, const std::string& to, int toLane, bool mayDefinitelyPass, bool keepClear, SUMOReal contPos);
494 
495 
500 
502  void generateStreetSigns();
503 
505  int guessSidewalks(SUMOReal width, SUMOReal minSpeed, SUMOReal maxSpeed, bool fromPermissions);
506 
507 
511  const std::set<EdgeSet> getRoundabouts() const;
512 
514  void addRoundabout(const EdgeSet& roundabout);
515 
517  void markRoundabouts();
518 
519 private:
526  EdgeVector getGeneratedFrom(const std::string& id) const;
527 
528 
530  bool ignoreFilterMatch(NBEdge* edge);
531 
533  static SUMOReal formFactor(const EdgeVector& loopEdges);
534 
535 private:
538 
543  public:
551  PostProcessConnection(const std::string& from_, int fromLane_, const std::string& to_, int toLane_, bool mayDefinitelyPass_, bool keepClear_, SUMOReal contPos_) :
552  from(from_), fromLane(fromLane_), to(to_), toLane(toLane_), mayDefinitelyPass(mayDefinitelyPass_), keepClear(keepClear_), contPos(contPos_) {
553  }
555  std::string from;
557  int fromLane;
559  std::string to;
561  int toLane;
565  bool keepClear;
568  };
569 
571  std::vector<PostProcessConnection> myConnections;
572 
573 
575  typedef std::map<std::string, NBEdge*> EdgeCont;
576 
578  EdgeCont myEdges;
579 
582 
584  std::set<std::string> myIgnoredEdges;
585 
587  unsigned int myEdgesSplit;
588 
591 
594 
597 
599  std::set<std::string> myEdges2Keep;
600 
602  std::set<std::string> myEdges2Remove;
603 
606 
609 
611  std::set<std::string> myTypes2Keep;
612 
614  std::set<std::string> myTypes2Remove;
615 
618 
622 
624  std::set<EdgeSet> myRoundabouts;
626  std::set<EdgeSet> myGuessedRoundabouts;
627 
628 
629 private:
631  NBEdgeCont(const NBEdgeCont& s);
632 
634  NBEdgeCont& operator=(const NBEdgeCont& s);
635 
636 
637 };
638 
639 
640 #endif
641 
642 /****************************************************************************/
643 
~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 ...
void sortOutgoingLanesConnections()
Sorts all lanes of all edges within the container by their direction.
Definition: NBEdgeCont.cpp:585
void markRoundabouts()
mark edge priorities and prohibit turn-arounds for all roundabout edges
Definition: NBEdgeCont.cpp:959
NBEdge * retrievePossiblySplit(const std::string &id, bool downstream) const
Tries to retrieve an edge, even if it is splitted.
Definition: NBEdgeCont.cpp:282
std::vector< std::string > getAllNames() const
Returns all ids of known edges.
Definition: NBEdgeCont.cpp:519
const std::set< EdgeSet > getRoundabouts() const
Returns the determined roundabouts.
Definition: NBEdgeCont.cpp:941
bool myNeedGeoTransformedPrunningBoundary
whether a geo transform has been applied to the pruning boundary
Definition: NBEdgeCont.h:620
A container for traffic light definitions and built programs.
int guessRoundabouts()
Determines which edges belong to roundabouts and increases their priority.
Definition: NBEdgeCont.cpp:834
bool myRemoveEdgesAfterJoining
Whether edges shall be joined first, then removed.
Definition: NBEdgeCont.h:596
std::map< std::string, NBEdge * > EdgeCont
The type of the dictionary where an edge may be found by its id.
Definition: NBEdgeCont.h:575
int SVCPermissions
The representation of a single edge during network building.
Definition: NBEdge.h:70
unsigned int getNoEdgeSplits() const
Returns the number of edge splits.
Definition: NBEdgeCont.h:297
A container for districts.
void clearControllingTLInformation() const
Clears information about controlling traffic lights for all connenections of all edges.
Definition: NBEdgeCont.cpp:577
void generateStreetSigns()
assigns street signs to edges based on toNode types
Definition: NBEdgeCont.cpp:985
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:763
unsigned int myEdgesSplit
the number of splits of edges during the building
Definition: NBEdgeCont.h:587
void computeLanes2Edges()
Computes for each edge which lanes approach the next edges.
Definition: NBEdgeCont.cpp:601
std::vector< PostProcessConnection > myConnections
The list of connections to recheck.
Definition: NBEdgeCont.h:571
void checkGeometries(const SUMOReal maxAngle, const SUMOReal minRadius, bool fix)
Definition: NBEdgeCont.cpp:566
NBEdgeCont(NBTypeCont &tc)
Constructor.
Definition: NBEdgeCont.cpp:66
SVCPermissions myVehicleClasses2Keep
Set of vehicle types which must be allowed on edges in order to keep them.
Definition: NBEdgeCont.h:605
void reduceGeometries(const SUMOReal minDist)
Definition: NBEdgeCont.cpp:558
bool keepClear
Whether the connection may be passed without braking.
Definition: NBEdgeCont.h:565
std::set< NBEdge * > EdgeSet
Definition: NBCont.h:51
std::map< std::string, NBEdge * >::const_iterator end() const
Returns the pointer to the end of the stored edges.
Definition: NBEdgeCont.h:198
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:530
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 list of positions.
void applyOptions(OptionsCont &oc)
Initialises the storage by applying given options.
Definition: NBEdgeCont.cpp:81
bool mayDefinitelyPass
Whether the connection may be passed without braking.
Definition: NBEdgeCont.h:563
std::set< std::string > myEdges2Keep
Set of ids of edges which shall explicitly be kept.
Definition: NBEdgeCont.h:599
void computeEdge2Edges(bool noLeftMovers)
Computes for each edge the approached edges.
Definition: NBEdgeCont.cpp:593
void computeLaneShapes()
Computes the shapes of all lanes of all edges stored in the container.
Definition: NBEdgeCont.cpp:641
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:547
EdgeCont myEdges
The instance of the dictionary (id->edge)
Definition: NBEdgeCont.h:578
void clear()
Deletes all edges.
Definition: NBEdgeCont.cpp:146
EdgeCont myExtractedEdges
The extracted nodes which are kept for reference.
Definition: NBEdgeCont.h:581
std::set< EdgeSet > myGuessedRoundabouts
Edges marked as belonging to a roundabout after guessing.
Definition: NBEdgeCont.h:626
std::set< EdgeSet > myRoundabouts
Edges marked as belonging to a roundabout by the user (each EdgeVector is a roundabout) ...
Definition: NBEdgeCont.h:624
void joinSameNodeConnectingEdges(NBDistrictCont &dc, NBTrafficLightLogicCont &tlc, EdgeVector edges)
Joins the given edges because they connect the same nodes.
Definition: NBEdgeCont.cpp:649
static SUMOReal formFactor(const EdgeVector &loopEdges)
compute the form factor for a loop of edges
Definition: NBEdgeCont.cpp:930
SVCPermissions myVehicleClasses2Remove
Set of vehicle types which need not be supported (edges which allow ONLY these are removed) ...
Definition: NBEdgeCont.h:608
std::string from
The id of the edge the connection starts at.
Definition: NBEdgeCont.h:555
std::map< std::string, NBEdge * >::const_iterator begin() const
Returns the pointer to the begin of the stored edges.
Definition: NBEdgeCont.h:190
PositionVector myPrunningBoundary
Boundary within which an edge must be located in order to be kept.
Definition: NBEdgeCont.h:617
std::set< std::string > myTypes2Keep
Set of edges types which shall be kept.
Definition: NBEdgeCont.h:611
SUMOReal contPos
custom position for internal junction on this connection
Definition: NBEdgeCont.h:567
SUMOReal myEdgesMinSpeed
The minimum speed an edge may have in order to be kept (default: -1)
Definition: NBEdgeCont.h:593
NBEdge * retrieve(const std::string &id, bool retrieveExtracted=false) const
Returns the edge that has the given id.
Definition: NBEdgeCont.cpp:246
bool wasRemoved(std::string id) const
Returns whether the edge with the id was deleted explicitly.
Definition: NBEdgeCont.h:471
void appendTurnarounds(bool noTLSControlled)
Appends turnarounds to all edges stored in the container.
Definition: NBEdgeCont.cpp:617
std::vector< NBEdge * > EdgeVector
Definition: NBCont.h:41
int toLane
The number of the lane the connection ends at.
Definition: NBEdgeCont.h:561
A storage for options typed value containers)
Definition: OptionsCont.h:108
void erase(NBDistrictCont &dc, NBEdge *edge)
Removes the given edge from the container (deleting it)
Definition: NBEdgeCont.cpp:380
NBEdgeCont & operator=(const NBEdgeCont &s)
invalidated assignment operator
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:633
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:537
std::string to
The id of the edge the connection ends at.
Definition: NBEdgeCont.h:559
void recheckLaneSpread()
Rechecks whether the lane spread is proper.
Definition: NBEdgeCont.cpp:736
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:71
#define SUMOReal
Definition: config.h:213
bool wasIgnored(std::string id) const
Returns whether the edge with the id was ignored during parsing.
Definition: NBEdgeCont.h:464
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:609
Container for nodes during the netbuilding process.
Definition: NBNodeCont.h:64
int fromLane
The number of the lane the connection starts at.
Definition: NBEdgeCont.h:557
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:792
void addRoundabout(const EdgeSet &roundabout)
add user specified roundabout
Definition: NBEdgeCont.cpp:949
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:757
PostProcessConnection(const std::string &from_, int fromLane_, const std::string &to_, int toLane_, bool mayDefinitelyPass_, bool keepClear_, SUMOReal contPos_)
Constructor.
Definition: NBEdgeCont.h:551
bool ignoreFilterMatch(NBEdge *edge)
Returns true if this edge matches one of the removal criteria.
Definition: NBEdgeCont.cpp:182
unsigned int size() const
Returns the number of edges.
Definition: NBEdgeCont.h:282
A storage for available types of edges.
Definition: NBTypeCont.h:62
std::set< std::string > myEdges2Remove
Set of ids of edges which shall explicitly be removed.
Definition: NBEdgeCont.h:602