Eclipse SUMO - Simulation of Urban MObility
GNERouteHandler.h
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2001-2020 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 /****************************************************************************/
18 // Builds demand objects for netedit
19 /****************************************************************************/
20 #pragma once
21 #include <config.h>
22 
30 
31 
32 // ===========================================================================
33 // class declarations
34 // ===========================================================================
35 
36 class GNEViewNet;
37 class GNEEdge;
38 class GNETAZ;
39 class GNEDemandElement;
40 class GNEVehicle;
41 class GNEPerson;
42 class GNEUndoList;
43 
44 // ===========================================================================
45 // class definitions
46 // ===========================================================================
47 
51 public:
53  struct RouteParameter {
54 
57 
59  RouteParameter(GNEDemandElement* originalDemandElement);
60 
62  void setEdges(GNENet* net, const std::string& edgeIDs);
63 
65  void setEdges(GNENet* net, const std::string& vehicleID, const std::string& fromID, const std::string& toID, const std::string& viaIDs);
66 
68  void clearEdges();
69 
71  std::string routeID;
72 
74  bool loadedID;
75 
77  std::vector<GNEEdge*> edges;
78 
81 
84 
87  };
88 
90  GNERouteHandler(const std::string& file, GNENet* net, bool undoDemandElements = true);
91 
94 
96  static bool isVehicleIdDuplicated(GNENet* net, const std::string& id);
97 
99  static bool isPersonIdDuplicated(GNENet* net, const std::string& id);
100 
103 
105  static void buildRoute(GNENet* net, bool undoDemandElements, const RouteParameter& routeParameters, const std::vector<SUMOVehicleParameter::Stop>& activeStops);
106 
108 
111 
113  static void buildVehicleOverRoute(GNENet* net, bool undoDemandElements, const SUMOVehicleParameter& vehicleParameters);
114 
116  static void buildFlowOverRoute(GNENet* net, bool undoDemandElements, const SUMOVehicleParameter& vehicleParameters);
117 
119  static void buildVehicleEmbeddedRoute(GNENet* net, bool undoDemandElements, SUMOVehicleParameter vehicleParameters, const std::vector<GNEEdge*>& edges);
120 
122  static void buildFlowEmbeddedRoute(GNENet* net, bool undoDemandElements, SUMOVehicleParameter vehicleParameters, const std::vector<GNEEdge*>& edges);
123 
125  static void buildTrip(GNENet* net, bool undoDemandElements, const SUMOVehicleParameter& vehicleParameters, GNEEdge* fromEdge, GNEEdge* toEdge, const std::vector<GNEEdge*>& via);
126 
128  static void buildFlow(GNENet* net, bool undoDemandElements, const SUMOVehicleParameter& vehicleParameters, GNEEdge* fromEdge, GNEEdge* toEdge, const std::vector<GNEEdge*>& via);
129 
131  static void buildStop(GNENet* net, bool undoDemandElements, const SUMOVehicleParameter::Stop& stopParameters, GNEDemandElement* stopParent);
133 
137  static void buildPerson(GNENet* net, bool undoDemandElements, const SUMOVehicleParameter& personParameters);
138 
140  static void buildPersonFlow(GNENet* net, bool undoDemandElements, const SUMOVehicleParameter& personFlowParameters);
142 
146  static bool buildPersonPlan(SumoXMLTag tag, GNEDemandElement* personParent, GNEFrameAttributesModuls::AttributesCreator* personPlanAttributes, GNEFrameModuls::PathCreator* pathCreator);
147 
149  static void buildPersonTrip(GNENet* net, bool undoDemandElements, GNEDemandElement* personParent, GNEEdge* fromEdge, GNEEdge* toEdge,
150  GNEAdditional* busStopFrom, GNEAdditional* busStopTo, double arrivalPos, const std::vector<std::string>& types, const std::vector<std::string>& modes);
151 
153  static void buildWalk(GNENet* net, bool undoDemandElements, GNEDemandElement* personParent, GNEEdge* fromEdge, GNEEdge* toEdge,
154  GNEAdditional* busStopFrom, GNEAdditional* busStopTo, const std::vector<GNEEdge*>& edges, GNEDemandElement* route, double arrivalPos);
155 
157  static void buildRide(GNENet* net, bool undoDemandElements, GNEDemandElement* personParent, GNEEdge* fromEdge, GNEEdge* toEdge,
158  GNEAdditional* busStopFrom, GNEAdditional* busStopTo, double arrivalPos, const std::vector<std::string>& lines);
159 
161  static void buildPersonStop(GNENet* net, bool undoDemandElements, GNEDemandElement* personParent, GNEEdge* edge, GNEAdditional* busStop, const SUMOVehicleParameter::Stop& stopParameters);
162 
164 
167 
169  static void transformToVehicle(GNEVehicle* originalVehicle, bool createEmbeddedRoute);
170 
172  static void transformToRouteFlow(GNEVehicle* originalVehicle, bool createEmbeddedRoute);
173 
175  static void transformToTrip(GNEVehicle* originalVehicle);
176 
178  static void transformToFlow(GNEVehicle* originalVehicle);
179 
181 
184 
186  static void transformToPerson(GNEPerson* originalPerson);
187 
189  static void transformToPersonFlow(GNEPerson* originalPerson);
190 
192 
194  static void setFlowParameters(const SumoXMLAttr attribute, int& parameters);
195 
196 protected:
199 
202 
204  void openRoute(const SUMOSAXAttributes& attrs);
205 
207  void openFlow(const SUMOSAXAttributes& attrs);
208 
210  void openRouteFlow(const SUMOSAXAttributes& attrs);
211 
213  void openTrip(const SUMOSAXAttributes& attrs);
214 
221  void closeRoute(const bool mayBeDisconnected = false);
222 
224  void openRouteDistribution(const SUMOSAXAttributes& attrs);
225 
227  void closeRouteDistribution();
228 
230  void closeVehicle();
231 
233  void closeVType();
234 
236  void closePerson();
237 
239  void closePersonFlow();
240 
242  void closeContainer();
243 
245  void closeFlow();
246 
248  void closeTrip();
249 
251  void addStop(const SUMOSAXAttributes& attrs);
252 
254  void addPersonTrip(const SUMOSAXAttributes& attrs);
255 
257  void addWalk(const SUMOSAXAttributes& attrs);
258 
260  void addPerson(const SUMOSAXAttributes& attrs);
261 
263  void addRide(const SUMOSAXAttributes& attrs);
264 
266  void addContainer(const SUMOSAXAttributes& attrs);
267 
269  void addTransport(const SUMOSAXAttributes& attrs);
270 
272  void addTranship(const SUMOSAXAttributes& attrs);
273 
274 private:
279 
281  void updateGNETag();
282 
284  bool checkIntegrity() const;
285 
287  bool isFirstPersonPlan() const;
288 
290  GNEEdge* getLastEdge() const;
291 
294 
297 
300 
302  std::vector<GNEEdge*> edges;
303 
306 
309 
312 
314  std::vector<std::string> vTypes;
315 
317  std::vector<std::string> modes;
318 
320  std::vector<std::string> lines;
321 
323  double arrivalPos;
324 
327 
330 
333 
336 
339 
342 
345 
346  private:
349 
352  };
353 
355  struct PersonValue {
357  bool addPersonValue(GNENet* net, SumoXMLTag tag, const SUMOSAXAttributes& attrs);
358 
360  bool checkPersonPlanValues();
361 
363  std::vector<PersonPlansValues> myPersonPlanValues;
364  };
365 
368 
371 
374 
377 
380 
382  bool myAbort;
383 };
384 
385 
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types.
SumoXMLTag
Numbers representing SUMO-XML - element names.
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
An Element which don't belongs to GNENet but has influency in the simulation.
Definition: GNEAdditional.h:47
An Element which don't belongs to GNENet but has influency in the simulation.
A road/street connecting two junctions (netedit-version)
Definition: GNEEdge.h:49
This lane is powered by an underlying GNEEdge and basically knows how to draw itself.
Definition: GNELane.h:45
A NBNetBuilder extended by visualisation and editing capabilities.
Definition: GNENet.h:40
Builds trigger objects for GNENet (busStops, chargingStations, detectors, etc..)
void closePerson()
Ends the processing of a person.
static void buildVehicleOverRoute(GNENet *net, bool undoDemandElements, const SUMOVehicleParameter &vehicleParameters)
build a vehicle over an existent route
static void buildRide(GNENet *net, bool undoDemandElements, GNEDemandElement *personParent, GNEEdge *fromEdge, GNEEdge *toEdge, GNEAdditional *busStopFrom, GNEAdditional *busStopTo, double arrivalPos, const std::vector< std::string > &lines)
build ride
RouteParameter myRouteParameter
NETEDIT Route Parameters.
void addStop(const SUMOSAXAttributes &attrs)
Processing of a stop.
void addTranship(const SUMOSAXAttributes &attrs)
Processing of a tranship.
bool myAbort
flag used for parsing values
static void buildFlowEmbeddedRoute(GNENet *net, bool undoDemandElements, SUMOVehicleParameter vehicleParameters, const std::vector< GNEEdge * > &edges)
build flow with a embedded route
static void buildPersonTrip(GNENet *net, bool undoDemandElements, GNEDemandElement *personParent, GNEEdge *fromEdge, GNEEdge *toEdge, GNEAdditional *busStopFrom, GNEAdditional *busStopTo, double arrivalPos, const std::vector< std::string > &types, const std::vector< std::string > &modes)
build person trip
void closeFlow()
Ends the processing of a routeFlow.
void addTransport(const SUMOSAXAttributes &attrs)
Processing of a transport.
void closeVehicleTypeDistribution()
closes (ends) the building of a distribution
static void buildPerson(GNENet *net, bool undoDemandElements, const SUMOVehicleParameter &personParameters)
void addContainer(const SUMOSAXAttributes &attrs)
Processing of a container.
static void transformToRouteFlow(GNEVehicle *originalVehicle, bool createEmbeddedRoute)
transform routeFlow over an existent route
GNENet * myNet
pointer to GNENet
void openRouteFlow(const SUMOSAXAttributes &attrs)
opens a routeFlow for reading
static bool isPersonIdDuplicated(GNENet *net, const std::string &id)
check if there is already a person (Person or PersonFlow) with the given ID
void closeContainer()
Ends the processing of a container.
static void buildRoute(GNENet *net, bool undoDemandElements, const RouteParameter &routeParameters, const std::vector< SUMOVehicleParameter::Stop > &activeStops)
build route
void closePersonFlow()
Ends the processing of a personFlow.
static void transformToFlow(GNEVehicle *originalVehicle)
transform to flow
void addPersonTrip(const SUMOSAXAttributes &attrs)
add a routing request for a walking or intermodal person
void closeVehicle()
Ends the processing of a vehicle.
void openRouteDistribution(const SUMOSAXAttributes &attrs)
opens a route distribution for reading
static void buildPersonStop(GNENet *net, bool undoDemandElements, GNEDemandElement *personParent, GNEEdge *edge, GNEAdditional *busStop, const SUMOVehicleParameter::Stop &stopParameters)
build stop
static void buildWalk(GNENet *net, bool undoDemandElements, GNEDemandElement *personParent, GNEEdge *fromEdge, GNEEdge *toEdge, GNEAdditional *busStopFrom, GNEAdditional *busStopTo, const std::vector< GNEEdge * > &edges, GNEDemandElement *route, double arrivalPos)
build walk
void addWalk(const SUMOSAXAttributes &attrs)
add a fully specified walk
void closeRoute(const bool mayBeDisconnected=false)
static void buildPersonFlow(GNENet *net, bool undoDemandElements, const SUMOVehicleParameter &personFlowParameters)
build person flow
void addPerson(const SUMOSAXAttributes &attrs)
Processing of a person.
void openRoute(const SUMOSAXAttributes &attrs)
opens a route for reading
static void setFlowParameters(const SumoXMLAttr attribute, int &parameters)
configure flow parameters
static bool isVehicleIdDuplicated(GNENet *net, const std::string &id)
check if there is already a vehicle (Vehicle, Trip, Flow or Flow) with the given ID
GNERouteHandler(const std::string &file, GNENet *net, bool undoDemandElements=true)
Constructor.
void openTrip(const SUMOSAXAttributes &attrs)
opens a trip for reading
PersonValue myPersonValues
NETEDIT person values.
void closeRouteDistribution()
closes (ends) the building of a distribution
static bool buildPersonPlan(SumoXMLTag tag, GNEDemandElement *personParent, GNEFrameAttributesModuls::AttributesCreator *personPlanAttributes, GNEFrameModuls::PathCreator *pathCreator)
void openFlow(const SUMOSAXAttributes &attrs)
opens a routeFlow for reading
static void transformToTrip(GNEVehicle *originalVehicle)
transform to trip
static void transformToPerson(GNEPerson *originalPerson)
transform person functions
void closeVType()
Ends the processing of a vehicle Type.
bool myUndoDemandElements
flag to check if created demand elements must be undo and redo
~GNERouteHandler()
Destructor.
GNEDemandElement * myLoadedVehicleWithEmbebbedRoute
Pointer to loaded vehicle with embebbed route (needed for GNEStops)
static void buildStop(GNENet *net, bool undoDemandElements, const SUMOVehicleParameter::Stop &stopParameters, GNEDemandElement *stopParent)
build stop
void closeTrip()
Ends the processing of a trip.
void addRide(const SUMOSAXAttributes &attrs)
Processing of a ride.
static void buildVehicleEmbeddedRoute(GNENet *net, bool undoDemandElements, SUMOVehicleParameter vehicleParameters, const std::vector< GNEEdge * > &edges)
build vehicle with a embedded route
void openVehicleTypeDistribution(const SUMOSAXAttributes &attrs)
opens a type distribution for reading
static void transformToPersonFlow(GNEPerson *originalPerson)
transform routeFlow over an existent route
static void buildFlowOverRoute(GNENet *net, bool undoDemandElements, const SUMOVehicleParameter &vehicleParameters)
build a flow over an existent route
static void buildFlow(GNENet *net, bool undoDemandElements, const SUMOVehicleParameter &vehicleParameters, GNEEdge *fromEdge, GNEEdge *toEdge, const std::vector< GNEEdge * > &via)
build flow
static void transformToVehicle(GNEVehicle *originalVehicle, bool createEmbeddedRoute)
transform vehicle functions
static void buildTrip(GNENet *net, bool undoDemandElements, const SUMOVehicleParameter &vehicleParameters, GNEEdge *fromEdge, GNEEdge *toEdge, const std::vector< GNEEdge * > &via)
build trip
Definition: GNETAZ.h:33
An upper class for objects with additional parameters.
Definition: Parameterised.h:39
Parser for routes during their loading.
Encapsulated SAX-Attributes.
Definition of vehicle stop (position and duration)
Structure representing possible vehicle parameter.
struct used for load person plans (Rides, Walks, etc.)
PersonPlansValues & operator=(PersonPlansValues *)=delete
Invalidated assignment operator.
GNEEdge * getLastEdge() const
return last valid edge (used to create consecutive person plans)
std::vector< std::string > vTypes
vehicle types
PersonPlansValues(PersonPlansValues *)=delete
Invalidated copy constructor.
GNEAdditional * chargingStation
charging station (stop)
bool isFirstPersonPlan() const
is first person plan
std::vector< std::string > lines
lines
GNEAdditional * fromBusStop
from busStop
std::vector< GNEEdge * > edges
list of edges
GNEAdditional * busStop
bus stop (stop)
SUMOVehicleParameter::Stop stopParameters
stop parameters
GNEAdditional * parkingArea
parking area (stop)
std::vector< std::string > modes
modes
GNEDemandElement * route
arrival route
GNEAdditional * toBusStop
to busStop
GNEAdditional * containerStop
container stop (stop)
bool checkIntegrity() const
check integrity
std::vector< PersonPlansValues > myPersonPlanValues
container for person trips loaded values
bool addPersonValue(GNENet *net, SumoXMLTag tag, const SUMOSAXAttributes &attrs)
add person plan value (
bool checkPersonPlanValues()
check person plan loaded (this will change tags, set begin and end elements, etc.)
struct for saving route parameters
bool loadedID
flag to check if route was loaded
std::string routeID
string for saving parsed Route ID
std::vector< GNEEdge * > edges
edges
RGBColor color
string for saving parsed route colors
Parameterised parameters
parameters
SUMOVehicleClass vClass
vClass used by this route
void setEdges(GNENet *net, const std::string &edgeIDs)
set edges (list of consecutive edges)