Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
MSRouteHandler.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>
31#include "MSVehicle.h"
32
33
34// ===========================================================================
35// class declarations
36// ===========================================================================
37class MSEdge;
38class MSVehicleType;
39
40
41// ===========================================================================
42// class definitions
43// ===========================================================================
52class MSRouteHandler : public SUMORouteHandler, public MapMatcher<MSEdge, MSLane, MSJunction> {
53public:
54
56 enum class ObjectTypeEnum {
57 PERSON,
60 };
61
63 MSRouteHandler(const std::string& file, bool addVehiclesDirectly);
64
66 virtual ~MSRouteHandler();
67
70 return &myParsingRNG;
71 }
72
73
74protected:
76
77
85 virtual void myStartElement(int element,
86 const SUMOSAXAttributes& attrs) override;
88
95 void parseFromViaTo(SumoXMLTag tag, const SUMOSAXAttributes& attrs);
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 virtual 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 MSStoppingPlace* retrieveStoppingPlace(const SUMOSAXAttributes& attrs, const std::string& errorSuffix, SUMOVehicleParameter::Stop* stopParam = nullptr);
155
157 Parameterised* addStop(const SUMOSAXAttributes& attrs) override;
158
160 void addPersonTrip(const SUMOSAXAttributes& attrs) override;
161
163 void addWalk(const SUMOSAXAttributes& attrs) override;
164
166 void addTransportable(const SUMOSAXAttributes& attrs, const bool isPerson) override;
167
169 void addRide(const SUMOSAXAttributes& attrs) override;
170
172 void addTranship(const SUMOSAXAttributes& attrs) override;
173
175 void addTransport(const SUMOSAXAttributes& attrs) override;
176
178 void parseWalkPositions(const SUMOSAXAttributes& attrs, const std::string& personID,
179 const MSEdge* fromEdge, const MSEdge*& toEdge,
180 double& departPos, double& arrivalPos, MSStoppingPlace*& bs,
181 const MSStage* const lastStage, bool& ok);
182
183 void initLaneTree(NamedRTree* tree) override;
184
185 MSEdge* retrieveEdge(const std::string& id) override;
186
187protected:
190
194
197
200
203
206
208 std::string myActiveTypeName;
209
212
215
218
221
224
227
230
233
235 std::string myScaleSuffix;
236
239
242
245
246private:
249
252
255
257 void closeTransportable();
258
260 int addFlowTransportable(SUMOTime depart, MSVehicleType* type, const std::string& baseID, int i);
261
262 double interpretDepartPosLat(const std::string& value, int departLane, const std::string& element);
263
266
268 MSRouteHandler(const MSRouteHandler& s) = delete;
269
272
274 void addRideOrTransport(const SUMOSAXAttributes& attrs, const SumoXMLTag modeTag);
275
276};
long long int SUMOTime
Definition GUI.h:36
std::vector< const MSEdge * > ConstMSEdgeVector
Definition MSEdge.h:74
std::shared_ptr< const MSRoute > ConstMSRoutePtr
Definition Route.h:32
SumoXMLTag
Numbers representing SUMO-XML - element names.
A road/street connecting two junctions.
Definition MSEdge.h:77
Parser and container for routes during their loading.
void closePerson() override
Ends the processing of a person.
RandomDistributor< ConstMSRoutePtr > * myCurrentRouteDistribution
The currently parsed distribution of routes (probability->route)
void addRideOrTransport(const SUMOSAXAttributes &attrs, const SumoXMLTag modeTag)
Processing of a transport.
void closeContainerFlow() override
Ends the processing of a containerFlow.
void openFlow(const SUMOSAXAttributes &attrs) override
opens a flow for reading
ConstMSRoutePtr addVehicleStopsToImplicitRoute(ConstMSRoutePtr route, bool isPermanent)
adapt implicit route (edges derived from stops) to additional vehicle-stops
void addWalk(const SUMOSAXAttributes &attrs) override
add a fully specified walk
void addTransport(const SUMOSAXAttributes &attrs) override
Processing of a transport.
void deleteActivePlanAndVehicleParameter()
delete already created MSTransportablePlans if error occurs before handing over responsibility to a M...
void initLaneTree(NamedRTree *tree) override
bool myAmLoadingState
whether a state file is being loaded
bool myStartTriggeredInFlow
whether we are loading a personFlow that is starting triggered in a vehicle flow
MSRouteHandler(const MSRouteHandler &s)=delete
Invalidated copy constructor.
void resetActivePlanAndVehicleParameter()
reset MSTransportablePlans after transportable tag closes
SUMOTime myActiveRoutePeriod
bool myHaveVia
Wether an object with 'via'-attribute is being parsed.
int addFlowTransportable(SUMOTime depart, MSVehicleType *type, const std::string &baseID, int i)
delete already created MSTransportablePlans if error occurs before handing over responsibility to a M...
void closeTransportable()
ends the processing of a transportable (as person or container)
MSEdge * retrieveEdge(const std::string &id) override
MSStoppingPlace * retrieveStoppingPlace(const SUMOSAXAttributes &attrs, const std::string &errorSuffix, SUMOVehicleParameter::Stop *stopParam=nullptr)
Parse destination stop.
std::string myCurrentVTypeDistributionID
The id of the currently parsed vehicle type distribution.
void openRoute(const SUMOSAXAttributes &attrs) override
opens a route for reading
MSRouteHandler & operator=(const MSRouteHandler &s)=delete
Invalidated assignment operator.
void closeVehicleTypeDistribution() override
closes (ends) the building of a distribution
void addTranship(const SUMOSAXAttributes &attrs) override
Processing of a tranship.
void closeRoute(const bool mayBeDisconnected=false) override
closes (ends) the building of a route.
static SumoRNG myParsingRNG
A random number generator used to choose from vtype/route distributions and computing the speed facto...
void parseFromViaTo(SumoXMLTag tag, const SUMOSAXAttributes &attrs)
Called for parsing from and to and the corresponding taz attributes.
void closeFlow() override
Ends the processing of a flow.
MSTransportable::MSTransportablePlan * myActiveTransportablePlan
The plan of the current transportable (person or container)
virtual void myStartElement(int element, const SUMOSAXAttributes &attrs) override
Called on the opening of a tag;.
std::string myCurrentRouteDistributionID
The id of the currently parsed route distribution.
RandomDistributor< MSVehicleType * > * myCurrentVTypeDistribution
The currently parsed distribution of vehicle types (probability->vehicle type)
void closeContainer() override
Ends the processing of a container.
SUMOTime myActiveRouteReplacedAtTime
The time at which this route was replaced (from vehroute-output)
void closeTrip() override
Ends the processing of a trip.
void openTrip(const SUMOSAXAttributes &attrs) override
opens a trip for reading
void addPersonTrip(const SUMOSAXAttributes &attrs) override
add a routing request for a walking or intermodal person
ConstMSEdgeVector myActiveRoute
The current route.
int myActiveRouteRepeat
number of repetitions of the active route
ObjectTypeEnum myActiveType
The type of the current object.
void closePersonFlow() override
Ends the processing of a personFlow.
int myActiveRouteReplacedIndex
The index at which this route was replaced (from vehroute-output)
void closeRouteDistribution() override
closes (ends) the building of a distribution
std::string myScaleSuffix
prefix when copying vehicles with –scale
ObjectTypeEnum
enum for object type
double interpretDepartPosLat(const std::string &value, int departLane, const std::string &element)
virtual ~MSRouteHandler()
standard destructor
bool myAddVehiclesDirectly
Information whether vehicles shall be directly added to the network or kept within the buffer.
bool myReplayRerouting
whether loaded rerouting events shall be replayed
static SumoRNG * getParsingRNG()
get parsing RNG
void openVehicleTypeDistribution(const SUMOSAXAttributes &attrs) override
opens a type distribution for reading
Parameterised * addStop(const SUMOSAXAttributes &attrs) override
Processing of a stop.
virtual void closeVehicle() override
Ends the processing of a vehicle (note: is virtual because is reimplemented in MSStateHandler)
void openRouteFlow(const SUMOSAXAttributes &attrs) override
opens a route flow for reading
void openRouteDistribution(const SUMOSAXAttributes &attrs) override
opens a route distribution for reading
void addRide(const SUMOSAXAttributes &attrs) override
Processing of a ride.
void parseWalkPositions(const SUMOSAXAttributes &attrs, const std::string &personID, const MSEdge *fromEdge, const MSEdge *&toEdge, double &departPos, double &arrivalPos, MSStoppingPlace *&bs, const MSStage *const lastStage, bool &ok)
@ brief parse depart- and arrival positions of a walk
bool myActiveRoutePermanent
whether the active route is stored indefinitely (used by state loader)
std::string myActiveTypeName
The name of the current object type.
void closeVType() override
Ends the processing of a vehicle type.
void addTransportable(const SUMOSAXAttributes &attrs, const bool isPerson) override
Processing of a person.
void closeTransportableFlow()
ends the flow of a transportable
A lane area vehicles can halt at.
std::vector< MSStage * > MSTransportablePlan
the structure holding the plan of a transportable
The car-following model and parameter.
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 upper class for objects with additional parameters.
Represents a generic random distribution.
Parser for routes during their loading.
Encapsulated SAX-Attributes.
Definition of vehicle stop (position and duration)