Eclipse SUMO - Simulation of Urban MObility
NBPTLine.h
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2001-2022 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 
25 #include <string>
26 #include <vector>
27 #include <map>
28 #include "NBEdge.h" // Cherednychek
29 
30 // ===========================================================================
31 // class declarations
32 // ===========================================================================
33 class OutputDevice;
34 class NBPTStop;
35 class NBEdgeCont;
36 class NBPTStopCont;
37 
38 class NBPTLine {
39 
40 public:
41  NBPTLine(const std::string& id, const std::string& name,
42  const std::string& type, const std::string& ref, int interval, const std::string& nightService,
43  SUMOVehicleClass vClass, RGBColor color);
44 
45  void addPTStop(NBPTStop* pStop);
46 
47  const std::string& getLineID() const {
48  return myPTLineId;
49  }
50 
51  const std::string& getName() const {
52  return myName;
53  }
54 
55  const std::string& getType() const {
56  return myType;
57  }
58 
59  std::vector<NBPTStop*> getStops();
60  void write(OutputDevice& device);
61  void addWayNode(long long int way, long long int node);
62 
63  void setMyNumOfStops(int numStops);
64 
66  const std::string& getRef() const {
67  return myRef;
68  }
69 
70  void replaceStops(std::vector<NBPTStop*> stops) {
71  myPTStops = stops;
72  }
74  std::vector<NBEdge*> getStopEdges(const NBEdgeCont& ec) const;
75 
77  NBEdge* getRouteStart(const NBEdgeCont& ec) const;
78 
80  NBEdge* getRouteEnd(const NBEdgeCont& ec) const;
81 
83  return myVClass;
84  }
85 
87  void replaceStop(NBPTStop* oldStop, NBPTStop* newStop);
88 
90  void replaceEdge(const std::string& edgeID, const EdgeVector& replacement);
91 
93  void deleteInvalidStops(const NBEdgeCont& ec, const NBPTStopCont& sc);
94  void deleteDuplicateStops();
95 
97  void removeInvalidEdges(const NBEdgeCont& ec);
98 
99  void setName(const std::string& name) {
100  myName = name;
101  }
102 
103 private:
104  std::string myName;
105  std::string myType;
106  std::vector<NBPTStop*> myPTStops;
107 
108 private:
109  std::map<std::string, std::vector<long long int> > myWaysNodes;
110  std::vector<std::string> myWays;
111 public:
112  const std::vector<std::string>& getMyWays() const;
113  std::vector<long long int>* getWaysNodes(std::string wayId);
114 private:
115 
116  std::string myCurrentWay;
117  std::string myPTLineId;
118  std::string myRef;
119  // official line color
121 
122  // @brief the service interval in minutes
124 
125  std::string myNightService;
127 
128 public:
129  void setEdges(const std::vector<NBEdge*>& edges);
130 private:
131  // route of ptline
132  std::vector<NBEdge*> myRoute;
133 public:
134  const std::vector<NBEdge*>& getRoute() const;
135 private:
136 
138 };
139 
140 
std::vector< NBEdge * > EdgeVector
container for (sorted) edges
Definition: NBCont.h:35
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:91
void deleteDuplicateStops()
Definition: NBPTLine.cpp:262
std::vector< NBPTStop * > myPTStops
Definition: NBPTLine.h:106
SUMOVehicleClass myVClass
Definition: NBPTLine.h:126
std::string myPTLineId
Definition: NBPTLine.h:117
NBPTLine(const std::string &id, const std::string &name, const std::string &type, const std::string &ref, int interval, const std::string &nightService, SUMOVehicleClass vClass, RGBColor color)
Definition: NBPTLine.cpp:32
void setName(const std::string &name)
Definition: NBPTLine.h:99
void addPTStop(NBPTStop *pStop)
Definition: NBPTLine.cpp:44
std::vector< std::string > myWays
Definition: NBPTLine.h:110
void deleteInvalidStops(const NBEdgeCont &ec, const NBPTStopCont &sc)
remove invalid stops from the line
Definition: NBPTLine.cpp:246
void replaceStops(std::vector< NBPTStop * > stops)
Definition: NBPTLine.h:70
void write(OutputDevice &device)
Definition: NBPTLine.cpp:60
std::vector< NBEdge * > myRoute
Definition: NBPTLine.h:132
void removeInvalidEdges(const NBEdgeCont &ec)
remove invalid edges from the line
Definition: NBPTLine.cpp:283
const std::vector< std::string > & getMyWays() const
Definition: NBPTLine.cpp:108
int myNumOfStops
Definition: NBPTLine.h:137
const std::string & getLineID() const
Definition: NBPTLine.h:47
int myInterval
Definition: NBPTLine.h:123
const std::string & getType() const
Definition: NBPTLine.h:55
std::string myName
Definition: NBPTLine.h:104
RGBColor myColor
Definition: NBPTLine.h:120
std::vector< long long int > * getWaysNodes(std::string wayId)
Definition: NBPTLine.cpp:111
std::string myCurrentWay
Definition: NBPTLine.h:116
std::string myRef
Definition: NBPTLine.h:118
SUMOVehicleClass getVClass() const
Definition: NBPTLine.h:82
NBEdge * getRouteEnd(const NBEdgeCont &ec) const
return last valid edge of myRoute (if it doest not lie before the last stop)
Definition: NBPTLine.cpp:191
const std::vector< NBEdge * > & getRoute() const
Definition: NBPTLine.cpp:145
void addWayNode(long long int way, long long int node)
Definition: NBPTLine.cpp:99
const std::string & getName() const
Definition: NBPTLine.h:51
const std::string & getRef() const
get line reference (not unique)
Definition: NBPTLine.h:66
std::string myType
Definition: NBPTLine.h:105
std::string myNightService
Definition: NBPTLine.h:125
NBEdge * getRouteStart(const NBEdgeCont &ec) const
return first valid edge of myRoute (if it doest not lie after the first stop)
Definition: NBPTLine.cpp:162
std::map< std::string, std::vector< long long int > > myWaysNodes
Definition: NBPTLine.h:109
std::vector< NBEdge * > getStopEdges(const NBEdgeCont &ec) const
get stop edges
Definition: NBPTLine.cpp:150
void setMyNumOfStops(int numStops)
Definition: NBPTLine.cpp:142
void replaceStop(NBPTStop *oldStop, NBPTStop *newStop)
replace the given stop
Definition: NBPTLine.cpp:220
void replaceEdge(const std::string &edgeID, const EdgeVector &replacement)
replace the edge with the given edge list
Definition: NBPTLine.cpp:229
std::vector< NBPTStop * > getStops()
Definition: NBPTLine.cpp:56
void setEdges(const std::vector< NBEdge * > &edges)
Definition: NBPTLine.cpp:119
The representation of a single pt stop.
Definition: NBPTStop.h:46
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:61