SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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-sim.org/
12 // Copyright (C) 2001-2013 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 
137  NBEdge* retrievePossiblySplit(const std::string& id, const std::string& hint, bool incoming) const;
138 
139 
150  NBEdge* retrievePossiblySplit(const std::string& id, SUMOReal pos) const;
151 
152 
159  void erase(NBDistrictCont& dc, NBEdge* edge);
160 
161 
171  void extract(NBDistrictCont& dc, NBEdge* edge, bool remember = false);
172 
173 
177  std::map<std::string, NBEdge*>::const_iterator begin() const {
178  return myEdges.begin();
179  }
180 
181 
185  std::map<std::string, NBEdge*>::const_iterator end() const {
186  return myEdges.end();
187  }
189 
190 
191 
194 
208  bool splitAt(NBDistrictCont& dc, NBEdge* edge, NBNode* node);
209 
210 
231  bool splitAt(NBDistrictCont& dc, NBEdge* edge, NBNode* node,
232  const std::string& firstEdgeName, const std::string& secondEdgeName,
233  unsigned int noLanesFirstEdge, unsigned int noLanesSecondEdge);
234 
235 
248  bool splitAt(NBDistrictCont& dc, NBEdge* edge, SUMOReal edgepos, NBNode* node,
249  const std::string& firstEdgeName, const std::string& secondEdgeName,
250  unsigned int noLanesFirstEdge, unsigned int noLanesSecondEdge);
252 
253 
254 
257 
261  unsigned int size() const {
262  return (unsigned int) myEdges.size();
263  }
264 
265 
270  std::vector<std::string> getAllNames() const;
271 
272 
276  unsigned int getNoEdgeSplits() const {
277  return myEdgesSplit;
278  }
280 
281 
282 
285 
291 
292 
301  void splitGeometry(NBNodeCont& nc);
302 
303 
308  void reduceGeometries(const SUMOReal minDist);
309 
310 
317  void checkGeometries(const SUMOReal maxAngle, const SUMOReal minRadius, bool fix);
319 
320 
321 
324 
333 
334 
343  void computeEdge2Edges(bool noLeftMovers);
344 
345 
353  void computeLanes2Edges();
354 
355 
363  void recheckLanes();
364 
365 
374  void appendTurnarounds(bool noTLSControlled);
375 
376 
383  void appendTurnarounds(const std::set<std::string>& ids, bool noTLSControlled);
384 
385 
394  void computeEdgeShapes();
395 
396 
405  void computeLaneShapes();
406 
407 
410  void clearControllingTLInformation() const;
411 
412 
421  NBTrafficLightLogicCont& tlc, EdgeVector edges);
422 
423 
428  void recheckLaneSpread();
430 
431 
432 
436  void guessRoundabouts(std::vector<EdgeVector>& marked);
437 
438 
442  bool isLeftHanded() const {
443  return myAmLeftHanded;
444  }
445 
446 
450  bool wasIgnored(std::string id) const {
451  return myIgnoredEdges.count(id) != 0;
452  }
453 
454 
457  bool wasRemoved(std::string id) const {
458  return myExtractedEdges.count(id) != 0;
459  }
460 
463  void rename(NBEdge* edge, const std::string& newID);
464 
465 
466 
469 
477  void addPostProcessConnection(const std::string& from, int fromLane, const std::string& to, int toLane, bool mayDefinitelyPass);
478 
479 
484 
486  void generateStreetSigns();
487 
488 private:
495  EdgeVector getGeneratedFrom(const std::string& id) const;
496 
497 
499  bool ignoreFilterMatch(NBEdge* edge);
500 
501 
502 private:
507  public:
515  PostProcessConnection(const std::string& from_, int fromLane_, const std::string& to_, int toLane_, bool mayDefinitelyPass_)
516  : from(from_), fromLane(fromLane_), to(to_), toLane(toLane_), mayDefinitelyPass(mayDefinitelyPass_)
517  { }
519  std::string from;
521  int fromLane;
523  std::string to;
525  int toLane;
528  };
529 
531  std::vector<PostProcessConnection> myConnections;
532 
533 
535  typedef std::map<std::string, NBEdge*> EdgeCont;
536 
539 
542 
544  std::set<std::string> myIgnoredEdges;
545 
547  unsigned int myEdgesSplit;
548 
551 
552 
555 
558 
561 
563  std::set<std::string> myEdges2Keep;
564 
566  std::set<std::string> myEdges2Remove;
567 
570 
573 
575  std::set<std::string> myTypes2Keep;
576 
578  std::set<std::string> myTypes2Remove;
579 
583 
584 
587 
588 
589 private:
591  NBEdgeCont(const NBEdgeCont& s);
592 
594  NBEdgeCont& operator=(const NBEdgeCont& s);
595 
596 
597 };
598 
599 
600 #endif
601 
602 /****************************************************************************/
603 
~NBEdgeCont()
Destructor.
Definition: NBEdgeCont.cpp:77
void sortOutgoingLanesConnections()
Sorts all lanes of all edges within the container by their direction.
Definition: NBEdgeCont.cpp:539
bool myAmLeftHanded
Whether the network is left-handed.
Definition: NBEdgeCont.h:550
std::vector< std::string > getAllNames() const
Returns all ids of known edges.
Definition: NBEdgeCont.cpp:473
A container for traffic light definitions and built programs.
bool myRemoveEdgesAfterJoining
Whether edges shall be joined first, then removed.
Definition: NBEdgeCont.h:560
std::map< std::string, NBEdge * > EdgeCont
The type of the dictionary where an edge may be found by its id.
Definition: NBEdgeCont.h:535
The representation of a single edge during network building.
Definition: NBEdge.h:71
unsigned int getNoEdgeSplits() const
Returns the number of edge splits.
Definition: NBEdgeCont.h:276
A container for districts.
void clearControllingTLInformation() const
Clears information about controlling traffic lights for all connenections of all edges.
Definition: NBEdgeCont.cpp:531
void generateStreetSigns()
assigns street signs to edges based on toNode types
Definition: NBEdgeCont.cpp:884
void rename(NBEdge *edge, const std::string &newID)
Renames the edge. Throws exception if newID already exists.
Definition: NBEdgeCont.cpp:355
bool splitAt(NBDistrictCont &dc, NBEdge *edge, NBNode *node)
Splits the edge at the position nearest to the given node.
Definition: NBEdgeCont.cpp:367
void recheckPostProcessConnections()
Try to set any stored connections.
Definition: NBEdgeCont.cpp:708
unsigned int myEdgesSplit
the number of splits of edges during the building
Definition: NBEdgeCont.h:547
void computeLanes2Edges()
Computes for each edge which lanes approach the next edges.
Definition: NBEdgeCont.cpp:555
PostProcessConnection(const std::string &from_, int fromLane_, const std::string &to_, int toLane_, bool mayDefinitelyPass_)
Constructor.
Definition: NBEdgeCont.h:515
std::vector< PostProcessConnection > myConnections
The list of connections to recheck.
Definition: NBEdgeCont.h:531
void checkGeometries(const SUMOReal maxAngle, const SUMOReal minRadius, bool fix)
Definition: NBEdgeCont.cpp:520
void guessRoundabouts(std::vector< EdgeVector > &marked)
Determines which edges belong to roundabouts and increases their priority.
Definition: NBEdgeCont.cpp:780
NBEdgeCont(NBTypeCont &tc)
Constructor.
Definition: NBEdgeCont.cpp:69
SVCPermissions myVehicleClasses2Keep
Set of vehicle types which must be allowed on edges in order to keep them.
Definition: NBEdgeCont.h:569
void reduceGeometries(const SUMOReal minDist)
Definition: NBEdgeCont.cpp:512
std::map< std::string, NBEdge * >::const_iterator end() const
Returns the pointer to the end of the stored edges.
Definition: NBEdgeCont.h:185
bool insert(NBEdge *edge, bool ignorePrunning=false)
Adds an edge to the dictionary.
Definition: NBEdgeCont.cpp:165
void removeUnwishedEdges(NBDistrictCont &dc)
Removes unwished edges (not in keep-edges)
Definition: NBEdgeCont.cpp:484
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:343
A list of positions.
void applyOptions(OptionsCont &oc)
Initialises the storage by applying given options.
Definition: NBEdgeCont.cpp:83
bool mayDefinitelyPass
Whether the connection may be passed without braking.
Definition: NBEdgeCont.h:527
std::set< std::string > myEdges2Keep
Set of ids of edges which shall explicitly be kept.
Definition: NBEdgeCont.h:563
void computeEdge2Edges(bool noLeftMovers)
Computes for each edge the approached edges.
Definition: NBEdgeCont.cpp:547
void computeLaneShapes()
Computes the shapes of all lanes of all edges stored in the container.
Definition: NBEdgeCont.cpp:595
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:501
EdgeCont myEdges
The instance of the dictionary (id-&gt;edge)
Definition: NBEdgeCont.h:538
void clear()
Deletes all edges.
Definition: NBEdgeCont.cpp:150
EdgeCont myExtractedEdges
The extracted nodes which are kept for reference.
Definition: NBEdgeCont.h:541
void joinSameNodeConnectingEdges(NBDistrictCont &dc, NBTrafficLightLogicCont &tlc, EdgeVector edges)
Joins the given edges because they connect the same nodes.
Definition: NBEdgeCont.cpp:603
SVCPermissions myVehicleClasses2Remove
Set of vehicle types which need not be supported (edges which allow ONLY these are removed) ...
Definition: NBEdgeCont.h:572
std::string from
The id of the edge the connection starts at.
Definition: NBEdgeCont.h:519
std::map< std::string, NBEdge * >::const_iterator begin() const
Returns the pointer to the begin of the stored edges.
Definition: NBEdgeCont.h:177
PositionVector myPrunningBoundary
Boundary within which an edge must be located in order to be kept.
Definition: NBEdgeCont.h:581
std::set< std::string > myTypes2Keep
Set of edges types which shall be kept.
Definition: NBEdgeCont.h:575
SUMOReal myEdgesMinSpeed
The minimum speed an edge may have in order to be kept (default: -1)
Definition: NBEdgeCont.h:557
NBEdge * retrieve(const std::string &id, bool retrieveExtracted=false) const
Returns the edge that has the given id.
Definition: NBEdgeCont.cpp:240
bool wasRemoved(std::string id) const
Returns whether the edge with the id was deleted explicitly.
Definition: NBEdgeCont.h:457
void appendTurnarounds(bool noTLSControlled)
Appends turnarounds to all edges stored in the container.
Definition: NBEdgeCont.cpp:571
bool isLeftHanded() const
Returns whether the built edges are left-handed.
Definition: NBEdgeCont.h:442
std::vector< NBEdge * > EdgeVector
Definition: NBCont.h:38
int toLane
The number of the lane the connection ends at.
Definition: NBEdgeCont.h:525
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:336
NBEdgeCont & operator=(const NBEdgeCont &s)
invalidated assignment operator
A structure representing a connection between two lanes.
Definition: NBEdgeCont.h:506
void computeEdgeShapes()
Computes the shapes of all edges stored in the container.
Definition: NBEdgeCont.cpp:587
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:586
std::string to
The id of the edge the connection ends at.
Definition: NBEdgeCont.h:523
void recheckLaneSpread()
Rechecks whether the lane spread is proper.
Definition: NBEdgeCont.cpp:681
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:70
#define SUMOReal
Definition: config.h:221
bool wasIgnored(std::string id) const
Returns whether the edge with the id was ignored during parsing.
Definition: NBEdgeCont.h:450
std::set< std::string > myTypes2Remove
Set of edges types which shall be removed.
Definition: NBEdgeCont.h:578
void recheckLanes()
Rechecks whether all lanes have a successor for each of the stored edges.
Definition: NBEdgeCont.cpp:563
Container for nodes during the netbuilding process.
Definition: NBNodeCont.h:63
int fromLane
The number of the lane the connection starts at.
Definition: NBEdgeCont.h:521
std::set< std::string > myIgnoredEdges
The ids of ignored edges.
Definition: NBEdgeCont.h:544
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:738
NBEdge * retrievePossiblySplit(const std::string &id, const std::string &hint, bool incoming) const
Tries to retrieve an edge, even if it is splitted.
Definition: NBEdgeCont.cpp:257
void addPostProcessConnection(const std::string &from, int fromLane, const std::string &to, int toLane, bool mayDefinitelyPass)
Adds a connection which could not be set during loading.
Definition: NBEdgeCont.cpp:702
bool ignoreFilterMatch(NBEdge *edge)
Returns true if this edge matches one of the removal criteria.
Definition: NBEdgeCont.cpp:189
unsigned int size() const
Returns the number of edges.
Definition: NBEdgeCont.h:261
A storage for available types of edges.
Definition: NBTypeCont.h:56
std::set< std::string > myEdges2Remove
Set of ids of edges which shall explicitly be removed.
Definition: NBEdgeCont.h:566