Line data Source code
1 : /****************************************************************************/
2 : // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3 : // Copyright (C) 2001-2024 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 : /****************************************************************************/
14 : /// @file MSJunction.h
15 : /// @author Christian Roessel
16 : /// @author Daniel Krajzewicz
17 : /// @author Sascha Krieg
18 : /// @author Michael Behrisch
19 : /// @date Wed, 12 Dez 2001
20 : ///
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>
30 : #include <utils/geom/PositionVector.h>
31 : #include <utils/common/Named.h>
32 : #include <utils/common/Parameterised.h>
33 : #include <utils/common/SUMOTime.h>
34 : #include <utils/common/UtilExceptions.h>
35 : #include <utils/xml/SUMOXMLDefinitions.h>
36 :
37 :
38 : // ===========================================================================
39 : // class declarations
40 : // ===========================================================================
41 : class MSVehicle;
42 : class MSLink;
43 : class MSLane;
44 : class MSEdge;
45 : class MSJunctionLogic;
46 :
47 : typedef std::vector<MSEdge*> MSEdgeVector;
48 : typedef std::vector<const MSEdge*> ConstMSEdgeVector;
49 :
50 :
51 : // ===========================================================================
52 : // class definitions
53 : // ===========================================================================
54 : /**
55 : * @class MSJunction
56 : * @brief The base class for an intersection
57 : */
58 : class MSJunction : public Named, public Parameterised {
59 : public:
60 : /** @brief Constructor
61 : * @param[in] id The id of the junction
62 : * @param[in] position The position of the junction
63 : * @param[in] shape The shape of the junction
64 : */
65 : MSJunction(const std::string& id,
66 : SumoXMLNodeType type,
67 : const Position& position,
68 : const PositionVector& shape,
69 : const std::string& name);
70 :
71 :
72 : /// @brief Destructor.
73 : virtual ~MSJunction();
74 :
75 :
76 : /** performs some initialisation after the loading
77 : (e.g., link map computation) */
78 : virtual void postloadInit();
79 :
80 : /// used by the gui
81 : void addSecondaryPosition(const Position& pos) {
82 0 : myPosition2 = pos;
83 : }
84 :
85 : /** returns the junction's position */
86 : const Position& getPosition(bool secondaryShape = false) const;
87 :
88 : /** @brief Returns this junction's shape
89 : * @return The shape of this junction
90 : */
91 : const PositionVector& getShape() const {
92 152956 : return myShape;
93 : }
94 :
95 : /// @brief return the junction name
96 : const std::string& getName() const {
97 0 : return myName;
98 : }
99 :
100 0 : virtual const std::vector<MSLink*>& getFoeLinks(const MSLink* const /*srcLink*/) const {
101 0 : return myEmptyLinks;
102 : }
103 :
104 0 : virtual const std::vector<MSLane*>& getFoeInternalLanes(const MSLink* const /*srcLink*/) const {
105 0 : return myEmptyLanes;
106 : }
107 :
108 : inline const ConstMSEdgeVector& getIncoming() const {
109 17249 : return myIncoming;
110 : }
111 :
112 : int getNrOfIncomingLanes() const;
113 :
114 : inline const ConstMSEdgeVector& getOutgoing() const {
115 436845 : return myOutgoing;
116 : }
117 :
118 : /** @brief Returns all internal lanes on the junction
119 : */
120 0 : virtual const std::vector<MSLane*> getInternalLanes() const {
121 0 : return myEmptyLanes;
122 : }
123 :
124 : void addIncoming(MSEdge* edge) {
125 1737559 : myIncoming.push_back(edge);
126 : }
127 :
128 : void addOutgoing(MSEdge* edge) {
129 1737559 : myOutgoing.push_back(edge);
130 : }
131 :
132 : /// @brief return the type of this Junction
133 : SumoXMLNodeType getType() const {
134 40086104 : return myType;
135 : }
136 :
137 : /// @brief erase vehicle from myLinkLeaders
138 : void passedJunction(const MSVehicle* vehicle);
139 :
140 : // @brief return the underlying right-of-way and conflict matrix
141 68 : virtual const MSJunctionLogic* getLogic() const {
142 68 : return nullptr;
143 : }
144 :
145 : protected:
146 : /// @brief Tye type of this junction
147 : SumoXMLNodeType myType;
148 :
149 : /// @brief The position of the junction
150 : Position myPosition;
151 :
152 : /// @brief The secondary position of the junction
153 : Position myPosition2;
154 :
155 : /// @brief The shape of the junction
156 : PositionVector myShape;
157 :
158 : /// @briefh The (optional) junction name
159 : std::string myName;
160 :
161 : std::vector<MSLink*> myEmptyLinks;
162 : std::vector<MSLane*> myEmptyLanes;
163 :
164 :
165 : /// @brief incoming edges
166 : ConstMSEdgeVector myIncoming;
167 : /// @brief outgoing edges
168 : ConstMSEdgeVector myOutgoing;
169 :
170 : private:
171 : /// @brief Invalidated copy constructor.
172 : MSJunction(const MSJunction&) = delete;
173 :
174 : /// @brief Invalidated assignment operator.
175 : MSJunction& operator=(const MSJunction&) = delete;
176 :
177 : };
|