Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
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 // overwrite 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 // overwrite 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 // check if loading was aborted
259 if (!myAbortLoading) {
260 // switch tag
261 switch (obj->getTag()) {
262 // vTypes
263 case SUMO_TAG_VTYPE:
264 // check if parse vType or Ref
266 if (buildVTypeRef(obj,
269 obj->markAsCreated();
270 }
271 } else {
272 if (buildVType(obj,
273 obj->getVehicleTypeParameter())) {
274 obj->markAsCreated();
275 }
276 }
277 break;
282 obj->markAsCreated();
283 }
284 break;
285 // route
286 case SUMO_TAG_ROUTE:
287 // embedded routes are created in build<Vehicle/Flow>EmbeddedRoute
289 if (buildRouteRef(obj,
292 obj->markAsCreated();
293 }
294 } else if (obj->hasStringAttribute(SUMO_ATTR_ID)) {
295 if (buildRoute(obj,
297 obj->getVClass(),
303 obj->getParameters())) {
304 obj->markAsCreated();
305 }
306 }
307 break;
311 obj->markAsCreated();
312 }
313 break;
314 // vehicles
315 case SUMO_TAG_TRIP:
316 if (checkVehicleParents(obj)) {
317 if (isOverFromToEdges(obj)) {
318 // build trip with from-to edges
319 if (buildTrip(obj,
320 obj->getVehicleParameter(),
323 obj->markAsCreated();
324 }
325 } else if (isOverFromToJunctions(obj)) {
326 // build trip with from-to junctions
327 if (buildTripJunctions(obj,
328 obj->getVehicleParameter(),
331 obj->markAsCreated();
332 }
333 } else if (isOverFromToTAZs(obj)) {
334 // build trip with from-to TAZs
335 if (buildTripTAZs(obj,
336 obj->getVehicleParameter(),
339 obj->markAsCreated();
340 }
341 }
342 }
343 break;
344 case SUMO_TAG_VEHICLE:
345 if (checkVehicleParents(obj)) {
347 // build vehicle over route
348 if (buildVehicleOverRoute(obj,
349 obj->getVehicleParameter())) {
350 obj->markAsCreated();
351 }
352 } else {
353 const auto embeddedRoute = getEmbeddedRoute(obj);
354 if (embeddedRoute) {
355 // build vehicle with embedded route
357 obj->getVehicleParameter(),
358 embeddedRoute->getStringListAttribute(SUMO_ATTR_EDGES),
359 embeddedRoute->getColorAttribute(SUMO_ATTR_COLOR),
360 embeddedRoute->getIntAttribute(SUMO_ATTR_REPEAT),
361 embeddedRoute->getTimeAttribute(SUMO_ATTR_CYCLETIME),
362 embeddedRoute->getParameters())) {
363 obj->markAsCreated();
364 }
365 }
366 }
367 }
368 break;
369 // flows
370 case SUMO_TAG_FLOW:
371 if (checkVehicleParents(obj)) {
373 // build flow over route
374 if (buildFlowOverRoute(obj,
375 obj->getVehicleParameter())) {
376 obj->markAsCreated();
377 }
378 } else if (isOverFromToEdges(obj)) {
379 // build flow with from-to edges
380 if (buildFlow(obj,
381 obj->getVehicleParameter(),
384 obj->markAsCreated();
385 }
386 } else if (isOverFromToJunctions(obj)) {
387 // build flow with from-to junctions
388 if (buildFlowJunctions(obj,
389 obj->getVehicleParameter(),
392 obj->markAsCreated();
393 }
394 } else if (isOverFromToTAZs(obj)) {
395 // build flow with from-to TAZs
396 if (buildFlowTAZs(obj,
397 obj->getVehicleParameter(),
400 obj->markAsCreated();
401 }
402
403 } else {
404 const auto embeddedRoute = getEmbeddedRoute(obj);
405 if (embeddedRoute) {
406 // build flow with embedded route
408 obj->getVehicleParameter(),
409 embeddedRoute->getStringListAttribute(SUMO_ATTR_EDGES),
410 embeddedRoute->getColorAttribute(SUMO_ATTR_COLOR),
411 embeddedRoute->getIntAttribute(SUMO_ATTR_REPEAT),
412 embeddedRoute->getTimeAttribute(SUMO_ATTR_CYCLETIME),
413 embeddedRoute->getParameters())) {
414 obj->markAsCreated();
415 }
416 }
417 }
418 }
419 break;
420 // persons
421 case SUMO_TAG_PERSON:
422 if (buildPerson(obj,
423 obj->getVehicleParameter())) {
424 obj->markAsCreated();
425 }
426 break;
428 if (buildPersonFlow(obj,
429 obj->getVehicleParameter())) {
430 obj->markAsCreated();
431 }
432 break;
433 // person plans
435 if (checkPersonPlanParents(obj)) {
436 if (buildPersonTrip(obj,
437 obj->getPlanParameters(),
444 obj->markAsCreated();
445 }
446 }
447 break;
448 case SUMO_TAG_RIDE:
449 if (checkPersonPlanParents(obj)) {
450 if (buildRide(obj,
451 obj->getPlanParameters(),
455 obj->markAsCreated();
456 }
457 }
458 break;
459 case SUMO_TAG_WALK:
460 if (checkPersonPlanParents(obj)) {
461 if (buildWalk(obj,
462 obj->getPlanParameters(),
466 obj->markAsCreated();
467 }
468 }
469 break;
470 // container
472 if (buildContainer(obj,
473 obj->getVehicleParameter())) {
474 obj->markAsCreated();
475 }
476 break;
478 if (buildContainerFlow(obj,
479 obj->getVehicleParameter())) {
480 obj->markAsCreated();
481 }
482 break;
483 // container plans
485 if (checkContainerPlanParents(obj)) {
486 if (buildTransport(obj,
487 obj->getPlanParameters(),
491 obj->markAsCreated();
492 }
493 }
494 break;
496 if (checkContainerPlanParents(obj)) {
497 if (buildTranship(obj,
498 obj->getPlanParameters(),
503 obj->markAsCreated();
504 }
505 }
506 break;
507 // stops
508 case SUMO_TAG_STOP:
509 if (checkStopParents(obj)) {
510 if (buildStop(obj,
511 obj->getPlanParameters(),
512 obj->getStopParameter())) {
513 obj->markAsCreated();
514 }
515 }
516 break;
517 default:
518 break;
519 }
520 // now iterate over childrens
521 for (const auto& child : obj->getSumoBaseObjectChildren()) {
522 // call this function recursively
523 parseSumoBaseObject(child);
524 }
525 }
526}
527
528
529void
531 // parse vehicleType
533 if (vehicleTypeParameter) {
534 // set tag
536 // add all attributes
538 // delete vehicleType parameter (because in XMLStructure we have a copy)
539 delete vehicleTypeParameter;
540 } else {
542 }
543}
544
545
546void
548 // declare Ok Flag
549 bool parsedOk = true;
550 // special case for ID
551 const std::string refId = attrs.get<std::string>(SUMO_ATTR_REFID, "", parsedOk);
552 const double probability = attrs.getOpt<double>(SUMO_ATTR_PROB, refId.c_str(), parsedOk, 1.0);
553 if (parsedOk) {
554 // set tag
556 // add all attributes
559 } else {
561 }
562}
563
564
565void
567 // declare Ok Flag
568 bool parsedOk = true;
569 // needed attributes
570 const std::string id = attrs.get<std::string>(SUMO_ATTR_ID, "", parsedOk);
571 // optional attributes
572 const int deterministic = attrs.getOpt<int>(SUMO_ATTR_DETERMINISTIC, id.c_str(), parsedOk, -1);
573 const std::vector<std::string> vTypes = attrs.getOpt<std::vector<std::string> >(SUMO_ATTR_VTYPES, id.c_str(), parsedOk);
574 const std::vector<double> probabilities = attrs.getOpt<std::vector<double> >(SUMO_ATTR_PROBS, id.c_str(), parsedOk);
575 if (parsedOk) {
576 // set tag
578 // add all attributes
583 } else {
585 }
586}
587
588
589void
591 // declare Ok Flag
592 bool parsedOk = true;
593 // needed attributes
594 const std::string id = attrs.get<std::string>(SUMO_ATTR_ID, "", parsedOk);
595 const std::vector<std::string> edges = attrs.get<std::vector<std::string> >(SUMO_ATTR_EDGES, id.c_str(), parsedOk);
596 // optional attributes
598 const RGBColor color = attrs.getOpt<RGBColor>(SUMO_ATTR_COLOR, id.c_str(), parsedOk, RGBColor::INVISIBLE);
599 const int repeat = attrs.getOpt<int>(SUMO_ATTR_REPEAT, id.c_str(), parsedOk, 0);
600 const SUMOTime cycleTime = attrs.getOptSUMOTimeReporting(SUMO_ATTR_CYCLETIME, id.c_str(), parsedOk, 0);
601 const double probability = attrs.getOpt<double>(SUMO_ATTR_PROB, id.c_str(), parsedOk, 1.0);
602 // check attributes
603 if (!checkNegative(SUMO_TAG_ROUTE, id, SUMO_ATTR_CYCLETIME, cycleTime, true)) {
604 parsedOk = false;
605 }
606 if (!checkNegative(SUMO_TAG_ROUTE, id, SUMO_ATTR_REPEAT, repeat, true)) {
607 parsedOk = false;
608 }
609 if (parsedOk) {
610 // set tag
612 // add all attributes
620 } else {
622 }
623}
624
625
626void
628 // declare Ok Flag
629 bool parsedOk = true;
630 // special case for ID
631 const std::string refId = attrs.get<std::string>(SUMO_ATTR_REFID, "", parsedOk);
632 const double probability = attrs.getOpt<double>(SUMO_ATTR_PROB, refId.c_str(), parsedOk, 1.0);
633 if (parsedOk) {
634 // set tag
636 // add all attributes
639 } else {
641 }
642}
643
644
645void
647 // first check if this is an embedded route
648 if (attrs.hasAttribute(SUMO_ATTR_ID)) {
649 writeError(TL("an embedded route cannot have their own ID"));
650 } else {
651 // declare Ok Flag
652 bool parsedOk = true;
653 // special case for ID
655 // needed attributes
656 const std::vector<std::string> edges = attrs.get<std::vector<std::string> >(SUMO_ATTR_EDGES, vehicleID.c_str(), parsedOk);
657 // optional attributes
659 const RGBColor color = attrs.getOpt<RGBColor>(SUMO_ATTR_COLOR, vehicleID.c_str(), parsedOk, RGBColor::INVISIBLE);
660 const int repeat = attrs.getOpt<int>(SUMO_ATTR_REPEAT, vehicleID.c_str(), parsedOk, 0);
661 const SUMOTime cycleTime = attrs.getOptSUMOTimeReporting(SUMO_ATTR_CYCLETIME, vehicleID.c_str(), parsedOk, 0);
662 // check attributes
663 if (!checkNegative(SUMO_TAG_ROUTE, vehicleID, SUMO_ATTR_CYCLETIME, cycleTime, true)) {
664 parsedOk = false;
665 }
666 if (!checkNegative(SUMO_TAG_ROUTE, vehicleID, SUMO_ATTR_REPEAT, repeat, true)) {
667 parsedOk = false;
668 }
669 if (parsedOk) {
670 // set tag
672 // add all attributes
678 } else {
680 }
681 }
682}
683
684
685void
687 // declare Ok Flag
688 bool parsedOk = true;
689 // needed attributes
690 const std::string id = attrs.get<std::string>(SUMO_ATTR_ID, "", parsedOk);
691 // optional attributes
692 const std::vector<std::string> routes = attrs.getOpt<std::vector<std::string> >(SUMO_ATTR_ROUTES, id.c_str(), parsedOk);
693 const std::vector<double> probabilities = attrs.getOpt<std::vector<double> >(SUMO_ATTR_PROBS, id.c_str(), parsedOk);
694 if (parsedOk) {
695 // set tag
697 // add all attributes
701 } else {
703 }
704}
705
706
707void
709 // declare Ok Flag
710 bool parsedOk = true;
711 // parse vehicle
713 if (tripParameter) {
714 // check from/to edge/junction
716 writeError(TL("Attributes 'from', 'fromJunction' and 'fromTaz' cannot be defined together"));
719 writeError(TL("Attributes 'to', 'toJunction' and 'toTaz' cannot be defined together"));
722 // from-to attributes
723 const std::string fromJunction = attrs.get<std::string>(SUMO_ATTR_FROM_JUNCTION, tripParameter->id.c_str(), parsedOk);
724 const std::string toJunction = attrs.get<std::string>(SUMO_ATTR_TO_JUNCTION, tripParameter->id.c_str(), parsedOk);
725 if (parsedOk) {
726 // set tag
728 // set vehicle parameters
730 // add other attributes
733 } else {
735 }
736 } else if (attrs.hasAttribute(SUMO_ATTR_FROM_TAZ) && attrs.hasAttribute(SUMO_ATTR_TO_TAZ)) {
737 // from-to attributes
738 const std::string fromJunction = attrs.get<std::string>(SUMO_ATTR_FROM_TAZ, tripParameter->id.c_str(), parsedOk);
739 const std::string toJunction = attrs.get<std::string>(SUMO_ATTR_TO_TAZ, tripParameter->id.c_str(), parsedOk);
740 if (parsedOk) {
741 // set tag
743 // set vehicle parameters
745 // add other attributes
748 } else {
750 }
751 } else {
752 // from-to attributes
753 const std::string from = attrs.getOpt<std::string>(SUMO_ATTR_FROM, tripParameter->id.c_str(), parsedOk, "");
754 const std::string to = attrs.getOpt<std::string>(SUMO_ATTR_TO, tripParameter->id.c_str(), parsedOk, "");
755 // optional attributes
756 const std::vector<std::string> via = attrs.getOpt<std::vector<std::string> >(SUMO_ATTR_VIA, tripParameter->id.c_str(), parsedOk);
757 if (parsedOk) {
758 // set tag
760 // set vehicle parameters
762 // add other attributes
766 } else {
768 }
769 }
770 // delete trip parameter (because in XMLStructure we have a copy)
771 delete tripParameter;
772 } else {
774 }
775}
776
777
778void
780 // first parse vehicle
782 if (vehicleParameter) {
783 // set tag
785 // set vehicle parameters
787 // delete vehicle parameter (because in XMLStructure we have a copy)
788 delete vehicleParameter;
789 } else {
791 }
792}
793
794
795void
797 // declare Ok Flag
798 bool parsedOk = true;
799 // first parse flow
801 if (flowParameter) {
802 // set vehicle parameters
804 // check from/to edge/junction
806 writeError(TL("Attributes 'from', 'fromJunction' and 'fromTaz' cannot be defined together"));
809 writeError(TL("Attributes 'to', 'toJunction' and 'toTaz' cannot be defined together"));
811 } else if (attrs.hasAttribute(SUMO_ATTR_FROM) && attrs.hasAttribute(SUMO_ATTR_TO)) {
812 // from-to attributes
813 const std::string from = attrs.get<std::string>(SUMO_ATTR_FROM, flowParameter->id.c_str(), parsedOk);
814 const std::string to = attrs.get<std::string>(SUMO_ATTR_TO, flowParameter->id.c_str(), parsedOk);
815 // optional attributes
816 const std::vector<std::string> via = attrs.getOpt<std::vector<std::string> >(SUMO_ATTR_VIA, flowParameter->id.c_str(), parsedOk);
817 if (parsedOk) {
818 // set tag
820 // add other attributes
824 } else {
826 }
828 // from-to attributes
829 const std::string fromJunction = attrs.get<std::string>(SUMO_ATTR_FROM_JUNCTION, flowParameter->id.c_str(), parsedOk);
830 const std::string toJunction = attrs.get<std::string>(SUMO_ATTR_TO_JUNCTION, flowParameter->id.c_str(), parsedOk);
831 if (parsedOk) {
832 // set tag
834 // add other attributes
837 } else {
839 }
840 } else if (attrs.hasAttribute(SUMO_ATTR_FROM_TAZ) && attrs.hasAttribute(SUMO_ATTR_TO_TAZ)) {
841 // from-to attributes
842 const std::string fromJunction = attrs.get<std::string>(SUMO_ATTR_FROM_TAZ, flowParameter->id.c_str(), parsedOk);
843 const std::string toJunction = attrs.get<std::string>(SUMO_ATTR_TO_TAZ, flowParameter->id.c_str(), parsedOk);
844 if (parsedOk) {
845 // set tag
847 // add other attributes
850 } else {
852 }
853 } else if (attrs.hasAttribute(SUMO_ATTR_ROUTE)) {
854 // from-to attributes
855 const std::string route = attrs.get<std::string>(SUMO_ATTR_ROUTE, flowParameter->id.c_str(), parsedOk);
856 if (parsedOk) {
857 // set tag
859 // add other attributes
861 } else {
863 }
864 } else {
865 // set tag
867 }
868 // delete flow parameter (because in XMLStructure we have a copy)
869 delete flowParameter;
870 } else {
872 }
873}
874
875
876void
878 // declare Ok Flag
879 bool parsedOk = true;
880 // declare stop
882 // plan parameters
883 const auto planParameters = CommonXMLStructure::PlanParameters(myCommonXMLStructure.getCurrentSumoBaseObject(), attrs, parsedOk);
884 // get parents
885 std::vector<SumoXMLTag> stopParents;
886 stopParents.insert(stopParents.end(), NamespaceIDs::routes.begin(), NamespaceIDs::routes.end());
887 stopParents.insert(stopParents.end(), NamespaceIDs::vehicles.begin(), NamespaceIDs::vehicles.end());
888 stopParents.insert(stopParents.end(), NamespaceIDs::persons.begin(), NamespaceIDs::persons.end());
889 stopParents.insert(stopParents.end(), NamespaceIDs::containers.begin(), NamespaceIDs::containers.end());
890 // check parents
891 checkParsedParent(SUMO_TAG_STOP, stopParents, parsedOk);
892 // parse stop
893 if (parsedOk && parseStopParameters(stop, attrs)) {
894 // set tag
896 // add stop attributes
899 } else {
901 }
902}
903
904
905void
907 // first parse vehicle
909 if (personParameter) {
910 // set tag
912 // set vehicle parameter
914 // delete person parameter (because in XMLStructure we have a copy)
915 delete personParameter;
916 } else {
918 }
919}
920
921
922void
924 // first parse flow
926 if (personFlowParameter) {
927 // set tag
929 // set vehicle parameter
931 // delete person flow parameter (because in XMLStructure we have a copy)
932 delete personFlowParameter;
933 } else {
935 }
936}
937
938
939void
941 // declare Ok Flag
942 bool parsedOk = true;
943 // plan parameters
944 const auto planParameters = CommonXMLStructure::PlanParameters(myCommonXMLStructure.getCurrentSumoBaseObject(), attrs, parsedOk);
945 // optional attributes
946 const std::vector<std::string> via = attrs.getOpt<std::vector<std::string> >(SUMO_ATTR_VIA, "", parsedOk);
947 const std::vector<std::string> vTypes = attrs.getOpt<std::vector<std::string> >(SUMO_ATTR_VTYPES, "", parsedOk);
948 const std::vector<std::string> lines = attrs.getOpt<std::vector<std::string> >(SUMO_ATTR_LINES, "", parsedOk);
949 std::vector<std::string> modes = attrs.getOpt<std::vector<std::string> >(SUMO_ATTR_MODES, "", parsedOk);
950 const double departPos = attrs.getOpt<double>(SUMO_ATTR_DEPARTPOS, "", parsedOk, -1);
951 const double arrivalPos = attrs.getOpt<double>(SUMO_ATTR_ARRIVALPOS, "", parsedOk, -1);
952 const double walkFactor = attrs.getOpt<double>(SUMO_ATTR_WALKFACTOR, "", parsedOk, 0);
953 const std::string group = attrs.getOpt<std::string>(SUMO_ATTR_GROUP, "", parsedOk, "");
954 // check modes
955 SVCPermissions dummyModeSet;
956 std::string dummyError;
957 if (!SUMOVehicleParameter::parsePersonModes(toString(modes), toString(SUMO_TAG_PERSONTRIP), "", dummyModeSet, dummyError)) {
958 WRITE_WARNING(dummyError);
959 modes.clear();
960 }
961 // check parents
963 if (parsedOk) {
964 // set tag
966 // add all attributes
975 } else {
977 }
978}
979
980
981void
984 writeError(TL("Speed and duration attributes cannot be defined together in walks"));
986 } else {
987 // declare Ok Flag
988 bool parsedOk = true;
989 // plan parameters
990 const auto planParameters = CommonXMLStructure::PlanParameters(myCommonXMLStructure.getCurrentSumoBaseObject(), attrs, parsedOk);
991 // optional attributes
992 const double departPos = attrs.getOpt<double>(SUMO_ATTR_DEPARTPOS, "", parsedOk, -1);
993 const double arrivalPos = attrs.getOpt<double>(SUMO_ATTR_ARRIVALPOS, "", parsedOk, -1);
994 const double speed = attrs.getOpt<double>(SUMO_ATTR_SPEED, "", parsedOk, 1.39);
995 const SUMOTime duration = attrs.getOptSUMOTimeReporting(SUMO_ATTR_DURATION, "", parsedOk, 0);
996 // check parents
998 if (parsedOk) {
999 // set tag
1001 // add all attributes
1007 } else {
1009 }
1010 }
1011}
1012
1013
1014void
1016 // declare Ok Flag
1017 bool parsedOk = true;
1018 // plan parameters
1019 const auto planParameters = CommonXMLStructure::PlanParameters(myCommonXMLStructure.getCurrentSumoBaseObject(), attrs, parsedOk);
1020 // optional attributes
1021 const std::vector<std::string> lines = attrs.getOpt<std::vector<std::string> >(SUMO_ATTR_LINES, "", parsedOk);
1022 const double arrivalPos = attrs.getOpt<double>(SUMO_ATTR_ARRIVALPOS, "", parsedOk, -1);
1023 const std::string group = attrs.getOpt<std::string>(SUMO_ATTR_GROUP, "", parsedOk, "");
1024 // check parents
1026 if (parsedOk) {
1027 // set tag
1029 // add all attributes
1034 } else {
1036 }
1037}
1038
1039
1040void
1042 // first parse container
1044 if (containerParameter) {
1045 // set tag
1047 // set vehicle parameter
1049 // delete container parameter (because in XMLStructure we have a copy)
1050 delete containerParameter;
1051 } else {
1053 }
1054}
1055
1056
1057void
1059 // first parse flow
1061 if (containerFlowParameter) {
1062 // set tag
1064 // set vehicle parameter
1066 // delete container flow parameter (because in XMLStructure we have a copy)
1067 delete containerFlowParameter;
1068 } else {
1070 }
1071}
1072
1073
1074void
1076 // declare Ok Flag
1077 bool parsedOk = true;
1078 // plan parameters
1079 const auto planParameters = CommonXMLStructure::PlanParameters(myCommonXMLStructure.getCurrentSumoBaseObject(), attrs, parsedOk);
1080 // optional attributes
1081 const std::vector<std::string> lines = attrs.getOpt<std::vector<std::string> >(SUMO_ATTR_LINES, "", parsedOk);
1082 const double arrivalPos = attrs.getOpt<double>(SUMO_ATTR_ARRIVALPOS, "", parsedOk, -1);
1083 const std::string group = attrs.getOpt<std::string>(SUMO_ATTR_GROUP, "", parsedOk, "");
1084 // check parents
1086 if (parsedOk) {
1087 // set tag
1089 // add all attributes
1094 } else {
1096 }
1097}
1098
1099
1100void
1103 writeError(TL("Speed and duration attributes cannot be defined together in tranships"));
1105 } else {
1106 // declare Ok Flag
1107 bool parsedOk = true;
1108 // plan parameters
1109 const auto planParameters = CommonXMLStructure::PlanParameters(myCommonXMLStructure.getCurrentSumoBaseObject(), attrs, parsedOk);
1110 // optional attributes
1111 const double arrivalPos = attrs.getOpt<double>(SUMO_ATTR_ARRIVALPOS, "", parsedOk, -1);
1112 const double departPos = attrs.getOpt<double>(SUMO_ATTR_DEPARTPOS, "", parsedOk, -1);
1113 const double speed = attrs.getOpt<double>(SUMO_ATTR_SPEED, "", parsedOk, 1.39);
1114 const SUMOTime duration = attrs.getOptSUMOTimeReporting(SUMO_ATTR_DURATION, "", parsedOk, 0);
1115 // check parents
1117 if (parsedOk) {
1118 // set tag
1120 // add all attributes
1126 } else {
1128 }
1129 }
1130}
1131
1132
1133void
1135 // declare Ok Flag
1136 bool parsedOk = true;
1137 // just parse begin and end default
1138 myFlowBeginDefault = attrs.getSUMOTimeReporting(SUMO_ATTR_BEGIN, nullptr, parsedOk);
1139 myFlowEndDefault = attrs.getSUMOTimeReporting(SUMO_ATTR_END, nullptr, parsedOk);
1140}
1141
1142
1143bool
1145 // write warning info
1146 WRITE_WARNINGF(TL("Defining car-following parameters in a nested element is deprecated in vType '%', use attributes instead!"), vTypeObject->getStringAttribute(SUMO_ATTR_ID));
1147 // get vType to modify it
1148 auto vType = vTypeObject->getVehicleTypeParameter();
1149 // parse nested CFM attributes
1150 if (SUMOVehicleParserHelper::parseCFMParams(&vType, tag, attrs, true)) {
1151 vTypeObject->setVehicleTypeParameter(&vType);
1152 return true;
1153 } else if (myHardFail) {
1154 throw ProcessError(TL("Invalid parsing embedded VType"));
1155 } else {
1156 return writeError(TL("Invalid parsing embedded VType"));
1157 }
1158 return false;
1159}
1160
1161
1162bool
1164 // check stop parameters
1165 if (attrs.hasAttribute(SUMO_ATTR_ARRIVAL)) {
1167 }
1168 if (attrs.hasAttribute(SUMO_ATTR_DURATION)) {
1170 }
1171 if (attrs.hasAttribute(SUMO_ATTR_UNTIL)) {
1173 }
1174 if (attrs.hasAttribute(SUMO_ATTR_STARTED)) {
1176 }
1177 if (attrs.hasAttribute(SUMO_ATTR_ENDED)) {
1179 }
1180 if (attrs.hasAttribute(SUMO_ATTR_EXTENSION)) {
1182 }
1183 if (attrs.hasAttribute(SUMO_ATTR_ENDPOS)) {
1185 }
1186 if (attrs.hasAttribute(SUMO_ATTR_STARTPOS)) {
1188 }
1191 }
1192 if (attrs.hasAttribute(SUMO_ATTR_TRIGGERED)) {
1194 }
1195 // legacy attribute
1198 }
1199 if (attrs.hasAttribute(SUMO_ATTR_PARKING)) {
1201 }
1202 if (attrs.hasAttribute(SUMO_ATTR_EXPECTED)) {
1204 }
1205 if (attrs.hasAttribute(SUMO_ATTR_PERMITTED)) {
1207 }
1210 }
1211 if (attrs.hasAttribute(SUMO_ATTR_TRIP_ID)) {
1213 }
1214 if (attrs.hasAttribute(SUMO_ATTR_SPLIT)) {
1216 }
1217 if (attrs.hasAttribute(SUMO_ATTR_JOIN)) {
1219 }
1220 if (attrs.hasAttribute(SUMO_ATTR_LINE)) {
1222 }
1223 if (attrs.hasAttribute(SUMO_ATTR_SPEED)) {
1225 }
1226 if (attrs.hasAttribute(SUMO_ATTR_ONDEMAND)) {
1228 }
1229 if (attrs.hasAttribute(SUMO_ATTR_JUMP)) {
1231 }
1234 }
1235 // get parameters
1236 bool ok = true;
1237 // edge/lane
1238 stop.edge = attrs.getOpt<std::string>(SUMO_ATTR_EDGE, nullptr, ok, "");
1239 stop.lane = attrs.getOpt<std::string>(SUMO_ATTR_LANE, nullptr, ok, stop.busstop);
1240 // check errors
1241 if (!stop.edge.empty() && !stop.lane.empty()) {
1242 return writeError(TL("A stop must be defined either with an edge or with an lane, not both"));
1243 }
1244 // stopping places
1245 stop.busstop = attrs.getOpt<std::string>(SUMO_ATTR_BUS_STOP, nullptr, ok, "");
1246 if (stop.busstop.empty()) {
1247 stop.busstop = attrs.getOpt<std::string>(SUMO_ATTR_TRAIN_STOP, nullptr, ok, stop.busstop);
1248 }
1249 stop.chargingStation = attrs.getOpt<std::string>(SUMO_ATTR_CHARGING_STATION, nullptr, ok, "");
1250 stop.overheadWireSegment = attrs.getOpt<std::string>(SUMO_ATTR_OVERHEAD_WIRE_SEGMENT, nullptr, ok, "");
1251 stop.containerstop = attrs.getOpt<std::string>(SUMO_ATTR_CONTAINER_STOP, nullptr, ok, "");
1252 stop.parkingarea = attrs.getOpt<std::string>(SUMO_ATTR_PARKING_AREA, nullptr, ok, "");
1253 //check stopping places
1254 const int numStoppingPlaces = !stop.busstop.empty() + !stop.chargingStation.empty() + !stop.overheadWireSegment.empty() +
1255 !stop.containerstop.empty() + !stop.parkingarea.empty();
1256 if (numStoppingPlaces > 1) {
1257 return writeError(TL("A stop must be defined only in a StoppingPlace"));
1258 } else if ((numStoppingPlaces == 0) && stop.edge.empty() && stop.lane.empty()) {
1259 return writeError(TL("A stop must be defined in an edge, a lane, or in a StoppingPlace"));
1260 }
1261 // declare error suffix
1262 std::string errorSuffix;
1263 if (stop.busstop != "") {
1264 errorSuffix = " at '" + stop.busstop + "'" + errorSuffix;
1265 } else if (stop.chargingStation != "") {
1266 errorSuffix = " at '" + stop.chargingStation + "'" + errorSuffix;
1267 } else if (stop.overheadWireSegment != "") {
1268 errorSuffix = " at '" + stop.overheadWireSegment + "'" + errorSuffix;
1269 } else if (stop.containerstop != "") {
1270 errorSuffix = " at '" + stop.containerstop + "'" + errorSuffix;
1271 } else if (stop.parkingarea != "") {
1272 errorSuffix = " at '" + stop.parkingarea + "'" + errorSuffix;
1273 } else if (stop.edge != "") {
1274 errorSuffix = " at '" + stop.edge + "'" + errorSuffix;
1275 } else {
1276 errorSuffix = " on lane '" + stop.lane + "'" + errorSuffix;
1277 }
1278 // speed for counting as stopped
1279 stop.speed = attrs.getOpt<double>(SUMO_ATTR_SPEED, nullptr, ok, 0);
1280 if (stop.speed < 0) {
1281 return writeError("Speed cannot be negative for stop" + errorSuffix);
1282 return false;
1283 }
1284 // get the standing duration
1285 bool expectTrigger = !attrs.hasAttribute(SUMO_ATTR_DURATION) && !attrs.hasAttribute(SUMO_ATTR_UNTIL) && !attrs.hasAttribute(SUMO_ATTR_SPEED);
1286 std::vector<std::string> triggers = attrs.getOpt<std::vector<std::string> >(SUMO_ATTR_TRIGGERED, nullptr, ok);
1287 // legacy
1288 if (attrs.getOpt<bool>(SUMO_ATTR_CONTAINER_TRIGGERED, nullptr, ok, false)) {
1289 triggers.push_back(toString(SUMO_TAG_CONTAINER));
1290 };
1291 SUMOVehicleParameter::parseStopTriggers(triggers, expectTrigger, stop);
1292 stop.startPos = attrs.getOpt<double>(SUMO_ATTR_STARTPOS, nullptr, ok, 0);
1293 stop.endPos = attrs.getOpt<double>(SUMO_ATTR_ENDPOS, nullptr, ok, 0);
1294 stop.friendlyPos = attrs.getOpt<bool>(SUMO_ATTR_FRIENDLY_POS, nullptr, ok, false);
1295 stop.arrival = attrs.getOptSUMOTimeReporting(SUMO_ATTR_ARRIVAL, nullptr, ok, -1);
1296 stop.duration = attrs.getOptSUMOTimeReporting(SUMO_ATTR_DURATION, nullptr, ok, -1);
1297 stop.until = attrs.getOptSUMOTimeReporting(SUMO_ATTR_UNTIL, nullptr, ok, -1);
1298 if (!expectTrigger && (!ok || (stop.duration < 0 && stop.until < 0 && stop.speed == 0))) {
1299 return writeError("Invalid duration or end time is given for a stop" + errorSuffix);
1300 return false;
1301 }
1302 stop.extension = attrs.getOptSUMOTimeReporting(SUMO_ATTR_EXTENSION, nullptr, ok, -1);
1303 const bool defaultParking = (stop.triggered || stop.containerTriggered || stop.parkingarea != "");
1304 stop.parking = attrs.getOpt<ParkingType>(SUMO_ATTR_PARKING, nullptr, ok, defaultParking ? ParkingType::OFFROAD : ParkingType::ONROAD);
1305 if ((stop.parkingarea != "") && (stop.parking == ParkingType::ONROAD)) {
1306 WRITE_WARNING("Stop at parkingarea overrides attribute 'parking' for stop" + errorSuffix);
1308 }
1309 if (!ok) {
1310 return writeError("Invalid bool for 'triggered', 'containerTriggered' or 'parking' for stop" + errorSuffix);
1311 return false;
1312 }
1313 // expected persons
1314 const std::vector<std::string>& expected = attrs.getOpt<std::vector<std::string> >(SUMO_ATTR_EXPECTED, nullptr, ok);
1315 stop.awaitedPersons.insert(expected.begin(), expected.end());
1316 if (stop.awaitedPersons.size() > 0 && (stop.parametersSet & STOP_TRIGGER_SET) == 0) {
1317 stop.triggered = true;
1318 if ((stop.parametersSet & STOP_PARKING_SET) == 0) {
1320 }
1321 }
1322 // permitted transportables
1323 const std::vector<std::string>& permitted = attrs.getOpt<std::vector<std::string> >(SUMO_ATTR_PERMITTED, nullptr, ok);
1324 stop.permitted.insert(permitted.begin(), permitted.end());
1325 // expected containers
1326 const std::vector<std::string>& expectedContainers = attrs.getOpt<std::vector<std::string> >(SUMO_ATTR_EXPECTED_CONTAINERS, nullptr, ok);
1327 stop.awaitedContainers.insert(expectedContainers.begin(), expectedContainers.end());
1328 if (stop.awaitedContainers.size() > 0 && (stop.parametersSet & STOP_CONTAINER_TRIGGER_SET) == 0) {
1329 stop.containerTriggered = true;
1330 if ((stop.parametersSet & STOP_PARKING_SET) == 0) {
1332 }
1333 }
1334 // public transport trip id
1335 stop.tripId = attrs.getOpt<std::string>(SUMO_ATTR_TRIP_ID, nullptr, ok, "");
1336 stop.split = attrs.getOpt<std::string>(SUMO_ATTR_SPLIT, nullptr, ok, "");
1337 stop.join = attrs.getOpt<std::string>(SUMO_ATTR_JOIN, nullptr, ok, "");
1338 stop.line = attrs.getOpt<std::string>(SUMO_ATTR_LINE, nullptr, ok, "");
1339 // index
1340 const std::string idx = attrs.getOpt<std::string>(SUMO_ATTR_INDEX, nullptr, ok, "end");
1341 if (idx == "end") {
1342 stop.index = STOP_INDEX_END;
1343 } else if (idx == "fit") {
1344 stop.index = STOP_INDEX_FIT;
1345 } else {
1346 stop.index = attrs.get<int>(SUMO_ATTR_INDEX, nullptr, ok);
1347 if (!ok || stop.index < 0) {
1348 return writeError("Invalid 'index' for stop" + errorSuffix);
1349 return false;
1350 }
1351 }
1352 stop.started = attrs.getOptSUMOTimeReporting(SUMO_ATTR_STARTED, nullptr, ok, -1);
1353 stop.ended = attrs.getOptSUMOTimeReporting(SUMO_ATTR_ENDED, nullptr, ok, -1);
1354 stop.posLat = attrs.getOpt<double>(SUMO_ATTR_POSITION_LAT, nullptr, ok, INVALID_DOUBLE);
1355 stop.actType = attrs.getOpt<std::string>(SUMO_ATTR_ACTTYPE, nullptr, ok, "");
1356 stop.onDemand = attrs.getOpt<bool>(SUMO_ATTR_ONDEMAND, nullptr, ok, false);
1357 stop.jump = attrs.getOptSUMOTimeReporting(SUMO_ATTR_JUMP, nullptr, ok, -1);
1358 stop.jumpUntil = attrs.getOptSUMOTimeReporting(SUMO_ATTR_JUMP_UNTIL, nullptr, ok, -1);
1359 return true;
1360}
1361
1362
1363bool
1365 return sumoBaseObject->hasStringAttribute(SUMO_ATTR_FROM) && sumoBaseObject->hasStringAttribute(SUMO_ATTR_TO);
1366}
1367
1368
1369bool
1373
1374
1375bool
1377 return sumoBaseObject->hasStringAttribute(SUMO_ATTR_FROM_TAZ) && sumoBaseObject->hasStringAttribute(SUMO_ATTR_TO_TAZ);
1378}
1379
1380/****************************************************************************/
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:68
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
bool myAbortLoading
abort loading
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.