Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
eclipse
GitHub Repository: eclipse/sumo
Path: blob/main/src/router/RORouteHandler.h
169666 views
1
/****************************************************************************/
2
// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3
// Copyright (C) 2001-2025 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
/****************************************************************************/
14
/// @file RORouteHandler.h
15
/// @author Daniel Krajzewicz
16
/// @author Jakob Erdmann
17
/// @author Michael Behrisch
18
/// @date Mon, 9 Jul 2001
19
///
20
// Parser and container for routes during their loading
21
/****************************************************************************/
22
#pragma once
23
#include <config.h>
24
25
#include <string>
26
#include <vector>
27
#include <utils/distribution/RandomDistributor.h>
28
#include <utils/common/SUMOTime.h>
29
#include <utils/common/MapMatcher.h>
30
#include <utils/router/PedestrianRouter.h>
31
#include <utils/vehicle/SUMORouteHandler.h>
32
#include "ROPerson.h"
33
34
35
// ===========================================================================
36
// class declarations
37
// ===========================================================================
38
class OutputDevice_String;
39
class ROEdge;
40
class ROLane;
41
class RONet;
42
class RORoute;
43
class RORouteDef;
44
45
46
// ===========================================================================
47
// class definitions
48
// ===========================================================================
49
/**
50
* @class RORouteHandler
51
* @brief Parser and container for routes during their loading
52
*
53
* RORouteHandler is the container for routes while they are build until
54
* their transfering to the MSNet::RouteDict
55
* The result of the operations are single MSNet::Route-instances
56
*/
57
class RORouteHandler : public SUMORouteHandler, public MapMatcher<ROEdge, ROLane, RONode> {
58
public:
59
/// @brief standard constructor
60
RORouteHandler(RONet& net, const std::string& file,
61
const bool tryRepair,
62
const bool emptyDestinationsAllowed,
63
const bool ignoreErrors,
64
const bool checkSchema);
65
66
/// @brief standard destructor
67
~RORouteHandler() override;
68
69
/// @brief Checks whether the route file is sorted by departure time if needed
70
bool checkLastDepart() override;
71
72
protected:
73
void deleteActivePlanAndVehicleParameter();
74
75
/// @name inherited from GenericSAXHandler
76
//@{
77
78
/** @brief Called on the opening of a tag;
79
*
80
* @param[in] element ID of the currently opened element
81
* @param[in] attrs Attributes within the currently opened element
82
* @exception ProcessError If something fails
83
* @see GenericSAXHandler::myStartElement
84
*/
85
void myStartElement(int element,
86
const SUMOSAXAttributes& attrs) override;
87
//@}
88
89
/** @brief Called for parsing from and to and the corresponding taz attributes
90
*
91
* @param[in] element description of the currently opened element
92
* @param[in] attrs Attributes within the currently opened element
93
* @exception ProcessError If something fails
94
*/
95
void parseFromViaTo(SumoXMLTag tag, const SUMOSAXAttributes& attrs, bool& ok);
96
97
/// @brief opens a type distribution for reading
98
void openVehicleTypeDistribution(const SUMOSAXAttributes& attrs) override;
99
100
/// @brief closes (ends) the building of a distribution
101
void closeVehicleTypeDistribution() override;
102
103
/// @brief opens a route for reading
104
void openRoute(const SUMOSAXAttributes& attrs) override;
105
106
/// @brief opens a flow for reading
107
void openFlow(const SUMOSAXAttributes& attrs) override;
108
109
/// @brief opens a route flow for reading
110
void openRouteFlow(const SUMOSAXAttributes& attrs) override;
111
112
/// @brief opens a trip for reading
113
void openTrip(const SUMOSAXAttributes& attrs) override;
114
115
/**@brief closes (ends) the building of a route.
116
* @note Afterwards no edges may be added to it;
117
* this method may throw exceptions when
118
* a) the route is empty or
119
* b) another route with the same id already exists
120
*/
121
void closeRoute(const bool mayBeDisconnected = false) override;
122
123
/// @brief opens a route distribution for reading
124
void openRouteDistribution(const SUMOSAXAttributes& attrs) override;
125
126
/// @brief closes (ends) the building of a distribution
127
void closeRouteDistribution() override;
128
129
/// @brief Ends the processing of a vehicle
130
void closeVehicle() override;
131
132
/// @brief Ends the processing of a vehicle type
133
void closeVType() override;
134
135
/// @brief Ends the processing of a person
136
void closePerson() override;
137
138
/// @brief Ends the processing of a personFlow
139
void closePersonFlow() override;
140
141
/// @brief Ends the processing of a container
142
void closeContainer() override;
143
144
/// @brief Ends the processing of a containerFlow
145
void closeContainerFlow() override;
146
147
/// @brief Ends the processing of a flow
148
void closeFlow() override;
149
150
/// @brief Ends the processing of a trip
151
void closeTrip() override;
152
153
/// @brief retrieve stopping place element
154
const SUMOVehicleParameter::Stop* retrieveStoppingPlace(const SUMOSAXAttributes& attrs, const std::string& errorSuffix, std::string& id, const SUMOVehicleParameter::Stop* stopParam = nullptr);
155
156
/// @brief Processing of a stop
157
Parameterised* addStop(const SUMOSAXAttributes& attrs) override;
158
159
/// @brief Processing of a person from a personFlow
160
void addFlowPerson(const std::string& typeID, SUMOTime depart, const std::string& baseID, int i);
161
162
/// @brief Processing of a ride
163
void addRide(const SUMOSAXAttributes& attrs) override;
164
165
/// @brief Processing of a transport
166
void addTransport(const SUMOSAXAttributes& attrs) override;
167
168
/// @brief Processing of a tranship
169
void addTranship(const SUMOSAXAttributes& attrs) override;
170
171
/// @brief Parse edges from strings
172
void parseEdges(const std::string& desc, ConstROEdgeVector& into,
173
const std::string& rid, bool& ok);
174
175
/// @brief add a routing request for a walking or intermodal person
176
void addPersonTrip(const SUMOSAXAttributes& attrs) override;
177
178
/// @brief add a fully specified walk
179
void addWalk(const SUMOSAXAttributes& attrs) override;
180
181
///@ brief parse depart- and arrival positions of a walk
182
void parseWalkPositions(const SUMOSAXAttributes& attrs, const std::string& personID,
183
const ROEdge* fromEdge, const ROEdge*& toEdge,
184
double& departPos, double& arrivalPos, std::string& busStopID,
185
const ROPerson::PlanItem* const lastStage, bool& ok);
186
187
void initLaneTree(NamedRTree* tree) override;
188
189
ROEdge* retrieveEdge(const std::string& id) override;
190
191
protected:
192
/// @brief The current route
193
RONet& myNet;
194
195
/// @brief The current route
196
ConstROEdgeVector myActiveRoute;
197
198
/// @brief number of repetitions of the active route
199
int myActiveRouteRepeat;
200
SUMOTime myActiveRoutePeriod;
201
202
/// @brief The plan of the current person
203
std::vector<ROPerson::PlanItem*>* myActivePlan;
204
205
/// @brief The plan of the current container
206
OutputDevice_String* myActiveContainerPlan;
207
208
/// @brief The number of stages in myActiveContainerPlan
209
int myActiveContainerPlanSize;
210
211
/// @brief Information whether routes shall be repaired
212
const bool myTryRepair;
213
214
/// @brief Information whether the "to" attribute is mandatory
215
const bool myEmptyDestinationsAllowed;
216
217
/// @brief Depending on the "ignore-errors" option different outputs are used
218
MsgHandler* const myErrorOutput;
219
220
/// @brief The begin time
221
const SUMOTime myBegin;
222
223
/// @brief whether to keep the vtype distribution in output
224
const bool myKeepVTypeDist;
225
226
/// @brief whether input is read all at once (no sorting check is necessary)
227
const bool myUnsortedInput;
228
229
/// @brief The currently parsed distribution of vehicle types (probability->vehicle type)
230
RandomDistributor<SUMOVTypeParameter*>* myCurrentVTypeDistribution;
231
232
/// @brief The id of the currently parsed vehicle type distribution
233
std::string myCurrentVTypeDistributionID;
234
235
/// @brief The currently parsed route alternatives
236
RORouteDef* myCurrentAlternatives;
237
238
/// @brief cached options
239
bool myUseTaz;
240
bool myWriteJunctions;
241
242
private:
243
/// @brief Invalidated copy constructor
244
RORouteHandler(const RORouteHandler& s) = delete;
245
246
/// @brief Invalidated assignment operator
247
RORouteHandler& operator=(const RORouteHandler& s) = delete;
248
};
249
250