Line data Source code
1 : /****************************************************************************/
2 : // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3 : // Copyright (C) 2001-2025 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 : /****************************************************************************/
14 : /// @file CommonXMLStructure.cpp
15 : /// @author Pablo Alvarez Lopez
16 : /// @date May 2021
17 : ///
18 : // Structure for common XML Parsing
19 : /****************************************************************************/
20 : #include <config.h>
21 :
22 : #include <utils/common/MsgHandler.h>
23 : #include <utils/common/StringTokenizer.h>
24 : #include <utils/xml/SUMOSAXHandler.h>
25 :
26 : #include "CommonXMLStructure.h"
27 :
28 :
29 : // ===========================================================================
30 : // method definitions
31 : // ===========================================================================
32 :
33 : // ---------------------------------------------------------------------------
34 : // CommonXMLStructure::PlanParameters - methods
35 : // ---------------------------------------------------------------------------
36 :
37 0 : CommonXMLStructure::PlanParameters::PlanParameters() {}
38 :
39 :
40 0 : CommonXMLStructure::PlanParameters::PlanParameters(const CommonXMLStructure::SumoBaseObject* sumoBaseObject,
41 0 : const SUMOSAXAttributes& attrs, bool& parsedOk) {
42 0 : if (sumoBaseObject->getParentSumoBaseObject() != nullptr) {
43 : // get plan parent ID (first check if exist!)
44 0 : const auto planParentID = sumoBaseObject->getParentSumoBaseObject()->hasStringAttribute(SUMO_ATTR_ID) ?
45 0 : sumoBaseObject->getParentSumoBaseObject()->getStringAttribute(SUMO_ATTR_ID).c_str() : "";
46 : // edges
47 0 : fromEdge = attrs.getOpt<std::string>(SUMO_ATTR_FROM, planParentID, parsedOk, "");
48 0 : toEdge = attrs.getOpt<std::string>(SUMO_ATTR_TO, planParentID, parsedOk, "");
49 0 : if (toEdge.empty()) {
50 0 : toEdge = attrs.getOpt<std::string>(SUMO_ATTR_EDGE, planParentID, parsedOk, "");
51 : }
52 0 : consecutiveEdges = attrs.getOpt<std::vector<std::string> >(SUMO_ATTR_EDGES, planParentID, parsedOk);
53 : // junctions
54 0 : fromJunction = attrs.getOpt<std::string>(SUMO_ATTR_FROM_JUNCTION, planParentID, parsedOk, "");
55 0 : toJunction = attrs.getOpt<std::string>(SUMO_ATTR_TO_JUNCTION, planParentID, parsedOk, "");
56 : // TAZs
57 0 : fromTAZ = attrs.getOpt<std::string>(SUMO_ATTR_FROM_TAZ, planParentID, parsedOk, "");
58 0 : toTAZ = attrs.getOpt<std::string>(SUMO_ATTR_TO_TAZ, planParentID, parsedOk, "");
59 : // bus stops
60 0 : fromBusStop = attrs.getOpt<std::string>(GNE_ATTR_FROM_BUSSTOP, planParentID, parsedOk, "");
61 0 : toBusStop = attrs.getOpt<std::string>(SUMO_ATTR_BUS_STOP, planParentID, parsedOk, "");
62 : // train stops
63 0 : fromTrainStop = attrs.getOpt<std::string>(GNE_ATTR_FROM_TRAINSTOP, planParentID, parsedOk, "");
64 0 : toTrainStop = attrs.getOpt<std::string>(SUMO_ATTR_TRAIN_STOP, planParentID, parsedOk, "");
65 : // container stops
66 0 : fromContainerStop = attrs.getOpt<std::string>(GNE_ATTR_FROM_CONTAINERSTOP, planParentID, parsedOk, "");
67 0 : toContainerStop = attrs.getOpt<std::string>(SUMO_ATTR_CONTAINER_STOP, planParentID, parsedOk, "");
68 : // charging stations
69 0 : fromChargingStation = attrs.getOpt<std::string>(GNE_ATTR_FROM_CHARGINGSTATION, planParentID, parsedOk, "");
70 0 : toChargingStation = attrs.getOpt<std::string>(SUMO_ATTR_CHARGING_STATION, planParentID, parsedOk, "");
71 : // parking areas
72 0 : fromParkingArea = attrs.getOpt<std::string>(GNE_ATTR_FROM_PARKINGAREA, planParentID, parsedOk, "");
73 0 : toParkingArea = attrs.getOpt<std::string>(SUMO_ATTR_PARKING_AREA, planParentID, parsedOk, "");
74 : // routes
75 0 : fromRoute = attrs.getOpt<std::string>(GNE_ATTR_FROM_ROUTE, planParentID, parsedOk, "");
76 0 : toRoute = attrs.getOpt<std::string>(SUMO_ATTR_ROUTE, planParentID, parsedOk, "");
77 : // update from attributes
78 0 : updateFromAttributes(sumoBaseObject);
79 : }
80 0 : }
81 :
82 :
83 : void
84 0 : CommonXMLStructure::PlanParameters::clear() {
85 : fromJunction.clear();
86 : toJunction.clear();
87 : fromEdge.clear();
88 : toEdge.clear();
89 : fromTAZ.clear();
90 : toTAZ.clear();
91 : fromBusStop.clear();
92 : toBusStop.clear();
93 : fromTrainStop.clear();
94 : toTrainStop.clear();
95 : fromContainerStop.clear();
96 : toContainerStop.clear();
97 : fromChargingStation.clear();
98 : toChargingStation.clear();
99 : fromParkingArea.clear();
100 : toParkingArea.clear();
101 : consecutiveEdges.clear();
102 : fromRoute.clear();
103 : toRoute.clear();
104 0 : }
105 :
106 :
107 : bool
108 0 : CommonXMLStructure::PlanParameters::isSingleEdgePlan() const {
109 0 : if (fromEdge.empty()) {
110 : return false;
111 : } else {
112 0 : return getNumberOfDefinedParameters() == 1;
113 : }
114 : }
115 :
116 :
117 : int
118 0 : CommonXMLStructure::PlanParameters::getNumberOfDefinedParameters() const {
119 0 : return (int)consecutiveEdges.size() +
120 0 : (fromJunction.empty() ? 0 : 1) +
121 0 : (toJunction.empty() ? 0 : 1) +
122 0 : (fromEdge.empty() ? 0 : 1) +
123 0 : (toEdge.empty() ? 0 : 1) +
124 0 : (fromTAZ.empty() ? 0 : 1) +
125 0 : (toTAZ.empty() ? 0 : 1) +
126 0 : (fromBusStop.empty() ? 0 : 1) +
127 0 : (toBusStop.empty() ? 0 : 1) +
128 0 : (fromTrainStop.empty() ? 0 : 1) +
129 0 : (toTrainStop.empty() ? 0 : 1) +
130 0 : (fromContainerStop.empty() ? 0 : 1) +
131 0 : (toContainerStop.empty() ? 0 : 1) +
132 0 : (fromChargingStation.empty() ? 0 : 1) +
133 0 : (toChargingStation.empty() ? 0 : 1) +
134 0 : (fromParkingArea.empty() ? 0 : 1) +
135 0 : (toParkingArea.empty() ? 0 : 1) +
136 0 : (fromRoute.empty() ? 0 : 1) +
137 0 : (toRoute.empty() ? 0 : 1);
138 : }
139 :
140 :
141 :
142 : SumoXMLTag
143 0 : CommonXMLStructure::PlanParameters::getWalkTag() const {
144 0 : if (isSingleEdgePlan()) {
145 : return GNE_TAG_WALK_EDGE_EDGE;
146 0 : } else if (consecutiveEdges.size() > 0) {
147 : return GNE_TAG_WALK_EDGES;
148 0 : } else if (!toRoute.empty()) {
149 : return GNE_TAG_WALK_ROUTE;
150 0 : } else if (!fromEdge.empty()) {
151 0 : if (!toEdge.empty()) {
152 : return GNE_TAG_WALK_EDGE_EDGE;
153 0 : } else if (!toTAZ.empty()) {
154 : return GNE_TAG_WALK_EDGE_TAZ;
155 0 : } else if (!toJunction.empty()) {
156 : return GNE_TAG_WALK_EDGE_JUNCTION;
157 0 : } else if (!toBusStop.empty()) {
158 : return GNE_TAG_WALK_EDGE_BUSSTOP;
159 0 : } else if (!toTrainStop.empty()) {
160 : return GNE_TAG_WALK_EDGE_TRAINSTOP;
161 0 : } else if (!toContainerStop.empty()) {
162 : return GNE_TAG_WALK_EDGE_CONTAINERSTOP;
163 0 : } else if (!toChargingStation.empty()) {
164 : return GNE_TAG_WALK_EDGE_CHARGINGSTATION;
165 0 : } else if (!toParkingArea.empty()) {
166 : return GNE_TAG_WALK_EDGE_PARKINGAREA;
167 : } else {
168 0 : return SUMO_TAG_NOTHING;
169 : }
170 0 : } else if (!fromTAZ.empty()) {
171 0 : if (!toEdge.empty()) {
172 : return GNE_TAG_WALK_TAZ_EDGE;
173 0 : } else if (!toTAZ.empty()) {
174 : return GNE_TAG_WALK_TAZ_TAZ;
175 0 : } else if (!toJunction.empty()) {
176 : return GNE_TAG_WALK_TAZ_JUNCTION;
177 0 : } else if (!toBusStop.empty()) {
178 : return GNE_TAG_WALK_TAZ_BUSSTOP;
179 0 : } else if (!toTrainStop.empty()) {
180 : return GNE_TAG_WALK_TAZ_TRAINSTOP;
181 0 : } else if (!toContainerStop.empty()) {
182 : return GNE_TAG_WALK_TAZ_CONTAINERSTOP;
183 0 : } else if (!toChargingStation.empty()) {
184 : return GNE_TAG_WALK_TAZ_CHARGINGSTATION;
185 0 : } else if (!toParkingArea.empty()) {
186 : return GNE_TAG_WALK_TAZ_PARKINGAREA;
187 : } else {
188 0 : return SUMO_TAG_NOTHING;
189 : }
190 0 : } else if (!fromJunction.empty()) {
191 0 : if (!toEdge.empty()) {
192 : return GNE_TAG_WALK_JUNCTION_EDGE;
193 0 : } else if (!toTAZ.empty()) {
194 : return GNE_TAG_WALK_JUNCTION_TAZ;
195 0 : } else if (!toJunction.empty()) {
196 : return GNE_TAG_WALK_JUNCTION_JUNCTION;
197 0 : } else if (!toBusStop.empty()) {
198 : return GNE_TAG_WALK_JUNCTION_BUSSTOP;
199 0 : } else if (!toTrainStop.empty()) {
200 : return GNE_TAG_WALK_JUNCTION_TRAINSTOP;
201 0 : } else if (!toContainerStop.empty()) {
202 : return GNE_TAG_WALK_JUNCTION_CONTAINERSTOP;
203 0 : } else if (!toChargingStation.empty()) {
204 : return GNE_TAG_WALK_JUNCTION_CHARGINGSTATION;
205 0 : } else if (!toParkingArea.empty()) {
206 : return GNE_TAG_WALK_JUNCTION_PARKINGAREA;
207 : } else {
208 0 : return SUMO_TAG_NOTHING;
209 : }
210 0 : } else if (!fromBusStop.empty()) {
211 0 : if (!toEdge.empty()) {
212 : return GNE_TAG_WALK_BUSSTOP_EDGE;
213 0 : } else if (!toTAZ.empty()) {
214 : return GNE_TAG_WALK_BUSSTOP_TAZ;
215 0 : } else if (!toJunction.empty()) {
216 : return GNE_TAG_WALK_BUSSTOP_JUNCTION;
217 0 : } else if (!toBusStop.empty()) {
218 : return GNE_TAG_WALK_BUSSTOP_BUSSTOP;
219 0 : } else if (!toTrainStop.empty()) {
220 : return GNE_TAG_WALK_BUSSTOP_TRAINSTOP;
221 0 : } else if (!toContainerStop.empty()) {
222 : return GNE_TAG_WALK_BUSSTOP_CONTAINERSTOP;
223 0 : } else if (!toChargingStation.empty()) {
224 : return GNE_TAG_WALK_BUSSTOP_CHARGINGSTATION;
225 0 : } else if (!toParkingArea.empty()) {
226 : return GNE_TAG_WALK_BUSSTOP_PARKINGAREA;
227 : } else {
228 0 : return SUMO_TAG_NOTHING;
229 : }
230 0 : } else if (!fromTrainStop.empty()) {
231 0 : if (!toEdge.empty()) {
232 : return GNE_TAG_WALK_TRAINSTOP_EDGE;
233 0 : } else if (!toTAZ.empty()) {
234 : return GNE_TAG_WALK_TRAINSTOP_TAZ;
235 0 : } else if (!toJunction.empty()) {
236 : return GNE_TAG_WALK_TRAINSTOP_JUNCTION;
237 0 : } else if (!toBusStop.empty()) {
238 : return GNE_TAG_WALK_TRAINSTOP_BUSSTOP;
239 0 : } else if (!toTrainStop.empty()) {
240 : return GNE_TAG_WALK_TRAINSTOP_TRAINSTOP;
241 0 : } else if (!toContainerStop.empty()) {
242 : return GNE_TAG_WALK_TRAINSTOP_CONTAINERSTOP;
243 0 : } else if (!toChargingStation.empty()) {
244 : return GNE_TAG_WALK_TRAINSTOP_CHARGINGSTATION;
245 0 : } else if (!toParkingArea.empty()) {
246 : return GNE_TAG_WALK_TRAINSTOP_PARKINGAREA;
247 : } else {
248 0 : return SUMO_TAG_NOTHING;
249 : }
250 0 : } else if (!fromContainerStop.empty()) {
251 0 : if (!toEdge.empty()) {
252 : return GNE_TAG_WALK_CONTAINERSTOP_EDGE;
253 0 : } else if (!toTAZ.empty()) {
254 : return GNE_TAG_WALK_CONTAINERSTOP_TAZ;
255 0 : } else if (!toJunction.empty()) {
256 : return GNE_TAG_WALK_CONTAINERSTOP_JUNCTION;
257 0 : } else if (!toBusStop.empty()) {
258 : return GNE_TAG_WALK_CONTAINERSTOP_BUSSTOP;
259 0 : } else if (!toTrainStop.empty()) {
260 : return GNE_TAG_WALK_CONTAINERSTOP_TRAINSTOP;
261 0 : } else if (!toContainerStop.empty()) {
262 : return GNE_TAG_WALK_CONTAINERSTOP_CONTAINERSTOP;
263 0 : } else if (!toChargingStation.empty()) {
264 : return GNE_TAG_WALK_CONTAINERSTOP_CHARGINGSTATION;
265 0 : } else if (!toParkingArea.empty()) {
266 : return GNE_TAG_WALK_CONTAINERSTOP_PARKINGAREA;
267 : } else {
268 0 : return SUMO_TAG_NOTHING;
269 : }
270 0 : } else if (!fromChargingStation.empty()) {
271 0 : if (!toEdge.empty()) {
272 : return GNE_TAG_WALK_CHARGINGSTATION_EDGE;
273 0 : } else if (!toTAZ.empty()) {
274 : return GNE_TAG_WALK_CHARGINGSTATION_TAZ;
275 0 : } else if (!toJunction.empty()) {
276 : return GNE_TAG_WALK_CHARGINGSTATION_JUNCTION;
277 0 : } else if (!toBusStop.empty()) {
278 : return GNE_TAG_WALK_CHARGINGSTATION_BUSSTOP;
279 0 : } else if (!toTrainStop.empty()) {
280 : return GNE_TAG_WALK_CHARGINGSTATION_TRAINSTOP;
281 0 : } else if (!toContainerStop.empty()) {
282 : return GNE_TAG_WALK_CHARGINGSTATION_CONTAINERSTOP;
283 0 : } else if (!toChargingStation.empty()) {
284 : return GNE_TAG_WALK_CHARGINGSTATION_CHARGINGSTATION;
285 0 : } else if (!toParkingArea.empty()) {
286 : return GNE_TAG_WALK_CHARGINGSTATION_PARKINGAREA;
287 : } else {
288 0 : return SUMO_TAG_NOTHING;
289 : }
290 0 : } else if (!fromParkingArea.empty()) {
291 0 : if (!toEdge.empty()) {
292 : return GNE_TAG_WALK_PARKINGAREA_EDGE;
293 0 : } else if (!toTAZ.empty()) {
294 : return GNE_TAG_WALK_PARKINGAREA_TAZ;
295 0 : } else if (!toJunction.empty()) {
296 : return GNE_TAG_WALK_PARKINGAREA_JUNCTION;
297 0 : } else if (!toBusStop.empty()) {
298 : return GNE_TAG_WALK_PARKINGAREA_BUSSTOP;
299 0 : } else if (!toTrainStop.empty()) {
300 : return GNE_TAG_WALK_PARKINGAREA_TRAINSTOP;
301 0 : } else if (!toContainerStop.empty()) {
302 : return GNE_TAG_WALK_PARKINGAREA_CONTAINERSTOP;
303 0 : } else if (!toChargingStation.empty()) {
304 : return GNE_TAG_WALK_PARKINGAREA_CHARGINGSTATION;
305 0 : } else if (!toParkingArea.empty()) {
306 : return GNE_TAG_WALK_PARKINGAREA_PARKINGAREA;
307 : } else {
308 0 : return SUMO_TAG_NOTHING;
309 : }
310 : } else {
311 : return SUMO_TAG_NOTHING;
312 : }
313 : }
314 :
315 :
316 : SumoXMLTag
317 0 : CommonXMLStructure::PlanParameters::getPersonTripTag() const {
318 0 : if (isSingleEdgePlan()) {
319 : return GNE_TAG_PERSONTRIP_EDGE_EDGE;
320 0 : } else if (!fromEdge.empty()) {
321 0 : if (!toEdge.empty()) {
322 : return GNE_TAG_PERSONTRIP_EDGE_EDGE;
323 0 : } else if (!toTAZ.empty()) {
324 : return GNE_TAG_PERSONTRIP_EDGE_TAZ;
325 0 : } else if (!toJunction.empty()) {
326 : return GNE_TAG_PERSONTRIP_EDGE_JUNCTION;
327 0 : } else if (!toBusStop.empty()) {
328 : return GNE_TAG_PERSONTRIP_EDGE_BUSSTOP;
329 0 : } else if (!toTrainStop.empty()) {
330 : return GNE_TAG_PERSONTRIP_EDGE_TRAINSTOP;
331 0 : } else if (!toContainerStop.empty()) {
332 : return GNE_TAG_PERSONTRIP_EDGE_CONTAINERSTOP;
333 0 : } else if (!toChargingStation.empty()) {
334 : return GNE_TAG_PERSONTRIP_EDGE_CHARGINGSTATION;
335 0 : } else if (!toParkingArea.empty()) {
336 : return GNE_TAG_PERSONTRIP_EDGE_PARKINGAREA;
337 : } else {
338 0 : return SUMO_TAG_NOTHING;
339 : }
340 0 : } else if (!fromTAZ.empty()) {
341 0 : if (!toEdge.empty()) {
342 : return GNE_TAG_PERSONTRIP_TAZ_EDGE;
343 0 : } else if (!toTAZ.empty()) {
344 : return GNE_TAG_PERSONTRIP_TAZ_TAZ;
345 0 : } else if (!toJunction.empty()) {
346 : return GNE_TAG_PERSONTRIP_TAZ_JUNCTION;
347 0 : } else if (!toBusStop.empty()) {
348 : return GNE_TAG_PERSONTRIP_TAZ_BUSSTOP;
349 0 : } else if (!toTrainStop.empty()) {
350 : return GNE_TAG_PERSONTRIP_TAZ_TRAINSTOP;
351 0 : } else if (!toContainerStop.empty()) {
352 : return GNE_TAG_PERSONTRIP_TAZ_CONTAINERSTOP;
353 0 : } else if (!toChargingStation.empty()) {
354 : return GNE_TAG_PERSONTRIP_TAZ_CHARGINGSTATION;
355 0 : } else if (!toParkingArea.empty()) {
356 : return GNE_TAG_PERSONTRIP_TAZ_PARKINGAREA;
357 : } else {
358 0 : return SUMO_TAG_NOTHING;
359 : }
360 0 : } else if (!fromJunction.empty()) {
361 0 : if (!toEdge.empty()) {
362 : return GNE_TAG_PERSONTRIP_JUNCTION_EDGE;
363 0 : } else if (!toTAZ.empty()) {
364 : return GNE_TAG_PERSONTRIP_JUNCTION_TAZ;
365 0 : } else if (!toJunction.empty()) {
366 : return GNE_TAG_PERSONTRIP_JUNCTION_JUNCTION;
367 0 : } else if (!toBusStop.empty()) {
368 : return GNE_TAG_PERSONTRIP_JUNCTION_BUSSTOP;
369 0 : } else if (!toTrainStop.empty()) {
370 : return GNE_TAG_PERSONTRIP_JUNCTION_TRAINSTOP;
371 0 : } else if (!toContainerStop.empty()) {
372 : return GNE_TAG_PERSONTRIP_JUNCTION_CONTAINERSTOP;
373 0 : } else if (!toChargingStation.empty()) {
374 : return GNE_TAG_PERSONTRIP_JUNCTION_CHARGINGSTATION;
375 0 : } else if (!toParkingArea.empty()) {
376 : return GNE_TAG_PERSONTRIP_JUNCTION_PARKINGAREA;
377 : } else {
378 0 : return SUMO_TAG_NOTHING;
379 : }
380 0 : } else if (!fromBusStop.empty()) {
381 0 : if (!toEdge.empty()) {
382 : return GNE_TAG_PERSONTRIP_BUSSTOP_EDGE;
383 0 : } else if (!toTAZ.empty()) {
384 : return GNE_TAG_PERSONTRIP_BUSSTOP_TAZ;
385 0 : } else if (!toJunction.empty()) {
386 : return GNE_TAG_PERSONTRIP_BUSSTOP_JUNCTION;
387 0 : } else if (!toBusStop.empty()) {
388 : return GNE_TAG_PERSONTRIP_BUSSTOP_BUSSTOP;
389 0 : } else if (!toTrainStop.empty()) {
390 : return GNE_TAG_PERSONTRIP_BUSSTOP_TRAINSTOP;
391 0 : } else if (!toContainerStop.empty()) {
392 : return GNE_TAG_PERSONTRIP_BUSSTOP_CONTAINERSTOP;
393 0 : } else if (!toChargingStation.empty()) {
394 : return GNE_TAG_PERSONTRIP_BUSSTOP_CHARGINGSTATION;
395 0 : } else if (!toParkingArea.empty()) {
396 : return GNE_TAG_PERSONTRIP_BUSSTOP_PARKINGAREA;
397 : } else {
398 0 : return SUMO_TAG_NOTHING;
399 : }
400 0 : } else if (!fromTrainStop.empty()) {
401 0 : if (!toEdge.empty()) {
402 : return GNE_TAG_PERSONTRIP_TRAINSTOP_EDGE;
403 0 : } else if (!toTAZ.empty()) {
404 : return GNE_TAG_PERSONTRIP_TRAINSTOP_TAZ;
405 0 : } else if (!toJunction.empty()) {
406 : return GNE_TAG_PERSONTRIP_TRAINSTOP_JUNCTION;
407 0 : } else if (!toBusStop.empty()) {
408 : return GNE_TAG_PERSONTRIP_TRAINSTOP_BUSSTOP;
409 0 : } else if (!toTrainStop.empty()) {
410 : return GNE_TAG_PERSONTRIP_TRAINSTOP_TRAINSTOP;
411 0 : } else if (!toContainerStop.empty()) {
412 : return GNE_TAG_PERSONTRIP_TRAINSTOP_CONTAINERSTOP;
413 0 : } else if (!toChargingStation.empty()) {
414 : return GNE_TAG_PERSONTRIP_TRAINSTOP_CHARGINGSTATION;
415 0 : } else if (!toParkingArea.empty()) {
416 : return GNE_TAG_PERSONTRIP_TRAINSTOP_PARKINGAREA;
417 : } else {
418 0 : return SUMO_TAG_NOTHING;
419 : }
420 0 : } else if (!fromContainerStop.empty()) {
421 0 : if (!toEdge.empty()) {
422 : return GNE_TAG_PERSONTRIP_CONTAINERSTOP_EDGE;
423 0 : } else if (!toTAZ.empty()) {
424 : return GNE_TAG_PERSONTRIP_CONTAINERSTOP_TAZ;
425 0 : } else if (!toJunction.empty()) {
426 : return GNE_TAG_PERSONTRIP_CONTAINERSTOP_JUNCTION;
427 0 : } else if (!toBusStop.empty()) {
428 : return GNE_TAG_PERSONTRIP_CONTAINERSTOP_BUSSTOP;
429 0 : } else if (!toTrainStop.empty()) {
430 : return GNE_TAG_PERSONTRIP_CONTAINERSTOP_TRAINSTOP;
431 0 : } else if (!toContainerStop.empty()) {
432 : return GNE_TAG_PERSONTRIP_CONTAINERSTOP_CONTAINERSTOP;
433 0 : } else if (!toChargingStation.empty()) {
434 : return GNE_TAG_PERSONTRIP_CONTAINERSTOP_CHARGINGSTATION;
435 0 : } else if (!toParkingArea.empty()) {
436 : return GNE_TAG_PERSONTRIP_CONTAINERSTOP_PARKINGAREA;
437 : } else {
438 0 : return SUMO_TAG_NOTHING;
439 : }
440 0 : } else if (!fromChargingStation.empty()) {
441 0 : if (!toEdge.empty()) {
442 : return GNE_TAG_PERSONTRIP_CHARGINGSTATION_EDGE;
443 0 : } else if (!toTAZ.empty()) {
444 : return GNE_TAG_PERSONTRIP_CHARGINGSTATION_TAZ;
445 0 : } else if (!toJunction.empty()) {
446 : return GNE_TAG_PERSONTRIP_CHARGINGSTATION_JUNCTION;
447 0 : } else if (!toBusStop.empty()) {
448 : return GNE_TAG_PERSONTRIP_CHARGINGSTATION_BUSSTOP;
449 0 : } else if (!toTrainStop.empty()) {
450 : return GNE_TAG_PERSONTRIP_CHARGINGSTATION_TRAINSTOP;
451 0 : } else if (!toContainerStop.empty()) {
452 : return GNE_TAG_PERSONTRIP_CHARGINGSTATION_CONTAINERSTOP;
453 0 : } else if (!toChargingStation.empty()) {
454 : return GNE_TAG_PERSONTRIP_CHARGINGSTATION_CHARGINGSTATION;
455 0 : } else if (!toParkingArea.empty()) {
456 : return GNE_TAG_PERSONTRIP_CHARGINGSTATION_PARKINGAREA;
457 : } else {
458 0 : return SUMO_TAG_NOTHING;
459 : }
460 0 : } else if (!fromParkingArea.empty()) {
461 0 : if (!toEdge.empty()) {
462 : return GNE_TAG_PERSONTRIP_PARKINGAREA_EDGE;
463 0 : } else if (!toTAZ.empty()) {
464 : return GNE_TAG_PERSONTRIP_PARKINGAREA_TAZ;
465 0 : } else if (!toJunction.empty()) {
466 : return GNE_TAG_PERSONTRIP_PARKINGAREA_JUNCTION;
467 0 : } else if (!toBusStop.empty()) {
468 : return GNE_TAG_PERSONTRIP_PARKINGAREA_BUSSTOP;
469 0 : } else if (!toTrainStop.empty()) {
470 : return GNE_TAG_PERSONTRIP_PARKINGAREA_TRAINSTOP;
471 0 : } else if (!toContainerStop.empty()) {
472 : return GNE_TAG_PERSONTRIP_PARKINGAREA_CONTAINERSTOP;
473 0 : } else if (!toChargingStation.empty()) {
474 : return GNE_TAG_PERSONTRIP_PARKINGAREA_CHARGINGSTATION;
475 0 : } else if (!toParkingArea.empty()) {
476 : return GNE_TAG_PERSONTRIP_PARKINGAREA_PARKINGAREA;
477 : } else {
478 0 : return SUMO_TAG_NOTHING;
479 : }
480 : } else {
481 : return SUMO_TAG_NOTHING;
482 : }
483 : }
484 :
485 :
486 : SumoXMLTag
487 0 : CommonXMLStructure::PlanParameters::getRideTag() const {
488 0 : if (isSingleEdgePlan()) {
489 : return GNE_TAG_RIDE_EDGE_EDGE;
490 0 : } else if (!fromEdge.empty()) {
491 0 : if (!toEdge.empty()) {
492 : return GNE_TAG_RIDE_EDGE_EDGE;
493 0 : } else if (!toBusStop.empty()) {
494 : return GNE_TAG_RIDE_EDGE_BUSSTOP;
495 0 : } else if (!toTrainStop.empty()) {
496 : return GNE_TAG_RIDE_EDGE_TRAINSTOP;
497 0 : } else if (!toContainerStop.empty()) {
498 : return GNE_TAG_RIDE_EDGE_CONTAINERSTOP;
499 0 : } else if (!toChargingStation.empty()) {
500 : return GNE_TAG_RIDE_EDGE_CHARGINGSTATION;
501 0 : } else if (!toParkingArea.empty()) {
502 : return GNE_TAG_RIDE_EDGE_PARKINGAREA;
503 : } else {
504 0 : return SUMO_TAG_NOTHING;
505 : }
506 0 : } else if (!fromBusStop.empty()) {
507 0 : if (!toEdge.empty()) {
508 : return GNE_TAG_RIDE_BUSSTOP_EDGE;
509 0 : } else if (!toBusStop.empty()) {
510 : return GNE_TAG_RIDE_BUSSTOP_BUSSTOP;
511 0 : } else if (!toTrainStop.empty()) {
512 : return GNE_TAG_RIDE_BUSSTOP_TRAINSTOP;
513 0 : } else if (!toContainerStop.empty()) {
514 : return GNE_TAG_RIDE_BUSSTOP_CONTAINERSTOP;
515 0 : } else if (!toChargingStation.empty()) {
516 : return GNE_TAG_RIDE_BUSSTOP_CHARGINGSTATION;
517 0 : } else if (!toParkingArea.empty()) {
518 : return GNE_TAG_RIDE_BUSSTOP_PARKINGAREA;
519 : } else {
520 0 : return SUMO_TAG_NOTHING;
521 : }
522 0 : } else if (!fromTrainStop.empty()) {
523 0 : if (!toEdge.empty()) {
524 : return GNE_TAG_RIDE_TRAINSTOP_EDGE;
525 0 : } else if (!toBusStop.empty()) {
526 : return GNE_TAG_RIDE_TRAINSTOP_BUSSTOP;
527 0 : } else if (!toTrainStop.empty()) {
528 : return GNE_TAG_RIDE_TRAINSTOP_TRAINSTOP;
529 0 : } else if (!toContainerStop.empty()) {
530 : return GNE_TAG_RIDE_TRAINSTOP_CONTAINERSTOP;
531 0 : } else if (!toChargingStation.empty()) {
532 : return GNE_TAG_RIDE_TRAINSTOP_CHARGINGSTATION;
533 0 : } else if (!toParkingArea.empty()) {
534 : return GNE_TAG_RIDE_TRAINSTOP_PARKINGAREA;
535 : } else {
536 0 : return SUMO_TAG_NOTHING;
537 : }
538 0 : } else if (!fromContainerStop.empty()) {
539 0 : if (!toEdge.empty()) {
540 : return GNE_TAG_RIDE_CONTAINERSTOP_EDGE;
541 0 : } else if (!toBusStop.empty()) {
542 : return GNE_TAG_RIDE_CONTAINERSTOP_BUSSTOP;
543 0 : } else if (!toTrainStop.empty()) {
544 : return GNE_TAG_RIDE_CONTAINERSTOP_TRAINSTOP;
545 0 : } else if (!toContainerStop.empty()) {
546 : return GNE_TAG_RIDE_CONTAINERSTOP_CONTAINERSTOP;
547 0 : } else if (!toChargingStation.empty()) {
548 : return GNE_TAG_RIDE_CONTAINERSTOP_CHARGINGSTATION;
549 0 : } else if (!toParkingArea.empty()) {
550 : return GNE_TAG_RIDE_CONTAINERSTOP_PARKINGAREA;
551 : } else {
552 0 : return SUMO_TAG_NOTHING;
553 : }
554 0 : } else if (!fromChargingStation.empty()) {
555 0 : if (!toEdge.empty()) {
556 : return GNE_TAG_RIDE_CHARGINGSTATION_EDGE;
557 0 : } else if (!toBusStop.empty()) {
558 : return GNE_TAG_RIDE_CHARGINGSTATION_BUSSTOP;
559 0 : } else if (!toTrainStop.empty()) {
560 : return GNE_TAG_RIDE_CHARGINGSTATION_TRAINSTOP;
561 0 : } else if (!toContainerStop.empty()) {
562 : return GNE_TAG_RIDE_CHARGINGSTATION_CONTAINERSTOP;
563 0 : } else if (!toChargingStation.empty()) {
564 : return GNE_TAG_RIDE_CHARGINGSTATION_CHARGINGSTATION;
565 0 : } else if (!toParkingArea.empty()) {
566 : return GNE_TAG_RIDE_CHARGINGSTATION_PARKINGAREA;
567 : } else {
568 0 : return SUMO_TAG_NOTHING;
569 : }
570 0 : } else if (!fromParkingArea.empty()) {
571 0 : if (!toEdge.empty()) {
572 : return GNE_TAG_RIDE_PARKINGAREA_EDGE;
573 0 : } else if (!toBusStop.empty()) {
574 : return GNE_TAG_RIDE_PARKINGAREA_BUSSTOP;
575 0 : } else if (!toTrainStop.empty()) {
576 : return GNE_TAG_RIDE_PARKINGAREA_TRAINSTOP;
577 0 : } else if (!toContainerStop.empty()) {
578 : return GNE_TAG_RIDE_PARKINGAREA_CONTAINERSTOP;
579 0 : } else if (!toChargingStation.empty()) {
580 : return GNE_TAG_RIDE_PARKINGAREA_CHARGINGSTATION;
581 0 : } else if (!toParkingArea.empty()) {
582 : return GNE_TAG_RIDE_PARKINGAREA_PARKINGAREA;
583 : } else {
584 0 : return SUMO_TAG_NOTHING;
585 : }
586 : } else {
587 : return SUMO_TAG_NOTHING;
588 : }
589 : }
590 :
591 :
592 : SumoXMLTag
593 0 : CommonXMLStructure::PlanParameters::getTransportTag() const {
594 0 : if (isSingleEdgePlan()) {
595 : return GNE_TAG_TRANSPORT_EDGE_EDGE;
596 0 : } else if (!fromEdge.empty()) {
597 0 : if (!toEdge.empty()) {
598 : return GNE_TAG_TRANSPORT_EDGE_EDGE;
599 0 : } else if (!toBusStop.empty()) {
600 : return GNE_TAG_TRANSPORT_EDGE_BUSSTOP;
601 0 : } else if (!toTrainStop.empty()) {
602 : return GNE_TAG_TRANSPORT_EDGE_TRAINSTOP;
603 0 : } else if (!toContainerStop.empty()) {
604 : return GNE_TAG_TRANSPORT_EDGE_CONTAINERSTOP;
605 0 : } else if (!toChargingStation.empty()) {
606 : return GNE_TAG_TRANSPORT_EDGE_CHARGINGSTATION;
607 0 : } else if (!toParkingArea.empty()) {
608 : return GNE_TAG_TRANSPORT_EDGE_PARKINGAREA;
609 : } else {
610 0 : return SUMO_TAG_NOTHING;
611 : }
612 0 : } else if (!fromBusStop.empty()) {
613 0 : if (!toEdge.empty()) {
614 : return GNE_TAG_TRANSPORT_BUSSTOP_EDGE;
615 0 : } else if (!toBusStop.empty()) {
616 : return GNE_TAG_TRANSPORT_BUSSTOP_BUSSTOP;
617 0 : } else if (!toTrainStop.empty()) {
618 : return GNE_TAG_TRANSPORT_BUSSTOP_TRAINSTOP;
619 0 : } else if (!toContainerStop.empty()) {
620 : return GNE_TAG_TRANSPORT_BUSSTOP_CONTAINERSTOP;
621 0 : } else if (!toChargingStation.empty()) {
622 : return GNE_TAG_TRANSPORT_BUSSTOP_CHARGINGSTATION;
623 0 : } else if (!toParkingArea.empty()) {
624 : return GNE_TAG_TRANSPORT_BUSSTOP_PARKINGAREA;
625 : } else {
626 0 : return SUMO_TAG_NOTHING;
627 : }
628 0 : } else if (!fromTrainStop.empty()) {
629 0 : if (!toEdge.empty()) {
630 : return GNE_TAG_TRANSPORT_TRAINSTOP_EDGE;
631 0 : } else if (!toBusStop.empty()) {
632 : return GNE_TAG_TRANSPORT_TRAINSTOP_BUSSTOP;
633 0 : } else if (!toTrainStop.empty()) {
634 : return GNE_TAG_TRANSPORT_TRAINSTOP_TRAINSTOP;
635 0 : } else if (!toContainerStop.empty()) {
636 : return GNE_TAG_TRANSPORT_TRAINSTOP_CONTAINERSTOP;
637 0 : } else if (!toChargingStation.empty()) {
638 : return GNE_TAG_TRANSPORT_TRAINSTOP_CHARGINGSTATION;
639 0 : } else if (!toParkingArea.empty()) {
640 : return GNE_TAG_TRANSPORT_TRAINSTOP_PARKINGAREA;
641 : } else {
642 0 : return SUMO_TAG_NOTHING;
643 : }
644 0 : } else if (!fromContainerStop.empty()) {
645 0 : if (!toEdge.empty()) {
646 : return GNE_TAG_TRANSPORT_CONTAINERSTOP_EDGE;
647 0 : } else if (!toBusStop.empty()) {
648 : return GNE_TAG_TRANSPORT_CONTAINERSTOP_BUSSTOP;
649 0 : } else if (!toTrainStop.empty()) {
650 : return GNE_TAG_TRANSPORT_CONTAINERSTOP_TRAINSTOP;
651 0 : } else if (!toContainerStop.empty()) {
652 : return GNE_TAG_TRANSPORT_CONTAINERSTOP_CONTAINERSTOP;
653 0 : } else if (!toChargingStation.empty()) {
654 : return GNE_TAG_TRANSPORT_CONTAINERSTOP_CHARGINGSTATION;
655 0 : } else if (!toParkingArea.empty()) {
656 : return GNE_TAG_TRANSPORT_CONTAINERSTOP_PARKINGAREA;
657 : } else {
658 0 : return SUMO_TAG_NOTHING;
659 : }
660 0 : } else if (!fromChargingStation.empty()) {
661 0 : if (!toEdge.empty()) {
662 : return GNE_TAG_TRANSPORT_CHARGINGSTATION_EDGE;
663 0 : } else if (!toBusStop.empty()) {
664 : return GNE_TAG_TRANSPORT_CHARGINGSTATION_BUSSTOP;
665 0 : } else if (!toTrainStop.empty()) {
666 : return GNE_TAG_TRANSPORT_CHARGINGSTATION_TRAINSTOP;
667 0 : } else if (!toContainerStop.empty()) {
668 : return GNE_TAG_TRANSPORT_CHARGINGSTATION_CONTAINERSTOP;
669 0 : } else if (!toChargingStation.empty()) {
670 : return GNE_TAG_TRANSPORT_CHARGINGSTATION_CHARGINGSTATION;
671 0 : } else if (!toParkingArea.empty()) {
672 : return GNE_TAG_TRANSPORT_CHARGINGSTATION_PARKINGAREA;
673 : } else {
674 0 : return SUMO_TAG_NOTHING;
675 : }
676 0 : } else if (!fromParkingArea.empty()) {
677 0 : if (!toEdge.empty()) {
678 : return GNE_TAG_TRANSPORT_PARKINGAREA_EDGE;
679 0 : } else if (!toBusStop.empty()) {
680 : return GNE_TAG_TRANSPORT_PARKINGAREA_BUSSTOP;
681 0 : } else if (!toTrainStop.empty()) {
682 : return GNE_TAG_TRANSPORT_PARKINGAREA_TRAINSTOP;
683 0 : } else if (!toContainerStop.empty()) {
684 : return GNE_TAG_TRANSPORT_PARKINGAREA_CONTAINERSTOP;
685 0 : } else if (!toChargingStation.empty()) {
686 : return GNE_TAG_TRANSPORT_PARKINGAREA_CHARGINGSTATION;
687 0 : } else if (!toParkingArea.empty()) {
688 : return GNE_TAG_TRANSPORT_PARKINGAREA_PARKINGAREA;
689 : } else {
690 0 : return SUMO_TAG_NOTHING;
691 : }
692 : } else {
693 : return SUMO_TAG_NOTHING;
694 : }
695 : }
696 :
697 :
698 : SumoXMLTag
699 0 : CommonXMLStructure::PlanParameters::getTranshipTag() const {
700 0 : if (isSingleEdgePlan()) {
701 : return GNE_TAG_TRANSHIP_EDGE_EDGE;
702 0 : } else if (consecutiveEdges.size() > 0) {
703 : return GNE_TAG_TRANSHIP_EDGES;
704 0 : } else if (!fromEdge.empty()) {
705 0 : if (!toEdge.empty()) {
706 : return GNE_TAG_TRANSHIP_EDGE_EDGE;
707 0 : } else if (!toBusStop.empty()) {
708 : return GNE_TAG_TRANSHIP_EDGE_BUSSTOP;
709 0 : } else if (!toTrainStop.empty()) {
710 : return GNE_TAG_TRANSHIP_EDGE_TRAINSTOP;
711 0 : } else if (!toContainerStop.empty()) {
712 : return GNE_TAG_TRANSHIP_EDGE_CONTAINERSTOP;
713 0 : } else if (!toChargingStation.empty()) {
714 : return GNE_TAG_TRANSHIP_EDGE_CHARGINGSTATION;
715 0 : } else if (!toParkingArea.empty()) {
716 : return GNE_TAG_TRANSHIP_EDGE_PARKINGAREA;
717 : } else {
718 0 : return SUMO_TAG_NOTHING;
719 : }
720 0 : } else if (!fromBusStop.empty()) {
721 0 : if (!toEdge.empty()) {
722 : return GNE_TAG_TRANSHIP_BUSSTOP_EDGE;
723 0 : } else if (!toBusStop.empty()) {
724 : return GNE_TAG_TRANSHIP_BUSSTOP_BUSSTOP;
725 0 : } else if (!toTrainStop.empty()) {
726 : return GNE_TAG_TRANSHIP_BUSSTOP_TRAINSTOP;
727 0 : } else if (!toContainerStop.empty()) {
728 : return GNE_TAG_TRANSHIP_BUSSTOP_CONTAINERSTOP;
729 0 : } else if (!toChargingStation.empty()) {
730 : return GNE_TAG_TRANSHIP_BUSSTOP_CHARGINGSTATION;
731 0 : } else if (!toParkingArea.empty()) {
732 : return GNE_TAG_TRANSHIP_BUSSTOP_PARKINGAREA;
733 : } else {
734 0 : return SUMO_TAG_NOTHING;
735 : }
736 0 : } else if (!fromTrainStop.empty()) {
737 0 : if (!toEdge.empty()) {
738 : return GNE_TAG_TRANSHIP_TRAINSTOP_EDGE;
739 0 : } else if (!toBusStop.empty()) {
740 : return GNE_TAG_TRANSHIP_TRAINSTOP_BUSSTOP;
741 0 : } else if (!toTrainStop.empty()) {
742 : return GNE_TAG_TRANSHIP_TRAINSTOP_TRAINSTOP;
743 0 : } else if (!toContainerStop.empty()) {
744 : return GNE_TAG_TRANSHIP_TRAINSTOP_CONTAINERSTOP;
745 0 : } else if (!toChargingStation.empty()) {
746 : return GNE_TAG_TRANSHIP_TRAINSTOP_CHARGINGSTATION;
747 0 : } else if (!toParkingArea.empty()) {
748 : return GNE_TAG_TRANSHIP_TRAINSTOP_PARKINGAREA;
749 : } else {
750 0 : return SUMO_TAG_NOTHING;
751 : }
752 0 : } else if (!fromContainerStop.empty()) {
753 0 : if (!toEdge.empty()) {
754 : return GNE_TAG_TRANSHIP_CONTAINERSTOP_EDGE;
755 0 : } else if (!toBusStop.empty()) {
756 : return GNE_TAG_TRANSHIP_CONTAINERSTOP_BUSSTOP;
757 0 : } else if (!toTrainStop.empty()) {
758 : return GNE_TAG_TRANSHIP_CONTAINERSTOP_TRAINSTOP;
759 0 : } else if (!toContainerStop.empty()) {
760 : return GNE_TAG_TRANSHIP_CONTAINERSTOP_CONTAINERSTOP;
761 0 : } else if (!toChargingStation.empty()) {
762 : return GNE_TAG_TRANSHIP_CONTAINERSTOP_CHARGINGSTATION;
763 0 : } else if (!toParkingArea.empty()) {
764 : return GNE_TAG_TRANSHIP_CONTAINERSTOP_PARKINGAREA;
765 : } else {
766 0 : return SUMO_TAG_NOTHING;
767 : }
768 0 : } else if (!fromChargingStation.empty()) {
769 0 : if (!toEdge.empty()) {
770 : return GNE_TAG_TRANSHIP_CHARGINGSTATION_EDGE;
771 0 : } else if (!toBusStop.empty()) {
772 : return GNE_TAG_TRANSHIP_CHARGINGSTATION_BUSSTOP;
773 0 : } else if (!toTrainStop.empty()) {
774 : return GNE_TAG_TRANSHIP_CHARGINGSTATION_TRAINSTOP;
775 0 : } else if (!toContainerStop.empty()) {
776 : return GNE_TAG_TRANSHIP_CHARGINGSTATION_CONTAINERSTOP;
777 0 : } else if (!toChargingStation.empty()) {
778 : return GNE_TAG_TRANSHIP_CHARGINGSTATION_CHARGINGSTATION;
779 0 : } else if (!toParkingArea.empty()) {
780 : return GNE_TAG_TRANSHIP_CHARGINGSTATION_PARKINGAREA;
781 : } else {
782 0 : return SUMO_TAG_NOTHING;
783 : }
784 0 : } else if (!fromParkingArea.empty()) {
785 0 : if (!toEdge.empty()) {
786 : return GNE_TAG_TRANSHIP_PARKINGAREA_EDGE;
787 0 : } else if (!toBusStop.empty()) {
788 : return GNE_TAG_TRANSHIP_PARKINGAREA_BUSSTOP;
789 0 : } else if (!toTrainStop.empty()) {
790 : return GNE_TAG_TRANSHIP_PARKINGAREA_TRAINSTOP;
791 0 : } else if (!toContainerStop.empty()) {
792 : return GNE_TAG_TRANSHIP_PARKINGAREA_CONTAINERSTOP;
793 0 : } else if (!toChargingStation.empty()) {
794 : return GNE_TAG_TRANSHIP_PARKINGAREA_CHARGINGSTATION;
795 0 : } else if (!toParkingArea.empty()) {
796 : return GNE_TAG_TRANSHIP_PARKINGAREA_PARKINGAREA;
797 : } else {
798 0 : return SUMO_TAG_NOTHING;
799 : }
800 : } else {
801 : return SUMO_TAG_NOTHING;
802 : }
803 : }
804 :
805 :
806 : SumoXMLTag
807 0 : CommonXMLStructure::PlanParameters::getPersonStopTag() const {
808 0 : if (!toEdge.empty()) {
809 : return GNE_TAG_STOPPERSON_EDGE;
810 0 : } else if (!toBusStop.empty()) {
811 : return GNE_TAG_STOPPERSON_BUSSTOP;
812 0 : } else if (!toTrainStop.empty()) {
813 : return GNE_TAG_STOPPERSON_TRAINSTOP;
814 0 : } else if (!toContainerStop.empty()) {
815 : return GNE_TAG_STOPPERSON_CONTAINERSTOP;
816 0 : } else if (!toChargingStation.empty()) {
817 : return GNE_TAG_STOPPERSON_CHARGINGSTATION;
818 0 : } else if (!toParkingArea.empty()) {
819 : return GNE_TAG_STOPPERSON_PARKINGAREA;
820 : } else {
821 0 : return SUMO_TAG_NOTHING;
822 : }
823 : }
824 :
825 :
826 : SumoXMLTag
827 0 : CommonXMLStructure::PlanParameters::getContainerStopTag() const {
828 0 : if (!toEdge.empty()) {
829 : return GNE_TAG_STOPCONTAINER_EDGE;
830 0 : } else if (!toBusStop.empty()) {
831 : return GNE_TAG_STOPCONTAINER_BUSSTOP;
832 0 : } else if (!toTrainStop.empty()) {
833 : return GNE_TAG_STOPCONTAINER_TRAINSTOP;
834 0 : } else if (!toContainerStop.empty()) {
835 : return GNE_TAG_STOPCONTAINER_CONTAINERSTOP;
836 0 : } else if (!toChargingStation.empty()) {
837 : return GNE_TAG_STOPCONTAINER_CHARGINGSTATION;
838 0 : } else if (!toParkingArea.empty()) {
839 : return GNE_TAG_STOPCONTAINER_PARKINGAREA;
840 : } else {
841 0 : return SUMO_TAG_NOTHING;
842 : }
843 : }
844 :
845 :
846 :
847 : const CommonXMLStructure::SumoBaseObject*
848 0 : CommonXMLStructure::PlanParameters::getPreviousPlanObj(const CommonXMLStructure::SumoBaseObject* sumoBaseObject) const {
849 : // first check if object exist
850 0 : if (sumoBaseObject == nullptr) {
851 : return nullptr;
852 : }
853 : // check if object has parent
854 0 : const CommonXMLStructure::SumoBaseObject* parentObject = sumoBaseObject->getParentSumoBaseObject();
855 0 : if (parentObject == nullptr) {
856 : return nullptr;
857 : }
858 : // check number of children
859 0 : if (parentObject->getSumoBaseObjectChildren().size() < 2) {
860 : return nullptr;
861 : }
862 : // search position of the given plan obj in the parent children
863 0 : const auto objIterator = std::find(parentObject->getSumoBaseObjectChildren().begin(), parentObject->getSumoBaseObjectChildren().end(), sumoBaseObject);
864 : // if obj is the first plan of person/container parent, then return null. If not, return previous object
865 0 : if (objIterator == parentObject->getSumoBaseObjectChildren().begin()) {
866 : return nullptr;
867 : } else {
868 0 : return *(objIterator - 1);
869 : }
870 : }
871 :
872 :
873 : void
874 0 : CommonXMLStructure::PlanParameters::updateFromAttributes(const CommonXMLStructure::SumoBaseObject* sumoBaseObject) {
875 : // check if previous plan object was defined but not the from
876 0 : const auto previousPlanObj = getPreviousPlanObj(sumoBaseObject);
877 0 : if (previousPlanObj) {
878 : // ge previous plan parameters
879 0 : const auto previousPlanParameters = previousPlanObj->getPlanParameters();
880 0 : if (!previousPlanParameters.toEdge.empty()) {
881 : // edge (to)
882 0 : resetPreviousFromAttributes(previousPlanObj, "edge", previousPlanParameters.toEdge);
883 0 : fromEdge = previousPlanParameters.toEdge;
884 0 : } else if (!previousPlanParameters.consecutiveEdges.empty()) {
885 : // consecutive edge
886 0 : resetPreviousFromAttributes(previousPlanObj, "consecutive edge", previousPlanParameters.consecutiveEdges.back());
887 0 : fromEdge = previousPlanParameters.consecutiveEdges.back();
888 0 : } else if (!previousPlanParameters.toRoute.empty()) {
889 : // route
890 0 : resetPreviousFromAttributes(previousPlanObj, "route edge", previousPlanParameters.toRoute);
891 0 : fromRoute = previousPlanParameters.toRoute;
892 0 : } else if (!previousPlanParameters.toJunction.empty()) {
893 : // junction
894 0 : resetPreviousFromAttributes(previousPlanObj, "junction", previousPlanParameters.toJunction);
895 0 : fromJunction = previousPlanParameters.toJunction;
896 0 : } else if (!previousPlanParameters.toTAZ.empty()) {
897 : // TAZ
898 0 : resetPreviousFromAttributes(previousPlanObj, "TAZ", previousPlanParameters.toTAZ);
899 0 : fromTAZ = previousPlanParameters.toTAZ;
900 0 : } else if (!previousPlanParameters.toBusStop.empty()) {
901 : // busStop
902 0 : resetPreviousFromAttributes(previousPlanObj, "bus stop", previousPlanParameters.toBusStop);
903 0 : fromBusStop = previousPlanParameters.toBusStop;
904 0 : } else if (!previousPlanParameters.toTrainStop.empty()) {
905 : // trainStop
906 0 : resetPreviousFromAttributes(previousPlanObj, "train stop", previousPlanParameters.toTrainStop);
907 0 : fromTrainStop = previousPlanParameters.toTrainStop;
908 0 : } else if (!previousPlanParameters.toContainerStop.empty()) {
909 : // containerStop
910 0 : resetPreviousFromAttributes(previousPlanObj, "container stop", previousPlanParameters.toContainerStop);
911 0 : fromContainerStop = previousPlanParameters.toContainerStop;
912 0 : } else if (!previousPlanParameters.toChargingStation.empty()) {
913 : // chargingStation
914 0 : resetPreviousFromAttributes(previousPlanObj, "charging station", previousPlanParameters.toChargingStation);
915 0 : fromChargingStation = previousPlanParameters.toChargingStation;
916 0 : } else if (!previousPlanParameters.toParkingArea.empty()) {
917 : // parkingArea
918 0 : resetPreviousFromAttributes(previousPlanObj, "parking area", previousPlanParameters.toParkingArea);
919 0 : fromParkingArea = previousPlanParameters.toParkingArea;
920 : }
921 0 : }
922 0 : }
923 :
924 :
925 : void
926 0 : CommonXMLStructure::PlanParameters::resetPreviousFromAttributes(const CommonXMLStructure::SumoBaseObject* previousPlanObj,
927 : const std::string& newType, const std::string& newId) const {
928 0 : if (!fromEdge.empty()) {
929 0 : writeIgnoringMessage(previousPlanObj, "edge", fromEdge, newType, newId);
930 : }
931 0 : if (!fromJunction.empty()) {
932 0 : writeIgnoringMessage(previousPlanObj, "junction", fromJunction, newType, newId);
933 : }
934 0 : if (!fromTAZ.empty()) {
935 0 : writeIgnoringMessage(previousPlanObj, "TAZ", fromTAZ, newType, newId);
936 : }
937 0 : if (!fromBusStop.empty()) {
938 0 : writeIgnoringMessage(previousPlanObj, "bus stop", fromBusStop, newType, newId);
939 : }
940 0 : if (!fromTrainStop.empty()) {
941 0 : writeIgnoringMessage(previousPlanObj, "train stop", fromTrainStop, newType, newId);
942 : }
943 0 : if (!fromContainerStop.empty()) {
944 0 : writeIgnoringMessage(previousPlanObj, "container stop", fromContainerStop, newType, newId);
945 : }
946 0 : if (!fromChargingStation.empty()) {
947 0 : writeIgnoringMessage(previousPlanObj, "charging station", fromChargingStation, newType, newId);
948 : }
949 0 : if (!fromParkingArea.empty()) {
950 0 : writeIgnoringMessage(previousPlanObj, "parking area", fromParkingArea, newType, newId);
951 : }
952 0 : }
953 :
954 :
955 : void
956 0 : CommonXMLStructure::PlanParameters::writeIgnoringMessage(const CommonXMLStructure::SumoBaseObject* previousPlanObj,
957 : const std::string& oldType, const std::string& oldId, const std::string& newType, const std::string& newId) const {
958 0 : WRITE_WARNING(TLF("Ignoring from % '%' used in % '%' and using instead the previous end element % '%'",
959 : oldType, oldId,
960 : toString(previousPlanObj->getParentSumoBaseObject()->getTag()),
961 : previousPlanObj->getParentSumoBaseObject()->getStringAttribute(SUMO_ATTR_ID),
962 : newType, newId));
963 0 : }
964 :
965 : // ---------------------------------------------------------------------------
966 : // CommonXMLStructure::SumoBaseObject - methods
967 : // ---------------------------------------------------------------------------
968 :
969 0 : CommonXMLStructure::SumoBaseObject::SumoBaseObject(SumoBaseObject* parent) :
970 0 : mySumoBaseObjectParent(parent),
971 0 : myVehicleTypeParameter("") {
972 : // add this SumoBaseObject into parent children
973 0 : if (mySumoBaseObjectParent) {
974 0 : mySumoBaseObjectParent->addSumoBaseObjectChild(this);
975 : }
976 0 : }
977 :
978 :
979 0 : CommonXMLStructure::SumoBaseObject::~SumoBaseObject() {
980 : // remove this SumoBaseObject from parent children
981 0 : if (mySumoBaseObjectParent) {
982 0 : mySumoBaseObjectParent->removeSumoBaseObjectChild(this);
983 : }
984 : // delete all SumoBaseObjectChildrens
985 0 : while (mySumoBaseObjectChildren.size() > 0) {
986 0 : delete mySumoBaseObjectChildren.back();
987 : }
988 0 : }
989 :
990 :
991 : void
992 0 : CommonXMLStructure::SumoBaseObject::clear() {
993 : // reset tag
994 0 : myTag = SUMO_TAG_NOTHING;
995 : // reset vClass
996 0 : myVClass = SVC_IGNORING;
997 : // clear containers
998 : myStringAttributes.clear();
999 : myIntAttributes.clear();
1000 : myDoubleAttributes.clear();
1001 : myBoolAttributes.clear();
1002 : myPositionAttributes.clear();
1003 : myTimeAttributes.clear();
1004 : myColorAttributes.clear();
1005 : myStringListAttributes.clear();
1006 : myDoubleListAttributes.clear();
1007 : myPositionVectorAttributes.clear();
1008 : myParentIDs.clear();
1009 : myParameters.clear();
1010 : mySumoBaseObjectChildren.clear();
1011 : // reset flags
1012 0 : myDefinedVehicleTypeParameter = false;
1013 0 : myDefinedVehicleParameter = false;
1014 0 : myDefinedStopParameter = false;
1015 : // delete all SumoBaseObjectChildrens
1016 0 : while (mySumoBaseObjectChildren.size() > 0) {
1017 0 : delete mySumoBaseObjectChildren.back();
1018 : }
1019 0 : }
1020 :
1021 :
1022 : void
1023 0 : CommonXMLStructure::SumoBaseObject::setTag(const SumoXMLTag tag) {
1024 0 : myTag = tag;
1025 0 : }
1026 :
1027 :
1028 : void
1029 0 : CommonXMLStructure::SumoBaseObject::markAsCreated() {
1030 0 : myWasCreated = true;
1031 0 : }
1032 :
1033 :
1034 : SumoXMLTag
1035 0 : CommonXMLStructure::SumoBaseObject::getTag() const {
1036 0 : return myTag;
1037 : }
1038 :
1039 :
1040 : bool
1041 0 : CommonXMLStructure::SumoBaseObject::wasCreated() const {
1042 0 : return myWasCreated;
1043 : }
1044 :
1045 :
1046 : CommonXMLStructure::SumoBaseObject*
1047 0 : CommonXMLStructure::SumoBaseObject::getParentSumoBaseObject() const {
1048 0 : return mySumoBaseObjectParent;
1049 : }
1050 :
1051 :
1052 : std::map<std::string, std::string>
1053 0 : CommonXMLStructure::SumoBaseObject::getAllAttributes() const {
1054 : std::map<std::string, std::string> result;
1055 0 : for (const auto& attr : myStringAttributes) {
1056 0 : result[toString(attr.first)] = attr.second;
1057 : }
1058 0 : for (const auto& attr : myIntAttributes) {
1059 0 : result[toString(attr.first)] = toString(attr.second);
1060 : }
1061 0 : for (const auto& attr : myDoubleAttributes) {
1062 0 : result[toString(attr.first)] = toString(attr.second);
1063 : }
1064 0 : for (const auto& attr : myBoolAttributes) {
1065 0 : result[toString(attr.first)] = toString(attr.second);
1066 : }
1067 0 : for (const auto& attr : myPositionAttributes) {
1068 0 : result[toString(attr.first)] = toString(attr.second);
1069 : }
1070 0 : for (const auto& attr : myTimeAttributes) {
1071 0 : result[toString(attr.first)] = time2string(attr.second);
1072 : }
1073 0 : for (const auto& attr : myColorAttributes) {
1074 0 : result[toString(attr.first)] = toString(attr.second);
1075 : }
1076 0 : for (const auto& attr : myStringListAttributes) {
1077 0 : result[toString(attr.first)] = toString(attr.second);
1078 : }
1079 0 : for (const auto& attr : myDoubleListAttributes) {
1080 0 : result[toString(attr.first)] = toString(attr.second);
1081 : }
1082 0 : for (const auto& attr : myPositionVectorAttributes) {
1083 0 : result[toString(attr.first)] = toString(attr.second);
1084 : }
1085 0 : return result;
1086 : }
1087 :
1088 :
1089 : const std::string&
1090 0 : CommonXMLStructure::SumoBaseObject::getStringAttribute(const SumoXMLAttr attr) const {
1091 0 : if (hasStringAttribute(attr)) {
1092 0 : return myStringAttributes.at(attr);
1093 : } else {
1094 0 : handleAttributeError(attr, "string");
1095 0 : throw ProcessError();
1096 : }
1097 : }
1098 :
1099 :
1100 : int
1101 0 : CommonXMLStructure::SumoBaseObject::getIntAttribute(const SumoXMLAttr attr) const {
1102 0 : if (hasIntAttribute(attr)) {
1103 0 : return myIntAttributes.at(attr);
1104 : } else {
1105 0 : handleAttributeError(attr, "int");
1106 0 : throw ProcessError();
1107 : }
1108 : }
1109 :
1110 :
1111 : double
1112 0 : CommonXMLStructure::SumoBaseObject::getDoubleAttribute(const SumoXMLAttr attr) const {
1113 0 : if (hasDoubleAttribute(attr)) {
1114 0 : return myDoubleAttributes.at(attr);
1115 : } else {
1116 0 : handleAttributeError(attr, "double");
1117 0 : throw ProcessError();
1118 : }
1119 : }
1120 :
1121 :
1122 : bool
1123 0 : CommonXMLStructure::SumoBaseObject::getBoolAttribute(const SumoXMLAttr attr) const {
1124 0 : if (hasBoolAttribute(attr)) {
1125 0 : return myBoolAttributes.at(attr);
1126 : } else {
1127 0 : handleAttributeError(attr, "bool");
1128 0 : throw ProcessError();
1129 : }
1130 : }
1131 :
1132 :
1133 : const Position&
1134 0 : CommonXMLStructure::SumoBaseObject::getPositionAttribute(const SumoXMLAttr attr) const {
1135 0 : if (hasPositionAttribute(attr)) {
1136 0 : return myPositionAttributes.at(attr);
1137 : } else {
1138 0 : handleAttributeError(attr, "position");
1139 0 : throw ProcessError();
1140 : }
1141 : }
1142 :
1143 :
1144 : SUMOTime
1145 0 : CommonXMLStructure::SumoBaseObject::getTimeAttribute(const SumoXMLAttr attr) const {
1146 0 : if (hasTimeAttribute(attr)) {
1147 0 : return myTimeAttributes.at(attr);
1148 : } else {
1149 0 : handleAttributeError(attr, "time");
1150 0 : throw ProcessError();
1151 : }
1152 : }
1153 :
1154 :
1155 : SUMOTime
1156 0 : CommonXMLStructure::SumoBaseObject::getPeriodAttribute() const {
1157 0 : SumoXMLAttr attr = SUMO_ATTR_PERIOD;
1158 0 : if (hasTimeAttribute(attr)) {
1159 0 : return myTimeAttributes.at(attr);
1160 : } else {
1161 : // try 'freq' as alias for 'period'
1162 0 : attr = SUMO_ATTR_FREQUENCY;
1163 0 : if (hasTimeAttribute(attr)) {
1164 0 : return myTimeAttributes.at(attr);
1165 : }
1166 0 : handleAttributeError(SUMO_ATTR_PERIOD, "time");
1167 0 : throw ProcessError();
1168 : }
1169 : }
1170 :
1171 :
1172 : const RGBColor&
1173 0 : CommonXMLStructure::SumoBaseObject::getColorAttribute(const SumoXMLAttr attr) const {
1174 0 : if (hasColorAttribute(attr)) {
1175 0 : return myColorAttributes.at(attr);
1176 : } else {
1177 0 : handleAttributeError(attr, "color");
1178 0 : throw ProcessError();
1179 : }
1180 : }
1181 :
1182 :
1183 : const std::vector<std::string>&
1184 0 : CommonXMLStructure::SumoBaseObject::getStringListAttribute(const SumoXMLAttr attr) const {
1185 0 : if (hasStringListAttribute(attr)) {
1186 0 : return myStringListAttributes.at(attr);
1187 : } else {
1188 0 : handleAttributeError(attr, "string list");
1189 0 : throw ProcessError();
1190 : }
1191 : }
1192 :
1193 :
1194 : const std::vector<double>&
1195 0 : CommonXMLStructure::SumoBaseObject::getDoubleListAttribute(const SumoXMLAttr attr) const {
1196 0 : if (hasDoubleListAttribute(attr)) {
1197 0 : return myDoubleListAttributes.at(attr);
1198 : } else {
1199 0 : handleAttributeError(attr, "double list");
1200 0 : throw ProcessError();
1201 : }
1202 : }
1203 :
1204 :
1205 : const PositionVector&
1206 0 : CommonXMLStructure::SumoBaseObject::getPositionVectorAttribute(const SumoXMLAttr attr) const {
1207 0 : if (hasPositionVectorAttribute(attr)) {
1208 0 : return myPositionVectorAttributes.at(attr);
1209 : } else {
1210 0 : handleAttributeError(attr, "position vector");
1211 0 : throw ProcessError();
1212 : }
1213 : }
1214 :
1215 : const std::string&
1216 0 : CommonXMLStructure::SumoBaseObject::getParentID(const SumoXMLTag tag) const {
1217 0 : if (hasParentID(tag)) {
1218 0 : return myParentIDs.at(tag);
1219 : } else {
1220 0 : WRITE_ERRORF(TL("Trying to get undefined parent '%' in SUMOBaseObject '%'"), toString(tag), toString(myTag));
1221 0 : throw ProcessError();
1222 : }
1223 : }
1224 :
1225 :
1226 : SUMOVehicleClass
1227 0 : CommonXMLStructure::SumoBaseObject::getVClass() const {
1228 0 : return myVClass;
1229 : }
1230 :
1231 :
1232 : const SUMOVTypeParameter&
1233 0 : CommonXMLStructure::SumoBaseObject::getVehicleTypeParameter() const {
1234 0 : if (myDefinedVehicleTypeParameter) {
1235 0 : return myVehicleTypeParameter;
1236 : } else {
1237 0 : throw ProcessError(TL("Undefined vehicleType parameter"));
1238 : }
1239 : }
1240 :
1241 :
1242 : const SUMOVehicleParameter&
1243 0 : CommonXMLStructure::SumoBaseObject::getVehicleParameter() const {
1244 0 : if (myDefinedVehicleParameter) {
1245 0 : return myVehicleParameter;
1246 : } else {
1247 0 : throw ProcessError(TL("Undefined vehicle parameter"));
1248 : }
1249 : }
1250 :
1251 :
1252 : const SUMOVehicleParameter::Stop&
1253 0 : CommonXMLStructure::SumoBaseObject::getStopParameter() const {
1254 0 : if (myDefinedStopParameter) {
1255 0 : return myStopParameter;
1256 : } else {
1257 0 : throw ProcessError(TL("Undefined stop parameter"));
1258 : }
1259 :
1260 : }
1261 :
1262 :
1263 : const std::map<std::string, std::string>&
1264 0 : CommonXMLStructure::SumoBaseObject::getParameters() const {
1265 0 : return myParameters;
1266 : }
1267 :
1268 :
1269 : const CommonXMLStructure::PlanParameters&
1270 0 : CommonXMLStructure::SumoBaseObject::getPlanParameters() const {
1271 0 : return myPlanParameters;
1272 : }
1273 :
1274 :
1275 : const std::vector<CommonXMLStructure::SumoBaseObject*>&
1276 0 : CommonXMLStructure::SumoBaseObject::getSumoBaseObjectChildren() const {
1277 0 : return mySumoBaseObjectChildren;
1278 : }
1279 :
1280 :
1281 : bool
1282 0 : CommonXMLStructure::SumoBaseObject::hasStringAttribute(const SumoXMLAttr attr) const {
1283 0 : return myStringAttributes.count(attr) > 0;
1284 : }
1285 :
1286 :
1287 : bool
1288 0 : CommonXMLStructure::SumoBaseObject::hasIntAttribute(const SumoXMLAttr attr) const {
1289 0 : return myIntAttributes.count(attr) > 0;
1290 : }
1291 :
1292 :
1293 : bool
1294 0 : CommonXMLStructure::SumoBaseObject::hasDoubleAttribute(const SumoXMLAttr attr) const {
1295 0 : return myDoubleAttributes.count(attr) > 0;
1296 : }
1297 :
1298 :
1299 : bool
1300 0 : CommonXMLStructure::SumoBaseObject::hasBoolAttribute(const SumoXMLAttr attr) const {
1301 0 : return myBoolAttributes.count(attr) > 0;
1302 : }
1303 :
1304 :
1305 : bool
1306 0 : CommonXMLStructure::SumoBaseObject::hasPositionAttribute(const SumoXMLAttr attr) const {
1307 0 : return myPositionAttributes.count(attr) > 0;
1308 : }
1309 :
1310 :
1311 : bool
1312 0 : CommonXMLStructure::SumoBaseObject::hasTimeAttribute(const SumoXMLAttr attr) const {
1313 0 : return myTimeAttributes.count(attr) > 0;
1314 : }
1315 :
1316 :
1317 : bool
1318 0 : CommonXMLStructure::SumoBaseObject::hasColorAttribute(const SumoXMLAttr attr) const {
1319 0 : return myColorAttributes.count(attr) > 0;
1320 : }
1321 :
1322 :
1323 : bool
1324 0 : CommonXMLStructure::SumoBaseObject::hasStringListAttribute(const SumoXMLAttr attr) const {
1325 0 : return myStringListAttributes.count(attr) > 0;
1326 : }
1327 :
1328 :
1329 : bool
1330 0 : CommonXMLStructure::SumoBaseObject::hasDoubleListAttribute(const SumoXMLAttr attr) const {
1331 0 : return myDoubleListAttributes.count(attr) > 0;
1332 : }
1333 :
1334 :
1335 : bool
1336 0 : CommonXMLStructure::SumoBaseObject::hasPositionVectorAttribute(const SumoXMLAttr attr) const {
1337 0 : return myPositionVectorAttributes.count(attr) > 0;
1338 : }
1339 :
1340 :
1341 : bool
1342 0 : CommonXMLStructure::SumoBaseObject::hasParentID(const SumoXMLTag tag) const {
1343 0 : return myParentIDs.count(tag) > 0;
1344 : }
1345 :
1346 :
1347 : void
1348 0 : CommonXMLStructure::SumoBaseObject::addStringAttribute(const SumoXMLAttr attr, const std::string& value) {
1349 0 : myStringAttributes[attr] = value;
1350 0 : }
1351 :
1352 :
1353 : void
1354 0 : CommonXMLStructure::SumoBaseObject::addIntAttribute(const SumoXMLAttr attr, const int value) {
1355 0 : myIntAttributes[attr] = value;
1356 0 : }
1357 :
1358 :
1359 : void
1360 0 : CommonXMLStructure::SumoBaseObject::addDoubleAttribute(const SumoXMLAttr attr, const double value) {
1361 0 : myDoubleAttributes[attr] = value;
1362 0 : }
1363 :
1364 :
1365 : void
1366 0 : CommonXMLStructure::SumoBaseObject::addBoolAttribute(const SumoXMLAttr attr, const bool value) {
1367 0 : myBoolAttributes[attr] = value;
1368 0 : }
1369 :
1370 :
1371 : void
1372 0 : CommonXMLStructure::SumoBaseObject::addPositionAttribute(const SumoXMLAttr attr, const Position& value) {
1373 0 : myPositionAttributes[attr] = value;
1374 0 : }
1375 :
1376 :
1377 : void
1378 0 : CommonXMLStructure::SumoBaseObject::addTimeAttribute(const SumoXMLAttr attr, const SUMOTime value) {
1379 0 : myTimeAttributes[attr] = value;
1380 0 : }
1381 :
1382 :
1383 : void
1384 0 : CommonXMLStructure::SumoBaseObject::addColorAttribute(const SumoXMLAttr attr, const RGBColor& value) {
1385 0 : myColorAttributes[attr] = value;
1386 0 : }
1387 :
1388 :
1389 : void
1390 0 : CommonXMLStructure::SumoBaseObject::addStringListAttribute(const SumoXMLAttr attr, const std::vector<std::string>& value) {
1391 0 : myStringListAttributes[attr] = value;
1392 0 : }
1393 :
1394 :
1395 : void
1396 0 : CommonXMLStructure::SumoBaseObject::addDoubleListAttribute(const SumoXMLAttr attr, const std::vector<double>& value) {
1397 0 : myDoubleListAttributes[attr] = value;
1398 0 : }
1399 :
1400 :
1401 : void
1402 0 : CommonXMLStructure::SumoBaseObject::addPositionVectorAttribute(const SumoXMLAttr attr, const PositionVector& value) {
1403 0 : myPositionVectorAttributes[attr] = value;
1404 0 : }
1405 :
1406 :
1407 : void
1408 0 : CommonXMLStructure::SumoBaseObject::addParentID(const SumoXMLTag tag, const std::string& ID) {
1409 0 : myParentIDs[tag] = ID;
1410 0 : }
1411 :
1412 :
1413 : void
1414 0 : CommonXMLStructure::SumoBaseObject::addParameters(const std::string& value) {
1415 0 : const auto parameters = StringTokenizer(value, '|').getVector();
1416 0 : for (const auto& parameter : parameters) {
1417 0 : const auto keyValue = StringTokenizer(parameter, '=').getVector();
1418 0 : addParameter(keyValue[0], keyValue[1]);
1419 0 : }
1420 0 : }
1421 :
1422 :
1423 : void
1424 0 : CommonXMLStructure::SumoBaseObject::addParameter(const std::string& key, const std::string& value) {
1425 : // check if we have to insert in vType, vehicle or stop parameters
1426 0 : if (myDefinedVehicleTypeParameter) {
1427 0 : myVehicleTypeParameter.setParameter(key, value);
1428 0 : } else if (myDefinedVehicleParameter) {
1429 0 : myVehicleParameter.setParameter(key, value);
1430 0 : } else if (myDefinedStopParameter) {
1431 0 : myStopParameter.setParameter(key, value);
1432 : } else {
1433 0 : myParameters[key] = value;
1434 : }
1435 0 : }
1436 :
1437 :
1438 : void
1439 0 : CommonXMLStructure::SumoBaseObject::setVClass(SUMOVehicleClass vClass) {
1440 0 : myVClass = vClass;
1441 0 : }
1442 :
1443 :
1444 : void
1445 0 : CommonXMLStructure::SumoBaseObject::setVehicleTypeParameter(const SUMOVTypeParameter* vehicleTypeParameter) {
1446 0 : myVehicleTypeParameter = *vehicleTypeParameter;
1447 0 : myDefinedVehicleTypeParameter = true;
1448 : // set attribute id
1449 0 : addStringAttribute(SUMO_ATTR_ID, myVehicleTypeParameter.id);
1450 0 : }
1451 :
1452 :
1453 : void
1454 0 : CommonXMLStructure::SumoBaseObject::setVehicleParameter(const SUMOVehicleParameter* vehicleParameter) {
1455 0 : myVehicleParameter = *vehicleParameter;
1456 0 : myDefinedVehicleParameter = true;
1457 : // set attribute id
1458 0 : if (!myVehicleParameter.id.empty()) {
1459 0 : addStringAttribute(SUMO_ATTR_ID, myVehicleParameter.id);
1460 : }
1461 : // set attribute route
1462 0 : if (!vehicleParameter->routeid.empty()) {
1463 0 : addStringAttribute(SUMO_ATTR_ROUTE, myVehicleParameter.routeid);
1464 : }
1465 0 : }
1466 :
1467 :
1468 : void
1469 0 : CommonXMLStructure::SumoBaseObject::setStopParameter(const SUMOVehicleParameter::Stop& stopParameter) {
1470 0 : myStopParameter = stopParameter;
1471 0 : myDefinedStopParameter = true;
1472 : // set attribute edge
1473 0 : if (!myStopParameter.edge.empty()) {
1474 0 : addStringAttribute(SUMO_ATTR_EDGE, myStopParameter.edge);
1475 : }
1476 : // set attribute lane
1477 0 : if (!myStopParameter.lane.empty()) {
1478 0 : addStringAttribute(SUMO_ATTR_LANE, myStopParameter.lane);
1479 : }
1480 : // set attribute busStop
1481 0 : if (!myStopParameter.busstop.empty()) {
1482 0 : addStringAttribute(SUMO_ATTR_BUS_STOP, myStopParameter.busstop);
1483 : }
1484 : // set attribute containerstop
1485 0 : if (!myStopParameter.containerstop.empty()) {
1486 0 : addStringAttribute(SUMO_ATTR_CONTAINER_STOP, myStopParameter.containerstop);
1487 : }
1488 : // set attribute parkingarea
1489 0 : if (!myStopParameter.parkingarea.empty()) {
1490 0 : addStringAttribute(SUMO_ATTR_PARKING_AREA, myStopParameter.parkingarea);
1491 : }
1492 : // set attribute chargingStation
1493 0 : if (!myStopParameter.chargingStation.empty()) {
1494 0 : addStringAttribute(SUMO_ATTR_CHARGING_STATION, myStopParameter.chargingStation);
1495 : }
1496 0 : }
1497 :
1498 :
1499 : void
1500 0 : CommonXMLStructure::SumoBaseObject::setPlanParameters(const CommonXMLStructure::PlanParameters& planParameters) {
1501 0 : myPlanParameters = planParameters;
1502 0 : }
1503 :
1504 : void
1505 0 : CommonXMLStructure::SumoBaseObject::addSumoBaseObjectChild(SumoBaseObject* sumoBaseObject) {
1506 : // just add it into mySumoBaseObjectChildren
1507 0 : mySumoBaseObjectChildren.push_back(sumoBaseObject);
1508 0 : }
1509 :
1510 :
1511 : void
1512 0 : CommonXMLStructure::SumoBaseObject::removeSumoBaseObjectChild(SumoBaseObject* sumoBaseObject) {
1513 : // find sumoBaseObject
1514 0 : auto it = std::find(mySumoBaseObjectChildren.begin(), mySumoBaseObjectChildren.end(), sumoBaseObject);
1515 : // check iterator
1516 0 : if (it != mySumoBaseObjectChildren.end()) {
1517 0 : mySumoBaseObjectChildren.erase(it);
1518 : }
1519 0 : }
1520 :
1521 :
1522 : void
1523 0 : CommonXMLStructure::SumoBaseObject::handleAttributeError(const SumoXMLAttr attr, const std::string& type) const {
1524 0 : WRITE_ERRORF(TL("Trying to get undefined % attribute '%' in SUMOBaseObject '%'"), type, toString(attr), toString(myTag));
1525 0 : }
1526 :
1527 : // ---------------------------------------------------------------------------
1528 : // CommonXMLStructure - methods
1529 : // ---------------------------------------------------------------------------
1530 :
1531 0 : CommonXMLStructure::CommonXMLStructure() :
1532 0 : mySumoBaseObjectRoot(nullptr),
1533 0 : myCurrentSumoBaseObject(nullptr) {
1534 :
1535 0 : }
1536 :
1537 :
1538 0 : CommonXMLStructure::~CommonXMLStructure() {
1539 : // delete mySumoBaseObjectRoot (this will also delete all SumoBaseObjectChildrens)
1540 0 : if (mySumoBaseObjectRoot) {
1541 0 : delete mySumoBaseObjectRoot;
1542 : }
1543 0 : }
1544 :
1545 :
1546 : void
1547 0 : CommonXMLStructure::openSUMOBaseOBject() {
1548 : // first check if root is empty
1549 0 : if (mySumoBaseObjectRoot == nullptr) {
1550 : // create root
1551 0 : mySumoBaseObjectRoot = new SumoBaseObject(nullptr);
1552 : // set tag
1553 0 : mySumoBaseObjectRoot->setTag(SUMO_TAG_ROOTFILE);
1554 : // update last inserted Root
1555 0 : myCurrentSumoBaseObject = mySumoBaseObjectRoot;
1556 : } else {
1557 : // create new node
1558 0 : SumoBaseObject* newSumoBaseObject = new SumoBaseObject(myCurrentSumoBaseObject);
1559 : // update last inserted node
1560 0 : myCurrentSumoBaseObject = newSumoBaseObject;
1561 : }
1562 0 : }
1563 :
1564 :
1565 : void
1566 0 : CommonXMLStructure::closeSUMOBaseOBject() {
1567 : // check that myCurrentSumoBaseObject is valid
1568 0 : if (myCurrentSumoBaseObject) {
1569 : // check if last inserted SumoBaseObject is the root
1570 0 : if (myCurrentSumoBaseObject->getParentSumoBaseObject() == nullptr) {
1571 : // reset both pointers
1572 0 : myCurrentSumoBaseObject = nullptr;
1573 0 : mySumoBaseObjectRoot = nullptr;
1574 : } else {
1575 : // update last inserted SumoBaseObject
1576 0 : myCurrentSumoBaseObject = myCurrentSumoBaseObject->getParentSumoBaseObject();
1577 : }
1578 : }
1579 0 : }
1580 :
1581 :
1582 : void
1583 0 : CommonXMLStructure::abortSUMOBaseOBject() {
1584 : // delete current sumo base object and use their parent as sumo base object
1585 0 : if (myCurrentSumoBaseObject) {
1586 0 : if (myCurrentSumoBaseObject == mySumoBaseObjectRoot) {
1587 0 : delete myCurrentSumoBaseObject;
1588 0 : myCurrentSumoBaseObject = nullptr;
1589 0 : mySumoBaseObjectRoot = nullptr;
1590 : } else {
1591 0 : auto parentSumoBaseObject = myCurrentSumoBaseObject->getParentSumoBaseObject();
1592 0 : delete myCurrentSumoBaseObject;
1593 0 : myCurrentSumoBaseObject = parentSumoBaseObject;
1594 : }
1595 : }
1596 0 : }
1597 :
1598 :
1599 : CommonXMLStructure::SumoBaseObject*
1600 0 : CommonXMLStructure::getSumoBaseObjectRoot() const {
1601 0 : return mySumoBaseObjectRoot;
1602 : }
1603 :
1604 :
1605 : CommonXMLStructure::SumoBaseObject*
1606 0 : CommonXMLStructure::getCurrentSumoBaseObject() const {
1607 0 : return myCurrentSumoBaseObject;
1608 : }
1609 :
1610 : /****************************************************************************/
|