Eclipse SUMO - Simulation of Urban MObility
RORouteHandler.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 /****************************************************************************/
20 // Parser and container for routes during their loading
21 /****************************************************************************/
22 #pragma once
23 #include <config.h>
24 
25 #include <string>
26 #include <vector>
28 #include <utils/common/SUMOTime.h>
32 #include "ROPerson.h"
33 
34 
35 // ===========================================================================
36 // class declarations
37 // ===========================================================================
39 class ROEdge;
40 class ROLane;
41 class RONet;
42 class RORoute;
43 class RORouteDef;
44 
45 
46 // ===========================================================================
47 // class definitions
48 // ===========================================================================
57 class RORouteHandler : public SUMORouteHandler, public MapMatcher<ROEdge, ROLane, RONode> {
58 public:
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 
67  ~RORouteHandler() override;
68 
70  bool checkLastDepart() override;
71 
72 protected:
74 
76 
77 
85  void myStartElement(int element,
86  const SUMOSAXAttributes& attrs) override;
88 
95  void parseFromViaTo(SumoXMLTag tag, const SUMOSAXAttributes& attrs, bool& ok);
96 
98  void openVehicleTypeDistribution(const SUMOSAXAttributes& attrs) override;
99 
101  void closeVehicleTypeDistribution() override;
102 
104  void openRoute(const SUMOSAXAttributes& attrs) override;
105 
107  void openFlow(const SUMOSAXAttributes& attrs) override;
108 
110  void openRouteFlow(const SUMOSAXAttributes& attrs) override;
111 
113  void openTrip(const SUMOSAXAttributes& attrs) override;
114 
121  void closeRoute(const bool mayBeDisconnected = false) override;
122 
124  void openRouteDistribution(const SUMOSAXAttributes& attrs) override;
125 
127  void closeRouteDistribution() override;
128 
130  void closeVehicle() override;
131 
133  void closeVType() override;
134 
136  void closePerson() override;
137 
139  void closePersonFlow() override;
140 
142  void closeContainer() override;
143 
145  void closeContainerFlow() override;
146 
148  void closeFlow() override;
149 
151  void closeTrip() override;
152 
154  const SUMOVehicleParameter::Stop* retrieveStoppingPlace(const SUMOSAXAttributes& attrs, const std::string& errorSuffix, std::string& id, const SUMOVehicleParameter::Stop* stopParam = nullptr);
155 
157  Parameterised* addStop(const SUMOSAXAttributes& attrs) override;
158 
160  void addFlowPerson(const std::string& typeID, SUMOTime depart, const std::string& baseID, int i);
161 
163  void addRide(const SUMOSAXAttributes& attrs) override;
164 
166  void addTransport(const SUMOSAXAttributes& attrs) override;
167 
169  void addTranship(const SUMOSAXAttributes& attrs) override;
170 
172  void parseEdges(const std::string& desc, ConstROEdgeVector& into,
173  const std::string& rid, bool& ok);
174 
176  void addPersonTrip(const SUMOSAXAttributes& attrs) override;
177 
179  void addWalk(const SUMOSAXAttributes& attrs) override;
180 
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:
194 
197 
201 
203  std::vector<ROPerson::PlanItem*>* myActivePlan;
204 
207 
210 
212  const bool myTryRepair;
213 
216 
219 
222 
224  const bool myKeepVTypeDist;
225 
227  const bool myUnsortedInput;
228 
231 
234 
237 
238 private:
240  RORouteHandler(const RORouteHandler& s) = delete;
241 
244 };
long long int SUMOTime
Definition: GUI.h:35
std::vector< const ROEdge * > ConstROEdgeVector
Definition: ROEdge.h:54
SumoXMLTag
Numbers representing SUMO-XML - element names.
Provides utility functions for matching locations to edges (during route parsing)
Definition: MapMatcher.h:44
A RT-tree for efficient storing of SUMO's Named objects.
Definition: NamedRTree.h:61
An output device that encapsulates an ofstream.
An upper class for objects with additional parameters.
Definition: Parameterised.h:41
A basic edge for routing applications.
Definition: ROEdge.h:70
A single lane the router may use.
Definition: ROLane.h:48
The router's network representation.
Definition: RONet.h:62
Every person has a plan comprising of multiple planItems.
Definition: ROPerson.h:83
Base class for a vehicle's route definition.
Definition: RORouteDef.h:53
Parser and container for routes during their loading.
void openVehicleTypeDistribution(const SUMOSAXAttributes &attrs) override
opens a type distribution for reading
const SUMOVehicleParameter::Stop * retrieveStoppingPlace(const SUMOSAXAttributes &attrs, const std::string &errorSuffix, std::string &id, const SUMOVehicleParameter::Stop *stopParam=nullptr)
retrieve stopping place element
void addTransport(const SUMOSAXAttributes &attrs) override
Processing of a transport.
void deleteActivePlanAndVehicleParameter()
void openRoute(const SUMOSAXAttributes &attrs) override
opens a route for reading
std::string myCurrentVTypeDistributionID
The id of the currently parsed vehicle type distribution.
void addFlowPerson(const std::string &typeID, SUMOTime depart, const std::string &baseID, int i)
Processing of a person from a personFlow.
void closeContainerFlow() override
Ends the processing of a containerFlow.
RORouteHandler(const RORouteHandler &s)=delete
Invalidated copy constructor.
RORouteHandler(RONet &net, const std::string &file, const bool tryRepair, const bool emptyDestinationsAllowed, const bool ignoreErrors, const bool checkSchema)
standard constructor
void parseEdges(const std::string &desc, ConstROEdgeVector &into, const std::string &rid, bool &ok)
Parse edges from strings.
RONet & myNet
The current route.
void addRide(const SUMOSAXAttributes &attrs) override
Processing of a ride.
ConstROEdgeVector myActiveRoute
The current route.
void closeRouteDistribution() override
closes (ends) the building of a distribution
void addTranship(const SUMOSAXAttributes &attrs) override
Processing of a tranship.
void closeContainer() override
Ends the processing of a container.
std::vector< ROPerson::PlanItem * > * myActivePlan
The plan of the current person.
const bool myTryRepair
Information whether routes shall be repaired.
bool checkLastDepart() override
Checks whether the route file is sorted by departure time if needed.
OutputDevice_String * myActiveContainerPlan
The plan of the current container.
void closeVehicle() override
Ends the processing of a vehicle.
SUMOTime myActiveRoutePeriod
const SUMOTime myBegin
The begin time.
void closeRoute(const bool mayBeDisconnected=false) override
closes (ends) the building of a route.
Parameterised * addStop(const SUMOSAXAttributes &attrs) override
Processing of a stop.
RandomDistributor< SUMOVTypeParameter * > * myCurrentVTypeDistribution
The currently parsed distribution of vehicle types (probability->vehicle type)
void closePersonFlow() override
Ends the processing of a personFlow.
void openRouteDistribution(const SUMOSAXAttributes &attrs) override
opens a route distribution for reading
int myActiveContainerPlanSize
The number of stages in myActiveContainerPlan.
const bool myKeepVTypeDist
whether to keep the the vtype distribution in output
void openTrip(const SUMOSAXAttributes &attrs) override
opens a trip for reading
const bool myUnsortedInput
whether input is read all at once (no sorting check is necessary)
const bool myEmptyDestinationsAllowed
Information whether the "to" attribute is mandatory.
void parseWalkPositions(const SUMOSAXAttributes &attrs, const std::string &personID, const ROEdge *fromEdge, const ROEdge *&toEdge, double &departPos, double &arrivalPos, std::string &busStopID, const ROPerson::PlanItem *const lastStage, bool &ok)
@ brief parse depart- and arrival positions of a walk
MsgHandler *const myErrorOutput
Depending on the "ignore-errors" option different outputs are used.
int myActiveRouteRepeat
number of repetitions of the active route
void closeFlow() override
Ends the processing of a flow.
ROEdge * retrieveEdge(const std::string &id) override
void addPersonTrip(const SUMOSAXAttributes &attrs) override
add a routing request for a walking or intermodal person
void closePerson() override
Ends the processing of a person.
~RORouteHandler() override
standard destructor
RORouteDef * myCurrentAlternatives
The currently parsed route alternatives.
void myStartElement(int element, const SUMOSAXAttributes &attrs) override
Called on the opening of a tag;.
void addWalk(const SUMOSAXAttributes &attrs) override
add a fully specified walk
void initLaneTree(NamedRTree *tree) override
RORouteHandler & operator=(const RORouteHandler &s)=delete
Invalidated assignment operator.
void openRouteFlow(const SUMOSAXAttributes &attrs) override
opens a route flow for reading
void closeTrip() override
Ends the processing of a trip.
void openFlow(const SUMOSAXAttributes &attrs) override
opens a flow for reading
void closeVType() override
Ends the processing of a vehicle type.
void closeVehicleTypeDistribution() override
closes (ends) the building of a distribution
void parseFromViaTo(SumoXMLTag tag, const SUMOSAXAttributes &attrs, bool &ok)
Called for parsing from and to and the corresponding taz attributes.
A complete router's route.
Definition: RORoute.h:52
Parser for routes during their loading.
Encapsulated SAX-Attributes.
Definition of vehicle stop (position and duration)