Eclipse SUMO - Simulation of Urban MObility
MSJunction.h
Go to the documentation of this file.
1/****************************************************************************/
2// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3// Copyright (C) 2001-2023 German Aerospace Center (DLR) and others.
4// This program and the accompanying materials are made available under the
5// terms of the Eclipse Public License 2.0 which is available at
6// https://www.eclipse.org/legal/epl-2.0/
7// This Source Code may also be made available under the following Secondary
8// Licenses when the conditions for such availability set forth in the Eclipse
9// Public License 2.0 are satisfied: GNU General Public License, version 2
10// or later which is available at
11// https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13/****************************************************************************/
21// The base class for an intersection
22/****************************************************************************/
23#pragma once
24#include <config.h>
25
26#include <string>
27#include <vector>
28#include <map>
29#include <utils/geom/Position.h>
31#include <utils/common/Named.h>
36
37
38// ===========================================================================
39// class declarations
40// ===========================================================================
41class MSVehicle;
42class MSLink;
43class MSLane;
44class MSEdge;
45class MSJunctionLogic;
46
47typedef std::vector<MSEdge*> MSEdgeVector;
48typedef std::vector<const MSEdge*> ConstMSEdgeVector;
49
50
51// ===========================================================================
52// class definitions
53// ===========================================================================
58class MSJunction : public Named, public Parameterised {
59public:
65 MSJunction(const std::string& id,
66 SumoXMLNodeType type,
67 const Position& position,
68 const PositionVector& shape,
69 const std::string& name);
70
71
73 virtual ~MSJunction();
74
75
78 virtual void postloadInit();
79
81 void addSecondaryPosition(const Position& pos) {
82 myPosition2 = pos;
83 }
84
86 const Position& getPosition(bool secondaryShape = false) const;
87
88
89
93 const PositionVector& getShape() const {
94 return myShape;
95 }
96
98 const std::string& getName() const {
99 return myName;
100 }
101
102 virtual const std::vector<MSLink*>& getFoeLinks(const MSLink* const /*srcLink*/) const {
103 return myEmptyLinks;
104 }
105
106 virtual const std::vector<MSLane*>& getFoeInternalLanes(const MSLink* const /*srcLink*/) const {
107 return myEmptyLanes;
108 }
109
110 inline const ConstMSEdgeVector& getIncoming() const {
111 return myIncoming;
112 }
113
114 int getNrOfIncomingLanes() const;
115
116 inline const ConstMSEdgeVector& getOutgoing() const {
117 return myOutgoing;
118 }
119
122 virtual const std::vector<MSLane*> getInternalLanes() const {
123 return myEmptyLanes;
124 }
125
126 void addIncoming(MSEdge* edge) {
127 myIncoming.push_back(edge);
128 }
129
130 void addOutgoing(MSEdge* edge) {
131 myOutgoing.push_back(edge);
132 }
133
136 return myType;
137 }
138
140 void passedJunction(const MSVehicle* vehicle);
141
142 // @brief return the underlying right-of-way and conflict matrix
143 virtual const MSJunctionLogic* getLogic() const {
144 return nullptr;
145 }
146
147protected:
150
153
156
159
161 std::string myName;
162
163 std::vector<MSLink*> myEmptyLinks;
164 std::vector<MSLane*> myEmptyLanes;
165
166
171
173 typedef std::map<std::string, MSJunction* > DictType;
174
175private:
178
181
182};
std::vector< const MSEdge * > ConstMSEdgeVector
Definition: MSEdge.h:74
std::vector< const MSEdge * > ConstMSEdgeVector
Definition: MSJunction.h:48
std::vector< MSEdge * > MSEdgeVector
Definition: MSJunction.h:47
SumoXMLNodeType
Numbers representing special SUMO-XML-attribute values for representing node- (junction-) types used ...
A road/street connecting two junctions.
Definition: MSEdge.h:77
The base class for an intersection.
Definition: MSJunction.h:58
virtual const std::vector< MSLane * > & getFoeInternalLanes(const MSLink *const) const
Definition: MSJunction.h:106
std::map< std::string, MSJunction * > DictType
definition of the static dictionary type
Definition: MSJunction.h:173
SumoXMLNodeType getType() const
return the type of this Junction
Definition: MSJunction.h:135
virtual const MSJunctionLogic * getLogic() const
Definition: MSJunction.h:143
MSJunction & operator=(const MSJunction &)
Invalidated assignment operator.
Position myPosition2
The secondary position of the junction.
Definition: MSJunction.h:155
std::vector< MSLane * > myEmptyLanes
Definition: MSJunction.h:164
virtual ~MSJunction()
Destructor.
Definition: MSJunction.cpp:64
PositionVector myShape
The shape of the junction.
Definition: MSJunction.h:158
ConstMSEdgeVector myOutgoing
outgoing edges
Definition: MSJunction.h:170
void addSecondaryPosition(const Position &pos)
used by the gui
Definition: MSJunction.h:81
std::vector< MSLink * > myEmptyLinks
Definition: MSJunction.h:163
Position myPosition
The position of the junction.
Definition: MSJunction.h:152
virtual const std::vector< MSLane * > getInternalLanes() const
Returns all internal lanes on the junction.
Definition: MSJunction.h:122
std::string myName
@briefh The (optional) junction name
Definition: MSJunction.h:161
int getNrOfIncomingLanes() const
Definition: MSJunction.cpp:78
MSJunction(const std::string &id, SumoXMLNodeType type, const Position &position, const PositionVector &shape, const std::string &name)
Constructor.
Definition: MSJunction.cpp:54
void addOutgoing(MSEdge *edge)
Definition: MSJunction.h:130
ConstMSEdgeVector myIncoming
incoming edges
Definition: MSJunction.h:168
void addIncoming(MSEdge *edge)
Definition: MSJunction.h:126
virtual const std::vector< MSLink * > & getFoeLinks(const MSLink *const) const
Definition: MSJunction.h:102
const ConstMSEdgeVector & getOutgoing() const
Definition: MSJunction.h:116
const std::string & getName() const
return the junction name
Definition: MSJunction.h:98
void passedJunction(const MSVehicle *vehicle)
erase vehicle from myLinkLeaders
MSJunction(const MSJunction &)
Invalidated copy constructor.
SumoXMLNodeType myType
Tye type of this junction.
Definition: MSJunction.h:149
const Position & getPosition(bool secondaryShape=false) const
Definition: MSJunction.cpp:68
const PositionVector & getShape() const
Returns this junction's shape.
Definition: MSJunction.h:93
virtual void postloadInit()
Definition: MSJunction.cpp:74
const ConstMSEdgeVector & getIncoming() const
Definition: MSJunction.h:110
Representation of a lane in the micro simulation.
Definition: MSLane.h:84
Representation of a vehicle in the micro simulation.
Definition: MSVehicle.h:77
Base class for objects which have an id.
Definition: Named.h:54
An upper class for objects with additional parameters.
Definition: Parameterised.h:41
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:37
A list of positions.