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-2026 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
68
69protected:
71
72
80 virtual void myStartElement(int element,
81 const SUMOSAXAttributes& attrs) override;
82
83 void myEndElement(int element) override;
85
92 void parseFromViaTo(SumoXMLTag tag, const SUMOSAXAttributes& attrs);
93
95 void openVehicleTypeDistribution(const SUMOSAXAttributes& attrs) override;
96
98 void closeVehicleTypeDistribution() override;
99
101 void openRoute(const SUMOSAXAttributes& attrs) override;
102
104 void openFlow(const SUMOSAXAttributes& attrs) override;
105
107 void openRouteFlow(const SUMOSAXAttributes& attrs) override;
108
110 void openTrip(const SUMOSAXAttributes& attrs) override;
111
118 void closeRoute(const bool mayBeDisconnected = false) override;
119
121 void openRouteDistribution(const SUMOSAXAttributes& attrs) override;
122
124 void closeRouteDistribution() override;
125
127 virtual void closeVehicle() override;
128
130 void closeVType() override;
131
133 void closePerson() override;
134
136 void closePersonFlow() override;
137
139 void closeContainer() override;
140
142 void closeContainerFlow() override;
143
145 void closeFlow() override;
146
148 void closeTrip() override;
149
151 MSStoppingPlace* retrieveStoppingPlace(const SUMOSAXAttributes& attrs, const std::string& errorSuffix, SUMOVehicleParameter::Stop* stopParam = nullptr);
152
154 Parameterised* addStop(const SUMOSAXAttributes& attrs) override;
155
157 void addPersonTrip(const SUMOSAXAttributes& attrs) override;
158
160 void addWalk(const SUMOSAXAttributes& attrs) override;
161
163 void addTransportable(const SUMOSAXAttributes& attrs, const bool isPerson) override;
164
166 void addRide(const SUMOSAXAttributes& attrs) override;
167
169 void addTranship(const SUMOSAXAttributes& attrs) override;
170
172 void addTransport(const SUMOSAXAttributes& attrs) override;
173
175 void parseWalkPositions(const SUMOSAXAttributes& attrs, const std::string& personID,
176 const MSEdge* fromEdge, const MSEdge*& toEdge,
177 double& departPos, double& arrivalPos, MSStoppingPlace*& bs,
178 const MSStage* const lastStage, bool& ok);
179
180 void initLaneTree(NamedRTree* tree) override;
181
182 MSEdge* retrieveEdge(const std::string& id) override;
183
184 SumoRNG* getRNG() override;
185
186 const SUMOVTypeParameter* getVTypeParameter(const std::string& refid) override;
187
188protected:
191
195
198
201
204
207
209 std::string myActiveTypeName;
210
213
216
219
222
225
228
231
234
236 std::string myScaleSuffix;
237
240
243
244private:
247
250
253
256
258 void closeTransportable();
259
261 int addFlowTransportable(SUMOTime depart, MSVehicleType* type, const std::string& baseID, int i);
262
263 double interpretDepartPosLat(const std::string& value, int departLane, const std::string& element);
264
267
269 MSRouteHandler(const MSRouteHandler& s) = delete;
270
273
275 void addRideOrTransport(const SUMOSAXAttributes& attrs, const SumoXMLTag modeTag);
276
277};
long long int SUMOTime
Definition GUI.h:36
std::vector< const MSEdge * > ConstMSEdgeVector
Definition MSEdge.h:75
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:78
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 myEndElement(int element) override
Called when a closing tag occurs.
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
Whether 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
std::size_t myDiscardedTransportableDepth
Stack depth of a discarded transportable, or zero during normal parsing.
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.
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.
SumoRNG * getRNG() override
const SUMOVTypeParameter * getVTypeParameter(const std::string &refid) override
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
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:45
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.
Structure representing possible vehicle parameter.
Definition of vehicle stop (position and duration)