Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
NBPTLine.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-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/****************************************************************************/
19// The representation of one direction of a single pt line
20/****************************************************************************/
21#pragma once
22#include <config.h>
23
24#include <memory>
25#include <map>
26#include <string>
27#include <vector>
28
29
30// ===========================================================================
31// class declarations
32// ===========================================================================
33class OutputDevice;
34class NBEdge;
35class NBEdgeCont;
36class NBPTStop;
37class NBPTStopCont;
38
39
40// ===========================================================================
41// class definitions
42// ===========================================================================
43class NBPTLine {
44public:
45 NBPTLine(const std::string& id, const std::string& name,
46 const std::string& type, const std::string& ref, int interval, const std::string& nightService,
47 SUMOVehicleClass vClass, RGBColor color);
48
49 void addPTStop(std::shared_ptr<NBPTStop> pStop);
50
51 const std::string& getLineID() const {
52 return myPTLineId;
53 }
54
55 const std::string& getName() const {
56 return myName;
57 }
58
59 const std::string& getType() const {
60 return myType;
61 }
62
63 const std::vector<std::shared_ptr<NBPTStop> >& getStops();
64 void write(OutputDevice& device);
65 void addWayNode(long long int way, long long int node);
66
67 void setNumOfStops(int numStops, int missingBefore, int missingAfter);
68
70 const std::string& getRef() const {
71 return myRef;
72 }
73
74 void replaceStops(std::vector<std::shared_ptr<NBPTStop> > stops) {
75 myPTStops = stops;
76 }
77
78 void setRevised(std::vector<bool> stopsRevised) {
79 myStopsRevised = stopsRevised;
80 }
82 struct PTStopInfo {
83 PTStopInfo(NBEdge* _edge, const std::string& _stopID, double _pos, bool _revised):
84 edge(_edge), stopID(_stopID), pos(_pos), revised(_revised) {}
86 std::string stopID;
87 double pos;
88 bool revised;
89 };
90 std::vector<PTStopInfo> getStopEdges(const NBEdgeCont& ec) const;
91
93 NBEdge* getRouteStart(const NBEdgeCont& ec) const;
94
96 NBEdge* getRouteEnd(const NBEdgeCont& ec) const;
97
99 bool isConsistent(std::vector<NBEdge*> stops) const;
100
102 return myVClass;
103 }
104
106 void replaceStop(std::shared_ptr<NBPTStop> oldStop, std::shared_ptr<NBPTStop> newStop);
107
109 void replaceEdge(const std::string& edgeID, const std::vector<NBEdge*>& replacement);
110
112 void deleteInvalidStops(const NBEdgeCont& ec, const NBPTStopCont& sc);
114
116 void removeInvalidEdges(const NBEdgeCont& ec);
117
118 void setName(const std::string& name) {
119 myName = name;
120 }
121
122 void setRef(const std::string& line) {
123 myRef = line;
124 }
125
126 void setPeriod(int intervalS) {
127 myInterval = intervalS / 60;
128 }
129
130 inline const std::vector<std::string>& getWays() const {
131 return myWays;
132 }
133
134 const std::vector<long long int>* getWayNodes(std::string wayId);
135
136 const EdgeVector& getEdges() const {
137 return myRoute;
138 }
139
140private:
141 std::string myName;
142 std::string myType;
143 std::vector<std::shared_ptr<NBPTStop> > myPTStops;
144 // @brief for each stop store a flag that states whether it was successfully matched to the osm-route
145 std::vector<bool> myStopsRevised;
146 std::map<std::string, std::vector<long long int> > myWayNodes;
147 std::vector<std::string> myWays;
148 std::string myCurrentWay;
149 std::string myPTLineId;
150 std::string myRef;
151 // official line color
153
154 // @brief the service interval in minutes
156
157 std::string myNightService;
159
160public:
161 void setEdges(const std::vector<NBEdge*>& edges);
162private:
163 // route of ptline
164 std::vector<NBEdge*> myRoute;
165public:
166 const std::vector<NBEdge*>& getRoute() const;
167private:
168
172};
std::vector< NBEdge * > EdgeVector
container for (sorted) edges
Definition NBCont.h:42
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types.
Storage for edges, including some functionality operating on multiple edges.
Definition NBEdgeCont.h:59
The representation of a single edge during network building.
Definition NBEdge.h:92
const std::string & getType() const
Definition NBPTLine.h:59
void replaceStop(std::shared_ptr< NBPTStop > oldStop, std::shared_ptr< NBPTStop > newStop)
replace the given stop
Definition NBPTLine.cpp:282
void setNumOfStops(int numStops, int missingBefore, int missingAfter)
Definition NBPTLine.cpp:166
int myMissingStopsAfter
Definition NBPTLine.h:171
bool isConsistent(std::vector< NBEdge * > stops) const
return whether the mentioned edges appear in that order in the route
Definition NBPTLine.cpp:256
void deleteDuplicateStops()
Definition NBPTLine.cpp:327
void replaceStops(std::vector< std::shared_ptr< NBPTStop > > stops)
Definition NBPTLine.h:74
const std::vector< long long int > * getWayNodes(std::string wayId)
Definition NBPTLine.cpp:132
int myMissingStopsBefore
Definition NBPTLine.h:170
SUMOVehicleClass myVClass
Definition NBPTLine.h:158
std::string myPTLineId
Definition NBPTLine.h:149
void replaceEdge(const std::string &edgeID, const std::vector< NBEdge * > &replacement)
replace the edge with the given edge list
Definition NBPTLine.cpp:292
void setName(const std::string &name)
Definition NBPTLine.h:118
std::map< std::string, std::vector< long long int > > myWayNodes
Definition NBPTLine.h:146
void setRef(const std::string &line)
Definition NBPTLine.h:122
std::vector< std::string > myWays
Definition NBPTLine.h:147
void deleteInvalidStops(const NBEdgeCont &ec, const NBPTStopCont &sc)
remove invalid stops from the line
Definition NBPTLine.cpp:310
void write(OutputDevice &device)
Definition NBPTLine.cpp:74
std::vector< NBEdge * > myRoute
Definition NBPTLine.h:164
void removeInvalidEdges(const NBEdgeCont &ec)
remove invalid edges from the line
Definition NBPTLine.cpp:349
const std::string & getName() const
Definition NBPTLine.h:55
std::vector< bool > myStopsRevised
Definition NBPTLine.h:145
int myNumOfStops
Definition NBPTLine.h:169
int myInterval
Definition NBPTLine.h:155
std::string myName
Definition NBPTLine.h:141
RGBColor myColor
Definition NBPTLine.h:152
const std::string & getLineID() const
Definition NBPTLine.h:51
std::vector< PTStopInfo > getStopEdges(const NBEdgeCont &ec) const
Definition NBPTLine.cpp:180
void setPeriod(int intervalS)
Definition NBPTLine.h:126
std::string myCurrentWay
Definition NBPTLine.h:148
std::string myRef
Definition NBPTLine.h:150
SUMOVehicleClass getVClass() const
Definition NBPTLine.h:101
const std::string & getRef() const
get line reference (not unique)
Definition NBPTLine.h:70
NBEdge * getRouteEnd(const NBEdgeCont &ec) const
return last valid edge of myRoute (if it doest not lie before the last stop)
Definition NBPTLine.cpp:226
const std::vector< NBEdge * > & getRoute() const
Definition NBPTLine.cpp:174
std::vector< std::shared_ptr< NBPTStop > > myPTStops
Definition NBPTLine.h:143
void addWayNode(long long int way, long long int node)
Definition NBPTLine.cpp:121
std::string myType
Definition NBPTLine.h:142
std::string myNightService
Definition NBPTLine.h:157
NBEdge * getRouteStart(const NBEdgeCont &ec) const
return first valid edge of myRoute (if it doest not lie after the first stop)
Definition NBPTLine.cpp:196
const std::vector< std::string > & getWays() const
Definition NBPTLine.h:130
const std::vector< std::shared_ptr< NBPTStop > > & getStops()
Definition NBPTLine.cpp:68
const EdgeVector & getEdges() const
Definition NBPTLine.h:136
void setRevised(std::vector< bool > stopsRevised)
Definition NBPTLine.h:78
void addPTStop(std::shared_ptr< NBPTStop > pStop)
Definition NBPTLine.cpp:54
void setEdges(const std::vector< NBEdge * > &edges)
Definition NBPTLine.cpp:141
Container for public transport stops during the net building process.
The representation of a single pt stop.
Definition NBPTStop.h:45
Static storage of an output device and its base (abstract) implementation.
get stop edges and stop ids and directional validity
Definition NBPTLine.h:82
std::string stopID
Definition NBPTLine.h:86
PTStopInfo(NBEdge *_edge, const std::string &_stopID, double _pos, bool _revised)
Definition NBPTLine.h:83