SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
NBNode.h
Go to the documentation of this file.
1 /****************************************************************************/
10 // The representation of a single node
11 /****************************************************************************/
12 // SUMO, Simulation of Urban MObility; see http://sumo-sim.org/
13 // Copyright (C) 2001-2013 DLR (http://www.dlr.de/) and contributors
14 /****************************************************************************/
15 //
16 // This file is part of SUMO.
17 // SUMO is free software: you can redistribute it and/or modify
18 // it under the terms of the GNU General Public License as published by
19 // the Free Software Foundation, either version 3 of the License, or
20 // (at your option) any later version.
21 //
22 /****************************************************************************/
23 #ifndef NBNode_h
24 #define NBNode_h
25 
26 
27 // ===========================================================================
28 // included modules
29 // ===========================================================================
30 #ifdef _MSC_VER
31 #include <windows_config.h>
32 #else
33 #include <config.h>
34 #endif
35 
36 #include <vector>
37 #include <deque>
38 #include <utility>
39 #include <string>
40 #include <set>
41 #include <utils/common/Named.h>
42 #include <utils/geom/Bresenham.h>
44 #include <utils/geom/Position.h>
45 #include <utils/geom/Line.h>
48 #include "NBEdge.h"
49 #include "NBConnection.h"
50 #include "NBConnectionDefs.h"
51 #include "NBContHelper.h"
52 
53 
54 // ===========================================================================
55 // class declarations
56 // ===========================================================================
57 class NBRequest;
58 class NBDistrict;
59 class OptionsCont;
61 class NBTypeCont;
63 class NBDistrictCont;
64 class OutputDevice;
65 
66 
67 // ===========================================================================
68 // class definitions
69 // ===========================================================================
74 class NBNode : public Named {
75  friend class NBNodeCont;
76  friend class GNEJunction; // < used for visualization (NETEDIT)
77  friend class NBNodesEdgesSorter; // < sorts the edges
78  friend class NBNodeTypeComputer; // < computes type
79  friend class NBEdgePriorityComputer; // < computes priorities of edges per intersection
80 
81 public:
94  private:
97 
100 
101  public:
106  ApproachingDivider(EdgeVector* approaching,
107  NBEdge* currentOutgoing);
108 
111 
113  void execute(const unsigned int src, const unsigned int dest);
114 
117  std::deque<int>* spread(const std::vector<int>& approachingLanes, int dest) const;
118 
119  };
120 
121 public:
126  NBNode(const std::string& id, const Position& position);
127 
128 
134  NBNode(const std::string& id, const Position& position, SumoXMLNodeType type);
135 
136 
142  NBNode(const std::string& id, const Position& position, NBDistrict* district);
143 
144 
146  ~NBNode();
147 
148 
155  void reinit(const Position& position, SumoXMLNodeType type,
156  bool updateEdgeGeometries = false);
157 
158 
161 
165  const Position& getPosition() const {
166  return myPosition;
167  }
168 
169 
171  Position getCenter() const;
172 
173 
177  const EdgeVector& getIncomingEdges() const {
178  return myIncomingEdges;
179  }
180 
181 
185  const EdgeVector& getOutgoingEdges() const {
186  return myOutgoingEdges;
187  }
188 
189 
193  const EdgeVector& getEdges() const {
194  return myAllEdges;
195  }
196 
197 
203  return myType;
204  }
206 
207 
208 
211 
216 
219 
222  void removeTrafficLights();
223 
224 
228  bool isTLControlled() const {
229  return myTrafficLights.size() != 0;
230  }
231 
232 
236  bool isJoinedTLSControlled() const;
237 
238 
242  const std::set<NBTrafficLightDefinition*>& getControllingTLS() const {
243  return myTrafficLights;
244  }
245 
246 
250 
251 
252 
255 
267 
268 
269 
272 
277  void reshiftPosition(SUMOReal xoff, SUMOReal yoff);
279 
280 
281 
283  void addIncomingEdge(NBEdge* edge);
284 
286  void addOutgoingEdge(NBEdge* edge);
287 
288 
289 
290 
292  void computeLanes2Lanes();
293 
295  void computeLogic(const NBEdgeCont& ec, OptionsCont& oc);
296 
299  bool writeLogic(OutputDevice& into, const bool checkLaneFoes) const;
300 
303  Position getEmptyDir() const;
304 
305 
310  bool hasIncoming(const NBEdge* const e) const;
311 
312 
317  bool hasOutgoing(const NBEdge* const e) const;
318 
319 
320  NBEdge* getOppositeIncoming(NBEdge* e) const;
323 
324  void removeDoubleEdges();
325  NBEdge* getConnectionTo(NBNode* n) const;
326 
327 
328  void addSortedLinkFoes(const NBConnection& mayDrive,
329  const NBConnection& mustStop);
330 
331  NBEdge* getPossiblySplittedIncoming(const std::string& edgeid);
332  NBEdge* getPossiblySplittedOutgoing(const std::string& edgeid);
333 
336  void removeEdge(NBEdge* edge, bool removeFromConnections = true);
337 
347  bool isLeftMover(const NBEdge* const from, const NBEdge* const to) const;
348 
349 
356  bool mustBrake(const NBEdge* const from, const NBEdge* const to, int toLane) const;
357 
358 
367  bool forbids(const NBEdge* const possProhibitorFrom, const NBEdge* const possProhibitorTo,
368  const NBEdge* const possProhibitedFrom, const NBEdge* const possProhibitedTo,
369  bool regardNonSignalisedLowerPriority) const;
370 
371 
379  bool foes(const NBEdge* const from1, const NBEdge* const to1,
380  const NBEdge* const from2, const NBEdge* const to2) const;
381 
382 
388  LinkDirection getDirection(const NBEdge* const incoming, const NBEdge* const outgoing) const;
389 
390  LinkState getLinkState(const NBEdge* incoming, NBEdge* outgoing,
391  int fromLane, bool mayDefinitelyPass, const std::string& tlID) const;
392 
393  void computeNodeShape(bool leftHand);
394 
395 
396  const PositionVector& getShape() const;
397 
398  bool checkIsRemovable() const;
399 
400 
401  std::vector<std::pair<NBEdge*, NBEdge*> > getEdgesToJoin() const;
402 
403 
404  friend class NBNodeShapeComputer;
405 
406  bool isNearDistrict() const;
407  bool isDistrict() const;
408 
409  bool needsCont(NBEdge* fromE, NBEdge* toE, NBEdge* otherFromE, NBEdge* otherToE, const NBEdge::Connection& c) const;
410 
420  NBEdge* fromE, int fromL, NBEdge* toE, int toL, int numPoints = 5) const;
421 
422 
425  void replaceIncoming(NBEdge* which, NBEdge* by, unsigned int laneOff);
426 
429  void replaceIncoming(const EdgeVector& which, NBEdge* by);
430 
433  void replaceOutgoing(NBEdge* which, NBEdge* by, unsigned int laneOff);
434 
437  void replaceOutgoing(const EdgeVector& which, NBEdge* by);
438 
439  void buildInnerEdges();
440 
442  return myBlockedConnections;
443  }
444 
447  bool geometryLike() const;
448 
450  void setRoundabout();
451 
457  public:
459  explicit nodes_by_id_sorter() { }
460 
463  int operator()(NBNode* n1, NBNode* n2) const {
464  return n1->getID() < n2->getID();
465  }
466 
467  };
468 
469 private:
470  bool isSimpleContinuation() const;
471 
474 
477  EdgeVector* getEdgesThatApproach(NBEdge* currentOutgoing);
478 
479 
480 
481 
483  unsigned int whichLaneOff, unsigned int byLaneOff);
484 
485 
487  NBEdge* removed, const EdgeVector& incoming, const EdgeVector& outgoing);
488 
489 
490 private:
493 
496 
499 
502 
505 
508 
511 
514 
516 
517  std::set<NBTrafficLightDefinition*> myTrafficLights;
518 
519 private:
521  NBNode(const NBNode& s);
522 
524  NBNode& operator=(const NBNode& s);
525 
526 
527 };
528 
529 
530 #endif
531 
532 /****************************************************************************/
533 
void replaceIncoming(NBEdge *which, NBEdge *by, unsigned int laneOff)
Replaces occurences of the first edge within the list of incoming by the second Connections are remap...
Definition: NBNode.cpp:797
const EdgeVector & getIncomingEdges() const
Returns this node&#39;s incoming edges.
Definition: NBNode.h:177
Position getEmptyDir() const
Returns something like the most unused direction Should only be used to add source or sink nodes...
Definition: NBNode.cpp:1003
A structure which describes a connection between edges or lanes.
Definition: NBEdge.h:148
void setRoundabout()
update the type of this node as a roundabout
Definition: NBNode.cpp:1437
Position getCenter() const
Returns a position that is guaranteed to lie within the node shape.
Definition: NBNode.cpp:1445
ApproachingDivider(EdgeVector *approaching, NBEdge *currentOutgoing)
Constructor.
Definition: NBNode.cpp:83
bool isDistrict() const
Definition: NBNode.cpp:1386
PositionVector myPoly
the (outer) shape of the junction
Definition: NBNode.h:513
NBEdge * getOppositeIncoming(NBEdge *e) const
Definition: NBNode.cpp:916
const NBConnectionProhibits & getProhibitions()
Definition: NBNode.h:441
void execute(const unsigned int src, const unsigned int dest)
Definition: NBNode.cpp:95
SumoXMLNodeType myType
The type of the junction.
Definition: NBNode.h:504
A container for traffic light definitions and built programs.
void reinit(const Position &position, SumoXMLNodeType type, bool updateEdgeGeometries=false)
Resets initial values.
Definition: NBNode.cpp:223
bool isTLControlled() const
Returns whether this node is controlled by any tls.
Definition: NBNode.h:228
~NBNode()
Destructor.
Definition: NBNode.cpp:217
PositionVector computeInternalLaneShape(NBEdge *fromE, int fromL, NBEdge *toE, int toL, int numPoints=5) const
Compute the shape for an internal lane.
Definition: NBNode.cpp:418
This class computes shapes of junctions.
void computeNodeShape(bool leftHand)
Definition: NBNode.cpp:620
void removeEdge(NBEdge *edge, bool removeFromConnections=true)
Removes edge from this node and optionally removes connections as well.
Definition: NBNode.cpp:977
void addIncomingEdge(NBEdge *edge)
adds an incoming edge
Definition: NBNode.cpp:369
The representation of a single edge during network building.
Definition: NBEdge.h:71
bool mustBrake(const NBEdge *const from, const NBEdge *const to, int toLane) const
Returns the information whether the described flow must let any other flow pass.
Definition: NBNode.cpp:1047
Used for sorting the cells by the begin time they describe.
Definition: NBNode.h:456
bool hasOutgoing(const NBEdge *const e) const
Returns whether the given edge starts at this node.
Definition: NBNode.cpp:910
A container for districts.
The base class for traffic light logic definitions.
bool isJoinedTLSControlled() const
Returns whether this node is controlled by a tls that spans over more than one node.
Definition: NBNode.cpp:282
void removeDoubleEdges()
Definition: NBNode.cpp:865
friend class GNEJunction
Definition: NBNode.h:76
bool checkIsRemovable() const
Definition: NBNode.cpp:1257
void removeTrafficLight(NBTrafficLightDefinition *tlDef)
Removes the given traffic light from this node.
Definition: NBNode.cpp:266
NBConnectionProhibits myBlockedConnections
Definition: NBNode.h:507
bool hasIncoming(const NBEdge *const e) const
Returns whether the given edge ends at this node.
Definition: NBNode.cpp:904
void addOutgoingEdge(NBEdge *edge)
adds an outgoing edge
Definition: NBNode.cpp:379
NBRequest * myRequest
Definition: NBNode.h:515
LinkDirection
The different directions a link between two lanes may take (or a stream between two edges)...
NBDistrict * myDistrict
The district the node is the centre of.
Definition: NBNode.h:510
A class representing a single district.
Definition: NBDistrict.h:72
const EdgeVector & getOutgoingEdges() const
Returns this node&#39;s outgoing edges.
Definition: NBNode.h:185
const std::string & getID() const
Returns the id.
Definition: Named.h:60
EdgeVector myAllEdges
Vector of incoming and outgoing edges.
Definition: NBNode.h:501
void computeLanes2Lanes()
computes the connections of lanes to edges
Definition: NBNode.cpp:637
void invalidateIncomingConnections()
Definition: NBNode.cpp:1031
void setPriorityJunctionPriorities()
sets the priorites in case of a priority junction
const Position & getPosition() const
Returns the position of this node.
Definition: NBNode.h:165
NBEdge * getPossiblySplittedIncoming(const std::string &edgeid)
Definition: NBNode.cpp:951
const std::set< NBTrafficLightDefinition * > & getControllingTLS() const
Returns the traffic lights that were assigned to this node.
Definition: NBNode.h:242
bool isSimpleContinuation() const
Definition: NBNode.cpp:389
int operator()(NBNode *n1, NBNode *n2) const
Comparing operator.
Definition: NBNode.h:463
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:46
A list of positions.
bool needsCont(NBEdge *fromE, NBEdge *toE, NBEdge *otherFromE, NBEdge *otherToE, const NBEdge::Connection &c) const
Definition: NBNode.cpp:542
SumoXMLNodeType getType() const
Returns the type of this node.
Definition: NBNode.h:202
bool geometryLike() const
whether this is structurally similar to a geometry node
Definition: NBNode.cpp:1412
void invalidateOutgoingConnections()
Definition: NBNode.cpp:1039
LinkState
The right-of-way state of a link between two lanes used when constructing a NBTrafficLightLogic, in MSLink and GNEInternalLane.
void removeTrafficLights()
Removes all references to traffic lights that control this tls.
Definition: NBNode.cpp:273
EdgeVector * getEdgesThatApproach(NBEdge *currentOutgoing)
Definition: NBNode.cpp:738
const EdgeVector & getEdges() const
Returns all edges which participate in this node.
Definition: NBNode.h:193
std::set< NBTrafficLightDefinition * > myTrafficLights
Definition: NBNode.h:517
Storage for edges, including some functionality operating on multiple edges.
Definition: NBEdgeCont.h:66
const PositionVector & getShape() const
Definition: NBNode.cpp:1338
NBEdge * getConnectionTo(NBNode *n) const
Definition: NBNode.cpp:1344
EdgeVector myIncomingEdges
Vector of incoming edges.
Definition: NBNode.h:495
bool isLeftMover(const NBEdge *const from, const NBEdge *const to) const
Computes whether the given connection is a left mover across the junction.
Definition: NBNode.cpp:1071
Base class for objects which have an id.
Definition: Named.h:45
std::vector< std::pair< NBEdge *, NBEdge * > > getEdgesToJoin() const
Definition: NBNode.cpp:1314
NBEdge * getPossiblySplittedOutgoing(const std::string &edgeid)
Definition: NBNode.cpp:964
unsigned int removeSelfLoops(NBDistrictCont &dc, NBEdgeCont &ec, NBTrafficLightLogicCont &tc)
Removes edges which are both incoming and outgoing into this node.
Definition: NBNode.cpp:326
EdgeVector myOutgoingEdges
Vector of outgoing edges.
Definition: NBNode.h:498
NBEdge * myCurrentOutgoing
The approached current edge.
Definition: NBNode.h:99
nodes_by_id_sorter()
Constructor.
Definition: NBNode.h:459
void addTrafficLight(NBTrafficLightDefinition *tlDef)
Adds a traffic light to the list of traffic lights that control this node.
Definition: NBNode.cpp:257
bool isNearDistrict() const
Definition: NBNode.cpp:1355
Position myPosition
The position the node lies at.
Definition: NBNode.h:492
std::map< NBConnection, NBConnectionVector > NBConnectionProhibits
Definition of a container for connection block dependencies Includes a list of all connections which ...
void replaceOutgoing(NBEdge *which, NBEdge *by, unsigned int laneOff)
Replaces occurences of the first edge within the list of outgoing by the second Connections are remap...
Definition: NBNode.cpp:761
~ApproachingDivider()
Destructor.
Definition: NBNode.cpp:91
LinkState getLinkState(const NBEdge *incoming, NBEdge *outgoing, int fromLane, bool mayDefinitelyPass, const std::string &tlID) const
Definition: NBNode.cpp:1234
SumoXMLNodeType
Numbers representing special SUMO-XML-attribute values for representing node- (junction-) types used ...
void replaceInConnectionProhibitions(NBEdge *which, NBEdge *by, unsigned int whichLaneOff, unsigned int byLaneOff)
Definition: NBNode.cpp:830
std::vector< NBEdge * > EdgeVector
Definition: NBCont.h:38
void buildInnerEdges()
Definition: NBNode.cpp:1392
NBNode & operator=(const NBNode &s)
invalidated assignment operator
EdgeVector * myApproaching
The list of edges that approach the current edge.
Definition: NBNode.h:96
A storage for options typed value containers)
Definition: OptionsCont.h:108
std::deque< int > * spread(const std::vector< int > &approachingLanes, int dest) const
Definition: NBNode.cpp:120
Represents a single node (junction) during network building.
Definition: NBNode.h:74
NBNode(const std::string &id, const Position &position)
Constructor.
Definition: NBNode.cpp:195
void addSortedLinkFoes(const NBConnection &mayDrive, const NBConnection &mustStop)
Definition: NBNode.cpp:934
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:70
#define SUMOReal
Definition: config.h:215
Computes lane-2-lane connections.
Definition: NBNode.h:93
bool writeLogic(OutputDevice &into, const bool checkLaneFoes) const
Definition: NBNode.cpp:610
void computeLogic(const NBEdgeCont &ec, OptionsCont &oc)
computes the node&#39;s type, logic and traffic light
Definition: NBNode.cpp:571
Container for nodes during the netbuilding process.
Definition: NBNodeCont.h:63
bool foes(const NBEdge *const from1, const NBEdge *const to1, const NBEdge *const from2, const NBEdge *const to2) const
Returns the information whether the given flows cross.
Definition: NBNode.cpp:1100
void invalidateTLS(NBTrafficLightLogicCont &tlCont)
causes the traffic light to be computed anew
Definition: NBNode.cpp:296
void reshiftPosition(SUMOReal xoff, SUMOReal yoff)
Applies an offset to the node.
Definition: NBNode.cpp:249
void remapRemoved(NBTrafficLightLogicCont &tc, NBEdge *removed, const EdgeVector &incoming, const EdgeVector &outgoing)
Definition: NBNode.cpp:1107
A storage for available types of edges.
Definition: NBTypeCont.h:56
bool forbids(const NBEdge *const possProhibitorFrom, const NBEdge *const possProhibitorTo, const NBEdge *const possProhibitedFrom, const NBEdge *const possProhibitedTo, bool regardNonSignalisedLowerPriority) const
Returns the information whether &quot;prohibited&quot; flow must let &quot;prohibitor&quot; flow pass.
Definition: NBNode.cpp:1090
LinkDirection getDirection(const NBEdge *const incoming, const NBEdge *const outgoing) const
Returns the representation of the described stream&#39;s direction.
Definition: NBNode.cpp:1188