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-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/****************************************************************************/
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 }
78 std::vector<std::pair<NBEdge*, std::string> > getStopEdges(const NBEdgeCont& ec) const;
79
81 NBEdge* getRouteStart(const NBEdgeCont& ec) const;
82
84 NBEdge* getRouteEnd(const NBEdgeCont& ec) const;
85
87 bool isConsistent(std::vector<NBEdge*> stops) const;
88
90 return myVClass;
91 }
92
94 void replaceStop(std::shared_ptr<NBPTStop> oldStop, std::shared_ptr<NBPTStop> newStop);
95
97 void replaceEdge(const std::string& edgeID, const std::vector<NBEdge*>& replacement);
98
100 void deleteInvalidStops(const NBEdgeCont& ec, const NBPTStopCont& sc);
102
104 void removeInvalidEdges(const NBEdgeCont& ec);
105
106 void setName(const std::string& name) {
107 myName = name;
108 }
109
110 void setRef(const std::string& line) {
111 myRef = line;
112 }
113
114 void setPeriod(int intervalS) {
115 myInterval = intervalS / 60;
116 }
117
118 inline const std::vector<std::string>& getWays() const {
119 return myWays;
120 }
121
122 const std::vector<long long int>* getWayNodes(std::string wayId);
123
124private:
125 std::string myName;
126 std::string myType;
127 std::vector<std::shared_ptr<NBPTStop> > myPTStops;
128 std::map<std::string, std::vector<long long int> > myWayNodes;
129 std::vector<std::string> myWays;
130 std::string myCurrentWay;
131 std::string myPTLineId;
132 std::string myRef;
133 // official line color
135
136 // @brief the service interval in minutes
138
139 std::string myNightService;
141
142public:
143 void setEdges(const std::vector<NBEdge*>& edges);
144private:
145 // route of ptline
146 std::vector<NBEdge*> myRoute;
147public:
148 const std::vector<NBEdge*>& getRoute() const;
149private:
150
154};
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:279
void setNumOfStops(int numStops, int missingBefore, int missingAfter)
Definition NBPTLine.cpp:166
int myMissingStopsAfter
Definition NBPTLine.h:153
bool isConsistent(std::vector< NBEdge * > stops) const
return whether the mentioned edges appear in that order in the route
Definition NBPTLine.cpp:253
void deleteDuplicateStops()
Definition NBPTLine.cpp:324
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:152
SUMOVehicleClass myVClass
Definition NBPTLine.h:140
std::string myPTLineId
Definition NBPTLine.h:131
void replaceEdge(const std::string &edgeID, const std::vector< NBEdge * > &replacement)
replace the edge with the given edge list
Definition NBPTLine.cpp:289
void setName(const std::string &name)
Definition NBPTLine.h:106
std::map< std::string, std::vector< long long int > > myWayNodes
Definition NBPTLine.h:128
void setRef(const std::string &line)
Definition NBPTLine.h:110
std::vector< std::string > myWays
Definition NBPTLine.h:129
void deleteInvalidStops(const NBEdgeCont &ec, const NBPTStopCont &sc)
remove invalid stops from the line
Definition NBPTLine.cpp:307
void write(OutputDevice &device)
Definition NBPTLine.cpp:74
std::vector< NBEdge * > myRoute
Definition NBPTLine.h:146
void removeInvalidEdges(const NBEdgeCont &ec)
remove invalid edges from the line
Definition NBPTLine.cpp:346
const std::string & getName() const
Definition NBPTLine.h:55
int myNumOfStops
Definition NBPTLine.h:151
std::vector< std::pair< NBEdge *, std::string > > getStopEdges(const NBEdgeCont &ec) const
get stop edges and stop ids
Definition NBPTLine.cpp:180
int myInterval
Definition NBPTLine.h:137
std::string myName
Definition NBPTLine.h:125
RGBColor myColor
Definition NBPTLine.h:134
const std::string & getLineID() const
Definition NBPTLine.h:51
void setPeriod(int intervalS)
Definition NBPTLine.h:114
std::string myCurrentWay
Definition NBPTLine.h:130
std::string myRef
Definition NBPTLine.h:132
SUMOVehicleClass getVClass() const
Definition NBPTLine.h:89
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:223
const std::vector< NBEdge * > & getRoute() const
Definition NBPTLine.cpp:174
std::vector< std::shared_ptr< NBPTStop > > myPTStops
Definition NBPTLine.h:127
void addWayNode(long long int way, long long int node)
Definition NBPTLine.cpp:121
std::string myType
Definition NBPTLine.h:126
std::string myNightService
Definition NBPTLine.h:139
NBEdge * getRouteStart(const NBEdgeCont &ec) const
return first valid edge of myRoute (if it doest not lie after the first stop)
Definition NBPTLine.cpp:193
const std::vector< std::string > & getWays() const
Definition NBPTLine.h:118
const std::vector< std::shared_ptr< NBPTStop > > & getStops()
Definition NBPTLine.cpp:68
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.