Eclipse SUMO - Simulation of Urban MObility
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
RouteHandler.cpp
Go to the documentation of this file.
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/****************************************************************************/
18// The XML-Handler for route elements loading
19/****************************************************************************/
20#include <config.h>
21
26#include <utils/shapes/Shape.h>
29#include <utils/xml/XMLSubSys.h>
31
32#include "RouteHandler.h"
33
34
35// ===========================================================================
36// method definitions
37// ===========================================================================
38
39RouteHandler::RouteHandler(const std::string& filename, const bool hardFail) :
40 CommonHandler(filename),
41 myHardFail(hardFail),
42 myFlowBeginDefault(string2time(OptionsCont::getOptions().getString("begin"))),
43 myFlowEndDefault(string2time(OptionsCont::getOptions().getString("end"))) {
44}
45
46
48
49
50bool
52 // open SUMOBaseOBject
54 // check tag
55 try {
56 switch (tag) {
57 // vTypes
58 case SUMO_TAG_VTYPE:
59 // continue depeding if we're parsing a vType or a reference
62 parseVTypeRef(attrs);
63 } else {
64 parseVType(attrs);
65 }
66 break;
69 break;
70 // routes
71 case SUMO_TAG_ROUTE: {
72 // continue depeding if we're parsing a basic route, an embedded route, or a distribution ref
73 const auto parentTag = myCommonXMLStructure.getSumoBaseObjectRoot()->getTag();
74 // this is temporal, until #16476
75 if (parentTag != SUMO_TAG_ERROR) {
76 if ((parentTag == SUMO_TAG_VEHICLE) || (parentTag == SUMO_TAG_FLOW)) {
77 parseRouteEmbedded(attrs);
78 } else if ((parentTag == SUMO_TAG_ROUTE_DISTRIBUTION) && attrs.hasAttribute(SUMO_ATTR_REFID)) {
79 parseRouteRef(attrs);
80 } else {
81 parseRoute(attrs);
82 }
83 }
84 break;
85 }
88 break;
89 // vehicles
90 case SUMO_TAG_TRIP:
91 parseTrip(attrs);
92 break;
94 parseVehicle(attrs);
95 break;
96 // flows
97 case SUMO_TAG_FLOW:
98 parseFlow(attrs);
99 break;
100 // stop
101 case SUMO_TAG_STOP:
102 parseStop(attrs);
103 break;
104 // persons
105 case SUMO_TAG_PERSON:
106 parsePerson(attrs);
107 break;
109 parsePersonFlow(attrs);
110 break;
111 // person plans
113 parsePersonTrip(attrs);
114 break;
115 case SUMO_TAG_RIDE:
116 parseRide(attrs);
117 break;
118 case SUMO_TAG_WALK:
119 parseWalk(attrs);
120 break;
121 // container
123 parseContainer(attrs);
124 break;
126 parseContainerFlow(attrs);
127 break;
128 // container plans
130 parseTransport(attrs);
131 break;
133 parseTranship(attrs);
134 break;
135 // parameters
136 case SUMO_TAG_PARAM:
137 parseParameters(attrs);
138 break;
139 // other
140 case SUMO_TAG_INTERVAL: {
141 parseInterval(attrs);
142 break;
143 }
144 default:
145 // get vehicle type Base object
147 // parse embedded car following model information
148 if (vTypeObject && (vTypeObject->getTag() == SUMO_TAG_VTYPE)) {
149 // nested CFM attributes
150 return parseNestedCFM(tag, attrs, vTypeObject);
151 } else {
152 // tag cannot be parsed in routeHandler
154 return false;
155 }
156 }
157 } catch (InvalidArgument& e) {
158 WRITE_ERROR(e.what());
159 }
160 return true;
161}
162
163
164void
166 // get last inserted object
168 // check tag
169 if (obj) {
170 // close SUMOBaseOBject
172 switch (obj->getTag()) {
173 case SUMO_TAG_ROUTE:
174 // special case, because embedded and distribution routes are created within other elements
175 if (obj->getParentSumoBaseObject() == nullptr) {
176 // parse object and all their childrens
178 // delete object (and all of their childrens)
179 delete obj;
180 }
181 break;
183 // overwritte probabilities in children
184 for (int i = 0; i < (int)obj->getStringListAttribute(SUMO_ATTR_ROUTES).size(); i++) {
185 const auto& routeID = obj->getStringListAttribute(SUMO_ATTR_ROUTES).at(i);
186 if (i < (int)obj->getDoubleListAttribute(SUMO_ATTR_PROBS).size()) {
187 const double probability = obj->getDoubleListAttribute(SUMO_ATTR_PROBS).at(i);
188 // find child
189 for (auto objChild : obj->getSumoBaseObjectChildren()) {
190 if (objChild->hasStringAttribute(SUMO_ATTR_ID) && (objChild->getStringAttribute(SUMO_ATTR_ID) == routeID)) {
191 // routes
192 objChild->addDoubleAttribute(SUMO_ATTR_PROB, probability);
193 } else if (objChild->hasStringAttribute(SUMO_ATTR_REFID) && (objChild->getStringAttribute(SUMO_ATTR_REFID) == routeID)) {
194 // routeReferences
195 objChild->addDoubleAttribute(SUMO_ATTR_PROB, probability);
196 }
197 }
198 }
199 }
200 // parse object and all their childrens
202 // delete object (and all of their childrens)
203 delete obj;
204 break;
206 // overwritte probabilities in children
207 for (int i = 0; i < (int)obj->getStringListAttribute(SUMO_ATTR_VTYPES).size(); i++) {
208 const auto& vTypeID = obj->getStringListAttribute(SUMO_ATTR_VTYPES).at(i);
209 if (i < (int)obj->getDoubleListAttribute(SUMO_ATTR_PROBS).size()) {
210 const double probability = obj->getDoubleListAttribute(SUMO_ATTR_PROBS).at(i);
211 // find child
212 for (auto objChild : obj->getSumoBaseObjectChildren()) {
213 if (objChild->hasStringAttribute(SUMO_ATTR_ID) && (objChild->getStringAttribute(SUMO_ATTR_ID) == vTypeID)) {
214 // vTypes
215 objChild->addDoubleAttribute(SUMO_ATTR_PROB, probability);
216 } else if (objChild->hasStringAttribute(SUMO_ATTR_REFID) && (objChild->getStringAttribute(SUMO_ATTR_REFID) == vTypeID)) {
217 // vTypeReferences
218 objChild->addDoubleAttribute(SUMO_ATTR_PROB, probability);
219 }
220 }
221 }
222 }
223 // parse object and all their childrens
225 // delete object (and all of their childrens)
226 delete obj;
227 break;
228 case SUMO_TAG_VTYPE:
229 // special case, because embedded and distribution routes are created within other elements
230 if (obj->getParentSumoBaseObject() == nullptr) {
231 // parse object and all their childrens
233 // delete object (and all of their childrens)
234 delete obj;
235 }
236 break;
237 case SUMO_TAG_TRIP:
238 case SUMO_TAG_VEHICLE:
239 case SUMO_TAG_FLOW:
240 case SUMO_TAG_PERSON:
244 // parse object and all their childrens
246 // delete object (and all of their childrens)
247 delete obj;
248 break;
249 default:
250 break;
251 }
252 }
253}
254
255
256void
258 // switch tag
259 switch (obj->getTag()) {
260 // vTypes
261 case SUMO_TAG_VTYPE:
262 // check if parse vType or Ref
264 if (buildVTypeRef(obj,
267 obj->markAsCreated();
268 }
269 } else {
270 if (buildVType(obj,
271 obj->getVehicleTypeParameter())) {
272 obj->markAsCreated();
273 }
274 }
275 break;
280 obj->markAsCreated();
281 }
282 break;
283 // route
284 case SUMO_TAG_ROUTE:
285 // embedded routes are created in build<Vehicle/Flow>EmbeddedRoute
287 if (buildRouteRef(obj,
290 obj->markAsCreated();
291 }
292 } else if (obj->hasStringAttribute(SUMO_ATTR_ID)) {
293 if (buildRoute(obj,
295 obj->getVClass(),
301 obj->getParameters())) {
302 obj->markAsCreated();
303 }
304 }
305 break;
309 obj->markAsCreated();
310 }
311 break;
312 // vehicles
313 case SUMO_TAG_TRIP:
314 if (checkVehicleParents(obj)) {
315 if (isOverFromToEdges(obj)) {
316 // build trip with from-to edges
317 if (buildTrip(obj,
318 obj->getVehicleParameter(),
321 obj->markAsCreated();
322 }
323 } else if (isOverFromToJunctions(obj)) {
324 // build trip with from-to junctions
325 if (buildTripJunctions(obj,
326 obj->getVehicleParameter(),
329 obj->markAsCreated();
330 }
331 } else if (isOverFromToTAZs(obj)) {
332 // build trip with from-to TAZs
333 if (buildTripTAZs(obj,
334 obj->getVehicleParameter(),
337 obj->markAsCreated();
338 }
339 }
340 }
341 break;
342 case SUMO_TAG_VEHICLE:
343 if (checkVehicleParents(obj)) {
345 // build vehicle over route
346 if (buildVehicleOverRoute(obj,
347 obj->getVehicleParameter())) {
348 obj->markAsCreated();
349 }
350 } else {
351 const auto embeddedRoute = getEmbeddedRoute(obj);
352 if (embeddedRoute) {
353 // build vehicle with embedded route
355 obj->getVehicleParameter(),
356 embeddedRoute->getStringListAttribute(SUMO_ATTR_EDGES),
357 embeddedRoute->getColorAttribute(SUMO_ATTR_COLOR),
358 embeddedRoute->getIntAttribute(SUMO_ATTR_REPEAT),
359 embeddedRoute->getTimeAttribute(SUMO_ATTR_CYCLETIME),
360 embeddedRoute->getParameters())) {
361 obj->markAsCreated();
362 }
363 }
364 }
365 }
366 break;
367 // flows
368 case SUMO_TAG_FLOW:
369 if (checkVehicleParents(obj)) {
371 // build flow over route
372 if (buildFlowOverRoute(obj,
373 obj->getVehicleParameter())) {
374 obj->markAsCreated();
375 }
376 } else if (isOverFromToEdges(obj)) {
377 // build flow with from-to edges
378 if (buildFlow(obj,
379 obj->getVehicleParameter(),
382 obj->markAsCreated();
383 }
384 } else if (isOverFromToJunctions(obj)) {
385 // build flow with from-to junctions
386 if (buildFlowJunctions(obj,
387 obj->getVehicleParameter(),
390 obj->markAsCreated();
391 }
392 } else if (isOverFromToTAZs(obj)) {
393 // build flow with from-to TAZs
394 if (buildFlowTAZs(obj,
395 obj->getVehicleParameter(),
398 obj->markAsCreated();
399 }
400
401 } else {
402 const auto embeddedRoute = getEmbeddedRoute(obj);
403 if (embeddedRoute) {
404 // build flow with embedded route
406 obj->getVehicleParameter(),
407 embeddedRoute->getStringListAttribute(SUMO_ATTR_EDGES),
408 embeddedRoute->getColorAttribute(SUMO_ATTR_COLOR),
409 embeddedRoute->getIntAttribute(SUMO_ATTR_REPEAT),
410 embeddedRoute->getTimeAttribute(SUMO_ATTR_CYCLETIME),
411 embeddedRoute->getParameters())) {
412 obj->markAsCreated();
413 }
414 }
415 }
416 }
417 break;
418 // persons
419 case SUMO_TAG_PERSON:
420 if (buildPerson(obj,
421 obj->getVehicleParameter())) {
422 obj->markAsCreated();
423 }
424 break;
426 if (buildPersonFlow(obj,
427 obj->getVehicleParameter())) {
428 obj->markAsCreated();
429 }
430 break;
431 // person plans
433 if (checkPersonPlanParents(obj)) {
434 if (buildPersonTrip(obj,
435 obj->getPlanParameters(),
442 obj->markAsCreated();
443 }
444 }
445 break;
446 case SUMO_TAG_RIDE:
447 if (checkPersonPlanParents(obj)) {
448 if (buildRide(obj,
449 obj->getPlanParameters(),
453 obj->markAsCreated();
454 }
455 }
456 break;
457 case SUMO_TAG_WALK:
458 if (checkPersonPlanParents(obj)) {
459 if (buildWalk(obj,
460 obj->getPlanParameters(),
464 obj->markAsCreated();
465 }
466 }
467 break;
468 // container
470 if (buildContainer(obj,
471 obj->getVehicleParameter())) {
472 obj->markAsCreated();
473 }
474 break;
476 if (buildContainerFlow(obj,
477 obj->getVehicleParameter())) {
478 obj->markAsCreated();
479 }
480 break;
481 // container plans
483 if (checkContainerPlanParents(obj)) {
484 if (buildTransport(obj,
485 obj->getPlanParameters(),
489 obj->markAsCreated();
490 }
491 }
492 break;
494 if (checkContainerPlanParents(obj)) {
495 if (buildTranship(obj,
496 obj->getPlanParameters(),
501 obj->markAsCreated();
502 }
503 }
504 break;
505 // stops
506 case SUMO_TAG_STOP:
507 if (checkStopParents(obj)) {
508 if (buildStop(obj,
509 obj->getPlanParameters(),
510 obj->getStopParameter())) {
511 obj->markAsCreated();
512 }
513 }
514 break;
515 default:
516 break;
517 }
518 // now iterate over childrens
519 for (const auto& child : obj->getSumoBaseObjectChildren()) {
520 // call this function recursively
521 parseSumoBaseObject(child);
522 }
523}
524
525
526void
528 // parse vehicleType
530 if (vehicleTypeParameter) {
531 // set tag
533 // add all attributes
535 // delete vehicleType parameter (because in XMLStructure we have a copy)
536 delete vehicleTypeParameter;
537 } else {
539 }
540}
541
542
543void
545 // declare Ok Flag
546 bool parsedOk = true;
547 // special case for ID
548 const std::string refId = attrs.get<std::string>(SUMO_ATTR_REFID, "", parsedOk);
549 const double probability = attrs.getOpt<double>(SUMO_ATTR_PROB, refId.c_str(), parsedOk, 1.0);
550 if (parsedOk) {
551 // set tag
553 // add all attributes
556 } else {
558 }
559}
560
561
562void
564 // declare Ok Flag
565 bool parsedOk = true;
566 // needed attributes
567 const std::string id = attrs.get<std::string>(SUMO_ATTR_ID, "", parsedOk);
568 // optional attributes
569 const int deterministic = attrs.getOpt<int>(SUMO_ATTR_DETERMINISTIC, id.c_str(), parsedOk, -1);
570 const std::vector<std::string> vTypes = attrs.getOpt<std::vector<std::string> >(SUMO_ATTR_VTYPES, id.c_str(), parsedOk);
571 const std::vector<double> probabilities = attrs.getOpt<std::vector<double> >(SUMO_ATTR_PROBS, id.c_str(), parsedOk);
572 if (parsedOk) {
573 // set tag
575 // add all attributes
580 } else {
582 }
583}
584
585
586void
588 // declare Ok Flag
589 bool parsedOk = true;
590 // needed attributes
591 const std::string id = attrs.get<std::string>(SUMO_ATTR_ID, "", parsedOk);
592 const std::vector<std::string> edges = attrs.get<std::vector<std::string> >(SUMO_ATTR_EDGES, id.c_str(), parsedOk);
593 // optional attributes
595 const RGBColor color = attrs.getOpt<RGBColor>(SUMO_ATTR_COLOR, id.c_str(), parsedOk, RGBColor::INVISIBLE);
596 const int repeat = attrs.getOpt<int>(SUMO_ATTR_REPEAT, id.c_str(), parsedOk, 0);
597 const SUMOTime cycleTime = attrs.getOptSUMOTimeReporting(SUMO_ATTR_CYCLETIME, id.c_str(), parsedOk, 0);
598 const double probability = attrs.getOpt<double>(SUMO_ATTR_PROB, id.c_str(), parsedOk, 1.0);
599 // check attributes
600 if (!checkNegative(SUMO_TAG_ROUTE, id, SUMO_ATTR_CYCLETIME, cycleTime, true)) {
601 parsedOk = false;
602 }
603 if (!checkNegative(SUMO_TAG_ROUTE, id, SUMO_ATTR_REPEAT, repeat, true)) {
604 parsedOk = false;
605 }
606 if (parsedOk) {
607 // set tag
609 // add all attributes
617 } else {
619 }
620}
621
622
623void
625 // declare Ok Flag
626 bool parsedOk = true;
627 // special case for ID
628 const std::string refId = attrs.get<std::string>(SUMO_ATTR_REFID, "", parsedOk);
629 const double probability = attrs.getOpt<double>(SUMO_ATTR_PROB, refId.c_str(), parsedOk, 1.0);
630 if (parsedOk) {
631 // set tag
633 // add all attributes
636 } else {
638 }
639}
640
641
642void
644 // first check if this is an embedded route
645 if (attrs.hasAttribute(SUMO_ATTR_ID)) {
646 writeError(TL("an embedded route cannot have their own ID"));
647 } else {
648 // declare Ok Flag
649 bool parsedOk = true;
650 // special case for ID
652 // needed attributes
653 const std::vector<std::string> edges = attrs.get<std::vector<std::string> >(SUMO_ATTR_EDGES, vehicleID.c_str(), parsedOk);
654 // optional attributes
656 const RGBColor color = attrs.getOpt<RGBColor>(SUMO_ATTR_COLOR, vehicleID.c_str(), parsedOk, RGBColor::INVISIBLE);
657 const int repeat = attrs.getOpt<int>(SUMO_ATTR_REPEAT, vehicleID.c_str(), parsedOk, 0);
658 const SUMOTime cycleTime = attrs.getOptSUMOTimeReporting(SUMO_ATTR_CYCLETIME, vehicleID.c_str(), parsedOk, 0);
659 // check attributes
660 if (!checkNegative(SUMO_TAG_ROUTE, vehicleID, SUMO_ATTR_CYCLETIME, cycleTime, true)) {
661 parsedOk = false;
662 }
663 if (!checkNegative(SUMO_TAG_ROUTE, vehicleID, SUMO_ATTR_REPEAT, repeat, true)) {
664 parsedOk = false;
665 }
666 if (parsedOk) {
667 // set tag
669 // add all attributes
675 } else {
677 }
678 }
679}
680
681
682void
684 // declare Ok Flag
685 bool parsedOk = true;
686 // needed attributes
687 const std::string id = attrs.get<std::string>(SUMO_ATTR_ID, "", parsedOk);
688 // optional attributes
689 const std::vector<std::string> routes = attrs.getOpt<std::vector<std::string> >(SUMO_ATTR_ROUTES, id.c_str(), parsedOk);
690 const std::vector<double> probabilities = attrs.getOpt<std::vector<double> >(SUMO_ATTR_PROBS, id.c_str(), parsedOk);
691 if (parsedOk) {
692 // set tag
694 // add all attributes
698 } else {
700 }
701}
702
703
704void
706 // declare Ok Flag
707 bool parsedOk = true;
708 // parse vehicle
710 if (tripParameter) {
711 // check from/to edge/junction
713 writeError(TL("Attributes 'from', 'fromJunction' and 'fromTaz' cannot be defined together"));
716 writeError(TL("Attributes 'to', 'toJunction' and 'toTaz' cannot be defined together"));
719 // from-to attributes
720 const std::string fromJunction = attrs.get<std::string>(SUMO_ATTR_FROM_JUNCTION, tripParameter->id.c_str(), parsedOk);
721 const std::string toJunction = attrs.get<std::string>(SUMO_ATTR_TO_JUNCTION, tripParameter->id.c_str(), parsedOk);
722 if (parsedOk) {
723 // set tag
725 // set vehicle parameters
727 // add other attributes
730 } else {
732 }
733 } else if (attrs.hasAttribute(SUMO_ATTR_FROM_TAZ) && attrs.hasAttribute(SUMO_ATTR_TO_TAZ)) {
734 // from-to attributes
735 const std::string fromJunction = attrs.get<std::string>(SUMO_ATTR_FROM_TAZ, tripParameter->id.c_str(), parsedOk);
736 const std::string toJunction = attrs.get<std::string>(SUMO_ATTR_TO_TAZ, tripParameter->id.c_str(), parsedOk);
737 if (parsedOk) {
738 // set tag
740 // set vehicle parameters
742 // add other attributes
745 } else {
747 }
748 } else {
749 // from-to attributes
750 const std::string from = attrs.getOpt<std::string>(SUMO_ATTR_FROM, tripParameter->id.c_str(), parsedOk, "");
751 const std::string to = attrs.getOpt<std::string>(SUMO_ATTR_TO, tripParameter->id.c_str(), parsedOk, "");
752 // optional attributes
753 const std::vector<std::string> via = attrs.getOpt<std::vector<std::string> >(SUMO_ATTR_VIA, tripParameter->id.c_str(), parsedOk);
754 if (parsedOk) {
755 // set tag
757 // set vehicle parameters
759 // add other attributes
763 } else {
765 }
766 }
767 // delete trip parameter (because in XMLStructure we have a copy)
768 delete tripParameter;
769 } else {
771 }
772}
773
774
775void
777 // first parse vehicle
779 if (vehicleParameter) {
780 // set tag
782 // set vehicle parameters
784 // delete vehicle parameter (because in XMLStructure we have a copy)
785 delete vehicleParameter;
786 } else {
788 }
789}
790
791
792void
794 // declare Ok Flag
795 bool parsedOk = true;
796 // first parse flow
798 if (flowParameter) {
799 // set vehicle parameters
801 // check from/to edge/junction
803 writeError(TL("Attributes 'from', 'fromJunction' and 'fromTaz' cannot be defined together"));
806 writeError(TL("Attributes 'to', 'toJunction' and 'toTaz' cannot be defined together"));
808 } else if (attrs.hasAttribute(SUMO_ATTR_FROM) && attrs.hasAttribute(SUMO_ATTR_TO)) {
809 // from-to attributes
810 const std::string from = attrs.get<std::string>(SUMO_ATTR_FROM, flowParameter->id.c_str(), parsedOk);
811 const std::string to = attrs.get<std::string>(SUMO_ATTR_TO, flowParameter->id.c_str(), parsedOk);
812 // optional attributes
813 const std::vector<std::string> via = attrs.getOpt<std::vector<std::string> >(SUMO_ATTR_VIA, flowParameter->id.c_str(), parsedOk);
814 if (parsedOk) {
815 // set tag
817 // add other attributes
821 } else {
823 }
825 // from-to attributes
826 const std::string fromJunction = attrs.get<std::string>(SUMO_ATTR_FROM_JUNCTION, flowParameter->id.c_str(), parsedOk);
827 const std::string toJunction = attrs.get<std::string>(SUMO_ATTR_TO_JUNCTION, flowParameter->id.c_str(), parsedOk);
828 if (parsedOk) {
829 // set tag
831 // add other attributes
834 } else {
836 }
837 } else if (attrs.hasAttribute(SUMO_ATTR_FROM_TAZ) && attrs.hasAttribute(SUMO_ATTR_TO_TAZ)) {
838 // from-to attributes
839 const std::string fromJunction = attrs.get<std::string>(SUMO_ATTR_FROM_TAZ, flowParameter->id.c_str(), parsedOk);
840 const std::string toJunction = attrs.get<std::string>(SUMO_ATTR_TO_TAZ, flowParameter->id.c_str(), parsedOk);
841 if (parsedOk) {
842 // set tag
844 // add other attributes
847 } else {
849 }
850 } else if (attrs.hasAttribute(SUMO_ATTR_ROUTE)) {
851 // from-to attributes
852 const std::string route = attrs.get<std::string>(SUMO_ATTR_ROUTE, flowParameter->id.c_str(), parsedOk);
853 if (parsedOk) {
854 // set tag
856 // add other attributes
858 } else {
860 }
861 } else {
862 // set tag
864 }
865 // delete flow parameter (because in XMLStructure we have a copy)
866 delete flowParameter;
867 } else {
869 }
870}
871
872
873void
875 // declare Ok Flag
876 bool parsedOk = true;
877 // declare stop
879 // plan parameters
880 const auto planParameters = CommonXMLStructure::PlanParameters(myCommonXMLStructure.getCurrentSumoBaseObject(), attrs, parsedOk);
881 // get parents
882 std::vector<SumoXMLTag> stopParents;
883 stopParents.insert(stopParents.end(), NamespaceIDs::routes.begin(), NamespaceIDs::routes.end());
884 stopParents.insert(stopParents.end(), NamespaceIDs::vehicles.begin(), NamespaceIDs::vehicles.end());
885 stopParents.insert(stopParents.end(), NamespaceIDs::persons.begin(), NamespaceIDs::persons.end());
886 stopParents.insert(stopParents.end(), NamespaceIDs::containers.begin(), NamespaceIDs::containers.end());
887 // check parents
888 checkParsedParent(SUMO_TAG_STOP, stopParents, parsedOk);
889 // parse stop
890 if (parsedOk && parseStopParameters(stop, attrs)) {
891 // set tag
893 // add stop attributes
896 } else {
898 }
899}
900
901
902void
904 // first parse vehicle
906 if (personParameter) {
907 // set tag
909 // set vehicle parameter
911 // delete person parameter (because in XMLStructure we have a copy)
912 delete personParameter;
913 } else {
915 }
916}
917
918
919void
921 // first parse flow
923 if (personFlowParameter) {
924 // set tag
926 // set vehicle parameter
928 // delete person flow parameter (because in XMLStructure we have a copy)
929 delete personFlowParameter;
930 } else {
932 }
933}
934
935
936void
938 // declare Ok Flag
939 bool parsedOk = true;
940 // plan parameters
941 const auto planParameters = CommonXMLStructure::PlanParameters(myCommonXMLStructure.getCurrentSumoBaseObject(), attrs, parsedOk);
942 // optional attributes
943 const std::vector<std::string> via = attrs.getOpt<std::vector<std::string> >(SUMO_ATTR_VIA, "", parsedOk);
944 const std::vector<std::string> vTypes = attrs.getOpt<std::vector<std::string> >(SUMO_ATTR_VTYPES, "", parsedOk);
945 const std::vector<std::string> lines = attrs.getOpt<std::vector<std::string> >(SUMO_ATTR_LINES, "", parsedOk);
946 std::vector<std::string> modes = attrs.getOpt<std::vector<std::string> >(SUMO_ATTR_MODES, "", parsedOk);
947 const double departPos = attrs.getOpt<double>(SUMO_ATTR_DEPARTPOS, "", parsedOk, -1);
948 const double arrivalPos = attrs.getOpt<double>(SUMO_ATTR_ARRIVALPOS, "", parsedOk, -1);
949 const double walkFactor = attrs.getOpt<double>(SUMO_ATTR_WALKFACTOR, "", parsedOk, 0);
950 const std::string group = attrs.getOpt<std::string>(SUMO_ATTR_GROUP, "", parsedOk, "");
951 // check modes
952 SVCPermissions dummyModeSet;
953 std::string dummyError;
954 if (!SUMOVehicleParameter::parsePersonModes(toString(modes), toString(SUMO_TAG_PERSONTRIP), "", dummyModeSet, dummyError)) {
955 WRITE_WARNING(dummyError);
956 modes.clear();
957 }
958 // check parents
960 if (parsedOk) {
961 // set tag
963 // add all attributes
972 } else {
974 }
975}
976
977
978void
981 writeError(TL("Speed and duration attributes cannot be defined together in walks"));
983 } else {
984 // declare Ok Flag
985 bool parsedOk = true;
986 // plan parameters
987 const auto planParameters = CommonXMLStructure::PlanParameters(myCommonXMLStructure.getCurrentSumoBaseObject(), attrs, parsedOk);
988 // optional attributes
989 const double departPos = attrs.getOpt<double>(SUMO_ATTR_DEPARTPOS, "", parsedOk, -1);
990 const double arrivalPos = attrs.getOpt<double>(SUMO_ATTR_ARRIVALPOS, "", parsedOk, -1);
991 const double speed = attrs.getOpt<double>(SUMO_ATTR_SPEED, "", parsedOk, 1.39);
992 const SUMOTime duration = attrs.getOptSUMOTimeReporting(SUMO_ATTR_DURATION, "", parsedOk, 0);
993 // check parents
995 if (parsedOk) {
996 // set tag
998 // add all attributes
1004 } else {
1006 }
1007 }
1008}
1009
1010
1011void
1013 // declare Ok Flag
1014 bool parsedOk = true;
1015 // plan parameters
1016 const auto planParameters = CommonXMLStructure::PlanParameters(myCommonXMLStructure.getCurrentSumoBaseObject(), attrs, parsedOk);
1017 // optional attributes
1018 const std::vector<std::string> lines = attrs.getOpt<std::vector<std::string> >(SUMO_ATTR_LINES, "", parsedOk);
1019 const double arrivalPos = attrs.getOpt<double>(SUMO_ATTR_ARRIVALPOS, "", parsedOk, -1);
1020 const std::string group = attrs.getOpt<std::string>(SUMO_ATTR_GROUP, "", parsedOk, "");
1021 // check parents
1023 if (parsedOk) {
1024 // set tag
1026 // add all attributes
1031 } else {
1033 }
1034}
1035
1036
1037void
1039 // first parse container
1041 if (containerParameter) {
1042 // set tag
1044 // set vehicle parameter
1046 // delete container parameter (because in XMLStructure we have a copy)
1047 delete containerParameter;
1048 } else {
1050 }
1051}
1052
1053
1054void
1056 // first parse flow
1058 if (containerFlowParameter) {
1059 // set tag
1061 // set vehicle parameter
1063 // delete container flow parameter (because in XMLStructure we have a copy)
1064 delete containerFlowParameter;
1065 } else {
1067 }
1068}
1069
1070
1071void
1073 // declare Ok Flag
1074 bool parsedOk = true;
1075 // plan parameters
1076 const auto planParameters = CommonXMLStructure::PlanParameters(myCommonXMLStructure.getCurrentSumoBaseObject(), attrs, parsedOk);
1077 // optional attributes
1078 const std::vector<std::string> lines = attrs.getOpt<std::vector<std::string> >(SUMO_ATTR_LINES, "", parsedOk);
1079 const double arrivalPos = attrs.getOpt<double>(SUMO_ATTR_ARRIVALPOS, "", parsedOk, -1);
1080 const std::string group = attrs.getOpt<std::string>(SUMO_ATTR_GROUP, "", parsedOk, "");
1081 // check parents
1083 if (parsedOk) {
1084 // set tag
1086 // add all attributes
1091 } else {
1093 }
1094}
1095
1096
1097void
1100 writeError(TL("Speed and duration attributes cannot be defined together in tranships"));
1102 } else {
1103 // declare Ok Flag
1104 bool parsedOk = true;
1105 // plan parameters
1106 const auto planParameters = CommonXMLStructure::PlanParameters(myCommonXMLStructure.getCurrentSumoBaseObject(), attrs, parsedOk);
1107 // optional attributes
1108 const double arrivalPos = attrs.getOpt<double>(SUMO_ATTR_ARRIVALPOS, "", parsedOk, -1);
1109 const double departPos = attrs.getOpt<double>(SUMO_ATTR_DEPARTPOS, "", parsedOk, -1);
1110 const double speed = attrs.getOpt<double>(SUMO_ATTR_SPEED, "", parsedOk, 1.39);
1111 const SUMOTime duration = attrs.getOptSUMOTimeReporting(SUMO_ATTR_DURATION, "", parsedOk, 0);
1112 // check parents
1114 if (parsedOk) {
1115 // set tag
1117 // add all attributes
1123 } else {
1125 }
1126 }
1127}
1128
1129
1130void
1132 // declare Ok Flag
1133 bool parsedOk = true;
1134 // just parse begin and end default
1135 myFlowBeginDefault = attrs.getSUMOTimeReporting(SUMO_ATTR_BEGIN, nullptr, parsedOk);
1136 myFlowEndDefault = attrs.getSUMOTimeReporting(SUMO_ATTR_END, nullptr, parsedOk);
1137}
1138
1139
1140bool
1142 // write warning info
1143 WRITE_WARNINGF(TL("Defining car-following parameters in a nested element is deprecated in vType '%', use attributes instead!"), vTypeObject->getStringAttribute(SUMO_ATTR_ID));
1144 // get vType to modify it
1145 auto vType = vTypeObject->getVehicleTypeParameter();
1146 // parse nested CFM attributes
1147 if (SUMOVehicleParserHelper::parseCFMParams(&vType, tag, attrs, true)) {
1148 vTypeObject->setVehicleTypeParameter(&vType);
1149 return true;
1150 } else if (myHardFail) {
1151 throw ProcessError(TL("Invalid parsing embedded VType"));
1152 } else {
1153 return writeError(TL("Invalid parsing embedded VType"));
1154 }
1155 return false;
1156}
1157
1158
1159bool
1161 // check stop parameters
1162 if (attrs.hasAttribute(SUMO_ATTR_ARRIVAL)) {
1164 }
1165 if (attrs.hasAttribute(SUMO_ATTR_DURATION)) {
1167 }
1168 if (attrs.hasAttribute(SUMO_ATTR_UNTIL)) {
1170 }
1171 if (attrs.hasAttribute(SUMO_ATTR_STARTED)) {
1173 }
1174 if (attrs.hasAttribute(SUMO_ATTR_ENDED)) {
1176 }
1177 if (attrs.hasAttribute(SUMO_ATTR_EXTENSION)) {
1179 }
1180 if (attrs.hasAttribute(SUMO_ATTR_ENDPOS)) {
1182 }
1183 if (attrs.hasAttribute(SUMO_ATTR_STARTPOS)) {
1185 }
1188 }
1189 if (attrs.hasAttribute(SUMO_ATTR_TRIGGERED)) {
1191 }
1192 // legacy attribute
1195 }
1196 if (attrs.hasAttribute(SUMO_ATTR_PARKING)) {
1198 }
1199 if (attrs.hasAttribute(SUMO_ATTR_EXPECTED)) {
1201 }
1202 if (attrs.hasAttribute(SUMO_ATTR_PERMITTED)) {
1204 }
1207 }
1208 if (attrs.hasAttribute(SUMO_ATTR_TRIP_ID)) {
1210 }
1211 if (attrs.hasAttribute(SUMO_ATTR_SPLIT)) {
1213 }
1214 if (attrs.hasAttribute(SUMO_ATTR_JOIN)) {
1216 }
1217 if (attrs.hasAttribute(SUMO_ATTR_LINE)) {
1219 }
1220 if (attrs.hasAttribute(SUMO_ATTR_SPEED)) {
1222 }
1223 if (attrs.hasAttribute(SUMO_ATTR_ONDEMAND)) {
1225 }
1226 if (attrs.hasAttribute(SUMO_ATTR_JUMP)) {
1228 }
1231 }
1232 // get parameters
1233 bool ok = true;
1234 // edge/lane
1235 stop.edge = attrs.getOpt<std::string>(SUMO_ATTR_EDGE, nullptr, ok, "");
1236 stop.lane = attrs.getOpt<std::string>(SUMO_ATTR_LANE, nullptr, ok, stop.busstop);
1237 // check errors
1238 if (!stop.edge.empty() && !stop.lane.empty()) {
1239 return writeError(TL("A stop must be defined either with an edge or with an lane, not both"));
1240 }
1241 // stopping places
1242 stop.busstop = attrs.getOpt<std::string>(SUMO_ATTR_BUS_STOP, nullptr, ok, "");
1243 if (stop.busstop.empty()) {
1244 stop.busstop = attrs.getOpt<std::string>(SUMO_ATTR_TRAIN_STOP, nullptr, ok, stop.busstop);
1245 }
1246 stop.chargingStation = attrs.getOpt<std::string>(SUMO_ATTR_CHARGING_STATION, nullptr, ok, "");
1247 stop.overheadWireSegment = attrs.getOpt<std::string>(SUMO_ATTR_OVERHEAD_WIRE_SEGMENT, nullptr, ok, "");
1248 stop.containerstop = attrs.getOpt<std::string>(SUMO_ATTR_CONTAINER_STOP, nullptr, ok, "");
1249 stop.parkingarea = attrs.getOpt<std::string>(SUMO_ATTR_PARKING_AREA, nullptr, ok, "");
1250 //check stopping places
1251 const int numStoppingPlaces = !stop.busstop.empty() + !stop.chargingStation.empty() + !stop.overheadWireSegment.empty() +
1252 !stop.containerstop.empty() + !stop.parkingarea.empty();
1253 if (numStoppingPlaces > 1) {
1254 return writeError(TL("A stop must be defined only in a StoppingPlace"));
1255 } else if ((numStoppingPlaces == 0) && stop.edge.empty() && stop.lane.empty()) {
1256 return writeError(TL("A stop must be defined in an edge, a lane, or in a StoppingPlace"));
1257 }
1258 // declare error suffix
1259 std::string errorSuffix;
1260 if (stop.busstop != "") {
1261 errorSuffix = " at '" + stop.busstop + "'" + errorSuffix;
1262 } else if (stop.chargingStation != "") {
1263 errorSuffix = " at '" + stop.chargingStation + "'" + errorSuffix;
1264 } else if (stop.overheadWireSegment != "") {
1265 errorSuffix = " at '" + stop.overheadWireSegment + "'" + errorSuffix;
1266 } else if (stop.containerstop != "") {
1267 errorSuffix = " at '" + stop.containerstop + "'" + errorSuffix;
1268 } else if (stop.parkingarea != "") {
1269 errorSuffix = " at '" + stop.parkingarea + "'" + errorSuffix;
1270 } else if (stop.edge != "") {
1271 errorSuffix = " at '" + stop.edge + "'" + errorSuffix;
1272 } else {
1273 errorSuffix = " on lane '" + stop.lane + "'" + errorSuffix;
1274 }
1275 // speed for counting as stopped
1276 stop.speed = attrs.getOpt<double>(SUMO_ATTR_SPEED, nullptr, ok, 0);
1277 if (stop.speed < 0) {
1278 return writeError("Speed cannot be negative for stop" + errorSuffix);
1279 return false;
1280 }
1281 // get the standing duration
1282 bool expectTrigger = !attrs.hasAttribute(SUMO_ATTR_DURATION) && !attrs.hasAttribute(SUMO_ATTR_UNTIL) && !attrs.hasAttribute(SUMO_ATTR_SPEED);
1283 std::vector<std::string> triggers = attrs.getOpt<std::vector<std::string> >(SUMO_ATTR_TRIGGERED, nullptr, ok);
1284 // legacy
1285 if (attrs.getOpt<bool>(SUMO_ATTR_CONTAINER_TRIGGERED, nullptr, ok, false)) {
1286 triggers.push_back(toString(SUMO_TAG_CONTAINER));
1287 };
1288 SUMOVehicleParameter::parseStopTriggers(triggers, expectTrigger, stop);
1289 stop.startPos = attrs.getOpt<double>(SUMO_ATTR_STARTPOS, nullptr, ok, 0);
1290 stop.endPos = attrs.getOpt<double>(SUMO_ATTR_ENDPOS, nullptr, ok, 0);
1291 stop.friendlyPos = attrs.getOpt<bool>(SUMO_ATTR_FRIENDLY_POS, nullptr, ok, false);
1292 stop.arrival = attrs.getOptSUMOTimeReporting(SUMO_ATTR_ARRIVAL, nullptr, ok, -1);
1293 stop.duration = attrs.getOptSUMOTimeReporting(SUMO_ATTR_DURATION, nullptr, ok, -1);
1294 stop.until = attrs.getOptSUMOTimeReporting(SUMO_ATTR_UNTIL, nullptr, ok, -1);
1295 if (!expectTrigger && (!ok || (stop.duration < 0 && stop.until < 0 && stop.speed == 0))) {
1296 return writeError("Invalid duration or end time is given for a stop" + errorSuffix);
1297 return false;
1298 }
1299 stop.extension = attrs.getOptSUMOTimeReporting(SUMO_ATTR_EXTENSION, nullptr, ok, -1);
1300 const bool defaultParking = (stop.triggered || stop.containerTriggered || stop.parkingarea != "");
1301 stop.parking = attrs.getOpt<ParkingType>(SUMO_ATTR_PARKING, nullptr, ok, defaultParking ? ParkingType::OFFROAD : ParkingType::ONROAD);
1302 if ((stop.parkingarea != "") && (stop.parking == ParkingType::ONROAD)) {
1303 WRITE_WARNING("Stop at parkingarea overrides attribute 'parking' for stop" + errorSuffix);
1305 }
1306 if (!ok) {
1307 return writeError("Invalid bool for 'triggered', 'containerTriggered' or 'parking' for stop" + errorSuffix);
1308 return false;
1309 }
1310 // expected persons
1311 const std::vector<std::string>& expected = attrs.getOpt<std::vector<std::string> >(SUMO_ATTR_EXPECTED, nullptr, ok);
1312 stop.awaitedPersons.insert(expected.begin(), expected.end());
1313 if (stop.awaitedPersons.size() > 0 && (stop.parametersSet & STOP_TRIGGER_SET) == 0) {
1314 stop.triggered = true;
1315 if ((stop.parametersSet & STOP_PARKING_SET) == 0) {
1317 }
1318 }
1319 // permitted transportables
1320 const std::vector<std::string>& permitted = attrs.getOpt<std::vector<std::string> >(SUMO_ATTR_PERMITTED, nullptr, ok);
1321 stop.permitted.insert(permitted.begin(), permitted.end());
1322 // expected containers
1323 const std::vector<std::string>& expectedContainers = attrs.getOpt<std::vector<std::string> >(SUMO_ATTR_EXPECTED_CONTAINERS, nullptr, ok);
1324 stop.awaitedContainers.insert(expectedContainers.begin(), expectedContainers.end());
1325 if (stop.awaitedContainers.size() > 0 && (stop.parametersSet & STOP_CONTAINER_TRIGGER_SET) == 0) {
1326 stop.containerTriggered = true;
1327 if ((stop.parametersSet & STOP_PARKING_SET) == 0) {
1329 }
1330 }
1331 // public transport trip id
1332 stop.tripId = attrs.getOpt<std::string>(SUMO_ATTR_TRIP_ID, nullptr, ok, "");
1333 stop.split = attrs.getOpt<std::string>(SUMO_ATTR_SPLIT, nullptr, ok, "");
1334 stop.join = attrs.getOpt<std::string>(SUMO_ATTR_JOIN, nullptr, ok, "");
1335 stop.line = attrs.getOpt<std::string>(SUMO_ATTR_LINE, nullptr, ok, "");
1336 // index
1337 const std::string idx = attrs.getOpt<std::string>(SUMO_ATTR_INDEX, nullptr, ok, "end");
1338 if (idx == "end") {
1339 stop.index = STOP_INDEX_END;
1340 } else if (idx == "fit") {
1341 stop.index = STOP_INDEX_FIT;
1342 } else {
1343 stop.index = attrs.get<int>(SUMO_ATTR_INDEX, nullptr, ok);
1344 if (!ok || stop.index < 0) {
1345 return writeError("Invalid 'index' for stop" + errorSuffix);
1346 return false;
1347 }
1348 }
1349 stop.started = attrs.getOptSUMOTimeReporting(SUMO_ATTR_STARTED, nullptr, ok, -1);
1350 stop.ended = attrs.getOptSUMOTimeReporting(SUMO_ATTR_ENDED, nullptr, ok, -1);
1351 stop.posLat = attrs.getOpt<double>(SUMO_ATTR_POSITION_LAT, nullptr, ok, INVALID_DOUBLE);
1352 stop.actType = attrs.getOpt<std::string>(SUMO_ATTR_ACTTYPE, nullptr, ok, "");
1353 stop.onDemand = attrs.getOpt<bool>(SUMO_ATTR_ONDEMAND, nullptr, ok, false);
1354 stop.jump = attrs.getOptSUMOTimeReporting(SUMO_ATTR_JUMP, nullptr, ok, -1);
1355 stop.jumpUntil = attrs.getOptSUMOTimeReporting(SUMO_ATTR_JUMP_UNTIL, nullptr, ok, -1);
1356 return true;
1357}
1358
1359
1360bool
1362 return sumoBaseObject->hasStringAttribute(SUMO_ATTR_FROM) && sumoBaseObject->hasStringAttribute(SUMO_ATTR_TO);
1363}
1364
1365
1366bool
1370
1371
1372bool
1374 return sumoBaseObject->hasStringAttribute(SUMO_ATTR_FROM_TAZ) && sumoBaseObject->hasStringAttribute(SUMO_ATTR_TO_TAZ);
1375}
1376
1377/****************************************************************************/
long long int SUMOTime
Definition GUI.h:36
#define WRITE_WARNINGF(...)
Definition MsgHandler.h:288
#define WRITE_ERROR(msg)
Definition MsgHandler.h:296
#define WRITE_WARNING(msg)
Definition MsgHandler.h:287
#define TL(string)
Definition MsgHandler.h:305
SUMOTime string2time(const std::string &r)
convert string to SUMOTime
Definition SUMOTime.cpp:46
long long int SVCPermissions
bitset where each bit declares whether a certain SVC may use this edge/lane
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types.
const int STOP_ARRIVAL_SET
const int STOP_DURATION_SET
const int STOP_INDEX_END
const int STOP_POSLAT_SET
const int STOP_EXPECTED_SET
const int STOP_SPEED_SET
const int STOP_JUMP_UNTIL_SET
const int STOP_UNTIL_SET
const int STOP_LINE_SET
const int STOP_PARKING_SET
const int STOP_TRIP_ID_SET
const int STOP_PERMITTED_SET
const int STOP_SPLIT_SET
const int STOP_START_SET
const int STOP_JOIN_SET
const int STOP_CONTAINER_TRIGGER_SET
const int STOP_EXTENSION_SET
const int STOP_INDEX_FIT
const int STOP_ENDED_SET
const int STOP_TRIGGER_SET
const int STOP_JUMP_SET
const int STOP_ONDEMAND_SET
const int STOP_END_SET
const int STOP_STARTED_SET
const int STOP_EXPECTED_CONTAINERS_SET
SumoXMLTag
Numbers representing SUMO-XML - element names.
@ SUMO_TAG_INTERVAL
an aggreagated-output interval
@ SUMO_TAG_VTYPE
description of a vehicle/person/container type
@ SUMO_TAG_WALK
@ SUMO_TAG_TRANSHIP
@ SUMO_TAG_CONTAINERFLOW
@ SUMO_TAG_STOP
stop for vehicles
@ SUMO_TAG_VEHICLE
description of a vehicle
@ SUMO_TAG_ROUTE_DISTRIBUTION
distribution of a route
@ SUMO_TAG_FLOW
a flow definition using from and to edges or a route
@ SUMO_TAG_TRANSPORT
@ SUMO_TAG_CONTAINER
@ SUMO_TAG_ROUTE
description of a route
@ SUMO_TAG_RIDE
@ SUMO_TAG_VTYPE_DISTRIBUTION
distribution of a vehicle type
@ SUMO_TAG_PARAM
parameter associated to a certain key
@ SUMO_TAG_ERROR
tag used for indicate that there is an error (usually loading elements in handlers)
@ SUMO_TAG_PERSON
@ SUMO_TAG_PERSONTRIP
@ SUMO_TAG_PERSONFLOW
@ SUMO_TAG_TRIP
a single trip definition (used by router)
ParkingType
Numbers representing special SUMO-XML-attribute values Information on whether a car is parking on the...
@ SUMO_ATTR_CONTAINER_TRIGGERED
@ SUMO_ATTR_STARTPOS
@ SUMO_ATTR_PARKING
@ SUMO_ATTR_EXTENSION
@ SUMO_ATTR_LINES
@ SUMO_ATTR_LANE
@ SUMO_ATTR_REFID
@ SUMO_ATTR_FROM_JUNCTION
@ SUMO_ATTR_SPEED
@ SUMO_ATTR_STARTED
@ SUMO_ATTR_VIA
@ SUMO_ATTR_CONTAINER_STOP
@ SUMO_ATTR_PARKING_AREA
@ SUMO_ATTR_EDGE
@ SUMO_ATTR_BUS_STOP
@ SUMO_ATTR_TRAIN_STOP
@ SUMO_ATTR_ENDPOS
@ SUMO_ATTR_TO_JUNCTION
@ SUMO_ATTR_ARRIVALPOS
@ SUMO_ATTR_SPLIT
@ SUMO_ATTR_ACTTYPE
@ SUMO_ATTR_PROBS
@ SUMO_ATTR_BEGIN
weights: time range begin
@ SUMO_ATTR_EDGES
the edges of a route
@ SUMO_ATTR_POSITION_LAT
@ SUMO_ATTR_EXPECTED
@ SUMO_ATTR_LINE
@ SUMO_ATTR_CHARGING_STATION
@ SUMO_ATTR_ROUTES
@ SUMO_ATTR_MODES
@ SUMO_ATTR_VTYPES
@ SUMO_ATTR_OVERHEAD_WIRE_SEGMENT
@ SUMO_ATTR_DEPARTPOS
@ SUMO_ATTR_GROUP
@ SUMO_ATTR_ENDED
@ SUMO_ATTR_ONDEMAND
@ SUMO_ATTR_INDEX
@ SUMO_ATTR_ARRIVAL
@ SUMO_ATTR_TO_TAZ
@ SUMO_ATTR_TRIP_ID
@ SUMO_ATTR_TO
@ SUMO_ATTR_FROM
@ SUMO_ATTR_END
weights: time range end
@ SUMO_ATTR_PERMITTED
@ SUMO_ATTR_FROM_TAZ
@ SUMO_ATTR_JOIN
@ SUMO_ATTR_JUMP
@ SUMO_ATTR_PROB
@ SUMO_ATTR_FRIENDLY_POS
@ SUMO_ATTR_WALKFACTOR
@ SUMO_ATTR_DETERMINISTIC
@ SUMO_ATTR_EXPECTED_CONTAINERS
@ SUMO_ATTR_ROUTE
@ SUMO_ATTR_COLOR
A color information.
@ SUMO_ATTR_ID
@ SUMO_ATTR_UNTIL
@ SUMO_ATTR_JUMP_UNTIL
@ SUMO_ATTR_TRIGGERED
@ SUMO_ATTR_DURATION
@ SUMO_ATTR_REPEAT
@ SUMO_ATTR_CYCLETIME
const double INVALID_DOUBLE
invalid double
Definition StdDefs.h:64
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition ToString.h:46
The XML-Handler for network loading.
bool checkStopParents(CommonXMLStructure::SumoBaseObject *obj)
check stop parents
CommonXMLStructure::SumoBaseObject * getEmbeddedRoute(const CommonXMLStructure::SumoBaseObject *sumoBaseObject) const
get embedded route from children
void checkParsedParent(const SumoXMLTag currentTag, const std::vector< SumoXMLTag > &parentTags, bool &ok)
check parsed parents
bool checkContainerPlanParents(CommonXMLStructure::SumoBaseObject *obj)
check container plan parents
bool writeError(const std::string &error)
write error and enable error creating element
void parseParameters(const SUMOSAXAttributes &attrs)
parse generic parameters
CommonXMLStructure myCommonXMLStructure
common XML Structure
bool checkVehicleParents(CommonXMLStructure::SumoBaseObject *obj)
check vehicle parents
const std::string myFilename
filename
bool checkNegative(const SumoXMLTag tag, const std::string &id, const SumoXMLAttr attribute, const int value, const bool canBeZero)
check if the given int value is NOT negative
bool checkPersonPlanParents(CommonXMLStructure::SumoBaseObject *obj)
check person plan parents
plan parameters (used for group all from-to parameters related with plans)
void addDoubleListAttribute(const SumoXMLAttr attr, const std::vector< double > &value)
add double list attribute into current SumoBaseObject node
const std::vector< double > & getDoubleListAttribute(const SumoXMLAttr attr) const
get double list attribute
void addIntAttribute(const SumoXMLAttr attr, const int value)
add int attribute into current SumoBaseObject node
void setVehicleTypeParameter(const SUMOVTypeParameter *vehicleTypeParameter)
set vehicle type parameters
const SUMOVehicleParameter::Stop & getStopParameter() const
get stop parameters
const RGBColor & getColorAttribute(const SumoXMLAttr attr) const
get color attribute
SUMOTime getTimeAttribute(const SumoXMLAttr attr) const
get time attribute
bool hasStringAttribute(const SumoXMLAttr attr) const
has function
void setTag(const SumoXMLTag tag)
set SumoBaseObject tag
SumoBaseObject * getParentSumoBaseObject() const
get pointer to mySumoBaseObjectParent SumoBaseObject (if is null, then is the root)
const CommonXMLStructure::PlanParameters & getPlanParameters() const
get plan parameteres
const std::map< std::string, std::string > & getParameters() const
get parameters
SUMOVehicleClass getVClass() const
vehicle class
void setPlanParameters(const CommonXMLStructure::PlanParameters &planParameters)
set plan parmeter
const SUMOVTypeParameter & getVehicleTypeParameter() const
get current vType
SumoXMLTag getTag() const
get XML myTag
void markAsCreated()
mark as successfully created
void addTimeAttribute(const SumoXMLAttr attr, const SUMOTime value)
add time attribute into current SumoBaseObject node
void addStringListAttribute(const SumoXMLAttr attr, const std::vector< std::string > &value)
add string list attribute into current SumoBaseObject node
int getIntAttribute(const SumoXMLAttr attr) const
get int attribute
void addDoubleAttribute(const SumoXMLAttr attr, const double value)
add double attribute into current SumoBaseObject node
void setVClass(SUMOVehicleClass vClass)
set vehicle class
void setVehicleParameter(const SUMOVehicleParameter *vehicleParameter)
set vehicle parameters
void addStringAttribute(const SumoXMLAttr attr, const std::string &value)
add string attribute into current SumoBaseObject node
void setStopParameter(const SUMOVehicleParameter::Stop &stopParameter)
add stop parameters
double getDoubleAttribute(const SumoXMLAttr attr) const
get double attribute
const SUMOVehicleParameter & getVehicleParameter() const
get vehicle parameters
const std::vector< std::string > & getStringListAttribute(const SumoXMLAttr attr) const
get string list attribute
void addColorAttribute(const SumoXMLAttr attr, const RGBColor &value)
add color attribute into current SumoBaseObject node
const std::string & getStringAttribute(const SumoXMLAttr attr) const
get string attribute
const std::vector< SumoBaseObject * > & getSumoBaseObjectChildren() const
get SumoBaseObject children
void abortSUMOBaseOBject()
abort SUMOBaseOBject
CommonXMLStructure::SumoBaseObject * getSumoBaseObjectRoot() const
get SumoBaseObject root
CommonXMLStructure::SumoBaseObject * getCurrentSumoBaseObject() const
get current editedSumoBaseObject
void openSUMOBaseOBject()
open SUMOBaseOBject
void closeSUMOBaseOBject()
close SUMOBaseOBject
static const std::vector< SumoXMLTag > vehicles
vehicles namespace
static const std::vector< SumoXMLTag > routes
route namespace
static const std::vector< SumoXMLTag > persons
persons namespace
static const std::vector< SumoXMLTag > containers
containers namespace
A storage for options typed value containers)
Definition OptionsCont.h:89
static const RGBColor INVISIBLE
Definition RGBColor.h:198
void parseWalk(const SUMOSAXAttributes &attrs)
parse walk
virtual bool buildTranship(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const CommonXMLStructure::PlanParameters &planParameters, const double arrivalPosition, const double departPosition, const double speed, const SUMOTime duration)=0
build tranship
void parseContainerFlow(const SUMOSAXAttributes &attrs)
parse container flow
void parseFlow(const SUMOSAXAttributes &attrs)
parse flow (including flows, flows over routes and flows with embedded routes)
virtual bool buildRouteRef(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const std::string &routeID, const double probability)=0
build route ref
bool parseNestedCFM(const SumoXMLTag tag, const SUMOSAXAttributes &attrs, CommonXMLStructure::SumoBaseObject *vTypeObject)
parse nested CarFollowingModel
bool isOverFromToJunctions(const CommonXMLStructure::SumoBaseObject *sumoBaseObject) const
check if element is defined over from-to junctions
bool beginParseAttributes(SumoXMLTag tag, const SUMOSAXAttributes &attrs)
begin parse attributes
virtual bool buildFlow(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const SUMOVehicleParameter &vehicleParameters, const std::string &fromEdgeID, const std::string &toEdgeID)=0
build flow (from-to edges)
void parsePerson(const SUMOSAXAttributes &attrs)
parse person
void parseTransport(const SUMOSAXAttributes &attrs)
parse transport
void parseRouteRef(const SUMOSAXAttributes &attrs)
parse route reference
void endParseAttributes()
end parse attributes
virtual bool buildPerson(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const SUMOVehicleParameter &personParameters)=0
build person
virtual bool buildFlowEmbeddedRoute(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const SUMOVehicleParameter &vehicleParameters, const std::vector< std::string > &edgeIDs, const RGBColor &color, const int repeat, const SUMOTime cycleTime, const Parameterised::Map &routeParameters)=0
build a flow with an embedded route
virtual bool buildPersonFlow(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const SUMOVehicleParameter &personFlowParameters)=0
build person flow
virtual bool buildContainer(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const SUMOVehicleParameter &containerParameters)=0
build container
virtual bool buildWalk(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const CommonXMLStructure::PlanParameters &planParameters, const double arrivalPos, const double speed, const SUMOTime duration)=0
build walk
void parseVTypeDistribution(const SUMOSAXAttributes &attrs)
parse vType distribution
virtual bool buildRide(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const CommonXMLStructure::PlanParameters &planParameters, const double arrivalPos, const std::vector< std::string > &lines, const std::string &group)=0
build ride
void parseVTypeRef(const SUMOSAXAttributes &attrs)
parse vType reference
virtual bool buildFlowOverRoute(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const SUMOVehicleParameter &vehicleParameters)=0
build a flow over an existent route
void parseStop(const SUMOSAXAttributes &attrs)
parse stop
void parseContainer(const SUMOSAXAttributes &attrs)
parse container
void parsePersonTrip(const SUMOSAXAttributes &attrs)
parse person trip
void parseRoute(const SUMOSAXAttributes &attrs)
parse route
bool isOverFromToTAZs(const CommonXMLStructure::SumoBaseObject *sumoBaseObject) const
check if element is defined over from-to junctions
void parseTrip(const SUMOSAXAttributes &attrs)
parse trip
SUMOTime myFlowEndDefault
The default value for flow ends.
virtual ~RouteHandler()
Destructor.
bool isOverFromToEdges(const CommonXMLStructure::SumoBaseObject *sumoBaseObject) const
check if element is defined over from-to edges
RouteHandler()=delete
invalidate default onstructor
virtual bool buildTripTAZs(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const SUMOVehicleParameter &vehicleParameters, const std::string &fromTazID, const std::string &toTazID)=0
build trip (from-to TAZs)
void parseSumoBaseObject(CommonXMLStructure::SumoBaseObject *obj)
parse SumoBaseObject (it's called recursivelly)
void parsePersonFlow(const SUMOSAXAttributes &attrs)
parse person flow
void parseInterval(const SUMOSAXAttributes &attrs)
parse interval
virtual bool buildPersonTrip(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const CommonXMLStructure::PlanParameters &planParameters, const double arrivalPos, const std::vector< std::string > &types, const std::vector< std::string > &modes, const std::vector< std::string > &lines, const double walkFactor, const std::string &group)=0
build person trip
void parseVType(const SUMOSAXAttributes &attrs)
void parseRide(const SUMOSAXAttributes &attrs)
parse ride
virtual bool buildFlowJunctions(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const SUMOVehicleParameter &vehicleParameters, const std::string &fromJunctionID, const std::string &toJunctionID)=0
build flow (from-to junctions)
virtual bool buildVType(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const SUMOVTypeParameter &vTypeParameter)=0
build vType
virtual bool buildFlowTAZs(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const SUMOVehicleParameter &vehicleParameters, const std::string &fromTAZID, const std::string &toTAZID)=0
build flow (from-to TAZs)
SUMOTime myFlowBeginDefault
The default value for flow begins.
virtual bool buildVehicleEmbeddedRoute(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const SUMOVehicleParameter &vehicleParameters, const std::vector< std::string > &edgeIDs, const RGBColor &color, const int repeat, const SUMOTime cycleTime, const Parameterised::Map &routeParameters)=0
build a vehicle with an embedded route
virtual bool buildRoute(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const std::string &id, SUMOVehicleClass vClass, const std::vector< std::string > &edgeIDs, const RGBColor &color, const int repeat, const SUMOTime cycleTime, const double probability, const Parameterised::Map &routeParameters)=0
build route
void parseVehicle(const SUMOSAXAttributes &attrs)
parse vehicle (including vehicles over routes and vehicles with embedded routes)
virtual bool buildStop(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const CommonXMLStructure::PlanParameters &planParameters, const SUMOVehicleParameter::Stop &stopParameters)=0
build stop
virtual bool buildTrip(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const SUMOVehicleParameter &vehicleParameters, const std::string &fromEdgeID, const std::string &toEdgeID)=0
build trip (from-to edges)
void parseRouteEmbedded(const SUMOSAXAttributes &attrs)
parse embedded route
virtual bool buildVTypeRef(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const std::string &vTypeID, const double probability)=0
build vType ref
virtual bool buildContainerFlow(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const SUMOVehicleParameter &containerFlowParameters)=0
build container flow
virtual bool buildVehicleOverRoute(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const SUMOVehicleParameter &vehicleParameters)=0
build a vehicle over an existent route
bool parseStopParameters(SUMOVehicleParameter::Stop &stop, const SUMOSAXAttributes &attrs)
parse stop parameters
virtual bool buildTripJunctions(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const SUMOVehicleParameter &vehicleParameters, const std::string &fromJunctionID, const std::string &toJunctionID)=0
build trip (from-to junctions)
virtual bool buildRouteDistribution(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const std::string &id)=0
build route distribution
const bool myHardFail
enable or disable hardFail (stop parsing if parameter aren't correct)
virtual bool buildTransport(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const CommonXMLStructure::PlanParameters &planParameters, const double arrivalPos, const std::vector< std::string > &lines, const std::string &group)=0
build transport
void parseRouteDistribution(const SUMOSAXAttributes &attrs)
parse route distribution
virtual bool buildVTypeDistribution(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const std::string &id, const int deterministic)=0
build vType distribution
void parseTranship(const SUMOSAXAttributes &attrs)
parse tranship
Encapsulated SAX-Attributes.
T getOpt(int attr, const char *objectid, bool &ok, T defaultValue=T(), bool report=true) const
Tries to read given attribute assuming it is an int.
SUMOTime getOptSUMOTimeReporting(int attr, const char *objectid, bool &ok, SUMOTime defaultValue, bool report=true) const
Tries to read given attribute assuming it is a SUMOTime.
T get(int attr, const char *objectid, bool &ok, bool report=true) const
Tries to read given attribute assuming it is an int.
virtual bool hasAttribute(int id) const =0
Returns the information whether the named (by its enum-value) attribute is within the current list.
SUMOTime getSUMOTimeReporting(int attr, const char *objectid, bool &ok, bool report=true) const
Tries to read given attribute assuming it is a SUMOTime.
Structure representing possible vehicle parameter.
Definition of vehicle stop (position and duration)
SUMOTime started
the time at which this stop was reached
std::string edge
The edge to stop at.
ParkingType parking
whether the vehicle is removed from the net while stopping
std::string lane
The lane to stop at.
SUMOTime extension
The maximum time extension for boarding / loading.
bool friendlyPos
enable or disable friendly position (used by netedit)
double speed
the speed at which this stop counts as reached (waypoint mode)
std::string parkingarea
(Optional) parking area if one is assigned to the stop
std::string split
the id of the vehicle (train portion) that splits of upon reaching this stop
double startPos
The stopping position start.
std::string line
the new line id of the trip within a cyclical public transport route
double posLat
the lateral offset when stopping
bool onDemand
whether the stop may be skipped
std::string chargingStation
(Optional) charging station if one is assigned to the stop
std::string overheadWireSegment
(Optional) overhead line segment if one is assigned to the stop
std::set< std::string > permitted
IDs of persons or containers that may board/load at this stop.
SUMOTime jumpUntil
earlierst jump end if there shall be a jump from this stop to the next route edge
int parametersSet
Information for the output which parameter were set.
int index
at which position in the stops list
SUMOTime jump
transfer time if there shall be a jump from this stop to the next route edge
std::string join
the id of the vehicle (train portion) to which this vehicle shall be joined
SUMOTime until
The time at which the vehicle may continue its journey.
std::string actType
act Type (only used by Persons) (used by netedit)
bool triggered
whether an arriving person lets the vehicle continue
SUMOTime ended
the time at which this stop was ended
double endPos
The stopping position end.
std::set< std::string > awaitedPersons
IDs of persons the vehicle has to wait for until departing.
std::set< std::string > awaitedContainers
IDs of containers the vehicle has to wait for until departing.
std::string busstop
(Optional) bus stop if one is assigned to the stop
std::string tripId
id of the trip within a cyclical public transport route
std::string containerstop
(Optional) container stop if one is assigned to the stop
bool containerTriggered
whether an arriving container lets the vehicle continue
SUMOTime arrival
The (expected) time at which the vehicle reaches the stop.
SUMOTime duration
The stopping duration.
Structure representing possible vehicle parameter.
std::string id
The vehicle's id.
static bool parsePersonModes(const std::string &modes, const std::string &element, const std::string &id, SVCPermissions &modeSet, std::string &error)
Validates a given person modes value.
static void parseStopTriggers(const std::vector< std::string > &triggers, bool expectTrigger, Stop &stop)
parses stop trigger values
static SUMOVTypeParameter * beginVTypeParsing(const SUMOSAXAttributes &attrs, const bool hardFail, const std::string &file)
Starts to parse a vehicle type.
static bool parseCFMParams(SUMOVTypeParameter *into, const SumoXMLTag element, const SUMOSAXAttributes &attrs, const bool nestedCFM)
Parses Car Following Mode params.
static SUMOVehicleParameter * parseVehicleAttributes(int element, const SUMOSAXAttributes &attrs, const bool hardFail, const bool optionalID=false, const bool skipDepart=false, const bool allowInternalRoutes=false)
Parses a vehicle's attributes.
static SUMOVehicleClass parseVehicleClass(const SUMOSAXAttributes &attrs, const std::string &id)
Parses the vehicle class.
static SUMOVehicleParameter * parseFlowAttributes(SumoXMLTag tag, const SUMOSAXAttributes &attrs, const bool hardFail, const bool needID, const SUMOTime beginDefault, const SUMOTime endDefault, const bool allowInternalRoutes=false)
Parses a flow's attributes.