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;
83
90 void parseFromViaTo(SumoXMLTag tag, const SUMOSAXAttributes& attrs);
91
93 void openVehicleTypeDistribution(const SUMOSAXAttributes& attrs) override;
94
96 void closeVehicleTypeDistribution() override;
97
99 void openRoute(const SUMOSAXAttributes& attrs) override;
100
102 void openFlow(const SUMOSAXAttributes& attrs) override;
103
105 void openRouteFlow(const SUMOSAXAttributes& attrs) override;
106
108 void openTrip(const SUMOSAXAttributes& attrs) override;
109
116 void closeRoute(const bool mayBeDisconnected = false) override;
117
119 void openRouteDistribution(const SUMOSAXAttributes& attrs) override;
120
122 void closeRouteDistribution() override;
123
125 virtual void closeVehicle() override;
126
128 void closeVType() override;
129
131 void closePerson() override;
132
134 void closePersonFlow() override;
135
137 void closeContainer() override;
138
140 void closeContainerFlow() override;
141
143 void closeFlow() override;
144
146 void closeTrip() override;
147
149 MSStoppingPlace* retrieveStoppingPlace(const SUMOSAXAttributes& attrs, const std::string& errorSuffix, SUMOVehicleParameter::Stop* stopParam = nullptr);
150
152 Parameterised* addStop(const SUMOSAXAttributes& attrs) override;
153
155 void addPersonTrip(const SUMOSAXAttributes& attrs) override;
156
158 void addWalk(const SUMOSAXAttributes& attrs) override;
159
161 void addTransportable(const SUMOSAXAttributes& attrs, const bool isPerson) override;
162
164 void addRide(const SUMOSAXAttributes& attrs) override;
165
167 void addTranship(const SUMOSAXAttributes& attrs) override;
168
170 void addTransport(const SUMOSAXAttributes& attrs) override;
171
173 void parseWalkPositions(const SUMOSAXAttributes& attrs, const std::string& personID,
174 const MSEdge* fromEdge, const MSEdge*& toEdge,
175 double& departPos, double& arrivalPos, MSStoppingPlace*& bs,
176 const MSStage* const lastStage, bool& ok);
177
178 void initLaneTree(NamedRTree* tree) override;
179
180 MSEdge* retrieveEdge(const std::string& id) override;
181
182 SumoRNG* getRNG() override;
183
184 const SUMOVTypeParameter* getVTypeParameter(const std::string& refid) override;
185
186protected:
189
193
196
199
202
205
207 std::string myActiveTypeName;
208
211
214
217
220
223
226
229
232
234 std::string myScaleSuffix;
235
238
241
242private:
245
248
251
253 void closeTransportable();
254
256 int addFlowTransportable(SUMOTime depart, MSVehicleType* type, const std::string& baseID, int i);
257
258 double interpretDepartPosLat(const std::string& value, int departLane, const std::string& element);
259
262
264 MSRouteHandler(const MSRouteHandler& s) = delete;
265
268
270 void addRideOrTransport(const SUMOSAXAttributes& attrs, const SumoXMLTag modeTag);
271
272};
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
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
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)