Line data Source code
1 : /****************************************************************************/
2 : // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3 : // Copyright (C) 2001-2026 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 NBPTStop.h
15 : /// @author Gregor Laemmel
16 : /// @date Tue, 20 Mar 2017
17 : ///
18 : // The representation of a single pt stop
19 : /****************************************************************************/
20 : #pragma once
21 : #include <config.h>
22 :
23 : #include <memory>
24 : #include <string>
25 : #include <utils/common/Parameterised.h>
26 : #include <utils/geom/Position.h>
27 : #include "NBPTPlatform.h"
28 :
29 :
30 : // ===========================================================================
31 : // class declarations
32 : // ===========================================================================
33 : class OutputDevice;
34 : class NBEdgeCont;
35 : class NBEdge;
36 :
37 :
38 : // ===========================================================================
39 : // class definitions
40 : // ===========================================================================
41 : /**
42 : * @class NBPTStop
43 : * @brief The representation of a single pt stop
44 : */
45 : class NBPTStop : public Parameterised {
46 :
47 : public:
48 : /**@brief Constructor
49 : * @param[in] id The id of the pt stop
50 : * @param[in] position The position of the pt stop
51 : * @param[in] edgeId The edge id of the pt stop
52 : * @param[in] length The length of the pt stop
53 : * @param[in] color ptStop color
54 : * @param[in] givenStartPos Loaded startPos (and implicit endPos) that should not be adapted
55 : */
56 : NBPTStop(SumoXMLTag tag, std::string ptStopId, Position position, std::string edgeId, std::string origEdgeId, double length, std::string name,
57 : SVCPermissions svcPermissions, double parkingLength = 0, const RGBColor color = RGBColor(false), double givenStartPos = -1);
58 :
59 : /// @brief Destructor
60 6768 : virtual ~NBPTStop() {};
61 :
62 : std::string getID() const;
63 :
64 : SumoXMLTag getElement() const {
65 390 : return myTag;
66 : }
67 :
68 : const std::string& getEdgeId() const;
69 :
70 : const std::string& getLaneId() const {
71 139 : return myLaneId;
72 : }
73 :
74 : const std::string getOrigEdgeId() const;
75 :
76 : const std::string getName() const;
77 :
78 : const Position& getPosition() const;
79 :
80 : SVCPermissions getPermissions() const;
81 :
82 : long long int getAreaID() const {
83 0 : return myAreaID;
84 : }
85 :
86 : void write(OutputDevice& device);
87 :
88 : void reshiftPosition(const double offsetX, const double offsetY);
89 :
90 : const std::vector<NBPTPlatform>& getPlatformCands();
91 :
92 : bool getIsMultipleStopPositions() const;
93 :
94 : void setIsMultipleStopPositions(bool multipleStopPositions, long long int areaID);
95 :
96 : double getLength() const;
97 :
98 : bool setEdgeId(std::string edgeId, const NBEdgeCont& ec);
99 :
100 : void registerAdditionalEdge(std::string wayId, std::string edgeId);
101 :
102 : void addPlatformCand(NBPTPlatform platform);
103 :
104 : bool findLaneAndComputeBusStopExtent(const NBEdgeCont& ec);
105 :
106 : bool findLaneAndComputeBusStopExtent(const NBEdge* edge);
107 :
108 : void setPTStopId(std::string id) {
109 215 : myPTStopId = id;
110 215 : }
111 :
112 : bool wasLoaded() const {
113 6303 : return myGivenStartPos >= 0;
114 : }
115 :
116 : void resetLoaded() {
117 5 : myGivenStartPos = -1;
118 : }
119 :
120 : void setIsPlatform() {
121 86 : myIsPlatform = true;
122 86 : }
123 :
124 : bool isPlatform() const {
125 139 : return myIsPlatform;
126 : }
127 : void addAccess(std::string laneID, double offset, double length);
128 :
129 : /// @brief remove all access definitions
130 : void clearAccess();
131 :
132 : /// @brief register line that services this stop (for displaying)
133 : void addLine(const std::string& line);
134 :
135 : void setBidiStop(std::shared_ptr<NBPTStop> bidiStop) {
136 : myBidiStop = bidiStop;
137 : }
138 :
139 : std::shared_ptr<NBPTStop> getBidiStop() const {
140 : return myBidiStop.lock();
141 : }
142 :
143 : bool isLoose() const {
144 2864 : return myIsLoose;
145 : }
146 :
147 : double getStartPos() const {
148 0 : return myStartPos;
149 : }
150 :
151 : double getEndPos() const {
152 2748 : return myEndPos;
153 : }
154 :
155 : const std::vector<std::string>& getLines() const {
156 : return myLines;
157 : }
158 :
159 : /// @brief mirror coordinates along the x-axis
160 : void mirrorX();
161 :
162 : /// @brief replace the stop edge with the closest edge on the given edge list in all stops
163 : bool replaceEdge(const std::string& edgeID, const std::vector<NBEdge*>& replacement);
164 :
165 : const std::map<std::string, std::string>& getAdditionalEdgeCandidates() const {
166 : return myAdditionalEdgeCandidates;
167 : }
168 : void setOrigEdgeId(const std::string& origEdgeId) {
169 85 : myOrigEdgeId = origEdgeId;
170 85 : }
171 : void setPTStopLength(double ptStopLength) {
172 270 : myPTStopLength = ptStopLength;
173 16 : }
174 :
175 : private:
176 : SumoXMLTag myTag;
177 : std::string myPTStopId;
178 : Position myPosition;
179 : std::string myEdgeId;
180 : std::map<std::string, std::string> myAdditionalEdgeCandidates;
181 : std::string myOrigEdgeId;
182 : double myPTStopLength;
183 : const std::string myName;
184 : const double myParkingLength;
185 : const RGBColor myColor;
186 : std::string myLaneId;
187 : const SVCPermissions myPermissions;
188 :
189 : double myStartPos;
190 : double myEndPos;
191 :
192 : /// @brief laneId, lanePos, accessLength
193 : std::vector<std::tuple<std::string, double, double>> myAccesses;
194 :
195 : /// @brief list of public transport lines (for displaying)
196 : std::vector<std::string> myLines;
197 :
198 : std::weak_ptr<NBPTStop> myBidiStop;
199 :
200 : /// @brief whether the stop was not part of the road network and must be mapped
201 : bool myIsLoose;
202 :
203 : /// @brief whether this stop was build from a platform position
204 : bool myIsPlatform;
205 :
206 : std::vector<NBPTPlatform> myPlatformCands;
207 : bool myIsMultipleStopPositions;
208 : long long int myAreaID;
209 : double myGivenStartPos;
210 :
211 : private:
212 : /// @brief Invalidated assignment operator.
213 : NBPTStop& operator=(const NBPTStop&);
214 :
215 : };
|