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 6480 : 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 6130 : return myGivenStartPos >= 0;
110 : }
111 :
112 : void setIsPlatform() {
113 74 : myIsPlatform = true;
114 74 : }
115 :
116 : bool isPlatform() const {
117 107 : return myIsPlatform;
118 : }
119 : void addAccess(std::string laneID, double offset, double length);
120 :
121 : /// @brief remove all access definitions
122 : void clearAccess();
123 :
124 : /// @brief register line that services this stop (for displaying)
125 : void addLine(const std::string& line);
126 :
127 : void setBidiStop(std::shared_ptr<NBPTStop> bidiStop) {
128 : myBidiStop = bidiStop;
129 : }
130 :
131 : std::shared_ptr<NBPTStop> getBidiStop() const {
132 : return myBidiStop.lock();
133 : }
134 :
135 : bool isLoose() const {
136 2681 : return myIsLoose;
137 : }
138 :
139 : double getEndPos() const {
140 34 : return myEndPos;
141 : }
142 :
143 : const std::vector<std::string>& getLines() const {
144 : return myLines;
145 : }
146 :
147 : /// @brief mirror coordinates along the x-axis
148 : void mirrorX();
149 :
150 : /// @brief replace the stop edge with the closest edge on the given edge list in all stops
151 : bool replaceEdge(const std::string& edgeID, const std::vector<NBEdge*>& replacement);
152 :
153 : const std::map<std::string, std::string>& getAdditionalEdgeCandidates() const {
154 : return myAdditionalEdgeCandidates;
155 : }
156 : void setOrigEdgeId(const std::string& origEdgeId) {
157 78 : myOrigEdgeId = origEdgeId;
158 78 : }
159 : void setPTStopLength(double ptStopLength) {
160 270 : myPTStopLength = ptStopLength;
161 16 : }
162 :
163 : private:
164 : std::string myPTStopId;
165 : Position myPosition;
166 : std::string myEdgeId;
167 : std::map<std::string, std::string> myAdditionalEdgeCandidates;
168 : std::string myOrigEdgeId;
169 : double myPTStopLength;
170 : const std::string myName;
171 : const double myParkingLength;
172 : const RGBColor myColor;
173 : std::string myLaneId;
174 : const SVCPermissions myPermissions;
175 :
176 : double myStartPos;
177 : double myEndPos;
178 :
179 : /// @brief laneId, lanePos, accessLength
180 : std::vector<std::tuple<std::string, double, double>> myAccesses;
181 :
182 : /// @brief list of public transport lines (for displaying)
183 : std::vector<std::string> myLines;
184 :
185 : std::weak_ptr<NBPTStop> myBidiStop;
186 :
187 : /// @brief whether the stop was not part of the road network and must be mapped
188 : bool myIsLoose;
189 :
190 : /// @brief whether this stop was build from a platform position
191 : bool myIsPlatform;
192 :
193 : std::vector<NBPTPlatform> myPlatformCands;
194 : bool myIsMultipleStopPositions;
195 : long long int myAreaID;
196 : double myGivenStartPos;
197 :
198 : private:
199 : /// @brief Invalidated assignment operator.
200 : NBPTStop& operator=(const NBPTStop&);
201 :
202 : };
|