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-2023 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 setMyNumOfStops(int numStops);
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(const 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 inline const std::vector<std::string>& getWays() const {
111 return myWays;
112 }
113
114 const std::vector<long long int>* getWayNodes(std::string wayId);
115
116private:
117 std::string myName;
118 std::string myType;
119 std::vector<std::shared_ptr<NBPTStop> > myPTStops;
120 std::map<std::string, std::vector<long long int> > myWayNodes;
121 std::vector<std::string> myWays;
122 std::string myCurrentWay;
123 std::string myPTLineId;
124 std::string myRef;
125 // official line color
127
128 // @brief the service interval in minutes
130
131 std::string myNightService;
133
134public:
135 void setEdges(const std::vector<NBEdge*>& edges);
136private:
137 // route of ptline
138 std::vector<NBEdge*> myRoute;
139public:
140 const std::vector<NBEdge*>& getRoute() const;
141private:
142
144};
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:260
void deleteDuplicateStops()
Definition: NBPTLine.cpp:305
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:123
SUMOVehicleClass myVClass
Definition: NBPTLine.h:132
std::string myPTLineId
Definition: NBPTLine.h:123
void replaceEdge(const std::string &edgeID, const std::vector< NBEdge * > &replacement)
replace the edge with the given edge list
Definition: NBPTLine.cpp:270
bool isConsistent(const std::vector< NBEdge * > &stops) const
return whether the mentioned edges appear in that order in the route
Definition: NBPTLine.cpp:242
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:37
void setName(const std::string &name)
Definition: NBPTLine.h:106
std::map< std::string, std::vector< long long int > > myWayNodes
Definition: NBPTLine.h:120
std::vector< std::string > myWays
Definition: NBPTLine.h:121
void deleteInvalidStops(const NBEdgeCont &ec, const NBPTStopCont &sc)
remove invalid stops from the line
Definition: NBPTLine.cpp:288
void write(OutputDevice &device)
Definition: NBPTLine.cpp:71
std::vector< NBEdge * > myRoute
Definition: NBPTLine.h:138
void removeInvalidEdges(const NBEdgeCont &ec)
remove invalid edges from the line
Definition: NBPTLine.cpp:327
const std::string & getName() const
Definition: NBPTLine.h:55
int myNumOfStops
Definition: NBPTLine.h:143
std::vector< std::pair< NBEdge *, std::string > > getStopEdges(const NBEdgeCont &ec) const
get stop edges and stop ids
Definition: NBPTLine.cpp:169
int myInterval
Definition: NBPTLine.h:129
std::string myName
Definition: NBPTLine.h:117
RGBColor myColor
Definition: NBPTLine.h:126
const std::string & getLineID() const
Definition: NBPTLine.h:51
std::string myCurrentWay
Definition: NBPTLine.h:122
std::string myRef
Definition: NBPTLine.h:124
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:212
const std::vector< NBEdge * > & getRoute() const
Definition: NBPTLine.cpp:163
std::vector< std::shared_ptr< NBPTStop > > myPTStops
Definition: NBPTLine.h:119
void addWayNode(long long int way, long long int node)
Definition: NBPTLine.cpp:112
std::string myType
Definition: NBPTLine.h:118
std::string myNightService
Definition: NBPTLine.h:131
NBEdge * getRouteStart(const NBEdgeCont &ec) const
return first valid edge of myRoute (if it doest not lie after the first stop)
Definition: NBPTLine.cpp:182
const std::vector< std::string > & getWays() const
Definition: NBPTLine.h:110
const std::vector< std::shared_ptr< NBPTStop > > & getStops()
Definition: NBPTLine.cpp:65
void setMyNumOfStops(int numStops)
Definition: NBPTLine.cpp:157
void addPTStop(std::shared_ptr< NBPTStop > pStop)
Definition: NBPTLine.cpp:51
void setEdges(const std::vector< NBEdge * > &edges)
Definition: NBPTLine.cpp:132
Container for public transport stops during the net building process.
Definition: NBPTStopCont.h:44
The representation of a single pt stop.
Definition: NBPTStop.h:45
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:61