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// ===========================================================================
33class OutputDevice;
34class NBPTStop;
35class NBEdgeCont;
36class NBPTStopCont;
37
38class NBPTLine {
39
40public:
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 const 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<std::pair<NBEdge*, std::string> > getStopEdges(const NBEdgeCont& ec) const;
75
77 NBEdge* getRouteStart(const NBEdgeCont& ec) const;
78
80 NBEdge* getRouteEnd(const NBEdgeCont& ec) const;
81
83 bool isConsistent(const std::vector<NBEdge*>& stops) const;
84
86 return myVClass;
87 }
88
90 void replaceStop(NBPTStop* oldStop, NBPTStop* newStop);
91
93 void replaceEdge(const std::string& edgeID, const EdgeVector& replacement);
94
96 void deleteInvalidStops(const NBEdgeCont& ec, const NBPTStopCont& sc);
98
100 void removeInvalidEdges(const NBEdgeCont& ec);
101
102 void setName(const std::string& name) {
103 myName = name;
104 }
105
106 inline const std::vector<std::string>& getWays() const {
107 return myWays;
108 }
109
110 std::vector<long long int>* getWaysNodes(std::string wayId);
111
112private:
113 std::string myName;
114 std::string myType;
115 std::vector<NBPTStop*> myPTStops;
116 std::map<std::string, std::vector<long long int> > myWaysNodes;
117 std::vector<std::string> myWays;
118 std::string myCurrentWay;
119 std::string myPTLineId;
120 std::string myRef;
121 // official line color
123
124 // @brief the service interval in minutes
126
127 std::string myNightService;
129
130public:
131 void setEdges(const std::vector<NBEdge*>& edges);
132private:
133 // route of ptline
134 std::vector<NBEdge*> myRoute;
135public:
136 const std::vector<NBEdge*>& getRoute() const;
137private:
138
140};
141
142
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:55
void deleteDuplicateStops()
Definition: NBPTLine.cpp:300
std::vector< NBPTStop * > myPTStops
Definition: NBPTLine.h:115
SUMOVehicleClass myVClass
Definition: NBPTLine.h:128
std::string myPTLineId
Definition: NBPTLine.h:119
bool isConsistent(const std::vector< NBEdge * > &stops) const
return whether the mentioned edges appear in that order in the route
Definition: NBPTLine.cpp:237
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:102
void addPTStop(NBPTStop *pStop)
Definition: NBPTLine.cpp:46
std::vector< std::string > myWays
Definition: NBPTLine.h:117
void deleteInvalidStops(const NBEdgeCont &ec, const NBPTStopCont &sc)
remove invalid stops from the line
Definition: NBPTLine.cpp:283
void replaceStops(std::vector< NBPTStop * > stops)
Definition: NBPTLine.h:70
void write(OutputDevice &device)
Definition: NBPTLine.cpp:66
std::vector< NBEdge * > myRoute
Definition: NBPTLine.h:134
const std::vector< NBPTStop * > & getStops()
Definition: NBPTLine.cpp:60
void removeInvalidEdges(const NBEdgeCont &ec)
remove invalid edges from the line
Definition: NBPTLine.cpp:322
const std::string & getName() const
Definition: NBPTLine.h:51
int myNumOfStops
Definition: NBPTLine.h:139
std::vector< std::pair< NBEdge *, std::string > > getStopEdges(const NBEdgeCont &ec) const
get stop edges and stop ids
Definition: NBPTLine.cpp:164
int myInterval
Definition: NBPTLine.h:125
std::string myName
Definition: NBPTLine.h:113
RGBColor myColor
Definition: NBPTLine.h:122
const std::string & getLineID() const
Definition: NBPTLine.h:47
std::vector< long long int > * getWaysNodes(std::string wayId)
Definition: NBPTLine.cpp:118
std::string myCurrentWay
Definition: NBPTLine.h:118
std::string myRef
Definition: NBPTLine.h:120
SUMOVehicleClass getVClass() const
Definition: NBPTLine.h:85
const std::string & getRef() const
get line reference (not unique)
Definition: NBPTLine.h:66
NBEdge * getRouteEnd(const NBEdgeCont &ec) const
return last valid edge of myRoute (if it doest not lie before the last stop)
Definition: NBPTLine.cpp:207
const std::vector< NBEdge * > & getRoute() const
Definition: NBPTLine.cpp:158
void addWayNode(long long int way, long long int node)
Definition: NBPTLine.cpp:107
std::string myType
Definition: NBPTLine.h:114
std::string myNightService
Definition: NBPTLine.h:127
NBEdge * getRouteStart(const NBEdgeCont &ec) const
return first valid edge of myRoute (if it doest not lie after the first stop)
Definition: NBPTLine.cpp:177
const std::vector< std::string > & getWays() const
Definition: NBPTLine.h:106
std::map< std::string, std::vector< long long int > > myWaysNodes
Definition: NBPTLine.h:116
void setMyNumOfStops(int numStops)
Definition: NBPTLine.cpp:152
void replaceStop(NBPTStop *oldStop, NBPTStop *newStop)
replace the given stop
Definition: NBPTLine.cpp:255
void replaceEdge(const std::string &edgeID, const EdgeVector &replacement)
replace the edge with the given edge list
Definition: NBPTLine.cpp:265
void setEdges(const std::vector< NBEdge * > &edges)
Definition: NBPTLine.cpp:127
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