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 (!toTAZ.empty()) {
494 : return GNE_TAG_RIDE_EDGE_TAZ;
495 0 : } else if (!toJunction.empty()) {
496 : return GNE_TAG_RIDE_EDGE_JUNCTION;
497 0 : } else if (!toBusStop.empty()) {
498 : return GNE_TAG_RIDE_EDGE_BUSSTOP;
499 0 : } else if (!toTrainStop.empty()) {
500 : return GNE_TAG_RIDE_EDGE_TRAINSTOP;
501 0 : } else if (!toContainerStop.empty()) {
502 : return GNE_TAG_RIDE_EDGE_CONTAINERSTOP;
503 0 : } else if (!toChargingStation.empty()) {
504 : return GNE_TAG_RIDE_EDGE_CHARGINGSTATION;
505 0 : } else if (!toParkingArea.empty()) {
506 : return GNE_TAG_RIDE_EDGE_PARKINGAREA;
507 : } else {
508 0 : return SUMO_TAG_NOTHING;
509 : }
510 0 : } else if (!fromTAZ.empty()) {
511 0 : if (!toEdge.empty()) {
512 : return GNE_TAG_RIDE_TAZ_EDGE;
513 0 : } else if (!toTAZ.empty()) {
514 : return GNE_TAG_RIDE_TAZ_TAZ;
515 0 : } else if (!toJunction.empty()) {
516 : return GNE_TAG_RIDE_TAZ_JUNCTION;
517 0 : } else if (!toBusStop.empty()) {
518 : return GNE_TAG_RIDE_TAZ_BUSSTOP;
519 0 : } else if (!toTrainStop.empty()) {
520 : return GNE_TAG_RIDE_TAZ_TRAINSTOP;
521 0 : } else if (!toContainerStop.empty()) {
522 : return GNE_TAG_RIDE_TAZ_CONTAINERSTOP;
523 0 : } else if (!toChargingStation.empty()) {
524 : return GNE_TAG_RIDE_TAZ_CHARGINGSTATION;
525 0 : } else if (!toParkingArea.empty()) {
526 : return GNE_TAG_RIDE_TAZ_PARKINGAREA;
527 : } else {
528 0 : return SUMO_TAG_NOTHING;
529 : }
530 0 : } else if (!fromJunction.empty()) {
531 0 : if (!toEdge.empty()) {
532 : return GNE_TAG_RIDE_JUNCTION_EDGE;
533 0 : } else if (!toTAZ.empty()) {
534 : return GNE_TAG_RIDE_JUNCTION_TAZ;
535 0 : } else if (!toJunction.empty()) {
536 : return GNE_TAG_RIDE_JUNCTION_JUNCTION;
537 0 : } else if (!toBusStop.empty()) {
538 : return GNE_TAG_RIDE_JUNCTION_BUSSTOP;
539 0 : } else if (!toTrainStop.empty()) {
540 : return GNE_TAG_RIDE_JUNCTION_TRAINSTOP;
541 0 : } else if (!toContainerStop.empty()) {
542 : return GNE_TAG_RIDE_JUNCTION_CONTAINERSTOP;
543 0 : } else if (!toChargingStation.empty()) {
544 : return GNE_TAG_RIDE_JUNCTION_CHARGINGSTATION;
545 0 : } else if (!toParkingArea.empty()) {
546 : return GNE_TAG_RIDE_JUNCTION_PARKINGAREA;
547 : } else {
548 0 : return SUMO_TAG_NOTHING;
549 : }
550 0 : } else if (!fromBusStop.empty()) {
551 0 : if (!toEdge.empty()) {
552 : return GNE_TAG_RIDE_BUSSTOP_EDGE;
553 0 : } else if (!toTAZ.empty()) {
554 : return GNE_TAG_RIDE_BUSSTOP_TAZ;
555 0 : } else if (!toJunction.empty()) {
556 : return GNE_TAG_RIDE_BUSSTOP_JUNCTION;
557 0 : } else if (!toBusStop.empty()) {
558 : return GNE_TAG_RIDE_BUSSTOP_BUSSTOP;
559 0 : } else if (!toTrainStop.empty()) {
560 : return GNE_TAG_RIDE_BUSSTOP_TRAINSTOP;
561 0 : } else if (!toContainerStop.empty()) {
562 : return GNE_TAG_RIDE_BUSSTOP_CONTAINERSTOP;
563 0 : } else if (!toChargingStation.empty()) {
564 : return GNE_TAG_RIDE_BUSSTOP_CHARGINGSTATION;
565 0 : } else if (!toParkingArea.empty()) {
566 : return GNE_TAG_RIDE_BUSSTOP_PARKINGAREA;
567 : } else {
568 0 : return SUMO_TAG_NOTHING;
569 : }
570 0 : } else if (!fromTrainStop.empty()) {
571 0 : if (!toEdge.empty()) {
572 : return GNE_TAG_RIDE_TRAINSTOP_EDGE;
573 0 : } else if (!toTAZ.empty()) {
574 : return GNE_TAG_RIDE_TRAINSTOP_TAZ;
575 0 : } else if (!toJunction.empty()) {
576 : return GNE_TAG_RIDE_TRAINSTOP_JUNCTION;
577 0 : } else if (!toBusStop.empty()) {
578 : return GNE_TAG_RIDE_TRAINSTOP_BUSSTOP;
579 0 : } else if (!toTrainStop.empty()) {
580 : return GNE_TAG_RIDE_TRAINSTOP_TRAINSTOP;
581 0 : } else if (!toContainerStop.empty()) {
582 : return GNE_TAG_RIDE_TRAINSTOP_CONTAINERSTOP;
583 0 : } else if (!toChargingStation.empty()) {
584 : return GNE_TAG_RIDE_TRAINSTOP_CHARGINGSTATION;
585 0 : } else if (!toParkingArea.empty()) {
586 : return GNE_TAG_RIDE_TRAINSTOP_PARKINGAREA;
587 : } else {
588 0 : return SUMO_TAG_NOTHING;
589 : }
590 0 : } else if (!fromContainerStop.empty()) {
591 0 : if (!toEdge.empty()) {
592 : return GNE_TAG_RIDE_CONTAINERSTOP_EDGE;
593 0 : } else if (!toTAZ.empty()) {
594 : return GNE_TAG_RIDE_CONTAINERSTOP_TAZ;
595 0 : } else if (!toJunction.empty()) {
596 : return GNE_TAG_RIDE_CONTAINERSTOP_JUNCTION;
597 0 : } else if (!toBusStop.empty()) {
598 : return GNE_TAG_RIDE_CONTAINERSTOP_BUSSTOP;
599 0 : } else if (!toTrainStop.empty()) {
600 : return GNE_TAG_RIDE_CONTAINERSTOP_TRAINSTOP;
601 0 : } else if (!toContainerStop.empty()) {
602 : return GNE_TAG_RIDE_CONTAINERSTOP_CONTAINERSTOP;
603 0 : } else if (!toChargingStation.empty()) {
604 : return GNE_TAG_RIDE_CONTAINERSTOP_CHARGINGSTATION;
605 0 : } else if (!toParkingArea.empty()) {
606 : return GNE_TAG_RIDE_CONTAINERSTOP_PARKINGAREA;
607 : } else {
608 0 : return SUMO_TAG_NOTHING;
609 : }
610 0 : } else if (!fromChargingStation.empty()) {
611 0 : if (!toEdge.empty()) {
612 : return GNE_TAG_RIDE_CHARGINGSTATION_EDGE;
613 0 : } else if (!toTAZ.empty()) {
614 : return GNE_TAG_RIDE_CHARGINGSTATION_TAZ;
615 0 : } else if (!toJunction.empty()) {
616 : return GNE_TAG_RIDE_CHARGINGSTATION_JUNCTION;
617 0 : } else if (!toBusStop.empty()) {
618 : return GNE_TAG_RIDE_CHARGINGSTATION_BUSSTOP;
619 0 : } else if (!toTrainStop.empty()) {
620 : return GNE_TAG_RIDE_CHARGINGSTATION_TRAINSTOP;
621 0 : } else if (!toContainerStop.empty()) {
622 : return GNE_TAG_RIDE_CHARGINGSTATION_CONTAINERSTOP;
623 0 : } else if (!toChargingStation.empty()) {
624 : return GNE_TAG_RIDE_CHARGINGSTATION_CHARGINGSTATION;
625 0 : } else if (!toParkingArea.empty()) {
626 : return GNE_TAG_RIDE_CHARGINGSTATION_PARKINGAREA;
627 : } else {
628 0 : return SUMO_TAG_NOTHING;
629 : }
630 0 : } else if (!fromParkingArea.empty()) {
631 0 : if (!toEdge.empty()) {
632 : return GNE_TAG_RIDE_PARKINGAREA_EDGE;
633 0 : } else if (!toTAZ.empty()) {
634 : return GNE_TAG_RIDE_PARKINGAREA_TAZ;
635 0 : } else if (!toJunction.empty()) {
636 : return GNE_TAG_RIDE_PARKINGAREA_JUNCTION;
637 0 : } else if (!toBusStop.empty()) {
638 : return GNE_TAG_RIDE_PARKINGAREA_BUSSTOP;
639 0 : } else if (!toTrainStop.empty()) {
640 : return GNE_TAG_RIDE_PARKINGAREA_TRAINSTOP;
641 0 : } else if (!toContainerStop.empty()) {
642 : return GNE_TAG_RIDE_PARKINGAREA_CONTAINERSTOP;
643 0 : } else if (!toChargingStation.empty()) {
644 : return GNE_TAG_RIDE_PARKINGAREA_CHARGINGSTATION;
645 0 : } else if (!toParkingArea.empty()) {
646 : return GNE_TAG_RIDE_PARKINGAREA_PARKINGAREA;
647 : } else {
648 0 : return SUMO_TAG_NOTHING;
649 : }
650 : } else {
651 : return SUMO_TAG_NOTHING;
652 : }
653 : }
654 :
655 :
656 : SumoXMLTag
657 0 : CommonXMLStructure::PlanParameters::getTransportTag() const {
658 0 : if (isSingleEdgePlan()) {
659 : return GNE_TAG_TRANSPORT_EDGE_EDGE;
660 0 : } else if (!fromEdge.empty()) {
661 0 : if (!toEdge.empty()) {
662 : return GNE_TAG_TRANSPORT_EDGE_EDGE;
663 0 : } else if (!toTAZ.empty()) {
664 : return GNE_TAG_TRANSPORT_EDGE_TAZ;
665 0 : } else if (!toJunction.empty()) {
666 : return GNE_TAG_TRANSPORT_EDGE_JUNCTION;
667 0 : } else if (!toBusStop.empty()) {
668 : return GNE_TAG_TRANSPORT_EDGE_BUSSTOP;
669 0 : } else if (!toTrainStop.empty()) {
670 : return GNE_TAG_TRANSPORT_EDGE_TRAINSTOP;
671 0 : } else if (!toContainerStop.empty()) {
672 : return GNE_TAG_TRANSPORT_EDGE_CONTAINERSTOP;
673 0 : } else if (!toChargingStation.empty()) {
674 : return GNE_TAG_TRANSPORT_EDGE_CHARGINGSTATION;
675 0 : } else if (!toParkingArea.empty()) {
676 : return GNE_TAG_TRANSPORT_EDGE_PARKINGAREA;
677 : } else {
678 0 : return SUMO_TAG_NOTHING;
679 : }
680 0 : } else if (!fromTAZ.empty()) {
681 0 : if (!toEdge.empty()) {
682 : return GNE_TAG_TRANSPORT_TAZ_EDGE;
683 0 : } else if (!toTAZ.empty()) {
684 : return GNE_TAG_TRANSPORT_TAZ_TAZ;
685 0 : } else if (!toJunction.empty()) {
686 : return GNE_TAG_TRANSPORT_TAZ_JUNCTION;
687 0 : } else if (!toBusStop.empty()) {
688 : return GNE_TAG_TRANSPORT_TAZ_BUSSTOP;
689 0 : } else if (!toTrainStop.empty()) {
690 : return GNE_TAG_TRANSPORT_TAZ_TRAINSTOP;
691 0 : } else if (!toContainerStop.empty()) {
692 : return GNE_TAG_TRANSPORT_TAZ_CONTAINERSTOP;
693 0 : } else if (!toChargingStation.empty()) {
694 : return GNE_TAG_TRANSPORT_TAZ_CHARGINGSTATION;
695 0 : } else if (!toParkingArea.empty()) {
696 : return GNE_TAG_TRANSPORT_TAZ_PARKINGAREA;
697 : } else {
698 0 : return SUMO_TAG_NOTHING;
699 : }
700 0 : } else if (!fromJunction.empty()) {
701 0 : if (!toEdge.empty()) {
702 : return GNE_TAG_TRANSPORT_JUNCTION_EDGE;
703 0 : } else if (!toTAZ.empty()) {
704 : return GNE_TAG_TRANSPORT_JUNCTION_TAZ;
705 0 : } else if (!toJunction.empty()) {
706 : return GNE_TAG_TRANSPORT_JUNCTION_JUNCTION;
707 0 : } else if (!toBusStop.empty()) {
708 : return GNE_TAG_TRANSPORT_JUNCTION_BUSSTOP;
709 0 : } else if (!toTrainStop.empty()) {
710 : return GNE_TAG_TRANSPORT_JUNCTION_TRAINSTOP;
711 0 : } else if (!toContainerStop.empty()) {
712 : return GNE_TAG_TRANSPORT_JUNCTION_CONTAINERSTOP;
713 0 : } else if (!toChargingStation.empty()) {
714 : return GNE_TAG_TRANSPORT_JUNCTION_CHARGINGSTATION;
715 0 : } else if (!toParkingArea.empty()) {
716 : return GNE_TAG_TRANSPORT_JUNCTION_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_TRANSPORT_BUSSTOP_EDGE;
723 0 : } else if (!toTAZ.empty()) {
724 : return GNE_TAG_TRANSPORT_BUSSTOP_TAZ;
725 0 : } else if (!toJunction.empty()) {
726 : return GNE_TAG_TRANSPORT_BUSSTOP_JUNCTION;
727 0 : } else if (!toBusStop.empty()) {
728 : return GNE_TAG_TRANSPORT_BUSSTOP_BUSSTOP;
729 0 : } else if (!toTrainStop.empty()) {
730 : return GNE_TAG_TRANSPORT_BUSSTOP_TRAINSTOP;
731 0 : } else if (!toContainerStop.empty()) {
732 : return GNE_TAG_TRANSPORT_BUSSTOP_CONTAINERSTOP;
733 0 : } else if (!toChargingStation.empty()) {
734 : return GNE_TAG_TRANSPORT_BUSSTOP_CHARGINGSTATION;
735 0 : } else if (!toParkingArea.empty()) {
736 : return GNE_TAG_TRANSPORT_BUSSTOP_PARKINGAREA;
737 : } else {
738 0 : return SUMO_TAG_NOTHING;
739 : }
740 0 : } else if (!fromTrainStop.empty()) {
741 0 : if (!toEdge.empty()) {
742 : return GNE_TAG_TRANSPORT_TRAINSTOP_EDGE;
743 0 : } else if (!toTAZ.empty()) {
744 : return GNE_TAG_TRANSPORT_TRAINSTOP_TAZ;
745 0 : } else if (!toJunction.empty()) {
746 : return GNE_TAG_TRANSPORT_TRAINSTOP_JUNCTION;
747 0 : } else if (!toBusStop.empty()) {
748 : return GNE_TAG_TRANSPORT_TRAINSTOP_BUSSTOP;
749 0 : } else if (!toTrainStop.empty()) {
750 : return GNE_TAG_TRANSPORT_TRAINSTOP_TRAINSTOP;
751 0 : } else if (!toContainerStop.empty()) {
752 : return GNE_TAG_TRANSPORT_TRAINSTOP_CONTAINERSTOP;
753 0 : } else if (!toChargingStation.empty()) {
754 : return GNE_TAG_TRANSPORT_TRAINSTOP_CHARGINGSTATION;
755 0 : } else if (!toParkingArea.empty()) {
756 : return GNE_TAG_TRANSPORT_TRAINSTOP_PARKINGAREA;
757 : } else {
758 0 : return SUMO_TAG_NOTHING;
759 : }
760 0 : } else if (!fromContainerStop.empty()) {
761 0 : if (!toEdge.empty()) {
762 : return GNE_TAG_TRANSPORT_CONTAINERSTOP_EDGE;
763 0 : } else if (!toTAZ.empty()) {
764 : return GNE_TAG_TRANSPORT_CONTAINERSTOP_TAZ;
765 0 : } else if (!toJunction.empty()) {
766 : return GNE_TAG_TRANSPORT_CONTAINERSTOP_JUNCTION;
767 0 : } else if (!toBusStop.empty()) {
768 : return GNE_TAG_TRANSPORT_CONTAINERSTOP_BUSSTOP;
769 0 : } else if (!toTrainStop.empty()) {
770 : return GNE_TAG_TRANSPORT_CONTAINERSTOP_TRAINSTOP;
771 0 : } else if (!toContainerStop.empty()) {
772 : return GNE_TAG_TRANSPORT_CONTAINERSTOP_CONTAINERSTOP;
773 0 : } else if (!toChargingStation.empty()) {
774 : return GNE_TAG_TRANSPORT_CONTAINERSTOP_CHARGINGSTATION;
775 0 : } else if (!toParkingArea.empty()) {
776 : return GNE_TAG_TRANSPORT_CONTAINERSTOP_PARKINGAREA;
777 : } else {
778 0 : return SUMO_TAG_NOTHING;
779 : }
780 0 : } else if (!fromChargingStation.empty()) {
781 0 : if (!toEdge.empty()) {
782 : return GNE_TAG_TRANSPORT_CHARGINGSTATION_EDGE;
783 0 : } else if (!toTAZ.empty()) {
784 : return GNE_TAG_TRANSPORT_CHARGINGSTATION_TAZ;
785 0 : } else if (!toJunction.empty()) {
786 : return GNE_TAG_TRANSPORT_CHARGINGSTATION_JUNCTION;
787 0 : } else if (!toBusStop.empty()) {
788 : return GNE_TAG_TRANSPORT_CHARGINGSTATION_BUSSTOP;
789 0 : } else if (!toTrainStop.empty()) {
790 : return GNE_TAG_TRANSPORT_CHARGINGSTATION_TRAINSTOP;
791 0 : } else if (!toContainerStop.empty()) {
792 : return GNE_TAG_TRANSPORT_CHARGINGSTATION_CONTAINERSTOP;
793 0 : } else if (!toChargingStation.empty()) {
794 : return GNE_TAG_TRANSPORT_CHARGINGSTATION_CHARGINGSTATION;
795 0 : } else if (!toParkingArea.empty()) {
796 : return GNE_TAG_TRANSPORT_CHARGINGSTATION_PARKINGAREA;
797 : } else {
798 0 : return SUMO_TAG_NOTHING;
799 : }
800 0 : } else if (!fromParkingArea.empty()) {
801 0 : if (!toEdge.empty()) {
802 : return GNE_TAG_TRANSPORT_PARKINGAREA_EDGE;
803 0 : } else if (!toTAZ.empty()) {
804 : return GNE_TAG_TRANSPORT_PARKINGAREA_TAZ;
805 0 : } else if (!toJunction.empty()) {
806 : return GNE_TAG_TRANSPORT_PARKINGAREA_JUNCTION;
807 0 : } else if (!toBusStop.empty()) {
808 : return GNE_TAG_TRANSPORT_PARKINGAREA_BUSSTOP;
809 0 : } else if (!toTrainStop.empty()) {
810 : return GNE_TAG_TRANSPORT_PARKINGAREA_TRAINSTOP;
811 0 : } else if (!toContainerStop.empty()) {
812 : return GNE_TAG_TRANSPORT_PARKINGAREA_CONTAINERSTOP;
813 0 : } else if (!toChargingStation.empty()) {
814 : return GNE_TAG_TRANSPORT_PARKINGAREA_CHARGINGSTATION;
815 0 : } else if (!toParkingArea.empty()) {
816 : return GNE_TAG_TRANSPORT_PARKINGAREA_PARKINGAREA;
817 : } else {
818 0 : return SUMO_TAG_NOTHING;
819 : }
820 : } else {
821 : return SUMO_TAG_NOTHING;
822 : }
823 : }
824 :
825 :
826 : SumoXMLTag
827 0 : CommonXMLStructure::PlanParameters::getTranshipTag() const {
828 0 : if (isSingleEdgePlan()) {
829 : return GNE_TAG_TRANSHIP_EDGE_EDGE;
830 0 : } else if (consecutiveEdges.size() > 0) {
831 : return GNE_TAG_TRANSHIP_EDGES;
832 0 : } else if (!fromEdge.empty()) {
833 0 : if (!toEdge.empty()) {
834 : return GNE_TAG_TRANSHIP_EDGE_EDGE;
835 0 : } else if (!toTAZ.empty()) {
836 : return GNE_TAG_TRANSHIP_EDGE_TAZ;
837 0 : } else if (!toJunction.empty()) {
838 : return GNE_TAG_TRANSHIP_EDGE_JUNCTION;
839 0 : } else if (!toBusStop.empty()) {
840 : return GNE_TAG_TRANSHIP_EDGE_BUSSTOP;
841 0 : } else if (!toTrainStop.empty()) {
842 : return GNE_TAG_TRANSHIP_EDGE_TRAINSTOP;
843 0 : } else if (!toContainerStop.empty()) {
844 : return GNE_TAG_TRANSHIP_EDGE_CONTAINERSTOP;
845 0 : } else if (!toChargingStation.empty()) {
846 : return GNE_TAG_TRANSHIP_EDGE_CHARGINGSTATION;
847 0 : } else if (!toParkingArea.empty()) {
848 : return GNE_TAG_TRANSHIP_EDGE_PARKINGAREA;
849 : } else {
850 0 : return SUMO_TAG_NOTHING;
851 : }
852 0 : } else if (!fromTAZ.empty()) {
853 0 : if (!toEdge.empty()) {
854 : return GNE_TAG_TRANSHIP_TAZ_EDGE;
855 0 : } else if (!toTAZ.empty()) {
856 : return GNE_TAG_TRANSHIP_TAZ_TAZ;
857 0 : } else if (!toJunction.empty()) {
858 : return GNE_TAG_TRANSHIP_TAZ_JUNCTION;
859 0 : } else if (!toBusStop.empty()) {
860 : return GNE_TAG_TRANSHIP_TAZ_BUSSTOP;
861 0 : } else if (!toTrainStop.empty()) {
862 : return GNE_TAG_TRANSHIP_TAZ_TRAINSTOP;
863 0 : } else if (!toContainerStop.empty()) {
864 : return GNE_TAG_TRANSHIP_TAZ_CONTAINERSTOP;
865 0 : } else if (!toChargingStation.empty()) {
866 : return GNE_TAG_TRANSHIP_TAZ_CHARGINGSTATION;
867 0 : } else if (!toParkingArea.empty()) {
868 : return GNE_TAG_TRANSHIP_TAZ_PARKINGAREA;
869 : } else {
870 0 : return SUMO_TAG_NOTHING;
871 : }
872 0 : } else if (!fromJunction.empty()) {
873 0 : if (!toEdge.empty()) {
874 : return GNE_TAG_TRANSHIP_JUNCTION_EDGE;
875 0 : } else if (!toTAZ.empty()) {
876 : return GNE_TAG_TRANSHIP_JUNCTION_TAZ;
877 0 : } else if (!toJunction.empty()) {
878 : return GNE_TAG_TRANSHIP_JUNCTION_JUNCTION;
879 0 : } else if (!toBusStop.empty()) {
880 : return GNE_TAG_TRANSHIP_JUNCTION_BUSSTOP;
881 0 : } else if (!toTrainStop.empty()) {
882 : return GNE_TAG_TRANSHIP_JUNCTION_TRAINSTOP;
883 0 : } else if (!toContainerStop.empty()) {
884 : return GNE_TAG_TRANSHIP_JUNCTION_CONTAINERSTOP;
885 0 : } else if (!toChargingStation.empty()) {
886 : return GNE_TAG_TRANSHIP_JUNCTION_CHARGINGSTATION;
887 0 : } else if (!toParkingArea.empty()) {
888 : return GNE_TAG_TRANSHIP_JUNCTION_PARKINGAREA;
889 : } else {
890 0 : return SUMO_TAG_NOTHING;
891 : }
892 0 : } else if (!fromBusStop.empty()) {
893 0 : if (!toEdge.empty()) {
894 : return GNE_TAG_TRANSHIP_BUSSTOP_EDGE;
895 0 : } else if (!toTAZ.empty()) {
896 : return GNE_TAG_TRANSHIP_BUSSTOP_TAZ;
897 0 : } else if (!toJunction.empty()) {
898 : return GNE_TAG_TRANSHIP_BUSSTOP_JUNCTION;
899 0 : } else if (!toBusStop.empty()) {
900 : return GNE_TAG_TRANSHIP_BUSSTOP_BUSSTOP;
901 0 : } else if (!toTrainStop.empty()) {
902 : return GNE_TAG_TRANSHIP_BUSSTOP_TRAINSTOP;
903 0 : } else if (!toContainerStop.empty()) {
904 : return GNE_TAG_TRANSHIP_BUSSTOP_CONTAINERSTOP;
905 0 : } else if (!toChargingStation.empty()) {
906 : return GNE_TAG_TRANSHIP_BUSSTOP_CHARGINGSTATION;
907 0 : } else if (!toParkingArea.empty()) {
908 : return GNE_TAG_TRANSHIP_BUSSTOP_PARKINGAREA;
909 : } else {
910 0 : return SUMO_TAG_NOTHING;
911 : }
912 0 : } else if (!fromTrainStop.empty()) {
913 0 : if (!toEdge.empty()) {
914 : return GNE_TAG_TRANSHIP_TRAINSTOP_EDGE;
915 0 : } else if (!toTAZ.empty()) {
916 : return GNE_TAG_TRANSHIP_TRAINSTOP_TAZ;
917 0 : } else if (!toJunction.empty()) {
918 : return GNE_TAG_TRANSHIP_TRAINSTOP_JUNCTION;
919 0 : } else if (!toBusStop.empty()) {
920 : return GNE_TAG_TRANSHIP_TRAINSTOP_BUSSTOP;
921 0 : } else if (!toTrainStop.empty()) {
922 : return GNE_TAG_TRANSHIP_TRAINSTOP_TRAINSTOP;
923 0 : } else if (!toContainerStop.empty()) {
924 : return GNE_TAG_TRANSHIP_TRAINSTOP_CONTAINERSTOP;
925 0 : } else if (!toChargingStation.empty()) {
926 : return GNE_TAG_TRANSHIP_TRAINSTOP_CHARGINGSTATION;
927 0 : } else if (!toParkingArea.empty()) {
928 : return GNE_TAG_TRANSHIP_TRAINSTOP_PARKINGAREA;
929 : } else {
930 0 : return SUMO_TAG_NOTHING;
931 : }
932 0 : } else if (!fromContainerStop.empty()) {
933 0 : if (!toEdge.empty()) {
934 : return GNE_TAG_TRANSHIP_CONTAINERSTOP_EDGE;
935 0 : } else if (!toTAZ.empty()) {
936 : return GNE_TAG_TRANSHIP_CONTAINERSTOP_TAZ;
937 0 : } else if (!toJunction.empty()) {
938 : return GNE_TAG_TRANSHIP_CONTAINERSTOP_JUNCTION;
939 0 : } else if (!toBusStop.empty()) {
940 : return GNE_TAG_TRANSHIP_CONTAINERSTOP_BUSSTOP;
941 0 : } else if (!toTrainStop.empty()) {
942 : return GNE_TAG_TRANSHIP_CONTAINERSTOP_TRAINSTOP;
943 0 : } else if (!toContainerStop.empty()) {
944 : return GNE_TAG_TRANSHIP_CONTAINERSTOP_CONTAINERSTOP;
945 0 : } else if (!toChargingStation.empty()) {
946 : return GNE_TAG_TRANSHIP_CONTAINERSTOP_CHARGINGSTATION;
947 0 : } else if (!toParkingArea.empty()) {
948 : return GNE_TAG_TRANSHIP_CONTAINERSTOP_PARKINGAREA;
949 : } else {
950 0 : return SUMO_TAG_NOTHING;
951 : }
952 0 : } else if (!fromChargingStation.empty()) {
953 0 : if (!toEdge.empty()) {
954 : return GNE_TAG_TRANSHIP_CHARGINGSTATION_EDGE;
955 0 : } else if (!toTAZ.empty()) {
956 : return GNE_TAG_TRANSHIP_CHARGINGSTATION_TAZ;
957 0 : } else if (!toJunction.empty()) {
958 : return GNE_TAG_TRANSHIP_CHARGINGSTATION_JUNCTION;
959 0 : } else if (!toBusStop.empty()) {
960 : return GNE_TAG_TRANSHIP_CHARGINGSTATION_BUSSTOP;
961 0 : } else if (!toTrainStop.empty()) {
962 : return GNE_TAG_TRANSHIP_CHARGINGSTATION_TRAINSTOP;
963 0 : } else if (!toContainerStop.empty()) {
964 : return GNE_TAG_TRANSHIP_CHARGINGSTATION_CONTAINERSTOP;
965 0 : } else if (!toChargingStation.empty()) {
966 : return GNE_TAG_TRANSHIP_CHARGINGSTATION_CHARGINGSTATION;
967 0 : } else if (!toParkingArea.empty()) {
968 : return GNE_TAG_TRANSHIP_CHARGINGSTATION_PARKINGAREA;
969 : } else {
970 0 : return SUMO_TAG_NOTHING;
971 : }
972 0 : } else if (!fromParkingArea.empty()) {
973 0 : if (!toEdge.empty()) {
974 : return GNE_TAG_TRANSHIP_PARKINGAREA_EDGE;
975 0 : } else if (!toTAZ.empty()) {
976 : return GNE_TAG_TRANSHIP_PARKINGAREA_TAZ;
977 0 : } else if (!toJunction.empty()) {
978 : return GNE_TAG_TRANSHIP_PARKINGAREA_JUNCTION;
979 0 : } else if (!toBusStop.empty()) {
980 : return GNE_TAG_TRANSHIP_PARKINGAREA_BUSSTOP;
981 0 : } else if (!toTrainStop.empty()) {
982 : return GNE_TAG_TRANSHIP_PARKINGAREA_TRAINSTOP;
983 0 : } else if (!toContainerStop.empty()) {
984 : return GNE_TAG_TRANSHIP_PARKINGAREA_CONTAINERSTOP;
985 0 : } else if (!toChargingStation.empty()) {
986 : return GNE_TAG_TRANSHIP_PARKINGAREA_CHARGINGSTATION;
987 0 : } else if (!toParkingArea.empty()) {
988 : return GNE_TAG_TRANSHIP_PARKINGAREA_PARKINGAREA;
989 : } else {
990 0 : return SUMO_TAG_NOTHING;
991 : }
992 : } else {
993 : return SUMO_TAG_NOTHING;
994 : }
995 : }
996 :
997 :
998 : SumoXMLTag
999 0 : CommonXMLStructure::PlanParameters::getPersonStopTag() const {
1000 0 : if (!toEdge.empty()) {
1001 : return GNE_TAG_STOPPERSON_EDGE;
1002 0 : } else if (!toBusStop.empty()) {
1003 : return GNE_TAG_STOPPERSON_BUSSTOP;
1004 0 : } else if (!toTrainStop.empty()) {
1005 : return GNE_TAG_STOPPERSON_TRAINSTOP;
1006 0 : } else if (!toContainerStop.empty()) {
1007 : return GNE_TAG_STOPPERSON_CONTAINERSTOP;
1008 0 : } else if (!toChargingStation.empty()) {
1009 : return GNE_TAG_STOPPERSON_CHARGINGSTATION;
1010 0 : } else if (!toParkingArea.empty()) {
1011 : return GNE_TAG_STOPPERSON_PARKINGAREA;
1012 : } else {
1013 0 : return SUMO_TAG_NOTHING;
1014 : }
1015 : }
1016 :
1017 :
1018 : SumoXMLTag
1019 0 : CommonXMLStructure::PlanParameters::getContainerStopTag() const {
1020 0 : if (!toEdge.empty()) {
1021 : return GNE_TAG_STOPCONTAINER_EDGE;
1022 0 : } else if (!toBusStop.empty()) {
1023 : return GNE_TAG_STOPCONTAINER_BUSSTOP;
1024 0 : } else if (!toTrainStop.empty()) {
1025 : return GNE_TAG_STOPCONTAINER_TRAINSTOP;
1026 0 : } else if (!toContainerStop.empty()) {
1027 : return GNE_TAG_STOPCONTAINER_CONTAINERSTOP;
1028 0 : } else if (!toChargingStation.empty()) {
1029 : return GNE_TAG_STOPCONTAINER_CHARGINGSTATION;
1030 0 : } else if (!toParkingArea.empty()) {
1031 : return GNE_TAG_STOPCONTAINER_PARKINGAREA;
1032 : } else {
1033 0 : return SUMO_TAG_NOTHING;
1034 : }
1035 : }
1036 :
1037 :
1038 :
1039 : const CommonXMLStructure::SumoBaseObject*
1040 0 : CommonXMLStructure::PlanParameters::getPreviousPlanObj(const CommonXMLStructure::SumoBaseObject* sumoBaseObject) const {
1041 : // first check if object exist
1042 0 : if (sumoBaseObject == nullptr) {
1043 : return nullptr;
1044 : }
1045 : // check if object has parent
1046 0 : const CommonXMLStructure::SumoBaseObject* parentObject = sumoBaseObject->getParentSumoBaseObject();
1047 0 : if (parentObject == nullptr) {
1048 : return nullptr;
1049 : }
1050 : // check number of children
1051 0 : if (parentObject->getSumoBaseObjectChildren().size() < 2) {
1052 : return nullptr;
1053 : }
1054 : // search position of the given plan obj in the parent children
1055 0 : const auto objIterator = std::find(parentObject->getSumoBaseObjectChildren().begin(), parentObject->getSumoBaseObjectChildren().end(), sumoBaseObject);
1056 : // if obj is the first plan of person/container parent, then return null. If not, return previous object
1057 0 : if (objIterator == parentObject->getSumoBaseObjectChildren().begin()) {
1058 : return nullptr;
1059 : } else {
1060 0 : return *(objIterator - 1);
1061 : }
1062 : }
1063 :
1064 :
1065 : void
1066 0 : CommonXMLStructure::PlanParameters::updateFromAttributes(const CommonXMLStructure::SumoBaseObject* sumoBaseObject) {
1067 : // check if previous plan object was defined but not the from
1068 0 : const auto previousPlanObj = getPreviousPlanObj(sumoBaseObject);
1069 0 : if (previousPlanObj) {
1070 : // ge previous plan parameters
1071 0 : const auto previousPlanParameters = previousPlanObj->getPlanParameters();
1072 : if (!previousPlanParameters.toEdge.empty()) {
1073 : // edge (to)
1074 0 : resetPreviousFromAttributes(previousPlanObj, "edge", previousPlanParameters.toEdge);
1075 0 : fromEdge = previousPlanParameters.toEdge;
1076 0 : } else if (!previousPlanParameters.consecutiveEdges.empty()) {
1077 : // consecutive edge
1078 0 : resetPreviousFromAttributes(previousPlanObj, "consecutive edge", previousPlanParameters.consecutiveEdges.back());
1079 0 : fromEdge = previousPlanParameters.consecutiveEdges.back();
1080 0 : } else if (!previousPlanParameters.toRoute.empty()) {
1081 : // route
1082 0 : resetPreviousFromAttributes(previousPlanObj, "route edge", previousPlanParameters.toRoute);
1083 0 : fromRoute = previousPlanParameters.toRoute;
1084 0 : } else if (!previousPlanParameters.toJunction.empty()) {
1085 : // junction
1086 0 : resetPreviousFromAttributes(previousPlanObj, "junction", previousPlanParameters.toJunction);
1087 0 : fromJunction = previousPlanParameters.toJunction;
1088 0 : } else if (!previousPlanParameters.toTAZ.empty()) {
1089 : // TAZ
1090 0 : resetPreviousFromAttributes(previousPlanObj, "TAZ", previousPlanParameters.toTAZ);
1091 0 : fromTAZ = previousPlanParameters.toTAZ;
1092 0 : } else if (!previousPlanParameters.toBusStop.empty()) {
1093 : // busStop
1094 0 : resetPreviousFromAttributes(previousPlanObj, "bus stop", previousPlanParameters.toBusStop);
1095 0 : fromBusStop = previousPlanParameters.toBusStop;
1096 0 : } else if (!previousPlanParameters.toTrainStop.empty()) {
1097 : // trainStop
1098 0 : resetPreviousFromAttributes(previousPlanObj, "train stop", previousPlanParameters.toTrainStop);
1099 0 : fromTrainStop = previousPlanParameters.toTrainStop;
1100 0 : } else if (!previousPlanParameters.toContainerStop.empty()) {
1101 : // containerStop
1102 0 : resetPreviousFromAttributes(previousPlanObj, "container stop", previousPlanParameters.toContainerStop);
1103 0 : fromContainerStop = previousPlanParameters.toContainerStop;
1104 0 : } else if (!previousPlanParameters.toChargingStation.empty()) {
1105 : // chargingStation
1106 0 : resetPreviousFromAttributes(previousPlanObj, "charging station", previousPlanParameters.toChargingStation);
1107 0 : fromChargingStation = previousPlanParameters.toChargingStation;
1108 0 : } else if (!previousPlanParameters.toParkingArea.empty()) {
1109 : // parkingArea
1110 0 : resetPreviousFromAttributes(previousPlanObj, "parking area", previousPlanParameters.toParkingArea);
1111 0 : fromParkingArea = previousPlanParameters.toParkingArea;
1112 : }
1113 0 : }
1114 0 : }
1115 :
1116 :
1117 : void
1118 0 : CommonXMLStructure::PlanParameters::resetPreviousFromAttributes(const CommonXMLStructure::SumoBaseObject* previousPlanObj,
1119 : const std::string& newType, const std::string& newId) const {
1120 0 : if (!fromEdge.empty()) {
1121 0 : writeIgnoringMessage(previousPlanObj, "edge", fromEdge, newType, newId);
1122 : }
1123 0 : if (!fromJunction.empty()) {
1124 0 : writeIgnoringMessage(previousPlanObj, "junction", fromJunction, newType, newId);
1125 : }
1126 0 : if (!fromTAZ.empty()) {
1127 0 : writeIgnoringMessage(previousPlanObj, "TAZ", fromTAZ, newType, newId);
1128 : }
1129 0 : if (!fromBusStop.empty()) {
1130 0 : writeIgnoringMessage(previousPlanObj, "bus stop", fromBusStop, newType, newId);
1131 : }
1132 0 : if (!fromTrainStop.empty()) {
1133 0 : writeIgnoringMessage(previousPlanObj, "train stop", fromTrainStop, newType, newId);
1134 : }
1135 0 : if (!fromContainerStop.empty()) {
1136 0 : writeIgnoringMessage(previousPlanObj, "container stop", fromContainerStop, newType, newId);
1137 : }
1138 0 : if (!fromChargingStation.empty()) {
1139 0 : writeIgnoringMessage(previousPlanObj, "charging station", fromChargingStation, newType, newId);
1140 : }
1141 0 : if (!fromParkingArea.empty()) {
1142 0 : writeIgnoringMessage(previousPlanObj, "parking area", fromParkingArea, newType, newId);
1143 : }
1144 0 : }
1145 :
1146 :
1147 : void
1148 0 : CommonXMLStructure::PlanParameters::writeIgnoringMessage(const CommonXMLStructure::SumoBaseObject* previousPlanObj,
1149 : const std::string& oldType, const std::string& oldId, const std::string& newType, const std::string& newId) const {
1150 0 : WRITE_WARNING(TLF("Ignoring from % '%' used in % '%' and using instead the previous end element % '%'",
1151 : oldType, oldId,
1152 : toString(previousPlanObj->getParentSumoBaseObject()->getTag()),
1153 : previousPlanObj->getParentSumoBaseObject()->getStringAttribute(SUMO_ATTR_ID),
1154 : newType, newId));
1155 0 : }
1156 :
1157 : // ---------------------------------------------------------------------------
1158 : // CommonXMLStructure::SumoBaseObject - methods
1159 : // ---------------------------------------------------------------------------
1160 :
1161 0 : CommonXMLStructure::SumoBaseObject::SumoBaseObject(SumoBaseObject* parent) :
1162 0 : mySumoBaseObjectParent(parent),
1163 0 : myVehicleTypeParameter("") {
1164 : // add this SumoBaseObject into parent children
1165 0 : if (mySumoBaseObjectParent) {
1166 0 : mySumoBaseObjectParent->addSumoBaseObjectChild(this);
1167 : }
1168 0 : }
1169 :
1170 :
1171 0 : CommonXMLStructure::SumoBaseObject::~SumoBaseObject() {
1172 : // remove this SumoBaseObject from parent children
1173 0 : if (mySumoBaseObjectParent) {
1174 0 : mySumoBaseObjectParent->removeSumoBaseObjectChild(this);
1175 : }
1176 : // delete all SumoBaseObjectChildrens
1177 0 : while (mySumoBaseObjectChildren.size() > 0) {
1178 0 : delete mySumoBaseObjectChildren.back();
1179 : }
1180 0 : }
1181 :
1182 :
1183 : void
1184 0 : CommonXMLStructure::SumoBaseObject::clear() {
1185 : // reset tag
1186 0 : myTag = SUMO_TAG_NOTHING;
1187 : // reset vClass
1188 0 : myVClass = SVC_IGNORING;
1189 : // clear containers
1190 : myStringAttributes.clear();
1191 : myIntAttributes.clear();
1192 : myDoubleAttributes.clear();
1193 : myBoolAttributes.clear();
1194 : myPositionAttributes.clear();
1195 : myTimeAttributes.clear();
1196 : myColorAttributes.clear();
1197 : myStringListAttributes.clear();
1198 : myDoubleListAttributes.clear();
1199 : myPositionVectorAttributes.clear();
1200 : myParentIDs.clear();
1201 : myParameters.clear();
1202 : mySumoBaseObjectChildren.clear();
1203 : // reset flags
1204 0 : myDefinedVehicleTypeParameter = false;
1205 0 : myDefinedVehicleParameter = false;
1206 0 : myDefinedStopParameter = false;
1207 : // delete all SumoBaseObjectChildrens
1208 0 : while (mySumoBaseObjectChildren.size() > 0) {
1209 0 : delete mySumoBaseObjectChildren.back();
1210 : }
1211 0 : }
1212 :
1213 :
1214 : void
1215 0 : CommonXMLStructure::SumoBaseObject::setTag(const SumoXMLTag tag) {
1216 0 : myTag = tag;
1217 0 : }
1218 :
1219 :
1220 : void
1221 0 : CommonXMLStructure::SumoBaseObject::markAsCreated() {
1222 0 : myWasCreated = true;
1223 0 : }
1224 :
1225 :
1226 : SumoXMLTag
1227 0 : CommonXMLStructure::SumoBaseObject::getTag() const {
1228 0 : return myTag;
1229 : }
1230 :
1231 :
1232 : bool
1233 0 : CommonXMLStructure::SumoBaseObject::wasCreated() const {
1234 0 : return myWasCreated;
1235 : }
1236 :
1237 :
1238 : CommonXMLStructure::SumoBaseObject*
1239 0 : CommonXMLStructure::SumoBaseObject::getParentSumoBaseObject() const {
1240 0 : return mySumoBaseObjectParent;
1241 : }
1242 :
1243 :
1244 : std::map<std::string, std::string>
1245 0 : CommonXMLStructure::SumoBaseObject::getAllAttributes() const {
1246 : std::map<std::string, std::string> result;
1247 0 : for (const auto& attr : myStringAttributes) {
1248 0 : result[toString(attr.first)] = attr.second;
1249 : }
1250 0 : for (const auto& attr : myIntAttributes) {
1251 0 : result[toString(attr.first)] = toString(attr.second);
1252 : }
1253 0 : for (const auto& attr : myDoubleAttributes) {
1254 0 : result[toString(attr.first)] = toString(attr.second);
1255 : }
1256 0 : for (const auto& attr : myBoolAttributes) {
1257 0 : result[toString(attr.first)] = toString(attr.second);
1258 : }
1259 0 : for (const auto& attr : myPositionAttributes) {
1260 0 : result[toString(attr.first)] = toString(attr.second);
1261 : }
1262 0 : for (const auto& attr : myTimeAttributes) {
1263 0 : result[toString(attr.first)] = time2string(attr.second);
1264 : }
1265 0 : for (const auto& attr : myColorAttributes) {
1266 0 : result[toString(attr.first)] = toString(attr.second);
1267 : }
1268 0 : for (const auto& attr : myStringListAttributes) {
1269 0 : result[toString(attr.first)] = toString(attr.second);
1270 : }
1271 0 : for (const auto& attr : myDoubleListAttributes) {
1272 0 : result[toString(attr.first)] = toString(attr.second);
1273 : }
1274 0 : for (const auto& attr : myPositionVectorAttributes) {
1275 0 : result[toString(attr.first)] = toString(attr.second);
1276 : }
1277 0 : return result;
1278 : }
1279 :
1280 :
1281 : const std::string&
1282 0 : CommonXMLStructure::SumoBaseObject::getStringAttribute(const SumoXMLAttr attr) const {
1283 0 : if (hasStringAttribute(attr)) {
1284 0 : return myStringAttributes.at(attr);
1285 : } else {
1286 0 : handleAttributeError(attr, "string");
1287 0 : throw ProcessError();
1288 : }
1289 : }
1290 :
1291 :
1292 : int
1293 0 : CommonXMLStructure::SumoBaseObject::getIntAttribute(const SumoXMLAttr attr) const {
1294 0 : if (hasIntAttribute(attr)) {
1295 0 : return myIntAttributes.at(attr);
1296 : } else {
1297 0 : handleAttributeError(attr, "int");
1298 0 : throw ProcessError();
1299 : }
1300 : }
1301 :
1302 :
1303 : double
1304 0 : CommonXMLStructure::SumoBaseObject::getDoubleAttribute(const SumoXMLAttr attr) const {
1305 0 : if (hasDoubleAttribute(attr)) {
1306 0 : return myDoubleAttributes.at(attr);
1307 : } else {
1308 0 : handleAttributeError(attr, "double");
1309 0 : throw ProcessError();
1310 : }
1311 : }
1312 :
1313 :
1314 : bool
1315 0 : CommonXMLStructure::SumoBaseObject::getBoolAttribute(const SumoXMLAttr attr) const {
1316 0 : if (hasBoolAttribute(attr)) {
1317 0 : return myBoolAttributes.at(attr);
1318 : } else {
1319 0 : handleAttributeError(attr, "bool");
1320 0 : throw ProcessError();
1321 : }
1322 : }
1323 :
1324 :
1325 : const Position&
1326 0 : CommonXMLStructure::SumoBaseObject::getPositionAttribute(const SumoXMLAttr attr) const {
1327 0 : if (hasPositionAttribute(attr)) {
1328 0 : return myPositionAttributes.at(attr);
1329 : } else {
1330 0 : handleAttributeError(attr, "position");
1331 0 : throw ProcessError();
1332 : }
1333 : }
1334 :
1335 :
1336 : SUMOTime
1337 0 : CommonXMLStructure::SumoBaseObject::getTimeAttribute(const SumoXMLAttr attr) const {
1338 0 : if (hasTimeAttribute(attr)) {
1339 0 : return myTimeAttributes.at(attr);
1340 : } else {
1341 0 : handleAttributeError(attr, "time");
1342 0 : throw ProcessError();
1343 : }
1344 : }
1345 :
1346 :
1347 : SUMOTime
1348 0 : CommonXMLStructure::SumoBaseObject::getPeriodAttribute() const {
1349 0 : SumoXMLAttr attr = SUMO_ATTR_PERIOD;
1350 0 : if (hasTimeAttribute(attr)) {
1351 0 : return myTimeAttributes.at(attr);
1352 : } else {
1353 : // try 'freq' as alias for 'period'
1354 0 : attr = SUMO_ATTR_FREQUENCY;
1355 0 : if (hasTimeAttribute(attr)) {
1356 0 : return myTimeAttributes.at(attr);
1357 : }
1358 0 : handleAttributeError(SUMO_ATTR_PERIOD, "time");
1359 0 : throw ProcessError();
1360 : }
1361 : }
1362 :
1363 :
1364 : const RGBColor&
1365 0 : CommonXMLStructure::SumoBaseObject::getColorAttribute(const SumoXMLAttr attr) const {
1366 0 : if (hasColorAttribute(attr)) {
1367 0 : return myColorAttributes.at(attr);
1368 : } else {
1369 0 : handleAttributeError(attr, "color");
1370 0 : throw ProcessError();
1371 : }
1372 : }
1373 :
1374 :
1375 : const std::vector<std::string>&
1376 0 : CommonXMLStructure::SumoBaseObject::getStringListAttribute(const SumoXMLAttr attr) const {
1377 0 : if (hasStringListAttribute(attr)) {
1378 0 : return myStringListAttributes.at(attr);
1379 : } else {
1380 0 : handleAttributeError(attr, "string list");
1381 0 : throw ProcessError();
1382 : }
1383 : }
1384 :
1385 :
1386 : const std::vector<double>&
1387 0 : CommonXMLStructure::SumoBaseObject::getDoubleListAttribute(const SumoXMLAttr attr) const {
1388 0 : if (hasDoubleListAttribute(attr)) {
1389 0 : return myDoubleListAttributes.at(attr);
1390 : } else {
1391 0 : handleAttributeError(attr, "double list");
1392 0 : throw ProcessError();
1393 : }
1394 : }
1395 :
1396 :
1397 : const PositionVector&
1398 0 : CommonXMLStructure::SumoBaseObject::getPositionVectorAttribute(const SumoXMLAttr attr) const {
1399 0 : if (hasPositionVectorAttribute(attr)) {
1400 0 : return myPositionVectorAttributes.at(attr);
1401 : } else {
1402 0 : handleAttributeError(attr, "position vector");
1403 0 : throw ProcessError();
1404 : }
1405 : }
1406 :
1407 : const std::string&
1408 0 : CommonXMLStructure::SumoBaseObject::getParentID(const SumoXMLTag tag) const {
1409 0 : if (hasParentID(tag)) {
1410 0 : return myParentIDs.at(tag);
1411 : } else {
1412 0 : WRITE_ERRORF(TL("Trying to get undefined parent '%' in SUMOBaseObject '%'"), toString(tag), toString(myTag));
1413 0 : throw ProcessError();
1414 : }
1415 : }
1416 :
1417 :
1418 : SUMOVehicleClass
1419 0 : CommonXMLStructure::SumoBaseObject::getVClass() const {
1420 0 : return myVClass;
1421 : }
1422 :
1423 :
1424 : const SUMOVTypeParameter&
1425 0 : CommonXMLStructure::SumoBaseObject::getVehicleTypeParameter() const {
1426 0 : if (myDefinedVehicleTypeParameter) {
1427 0 : return myVehicleTypeParameter;
1428 : } else {
1429 0 : throw ProcessError(TL("Undefined vehicleType parameter"));
1430 : }
1431 : }
1432 :
1433 :
1434 : const SUMOVehicleParameter&
1435 0 : CommonXMLStructure::SumoBaseObject::getVehicleParameter() const {
1436 0 : if (myDefinedVehicleParameter) {
1437 0 : return myVehicleParameter;
1438 : } else {
1439 0 : throw ProcessError(TL("Undefined vehicle parameter"));
1440 : }
1441 : }
1442 :
1443 :
1444 : const SUMOVehicleParameter::Stop&
1445 0 : CommonXMLStructure::SumoBaseObject::getStopParameter() const {
1446 0 : if (myDefinedStopParameter) {
1447 0 : return myStopParameter;
1448 : } else {
1449 0 : throw ProcessError(TL("Undefined stop parameter"));
1450 : }
1451 :
1452 : }
1453 :
1454 :
1455 : const std::map<std::string, std::string>&
1456 0 : CommonXMLStructure::SumoBaseObject::getParameters() const {
1457 0 : return myParameters;
1458 : }
1459 :
1460 :
1461 : const CommonXMLStructure::PlanParameters&
1462 0 : CommonXMLStructure::SumoBaseObject::getPlanParameters() const {
1463 0 : return myPlanParameters;
1464 : }
1465 :
1466 :
1467 : const std::vector<CommonXMLStructure::SumoBaseObject*>&
1468 0 : CommonXMLStructure::SumoBaseObject::getSumoBaseObjectChildren() const {
1469 0 : return mySumoBaseObjectChildren;
1470 : }
1471 :
1472 :
1473 : bool
1474 0 : CommonXMLStructure::SumoBaseObject::hasStringAttribute(const SumoXMLAttr attr) const {
1475 0 : return myStringAttributes.count(attr) > 0;
1476 : }
1477 :
1478 :
1479 : bool
1480 0 : CommonXMLStructure::SumoBaseObject::hasIntAttribute(const SumoXMLAttr attr) const {
1481 0 : return myIntAttributes.count(attr) > 0;
1482 : }
1483 :
1484 :
1485 : bool
1486 0 : CommonXMLStructure::SumoBaseObject::hasDoubleAttribute(const SumoXMLAttr attr) const {
1487 0 : return myDoubleAttributes.count(attr) > 0;
1488 : }
1489 :
1490 :
1491 : bool
1492 0 : CommonXMLStructure::SumoBaseObject::hasBoolAttribute(const SumoXMLAttr attr) const {
1493 0 : return myBoolAttributes.count(attr) > 0;
1494 : }
1495 :
1496 :
1497 : bool
1498 0 : CommonXMLStructure::SumoBaseObject::hasPositionAttribute(const SumoXMLAttr attr) const {
1499 0 : return myPositionAttributes.count(attr) > 0;
1500 : }
1501 :
1502 :
1503 : bool
1504 0 : CommonXMLStructure::SumoBaseObject::hasTimeAttribute(const SumoXMLAttr attr) const {
1505 0 : return myTimeAttributes.count(attr) > 0;
1506 : }
1507 :
1508 :
1509 : bool
1510 0 : CommonXMLStructure::SumoBaseObject::hasColorAttribute(const SumoXMLAttr attr) const {
1511 0 : return myColorAttributes.count(attr) > 0;
1512 : }
1513 :
1514 :
1515 : bool
1516 0 : CommonXMLStructure::SumoBaseObject::hasStringListAttribute(const SumoXMLAttr attr) const {
1517 0 : return myStringListAttributes.count(attr) > 0;
1518 : }
1519 :
1520 :
1521 : bool
1522 0 : CommonXMLStructure::SumoBaseObject::hasDoubleListAttribute(const SumoXMLAttr attr) const {
1523 0 : return myDoubleListAttributes.count(attr) > 0;
1524 : }
1525 :
1526 :
1527 : bool
1528 0 : CommonXMLStructure::SumoBaseObject::hasPositionVectorAttribute(const SumoXMLAttr attr) const {
1529 0 : return myPositionVectorAttributes.count(attr) > 0;
1530 : }
1531 :
1532 :
1533 : bool
1534 0 : CommonXMLStructure::SumoBaseObject::hasParentID(const SumoXMLTag tag) const {
1535 0 : return myParentIDs.count(tag) > 0;
1536 : }
1537 :
1538 :
1539 : void
1540 0 : CommonXMLStructure::SumoBaseObject::addStringAttribute(const SumoXMLAttr attr, const std::string& value) {
1541 0 : myStringAttributes[attr] = value;
1542 0 : }
1543 :
1544 :
1545 : void
1546 0 : CommonXMLStructure::SumoBaseObject::addIntAttribute(const SumoXMLAttr attr, const int value) {
1547 0 : myIntAttributes[attr] = value;
1548 0 : }
1549 :
1550 :
1551 : void
1552 0 : CommonXMLStructure::SumoBaseObject::addDoubleAttribute(const SumoXMLAttr attr, const double value) {
1553 0 : myDoubleAttributes[attr] = value;
1554 0 : }
1555 :
1556 :
1557 : void
1558 0 : CommonXMLStructure::SumoBaseObject::addBoolAttribute(const SumoXMLAttr attr, const bool value) {
1559 0 : myBoolAttributes[attr] = value;
1560 0 : }
1561 :
1562 :
1563 : void
1564 0 : CommonXMLStructure::SumoBaseObject::addPositionAttribute(const SumoXMLAttr attr, const Position& value) {
1565 0 : myPositionAttributes[attr] = value;
1566 0 : }
1567 :
1568 :
1569 : void
1570 0 : CommonXMLStructure::SumoBaseObject::addTimeAttribute(const SumoXMLAttr attr, const SUMOTime value) {
1571 0 : myTimeAttributes[attr] = value;
1572 0 : }
1573 :
1574 :
1575 : void
1576 0 : CommonXMLStructure::SumoBaseObject::addColorAttribute(const SumoXMLAttr attr, const RGBColor& value) {
1577 0 : myColorAttributes[attr] = value;
1578 0 : }
1579 :
1580 :
1581 : void
1582 0 : CommonXMLStructure::SumoBaseObject::addStringListAttribute(const SumoXMLAttr attr, const std::vector<std::string>& value) {
1583 0 : myStringListAttributes[attr] = value;
1584 0 : }
1585 :
1586 :
1587 : void
1588 0 : CommonXMLStructure::SumoBaseObject::addDoubleListAttribute(const SumoXMLAttr attr, const std::vector<double>& value) {
1589 0 : myDoubleListAttributes[attr] = value;
1590 0 : }
1591 :
1592 :
1593 : void
1594 0 : CommonXMLStructure::SumoBaseObject::addPositionVectorAttribute(const SumoXMLAttr attr, const PositionVector& value) {
1595 0 : myPositionVectorAttributes[attr] = value;
1596 0 : }
1597 :
1598 :
1599 : void
1600 0 : CommonXMLStructure::SumoBaseObject::addParentID(const SumoXMLTag tag, const std::string& ID) {
1601 0 : myParentIDs[tag] = ID;
1602 0 : }
1603 :
1604 :
1605 : void
1606 0 : CommonXMLStructure::SumoBaseObject::addParameters(const std::string& value) {
1607 0 : const auto parameters = StringTokenizer(value, '|').getVector();
1608 0 : for (const auto& parameter : parameters) {
1609 0 : const auto keyValue = StringTokenizer(parameter, '=').getVector();
1610 0 : addParameter(keyValue[0], keyValue[1]);
1611 0 : }
1612 0 : }
1613 :
1614 :
1615 : void
1616 0 : CommonXMLStructure::SumoBaseObject::addParameter(const std::string& key, const std::string& value) {
1617 : // check if we have to insert in vType, vehicle or stop parameters
1618 0 : if (myDefinedVehicleTypeParameter) {
1619 0 : myVehicleTypeParameter.setParameter(key, value);
1620 0 : } else if (myDefinedVehicleParameter) {
1621 0 : myVehicleParameter.setParameter(key, value);
1622 0 : } else if (myDefinedStopParameter) {
1623 0 : myStopParameter.setParameter(key, value);
1624 : } else {
1625 0 : myParameters[key] = value;
1626 : }
1627 0 : }
1628 :
1629 :
1630 : void
1631 0 : CommonXMLStructure::SumoBaseObject::setVClass(SUMOVehicleClass vClass) {
1632 0 : myVClass = vClass;
1633 0 : }
1634 :
1635 :
1636 : void
1637 0 : CommonXMLStructure::SumoBaseObject::setVehicleTypeParameter(const SUMOVTypeParameter* vehicleTypeParameter) {
1638 0 : myVehicleTypeParameter = *vehicleTypeParameter;
1639 0 : myDefinedVehicleTypeParameter = true;
1640 : // set attribute id
1641 0 : addStringAttribute(SUMO_ATTR_ID, myVehicleTypeParameter.id);
1642 0 : }
1643 :
1644 :
1645 : void
1646 0 : CommonXMLStructure::SumoBaseObject::setVehicleParameter(const SUMOVehicleParameter* vehicleParameter) {
1647 0 : myVehicleParameter = *vehicleParameter;
1648 0 : myDefinedVehicleParameter = true;
1649 : // set attribute id
1650 0 : if (!myVehicleParameter.id.empty()) {
1651 0 : addStringAttribute(SUMO_ATTR_ID, myVehicleParameter.id);
1652 : }
1653 : // set attribute route
1654 0 : if (!vehicleParameter->routeid.empty()) {
1655 0 : addStringAttribute(SUMO_ATTR_ROUTE, myVehicleParameter.routeid);
1656 : }
1657 0 : }
1658 :
1659 :
1660 : void
1661 0 : CommonXMLStructure::SumoBaseObject::setStopParameter(const SUMOVehicleParameter::Stop& stopParameter) {
1662 0 : myStopParameter = stopParameter;
1663 0 : myDefinedStopParameter = true;
1664 : // set attribute edge
1665 0 : if (!myStopParameter.edge.empty()) {
1666 0 : addStringAttribute(SUMO_ATTR_EDGE, myStopParameter.edge);
1667 : }
1668 : // set attribute lane
1669 0 : if (!myStopParameter.lane.empty()) {
1670 0 : addStringAttribute(SUMO_ATTR_LANE, myStopParameter.lane);
1671 : }
1672 : // set attribute busStop
1673 0 : if (!myStopParameter.busstop.empty()) {
1674 0 : addStringAttribute(SUMO_ATTR_BUS_STOP, myStopParameter.busstop);
1675 : }
1676 : // set attribute containerstop
1677 0 : if (!myStopParameter.containerstop.empty()) {
1678 0 : addStringAttribute(SUMO_ATTR_CONTAINER_STOP, myStopParameter.containerstop);
1679 : }
1680 : // set attribute parkingarea
1681 0 : if (!myStopParameter.parkingarea.empty()) {
1682 0 : addStringAttribute(SUMO_ATTR_PARKING_AREA, myStopParameter.parkingarea);
1683 : }
1684 : // set attribute chargingStation
1685 0 : if (!myStopParameter.chargingStation.empty()) {
1686 0 : addStringAttribute(SUMO_ATTR_CHARGING_STATION, myStopParameter.chargingStation);
1687 : }
1688 0 : }
1689 :
1690 :
1691 : void
1692 0 : CommonXMLStructure::SumoBaseObject::setPlanParameters(const CommonXMLStructure::PlanParameters& planParameters) {
1693 0 : myPlanParameters = planParameters;
1694 0 : }
1695 :
1696 : void
1697 0 : CommonXMLStructure::SumoBaseObject::addSumoBaseObjectChild(SumoBaseObject* sumoBaseObject) {
1698 : // just add it into mySumoBaseObjectChildren
1699 0 : mySumoBaseObjectChildren.push_back(sumoBaseObject);
1700 0 : }
1701 :
1702 :
1703 : void
1704 0 : CommonXMLStructure::SumoBaseObject::removeSumoBaseObjectChild(SumoBaseObject* sumoBaseObject) {
1705 : // find sumoBaseObject
1706 0 : auto it = std::find(mySumoBaseObjectChildren.begin(), mySumoBaseObjectChildren.end(), sumoBaseObject);
1707 : // check iterator
1708 0 : if (it != mySumoBaseObjectChildren.end()) {
1709 0 : mySumoBaseObjectChildren.erase(it);
1710 : }
1711 0 : }
1712 :
1713 :
1714 : void
1715 0 : CommonXMLStructure::SumoBaseObject::handleAttributeError(const SumoXMLAttr attr, const std::string& type) const {
1716 0 : WRITE_ERRORF(TL("Trying to get undefined % attribute '%' in SUMOBaseObject '%'"), type, toString(attr), toString(myTag));
1717 0 : }
1718 :
1719 : // ---------------------------------------------------------------------------
1720 : // CommonXMLStructure - methods
1721 : // ---------------------------------------------------------------------------
1722 :
1723 0 : CommonXMLStructure::CommonXMLStructure() :
1724 0 : mySumoBaseObjectRoot(nullptr),
1725 0 : myCurrentSumoBaseObject(nullptr) {
1726 :
1727 0 : }
1728 :
1729 :
1730 0 : CommonXMLStructure::~CommonXMLStructure() {
1731 : // delete mySumoBaseObjectRoot (this will also delete all SumoBaseObjectChildrens)
1732 0 : if (mySumoBaseObjectRoot) {
1733 0 : delete mySumoBaseObjectRoot;
1734 : }
1735 0 : }
1736 :
1737 :
1738 : void
1739 0 : CommonXMLStructure::openSUMOBaseOBject() {
1740 : // first check if root is empty
1741 0 : if (mySumoBaseObjectRoot == nullptr) {
1742 : // create root
1743 0 : mySumoBaseObjectRoot = new SumoBaseObject(nullptr);
1744 : // set tag
1745 0 : mySumoBaseObjectRoot->setTag(SUMO_TAG_ROOTFILE);
1746 : // update last inserted Root
1747 0 : myCurrentSumoBaseObject = mySumoBaseObjectRoot;
1748 : } else {
1749 : // create new node
1750 0 : SumoBaseObject* newSumoBaseObject = new SumoBaseObject(myCurrentSumoBaseObject);
1751 : // update last inserted node
1752 0 : myCurrentSumoBaseObject = newSumoBaseObject;
1753 : }
1754 0 : }
1755 :
1756 :
1757 : void
1758 0 : CommonXMLStructure::closeSUMOBaseOBject() {
1759 : // check that myCurrentSumoBaseObject is valid
1760 0 : if (myCurrentSumoBaseObject) {
1761 : // check if last inserted SumoBaseObject is the root
1762 0 : if (myCurrentSumoBaseObject->getParentSumoBaseObject() == nullptr) {
1763 : // reset both pointers
1764 0 : myCurrentSumoBaseObject = nullptr;
1765 0 : mySumoBaseObjectRoot = nullptr;
1766 : } else {
1767 : // update last inserted SumoBaseObject
1768 0 : myCurrentSumoBaseObject = myCurrentSumoBaseObject->getParentSumoBaseObject();
1769 : }
1770 : }
1771 0 : }
1772 :
1773 :
1774 : void
1775 0 : CommonXMLStructure::abortSUMOBaseOBject() {
1776 : // delete current sumo base object and use their parent as sumo base object
1777 0 : if (myCurrentSumoBaseObject) {
1778 0 : if (myCurrentSumoBaseObject == mySumoBaseObjectRoot) {
1779 0 : delete myCurrentSumoBaseObject;
1780 0 : myCurrentSumoBaseObject = nullptr;
1781 0 : mySumoBaseObjectRoot = nullptr;
1782 : } else {
1783 0 : auto parentSumoBaseObject = myCurrentSumoBaseObject->getParentSumoBaseObject();
1784 0 : delete myCurrentSumoBaseObject;
1785 0 : myCurrentSumoBaseObject = parentSumoBaseObject;
1786 : }
1787 : }
1788 0 : }
1789 :
1790 :
1791 : CommonXMLStructure::SumoBaseObject*
1792 0 : CommonXMLStructure::getSumoBaseObjectRoot() const {
1793 0 : return mySumoBaseObjectRoot;
1794 : }
1795 :
1796 :
1797 : CommonXMLStructure::SumoBaseObject*
1798 0 : CommonXMLStructure::getCurrentSumoBaseObject() const {
1799 0 : return myCurrentSumoBaseObject;
1800 : }
1801 :
1802 : /****************************************************************************/
|