Line data Source code
1 : /****************************************************************************/
2 : // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3 : // Copyright (C) 2001-2025 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(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 6492 : virtual ~NBPTStop() {};
61 :
62 : std::string getID() const;
63 :
64 : const std::string& getEdgeId() const;
65 :
66 : const std::string& getLaneId() const {
67 124 : return myLaneId;
68 : }
69 :
70 : const std::string getOrigEdgeId() const;
71 :
72 : const std::string getName() const;
73 :
74 : const Position& getPosition() const;
75 :
76 : SVCPermissions getPermissions() const;
77 :
78 : long long int getAreaID() const {
79 0 : return myAreaID;
80 : }
81 :
82 : void write(OutputDevice& device);
83 :
84 : void reshiftPosition(const double offsetX, const double offsetY);
85 :
86 : const std::vector<NBPTPlatform>& getPlatformCands();
87 :
88 : bool getIsMultipleStopPositions() const;
89 :
90 : void setIsMultipleStopPositions(bool multipleStopPositions, long long int areaID);
91 :
92 : double getLength() const;
93 :
94 : bool setEdgeId(std::string edgeId, const NBEdgeCont& ec);
95 :
96 : void registerAdditionalEdge(std::string wayId, std::string edgeId);
97 :
98 : void addPlatformCand(NBPTPlatform platform);
99 :
100 : bool findLaneAndComputeBusStopExtent(const NBEdgeCont& ec);
101 :
102 : bool findLaneAndComputeBusStopExtent(const NBEdge* edge);
103 :
104 : void setPTStopId(std::string id) {
105 215 : myPTStopId = id;
106 215 : }
107 :
108 : bool wasLoaded() const {
109 6147 : return myGivenStartPos >= 0;
110 : }
111 :
112 : void resetLoaded() {
113 5 : myGivenStartPos = -1;
114 : }
115 :
116 : void setIsPlatform() {
117 74 : myIsPlatform = true;
118 74 : }
119 :
120 : bool isPlatform() const {
121 107 : return myIsPlatform;
122 : }
123 : void addAccess(std::string laneID, double offset, double length);
124 :
125 : /// @brief remove all access definitions
126 : void clearAccess();
127 :
128 : /// @brief register line that services this stop (for displaying)
129 : void addLine(const std::string& line);
130 :
131 : void setBidiStop(std::shared_ptr<NBPTStop> bidiStop) {
132 : myBidiStop = bidiStop;
133 : }
134 :
135 : std::shared_ptr<NBPTStop> getBidiStop() const {
136 : return myBidiStop.lock();
137 : }
138 :
139 : bool isLoose() const {
140 2681 : return myIsLoose;
141 : }
142 :
143 : double getEndPos() const {
144 34 : return myEndPos;
145 : }
146 :
147 : const std::vector<std::string>& getLines() const {
148 : return myLines;
149 : }
150 :
151 : /// @brief mirror coordinates along the x-axis
152 : void mirrorX();
153 :
154 : /// @brief replace the stop edge with the closest edge on the given edge list in all stops
155 : bool replaceEdge(const std::string& edgeID, const std::vector<NBEdge*>& replacement);
156 :
157 : const std::map<std::string, std::string>& getAdditionalEdgeCandidates() const {
158 : return myAdditionalEdgeCandidates;
159 : }
160 : void setOrigEdgeId(const std::string& origEdgeId) {
161 78 : myOrigEdgeId = origEdgeId;
162 78 : }
163 : void setPTStopLength(double ptStopLength) {
164 270 : myPTStopLength = ptStopLength;
165 16 : }
166 :
167 : private:
168 : std::string myPTStopId;
169 : Position myPosition;
170 : std::string myEdgeId;
171 : std::map<std::string, std::string> myAdditionalEdgeCandidates;
172 : std::string myOrigEdgeId;
173 : double myPTStopLength;
174 : const std::string myName;
175 : const double myParkingLength;
176 : const RGBColor myColor;
177 : std::string myLaneId;
178 : const SVCPermissions myPermissions;
179 :
180 : double myStartPos;
181 : double myEndPos;
182 :
183 : /// @brief laneId, lanePos, accessLength
184 : std::vector<std::tuple<std::string, double, double>> myAccesses;
185 :
186 : /// @brief list of public transport lines (for displaying)
187 : std::vector<std::string> myLines;
188 :
189 : std::weak_ptr<NBPTStop> myBidiStop;
190 :
191 : /// @brief whether the stop was not part of the road network and must be mapped
192 : bool myIsLoose;
193 :
194 : /// @brief whether this stop was build from a platform position
195 : bool myIsPlatform;
196 :
197 : std::vector<NBPTPlatform> myPlatformCands;
198 : bool myIsMultipleStopPositions;
199 : long long int myAreaID;
200 : double myGivenStartPos;
201 :
202 : private:
203 : /// @brief Invalidated assignment operator.
204 : NBPTStop& operator=(const NBPTStop&);
205 :
206 : };
|