-
Notifications
You must be signed in to change notification settings - Fork 1.4k
/
GNERouteHandler.h
292 lines (212 loc) · 13.1 KB
/
GNERouteHandler.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
/****************************************************************************/
// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
// Copyright (C) 2001-2023 German Aerospace Center (DLR) and others.
// This program and the accompanying materials are made available under the
// terms of the Eclipse Public License 2.0 which is available at
// https://www.eclipse.org/legal/epl-2.0/
// This Source Code may also be made available under the following Secondary
// Licenses when the conditions for such availability set forth in the Eclipse
// Public License 2.0 are satisfied: GNU General Public License, version 2
// or later which is available at
// https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
/****************************************************************************/
/// @file GNERouteHandler.h
/// @author Pablo Alvarez Lopez
/// @date Jan 2019
///
// Builds demand objects for netedit
/****************************************************************************/
#pragma once
#include <config.h>
#include <netedit/frames/GNEFrameAttributeModules.h>
#include <netedit/frames/GNEPathCreator.h>
#include <netedit/frames/GNEAttributesCreator.h>
#include <utils/common/SUMOVehicleClass.h>
#include <utils/vehicle/SUMORouteHandler.h>
#include <utils/xml/SUMOSAXAttributes.h>
#include <utils/xml/SUMOSAXHandler.h>
#include <utils/xml/SUMOXMLDefinitions.h>
#include <utils/handlers/RouteHandler.h>
// ===========================================================================
// class declarations
// ===========================================================================
class GNEViewNet;
class GNEEdge;
class GNETAZ;
class GNEDemandElement;
class GNEVehicle;
class GNEPerson;
class GNEContainer;
class GNEUndoList;
// ===========================================================================
// class definitions
// ===========================================================================
/// @class GNERouteHandler
/// @brief Builds trigger objects for GNENet (busStops, chargingStations, detectors, etc..)
class GNERouteHandler : public RouteHandler {
public:
/// @brief Constructor
GNERouteHandler(const std::string& file, GNENet* net, const bool allowUndoRedo, const bool overwrite);
/// @brief Destructor
virtual ~GNERouteHandler();
/// @name build functions
/// @{
/// @brief build vType
void buildVType(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const SUMOVTypeParameter& vTypeParameter);
/// @brief build vType distribution
void buildVTypeDistribution(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& id, const int deterministic,
const std::vector<std::string>& vTypeIDs, const std::vector<double>& probabilities);
/// @brief build route
void buildRoute(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& id, SUMOVehicleClass vClass,
const std::vector<std::string>& edgeIDs, const RGBColor& color, const int repeat, const SUMOTime cycleTime,
const Parameterised::Map& routeParameters);
/// @brief build embedded route
void buildEmbeddedRoute(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::vector<std::string>& edgeIDs,
const RGBColor& color, const int repeat, const SUMOTime cycleTime,
const Parameterised::Map& routeParameters);
/// @brief build route distribution
void buildRouteDistribution(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& id);
/// @brief build a vehicle over an existent route
void buildVehicleOverRoute(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const SUMOVehicleParameter& vehicleParameters);
/// @brief build a flow over an existent route
void buildFlowOverRoute(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const SUMOVehicleParameter& vehicleParameters);
/// @brief build trip
void buildTrip(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const SUMOVehicleParameter& vehicleParameters,
const std::string& fromEdgeID, const std::string& toEdgeID);
/// @brief build trip over junctions
void buildTripJunctions(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const SUMOVehicleParameter& vehicleParameters,
const std::string& fromJunctionID, const std::string& toJunctionID);
/// @brief build trip over TAZs
void buildTripTAZs(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const SUMOVehicleParameter& vehicleParameters,
const std::string& fromTAZID, const std::string& toTAZID);
/// @brief build flow
void buildFlow(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const SUMOVehicleParameter& vehicleParameters,
const std::string& fromEdgeID, const std::string& toEdgeIDs);
/// @brief build flow over junctions
void buildFlowJunctions(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const SUMOVehicleParameter& vehicleParameters,
const std::string& fromJunctionID, const std::string& toJunctionID);
/// @brief build flow over junctions
void buildFlowTAZs(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const SUMOVehicleParameter& vehicleParameters,
const std::string& fromTAZID, const std::string& toTAZID);
/// @brief build person
void buildPerson(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const SUMOVehicleParameter& personParameters);
/// @brief build person flow
void buildPersonFlow(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const SUMOVehicleParameter& personFlowParameters);
/// @brief build person trip
void buildPersonTrip(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& fromEdgeID, const std::string& toEdgeID,
const std::string& fromJunctionID, const std::string& toJunctionID, const std::string& toBusStopID, const std::string& toTrainStopID,
double arrivalPos, const std::vector<std::string>& types, const std::vector<std::string>& modes, const std::vector<std::string>& lines);
/// @brief build walk
void buildWalk(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& fromEdgeID, const std::string& toEdgeID,
const std::string& fromJunctionID, const std::string& toJunctionID, const std::string& toBusStopID, const std::string& toTrainStopID,
const std::vector<std::string>& edgeIDs, const std::string& routeID, double arrivalPos);
/// @brief build ride
void buildRide(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& fromEdgeID, const std::string& toEdgeID,
const std::string& toBusStopID, const std::string& toTrainStopID, double arrivalPos, const std::vector<std::string>& lines);
/// @brief build container
void buildContainer(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const SUMOVehicleParameter& containerParameters);
/// @brief build container flow
void buildContainerFlow(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const SUMOVehicleParameter& containerFlowParameters);
/// @brief build transport
void buildTransport(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& fromEdgeID, const std::string& toEdgeID,
const std::string& toBusStopID, const std::vector<std::string>& lines, const double arrivalPos);
/// @brief build tranship
void buildTranship(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& fromEdgeID, const std::string& toEdgeID,
const std::string& toBusStopID, const std::vector<std::string>& edgeIDs, const double speed, const double departPosition,
const double arrivalPosition);
/// @}
/// @brief build stop
void buildStop(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const SUMOVehicleParameter::Stop& stopParameters);
/// @brief build person plan
bool buildPersonPlan(SumoXMLTag tag, GNEDemandElement* personParent, GNEAttributesCreator* personPlanAttributes,
GNEPathCreator* pathCreator, const bool centerAfterCreation);
/// @brief build container plan
bool buildContainerPlan(SumoXMLTag tag, GNEDemandElement* containerParent, GNEAttributesCreator* containerPlanAttributes, GNEPathCreator* pathCreator, const bool centerAfterCreation);
/// @brief check if there is already a vehicle (Vehicle, Trip, Flow or Flow) with the given ID
bool isVehicleIdDuplicated(const std::string& id);
/// @brief check if via attribute is valid
bool isViaAttributeValid(const std::vector<std::string>& via);
/// @brief check if there is already a person (Person or PersonFlow) with the given ID
bool isPersonIdDuplicated(const std::string& id);
/// @brief check if there is already a container (Container or ContainerFlow) with the given ID
bool isContainerIdDuplicated(const std::string& id);
/// @brief transform vehicle functions
/// @{
/// @brief transform to vehicle over an existent route
static void transformToVehicle(GNEVehicle* originalVehicle, bool createEmbeddedRoute);
/// @brief transform routeFlow over an existent route
static void transformToRouteFlow(GNEVehicle* originalVehicle, bool createEmbeddedRoute);
/// @brief transform to trip
static void transformToTrip(GNEVehicle* originalVehicle);
/// @brief transform to flow
static void transformToFlow(GNEVehicle* originalVehicle);
/// @brief transform to trip over junctions
static void transformToTripJunctions(GNEVehicle* originalVehicle);
/// @brief transform to flow over junctions
static void transformToFlowJunctions(GNEVehicle* originalVehicle);
/// @brief transform to trip over TAZs
static void transformToTripTAZs(GNEVehicle* originalVehicle);
/// @brief transform to flow over TAZs
static void transformToFlowTAZs(GNEVehicle* originalVehicle);
/// @}
/// @brief transform person functions
/// @{
/// @brief transform to vehicle over an existent route
static void transformToPerson(GNEPerson* originalPerson);
/// @brief transform routeFlow over an existent route
static void transformToPersonFlow(GNEPerson* originalPerson);
/// @}
/// @brief transform container functions
/// @{
/// @brief transform to vehicle over an existent route
static void transformToContainer(GNEContainer* originalContainer);
/// @brief transform routeFlow over an existent route
static void transformToContainerFlow(GNEContainer* originalContainer);
/// @}
/// @brief reverse functions
/// @{
/// @brief check if the given vehicle can be reversed
static bool canReverse(const GNEDemandElement* element);
/// @brief check if the given list of edges can be reversed
static bool canReverse(GNENet* net, SUMOVehicleClass vClass, const std::vector<GNEEdge*> &edges);
/// @brief reverse given demand element
static void reverse(GNEDemandElement* element);
/// @brief add reverse for given demand element
static void addReverse(GNEDemandElement* element);
/// @}
protected:
/// @brief parse junction
GNEJunction* parseJunction(const SumoXMLTag tag, const std::string& junctionID);
/// @brief parse TAZ
GNEAdditional* parseTAZ(const SumoXMLTag tag, const std::string& TAZID);
/// @brief parse edge
GNEEdge* parseEdge(const SumoXMLTag tag, const std::string& edgeID);
/// @brief parse edges
std::vector<GNEEdge*> parseEdges(const SumoXMLTag tag, const std::vector<std::string>& edgeIDs);
/// @brief get type (Either type o typeDistribution)
GNEDemandElement* getType(const std::string &id) const;
/// @brief get person parent
GNEDemandElement* getPersonParent(const CommonXMLStructure::SumoBaseObject* sumoBaseObject) const;
/// @brief get container parent
GNEDemandElement* getContainerParent(const CommonXMLStructure::SumoBaseObject* sumoBaseObject) const;
/// @brief get previos person/container plan edge
GNEEdge* getPreviousPlanEdge(const bool person, const CommonXMLStructure::SumoBaseObject* obj) const;
/// @brief get previos person/container plan junction
GNEJunction* getPreviousPlanJunction(const bool person, const CommonXMLStructure::SumoBaseObject* obj) const;
/// @brief check if given ID correspond to a duplicated demand element
bool checkDuplicatedDemandElement(const SumoXMLTag tag, const std::string& id);
/// @brief remove overwrited demand element
void overwriteDemandElement();
private:
/// @brief pointer to GNENet
GNENet* myNet;
/// @brief pointer for person and container plans
CommonXMLStructure::SumoBaseObject* myPlanObject;
/// @brief allow undo/redo
const bool myAllowUndoRedo;
/// @brief check if overwrite
const bool myOverwrite;
/// @brief demand to overwrite (using undor-redo
GNEDemandElement* myDemandToOverwrite = nullptr;
};