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-2024 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 myFilename(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 parseVType(attrs);
60 break;
63 break;
64 // routes
65 case SUMO_TAG_ROUTE:
66 parseRoute(attrs);
67 break;
70 break;
71 // vehicles
72 case SUMO_TAG_TRIP:
73 parseTrip(attrs);
74 break;
76 parseVehicle(attrs);
77 break;
78 // flows
79 case SUMO_TAG_FLOW:
80 parseFlow(attrs);
81 break;
82 // stop
83 case SUMO_TAG_STOP:
84 parseStop(attrs);
85 break;
86 // persons
87 case SUMO_TAG_PERSON:
88 parsePerson(attrs);
89 break;
91 parsePersonFlow(attrs);
92 break;
93 // person plans
95 parsePersonTrip(attrs);
96 break;
97 case SUMO_TAG_RIDE:
98 parseRide(attrs);
99 break;
100 case SUMO_TAG_WALK:
101 parseWalk(attrs);
102 break;
103 // container
105 parseContainer(attrs);
106 break;
108 parseContainerFlow(attrs);
109 break;
110 // container plans
112 parseTransport(attrs);
113 break;
115 parseTranship(attrs);
116 break;
117 // parameters
118 case SUMO_TAG_PARAM:
119 parseParameters(attrs);
120 break;
121 // other
122 case SUMO_TAG_INTERVAL: {
123 parseInterval(attrs);
124 break;
125 }
126 default:
127 // get vehicle type Base object
129 // parse embedded car following model information
130 if (vTypeObject && (vTypeObject->getTag() == SUMO_TAG_VTYPE)) {
131 // nested CFM attributes
132 return parseNestedCFM(tag, attrs, vTypeObject);
133 } else {
134 // tag cannot be parsed in routeHandler
136 return false;
137 }
138 }
139 } catch (InvalidArgument& e) {
140 WRITE_ERROR(e.what());
141 }
142 return true;
143}
144
145
146void
148 // get last inserted object
150 // check tag
151 if (obj) {
152 // close SUMOBaseOBject
154 // get parent tag (if exist)
155 const auto parentTag = obj->getParentSumoBaseObject() ? obj->getParentSumoBaseObject()->getTag() : SUMO_TAG_NOTHING;
156 switch (obj->getTag()) {
157 // specia case for route (because can be embedded)
158 case SUMO_TAG_ROUTE:
159 // only parse non-embedded and without distributionsroutes
160 if ((obj->getStringAttribute(SUMO_ATTR_ID).size() > 0) &&
161 (parentTag != SUMO_TAG_ROUTE_DISTRIBUTION)) {
162 // parse route and all their childrens
164 // delete object (and all of their childrens)
165 delete obj;
166 }
167 break;
168 // demand elements
169 case SUMO_TAG_VTYPE:
170 // only parse vTypes without distributions
171 if (parentTag != SUMO_TAG_VTYPE_DISTRIBUTION) {
172 // parse vType and all their childrens
174 // delete object (and all of their childrens)
175 delete obj;
176 }
177 break;
180 case SUMO_TAG_TRIP:
181 case SUMO_TAG_VEHICLE:
182 case SUMO_TAG_FLOW:
183 case SUMO_TAG_PERSON:
187 // parse object and all their childrens
189 // delete object (and all of their childrens)
190 delete obj;
191 break;
192 default:
193 break;
194 }
195 }
196}
197
198
199void
201 // switch tag
202 switch (obj->getTag()) {
203 // vTypes
204 case SUMO_TAG_VTYPE:
205 buildVType(obj,
207 break;
214 break;
215 // route
216 case SUMO_TAG_ROUTE:
217 if (obj->getStringAttribute(SUMO_ATTR_ID).empty()) {
223 obj->getParameters());
224 } else {
225 buildRoute(obj,
227 obj->getVClass(),
233 obj->getParameters());
234 }
235 break;
241 break;
242 // vehicles
243 case SUMO_TAG_TRIP:
246 // build trip with from-to junctions
248 obj->getVehicleParameter(),
251 } else if (obj->hasStringAttribute(SUMO_ATTR_FROM_TAZ) &&
253 // build trip with from-to TAZs
254 buildTripTAZs(obj,
255 obj->getVehicleParameter(),
258 } else {
259 // build trip with from-to edges
260 buildTrip(obj,
261 obj->getVehicleParameter(),
264 }
265 break;
266 case SUMO_TAG_VEHICLE:
269 obj->getVehicleParameter());
270 }
271 break;
272 // flows
273 case SUMO_TAG_FLOW:
275 // build flow over route
277 obj->getVehicleParameter());
280 // build flow with from-to junctions
282 obj->getVehicleParameter(),
285 } else if (obj->hasStringAttribute(SUMO_ATTR_FROM_TAZ) &&
287 // build flow with from-to TAZs
288 buildFlowTAZs(obj,
289 obj->getVehicleParameter(),
292 } else {
293 // build flow with from-to edges
294 buildFlow(obj,
295 obj->getVehicleParameter(),
298 }
299 break;
300 // persons
301 case SUMO_TAG_PERSON:
302 buildPerson(obj,
303 obj->getVehicleParameter());
304 break;
306 buildPersonFlow(obj,
307 obj->getVehicleParameter());
308 break;
309 // person plans
311 buildPersonTrip(obj,
312 obj->getPlanParameters(),
319 break;
320 case SUMO_TAG_RIDE:
321 buildRide(obj,
322 obj->getPlanParameters(),
326 break;
327 case SUMO_TAG_WALK:
328 buildWalk(obj,
329 obj->getPlanParameters(),
333 break;
334 // container
336 buildContainer(obj,
337 obj->getVehicleParameter());
338 break;
341 obj->getVehicleParameter());
342 break;
343 // container plans
345 buildTransport(obj,
346 obj->getPlanParameters(),
350 break;
352 buildTranship(obj,
353 obj->getPlanParameters(),
358 break;
359 // stopss
360 case SUMO_TAG_STOP:
361 buildStop(obj,
362 obj->getPlanParameters(),
363 obj->getStopParameter());
364 break;
365 default:
366 break;
367 }
368 // now iterate over childrens
369 for (const auto& child : obj->getSumoBaseObjectChildren()) {
370 // call this function recursively
371 parseSumoBaseObject(child);
372 }
373}
374
375
376bool
380
381
382void
383RouteHandler::writeError(const std::string& error) {
384 WRITE_ERROR(error);
386}
387
388
389void
390RouteHandler::writeErrorInvalidID(const SumoXMLTag tag, const std::string& id) {
391 WRITE_ERRORF(TL("Could not build % with ID '%' in netedit; ID contains invalid characters."), toString(tag), id);
393}
394
395
396void
398 WRITE_ERRORF(TL("Could not build % with ID '%' in netedit; Distinct number of distribution values and probabilities."), toString(tag), id);
400}
401
402
403void
405 // parse vehicleType
407 if (vehicleTypeParameter) {
408 // set tag
410 // add all attributes
412 // delete vehicleType parameter (because in XMLStructure we have a copy)
413 delete vehicleTypeParameter;
414 }
415}
416
417
418void
420 // declare Ok Flag
421 bool parsedOk = true;
422 // needed attributes
423 const std::string id = attrs.get<std::string>(SUMO_ATTR_ID, "", parsedOk);
424 // optional attributes
425 const int deterministic = attrs.getOpt<int>(SUMO_ATTR_DETERMINISTIC, id.c_str(), parsedOk, -1);
426 const std::vector<std::string> vTypes = attrs.getOpt<std::vector<std::string> >(SUMO_ATTR_VTYPES, id.c_str(), parsedOk);
427 const std::vector<double> probabilities = attrs.getOpt<std::vector<double> >(SUMO_ATTR_PROBS, id.c_str(), parsedOk);
428 if (parsedOk) {
431 } else if (vTypes.size() != probabilities.size()) {
433 } else {
434 // set tag
436 // add all attributes
441 }
442 }
443}
444
445
446void
448 // get embedded route flag
449 const bool embeddedRoute = isEmbeddedRoute(attrs);
450 // first check if this is an embedded route
451 if ((embeddedRoute && attrs.hasAttribute(SUMO_ATTR_ID)) || (!embeddedRoute && !attrs.hasAttribute(SUMO_ATTR_ID))) {
452 writeError(TL("a route must be defined either within a vehicle/flow or with an ID attribute"));
453 } else {
454 // declare Ok Flag
455 bool parsedOk = true;
456 // special case for ID
457 const std::string id = attrs.getOpt<std::string>(SUMO_ATTR_ID, "", parsedOk, "");
458 // needed attributes
459 const std::vector<std::string> edges = attrs.get<std::vector<std::string> >(SUMO_ATTR_EDGES, id.c_str(), parsedOk);
460 // optional attributes
462 const RGBColor color = attrs.getOpt<RGBColor>(SUMO_ATTR_COLOR, id.c_str(), parsedOk, RGBColor::INVISIBLE);
463 const int repeat = attrs.getOpt<int>(SUMO_ATTR_REPEAT, id.c_str(), parsedOk, 0);
464 const SUMOTime cycleTime = attrs.getOptSUMOTimeReporting(SUMO_ATTR_CYCLETIME, id.c_str(), parsedOk, 0);
465 const double probability = attrs.getOpt<double>(SUMO_ATTR_PROB, id.c_str(), parsedOk, 0);
466 if (parsedOk) {
467 if (!id.empty() && !SUMOXMLDefinitions::isValidVehicleID(id)) {
469 } else if (cycleTime < 0) {
470 writeError(TLF("cycleTime of % must be equal or greater than 0", toString(SUMO_TAG_DEST_PROB_REROUTE)));
471 } else {
472 // set tag
474 // add all attributes
482 }
483 }
484 }
485}
486
487
488void
490 // declare Ok Flag
491 bool parsedOk = true;
492 // needed attributes
493 const std::string id = attrs.get<std::string>(SUMO_ATTR_ID, "", parsedOk);
494 // optional attributes
495 const std::vector<std::string> routes = attrs.getOpt<std::vector<std::string> >(SUMO_ATTR_ROUTES, id.c_str(), parsedOk);
496 const std::vector<double> probabilities = attrs.getOpt<std::vector<double> >(SUMO_ATTR_PROBS, id.c_str(), parsedOk);
497 if (parsedOk) {
500 } else if (routes.size() != probabilities.size()) {
502 } else {
503 // set tag
505 // add all attributes
509 }
510 }
511}
512
513
514void
516 // declare Ok Flag
517 bool parsedOk = true;
518 // parse vehicle
520 if (tripParameter) {
521 // check from/to edge/junction
523 writeError(TL("Attributes 'from', 'fromJunction' and 'fromTaz' cannot be defined together"));
525 writeError(TL("Attributes 'to', 'toJunction' and 'toTaz' cannot be defined together"));
527 // from-to attributes
528 const std::string fromJunction = attrs.get<std::string>(SUMO_ATTR_FROM_JUNCTION, tripParameter->id.c_str(), parsedOk);
529 const std::string toJunction = attrs.get<std::string>(SUMO_ATTR_TO_JUNCTION, tripParameter->id.c_str(), parsedOk);
530 if (parsedOk) {
531 // set tag
533 // set vehicle parameters
535 // add other attributes
538 }
539 } else if (attrs.hasAttribute(SUMO_ATTR_FROM_TAZ) && attrs.hasAttribute(SUMO_ATTR_TO_TAZ)) {
540 // from-to attributes
541 const std::string fromJunction = attrs.get<std::string>(SUMO_ATTR_FROM_TAZ, tripParameter->id.c_str(), parsedOk);
542 const std::string toJunction = attrs.get<std::string>(SUMO_ATTR_TO_TAZ, tripParameter->id.c_str(), parsedOk);
543 if (parsedOk) {
544 // set tag
546 // set vehicle parameters
548 // add other attributes
551 }
552 } else {
553 // from-to attributes
554 const std::string from = attrs.getOpt<std::string>(SUMO_ATTR_FROM, tripParameter->id.c_str(), parsedOk, "");
555 const std::string to = attrs.getOpt<std::string>(SUMO_ATTR_TO, tripParameter->id.c_str(), parsedOk, "");
556 // optional attributes
557 const std::vector<std::string> via = attrs.getOpt<std::vector<std::string> >(SUMO_ATTR_VIA, tripParameter->id.c_str(), parsedOk);
558 if (parsedOk) {
559 // set tag
561 // set vehicle parameters
563 // add other attributes
567 }
568 }
569 // delete trip parameter (because in XMLStructure we have a copy)
570 delete tripParameter;
571 }
572}
573
574
575void
577 // first parse vehicle
579 if (vehicleParameter) {
580 // set tag
582 // set vehicle parameters
584 // delete vehicle parameter (because in XMLStructure we have a copy)
585 delete vehicleParameter;
586 }
587}
588
589
590void
592 // declare Ok Flag
593 bool parsedOk = true;
594 // first parse flow
596 if (flowParameter) {
597 // set vehicle parameters
599 // check from/to edge/junction
601 writeError(TL("Attributes 'from', 'fromJunction' and 'fromTaz' cannot be defined together"));
603 writeError(TL("Attributes 'to', 'toJunction' and 'toTaz' cannot be defined together"));
604 } else if (attrs.hasAttribute(SUMO_ATTR_FROM) && attrs.hasAttribute(SUMO_ATTR_TO)) {
605 // from-to attributes
606 const std::string from = attrs.get<std::string>(SUMO_ATTR_FROM, flowParameter->id.c_str(), parsedOk);
607 const std::string to = attrs.get<std::string>(SUMO_ATTR_TO, flowParameter->id.c_str(), parsedOk);
608 // optional attributes
609 const std::vector<std::string> via = attrs.getOpt<std::vector<std::string> >(SUMO_ATTR_VIA, flowParameter->id.c_str(), parsedOk);
610 if (parsedOk) {
611 // set tag
613 // add other attributes
617 }
619 // from-to attributes
620 const std::string fromJunction = attrs.get<std::string>(SUMO_ATTR_FROM_JUNCTION, flowParameter->id.c_str(), parsedOk);
621 const std::string toJunction = attrs.get<std::string>(SUMO_ATTR_TO_JUNCTION, flowParameter->id.c_str(), parsedOk);
622 if (parsedOk) {
623 // set tag
625 // add other attributes
628 }
629 } else if (attrs.hasAttribute(SUMO_ATTR_FROM_TAZ) && attrs.hasAttribute(SUMO_ATTR_TO_TAZ)) {
630 // from-to attributes
631 const std::string fromJunction = attrs.get<std::string>(SUMO_ATTR_FROM_TAZ, flowParameter->id.c_str(), parsedOk);
632 const std::string toJunction = attrs.get<std::string>(SUMO_ATTR_TO_TAZ, flowParameter->id.c_str(), parsedOk);
633 if (parsedOk) {
634 // set tag
636 // add other attributes
639 }
640 } else if (attrs.hasAttribute(SUMO_ATTR_ROUTE)) {
641 // from-to attributes
642 const std::string route = attrs.get<std::string>(SUMO_ATTR_ROUTE, flowParameter->id.c_str(), parsedOk);
643 if (parsedOk) {
644 // set tag
646 // add other attributes
648 }
649 } else {
650 // set tag
652 }
653 // delete flow parameter (because in XMLStructure we have a copy)
654 delete flowParameter;
655 }
656}
657
658
659void
661 // declare Ok Flag
662 bool parsedOk = true;
663 // declare stop
665 // plan parameters
666 const auto planParameters = CommonXMLStructure::PlanParameters(myCommonXMLStructure.getCurrentSumoBaseObject(), attrs, parsedOk);
667 // get parents
668 std::vector<SumoXMLTag> stopParents;
669 stopParents.insert(stopParents.end(), NamespaceIDs::vehicles.begin(), NamespaceIDs::vehicles.end());
670 stopParents.insert(stopParents.end(), NamespaceIDs::routes.begin(), NamespaceIDs::routes.end());
671 stopParents.insert(stopParents.end(), NamespaceIDs::persons.begin(), NamespaceIDs::persons.end());
672 stopParents.insert(stopParents.end(), NamespaceIDs::containers.begin(), NamespaceIDs::containers.end());
673 // check parents
674 checkParent(SUMO_TAG_STOP, stopParents, parsedOk);
675 // parse stop
676 if (parsedOk && parseStopParameters(stop, attrs)) {
677 // set tag
679 // add stop attributes
682 }
683}
684
685
686void
688 // first parse vehicle
690 if (personParameter) {
691 // set tag
693 // set vehicle parameter
695 // delete person parameter (because in XMLStructure we have a copy)
696 delete personParameter;
697 }
698}
699
700
701void
703 // first parse flow
705 if (personFlowParameter) {
706 // set tag
708 // set vehicle parameter
710 // delete person flow parameter (because in XMLStructure we have a copy)
711 delete personFlowParameter;
712 }
713}
714
715
716void
718 // declare Ok Flag
719 bool parsedOk = true;
720 // plan parameters
721 const auto planParameters = CommonXMLStructure::PlanParameters(myCommonXMLStructure.getCurrentSumoBaseObject(), attrs, parsedOk);
722 // optional attributes
723 const std::vector<std::string> via = attrs.getOpt<std::vector<std::string> >(SUMO_ATTR_VIA, "", parsedOk);
724 const std::vector<std::string> vTypes = attrs.getOpt<std::vector<std::string> >(SUMO_ATTR_VTYPES, "", parsedOk);
725 const std::vector<std::string> lines = attrs.getOpt<std::vector<std::string> >(SUMO_ATTR_LINES, "", parsedOk);
726 std::vector<std::string> modes = attrs.getOpt<std::vector<std::string> >(SUMO_ATTR_MODES, "", parsedOk);
727 const double departPos = attrs.getOpt<double>(SUMO_ATTR_DEPARTPOS, "", parsedOk, -1);
728 const double arrivalPos = attrs.getOpt<double>(SUMO_ATTR_ARRIVALPOS, "", parsedOk, -1);
729 const double walkFactor = attrs.getOpt<double>(SUMO_ATTR_WALKFACTOR, "", parsedOk, 0);
730 const std::string group = attrs.getOpt<std::string>(SUMO_ATTR_GROUP, "", parsedOk, "");
731 // check modes
732 SVCPermissions dummyModeSet;
733 std::string dummyError;
734 if (!SUMOVehicleParameter::parsePersonModes(toString(modes), toString(SUMO_TAG_PERSONTRIP), "", dummyModeSet, dummyError)) {
735 WRITE_WARNING(dummyError);
736 modes.clear();
737 }
738 if (parsedOk) {
739 // set tag
741 // add all attributes
750 }
751}
752
753
754void
757 WRITE_ERROR(TL("Speed and duration attributes cannot be defined together in walks"));
758 } else {
759 // declare Ok Flag
760 bool parsedOk = true;
761 // plan parameters
762 const auto planParameters = CommonXMLStructure::PlanParameters(myCommonXMLStructure.getCurrentSumoBaseObject(), attrs, parsedOk);
763 // optional attributes
764 const double departPos = attrs.getOpt<double>(SUMO_ATTR_DEPARTPOS, "", parsedOk, -1);
765 const double arrivalPos = attrs.getOpt<double>(SUMO_ATTR_ARRIVALPOS, "", parsedOk, -1);
766 const double speed = attrs.getOpt<double>(SUMO_ATTR_SPEED, "", parsedOk, 1.39);
767 const SUMOTime duration = attrs.getOptSUMOTimeReporting(SUMO_ATTR_DURATION, "", parsedOk, 0);
768 if (parsedOk) {
769 // set tag
771 // add all attributes
777 }
778 }
779}
780
781
782void
784 // declare Ok Flag
785 bool parsedOk = true;
786 // plan parameters
787 const auto planParameters = CommonXMLStructure::PlanParameters(myCommonXMLStructure.getCurrentSumoBaseObject(), attrs, parsedOk);
788 // optional attributes
789 const std::vector<std::string> lines = attrs.getOpt<std::vector<std::string> >(SUMO_ATTR_LINES, "", parsedOk);
790 const double arrivalPos = attrs.getOpt<double>(SUMO_ATTR_ARRIVALPOS, "", parsedOk, -1);
791 const std::string group = attrs.getOpt<std::string>(SUMO_ATTR_GROUP, "", parsedOk, "");
792 if (parsedOk) {
793 // set tag
795 // add all attributes
800 }
801}
802
803
804void
806 // first parse container
808 if (containerParameter) {
809 // set tag
811 // set vehicle parameter
813 // delete container parameter (because in XMLStructure we have a copy)
814 delete containerParameter;
815 }
816}
817
818
819void
821 // first parse flow
823 if (containerFlowParameter) {
824 // set tag
826 // set vehicle parameter
828 // delete container flow parameter (because in XMLStructure we have a copy)
829 delete containerFlowParameter;
830 }
831}
832
833
834void
836 // declare Ok Flag
837 bool parsedOk = true;
838 // plan parameters
839 const auto planParameters = CommonXMLStructure::PlanParameters(myCommonXMLStructure.getCurrentSumoBaseObject(), attrs, parsedOk);
840 // optional attributes
841 const std::vector<std::string> lines = attrs.getOpt<std::vector<std::string> >(SUMO_ATTR_LINES, "", parsedOk);
842 const double arrivalPos = attrs.getOpt<double>(SUMO_ATTR_ARRIVALPOS, "", parsedOk, -1);
843 const std::string group = attrs.getOpt<std::string>(SUMO_ATTR_GROUP, "", parsedOk, "");
844 if (parsedOk) {
845 // set tag
847 // add all attributes
852 }
853}
854
855
856void
859 WRITE_ERROR(TL("Speed and duration attributes cannot be defined together in walks"));
860 } else {
861 // declare Ok Flag
862 bool parsedOk = true;
863 // plan parameters
864 const auto planParameters = CommonXMLStructure::PlanParameters(myCommonXMLStructure.getCurrentSumoBaseObject(), attrs, parsedOk);
865 // optional attributes
866 const double arrivalPos = attrs.getOpt<double>(SUMO_ATTR_ARRIVALPOS, "", parsedOk, -1);
867 const double departPos = attrs.getOpt<double>(SUMO_ATTR_DEPARTPOS, "", parsedOk, -1);
868 const double speed = attrs.getOpt<double>(SUMO_ATTR_SPEED, "", parsedOk, 1.39);
869 const SUMOTime duration = attrs.getOptSUMOTimeReporting(SUMO_ATTR_DURATION, "", parsedOk, 0);
870 if (parsedOk) {
871 // set tag
873 // add all attributes
879 }
880 }
881}
882
883
884void
886 // declare Ok Flag
887 bool parsedOk = true;
888 // just parse begin and end default
889 myFlowBeginDefault = attrs.getSUMOTimeReporting(SUMO_ATTR_BEGIN, nullptr, parsedOk);
890 myFlowEndDefault = attrs.getSUMOTimeReporting(SUMO_ATTR_END, nullptr, parsedOk);
891}
892
893
894void
896 // declare Ok Flag
897 bool parsedOk = true;
898 // get key
899 const std::string key = attrs.get<std::string>(SUMO_ATTR_KEY, nullptr, parsedOk);
900 // get SumoBaseObject parent
902 // check parent
903 if (SumoBaseObjectParent == nullptr) {
904 writeError(TL("Parameters must be defined within an object"));
905 } else if (SumoBaseObjectParent->getTag() == SUMO_TAG_ROOTFILE) {
906 writeError(TL("Parameters cannot be defined in the additional file's root."));
907 } else if (SumoBaseObjectParent->getTag() == SUMO_TAG_PARAM) {
908 writeError(TL("Parameters cannot be defined within another parameter."));
909 } else if (parsedOk) {
910 // get tag str
911 const std::string parentTagStr = toString(SumoBaseObjectParent->getTag());
912 // circumventing empty string value
913 const std::string value = attrs.hasAttribute(SUMO_ATTR_VALUE) ? attrs.getString(SUMO_ATTR_VALUE) : "";
914 // show warnings if values are invalid
915 if (key.empty()) {
916 WRITE_WARNINGF(TL("Error parsing key from % generic parameter. Key cannot be empty"), parentTagStr);
918 WRITE_WARNINGF(TL("Error parsing key from % generic parameter. Key contains invalid characters"), parentTagStr);
919 } else {
920 WRITE_DEBUG("Inserting generic parameter '" + key + "|" + value + "' into " + parentTagStr);
921 // insert parameter in SumoBaseObjectParent
922 SumoBaseObjectParent->addParameter(key, value);
923 }
924 }
925}
926
927
928bool
931 // write warning info
932 WRITE_WARNINGF(TL("Defining car-following parameters in a nested element is deprecated in vType '%', use attributes instead!"), vTypeObject->getStringAttribute(SUMO_ATTR_ID));
933 // get vType to modify it
934 auto vType = vTypeObject->getVehicleTypeParameter();
935 // parse nested CFM attributes
936 if (SUMOVehicleParserHelper::parseCFMParams(&vType, tag, attrs, true)) {
937 vTypeObject->setVehicleTypeParameter(&vType);
938 return true;
939 } else if (myHardFail) {
940 throw ProcessError(TL("Invalid parsing embedded VType"));
941 } else {
942 writeError(TL("Invalid parsing embedded VType"));
943 }
944 return false;
945}
946
947
948bool
950 // check stop parameters
951 if (attrs.hasAttribute(SUMO_ATTR_ARRIVAL)) {
953 }
954 if (attrs.hasAttribute(SUMO_ATTR_DURATION)) {
956 }
957 if (attrs.hasAttribute(SUMO_ATTR_UNTIL)) {
959 }
960 if (attrs.hasAttribute(SUMO_ATTR_STARTED)) {
962 }
963 if (attrs.hasAttribute(SUMO_ATTR_ENDED)) {
965 }
968 }
969 if (attrs.hasAttribute(SUMO_ATTR_ENDPOS)) {
971 }
972 if (attrs.hasAttribute(SUMO_ATTR_STARTPOS)) {
974 }
977 }
980 }
981 // legacy attribute
984 }
985 if (attrs.hasAttribute(SUMO_ATTR_PARKING)) {
987 }
988 if (attrs.hasAttribute(SUMO_ATTR_EXPECTED)) {
990 }
993 }
996 }
997 if (attrs.hasAttribute(SUMO_ATTR_TRIP_ID)) {
999 }
1000 if (attrs.hasAttribute(SUMO_ATTR_SPLIT)) {
1002 }
1003 if (attrs.hasAttribute(SUMO_ATTR_JOIN)) {
1005 }
1006 if (attrs.hasAttribute(SUMO_ATTR_LINE)) {
1008 }
1009 if (attrs.hasAttribute(SUMO_ATTR_SPEED)) {
1011 }
1012 if (attrs.hasAttribute(SUMO_ATTR_ONDEMAND)) {
1014 }
1015 if (attrs.hasAttribute(SUMO_ATTR_JUMP)) {
1017 }
1018 // get parameters
1019 bool ok = true;
1020 // edge/lane
1021 stop.edge = attrs.getOpt<std::string>(SUMO_ATTR_EDGE, nullptr, ok, "");
1022 stop.lane = attrs.getOpt<std::string>(SUMO_ATTR_LANE, nullptr, ok, stop.busstop);
1023 // check errors
1024 if (!stop.edge.empty() && !stop.lane.empty()) {
1025 writeError(TL("A stop must be defined either with an edge or with an lane, not both"));
1026 return false;
1027 }
1028 // stopping places
1029 stop.busstop = attrs.getOpt<std::string>(SUMO_ATTR_BUS_STOP, nullptr, ok, "");
1030 if (stop.busstop.empty()) {
1031 stop.busstop = attrs.getOpt<std::string>(SUMO_ATTR_TRAIN_STOP, nullptr, ok, stop.busstop);
1032 }
1033 stop.chargingStation = attrs.getOpt<std::string>(SUMO_ATTR_CHARGING_STATION, nullptr, ok, "");
1034 stop.overheadWireSegment = attrs.getOpt<std::string>(SUMO_ATTR_OVERHEAD_WIRE_SEGMENT, nullptr, ok, "");
1035 stop.containerstop = attrs.getOpt<std::string>(SUMO_ATTR_CONTAINER_STOP, nullptr, ok, "");
1036 stop.parkingarea = attrs.getOpt<std::string>(SUMO_ATTR_PARKING_AREA, nullptr, ok, "");
1037 //check stopping places
1038 const int numStoppingPlaces = !stop.busstop.empty() + !stop.chargingStation.empty() + !stop.overheadWireSegment.empty() +
1039 !stop.containerstop.empty() + !stop.parkingarea.empty();
1040 if (numStoppingPlaces > 1) {
1041 writeError(TL("A stop must be defined only in a StoppingPlace"));
1042 return false;
1043 } else if ((numStoppingPlaces == 0) && stop.edge.empty() && stop.lane.empty()) {
1044 writeError(TL("A stop must be defined in an edge, a lane, or in a StoppingPlace"));
1045 return false;
1046 }
1047 // declare error suffix
1048 std::string errorSuffix;
1049 if (stop.busstop != "") {
1050 errorSuffix = " at '" + stop.busstop + "'" + errorSuffix;
1051 } else if (stop.chargingStation != "") {
1052 errorSuffix = " at '" + stop.chargingStation + "'" + errorSuffix;
1053 } else if (stop.overheadWireSegment != "") {
1054 errorSuffix = " at '" + stop.overheadWireSegment + "'" + errorSuffix;
1055 } else if (stop.containerstop != "") {
1056 errorSuffix = " at '" + stop.containerstop + "'" + errorSuffix;
1057 } else if (stop.parkingarea != "") {
1058 errorSuffix = " at '" + stop.parkingarea + "'" + errorSuffix;
1059 } else if (stop.edge != "") {
1060 errorSuffix = " at '" + stop.edge + "'" + errorSuffix;
1061 } else {
1062 errorSuffix = " on lane '" + stop.lane + "'" + errorSuffix;
1063 }
1064 // speed for counting as stopped
1065 stop.speed = attrs.getOpt<double>(SUMO_ATTR_SPEED, nullptr, ok, 0);
1066 if (stop.speed < 0) {
1067 writeError("Speed cannot be negative for stop" + errorSuffix);
1068 return false;
1069 }
1070 // get the standing duration
1071 bool expectTrigger = !attrs.hasAttribute(SUMO_ATTR_DURATION) && !attrs.hasAttribute(SUMO_ATTR_UNTIL) && !attrs.hasAttribute(SUMO_ATTR_SPEED);
1072 std::vector<std::string> triggers = attrs.getOpt<std::vector<std::string> >(SUMO_ATTR_TRIGGERED, nullptr, ok);
1073 // legacy
1074 if (attrs.getOpt<bool>(SUMO_ATTR_CONTAINER_TRIGGERED, nullptr, ok, false)) {
1075 triggers.push_back(toString(SUMO_TAG_CONTAINER));
1076 };
1077 SUMOVehicleParameter::parseStopTriggers(triggers, expectTrigger, stop);
1078 stop.startPos = attrs.getOpt<double>(SUMO_ATTR_STARTPOS, nullptr, ok, 0);
1079 stop.endPos = attrs.getOpt<double>(SUMO_ATTR_ENDPOS, nullptr, ok, 0);
1080 stop.friendlyPos = attrs.getOpt<bool>(SUMO_ATTR_FRIENDLY_POS, nullptr, ok, false);
1081 stop.arrival = attrs.getOptSUMOTimeReporting(SUMO_ATTR_ARRIVAL, nullptr, ok, -1);
1082 stop.duration = attrs.getOptSUMOTimeReporting(SUMO_ATTR_DURATION, nullptr, ok, -1);
1083 stop.until = attrs.getOptSUMOTimeReporting(SUMO_ATTR_UNTIL, nullptr, ok, -1);
1084 if (!expectTrigger && (!ok || (stop.duration < 0 && stop.until < 0 && stop.speed == 0))) {
1085 writeError("Invalid duration or end time is given for a stop" + errorSuffix);
1086 return false;
1087 }
1088 stop.extension = attrs.getOptSUMOTimeReporting(SUMO_ATTR_EXTENSION, nullptr, ok, -1);
1089 const bool defaultParking = (stop.triggered || stop.containerTriggered || stop.parkingarea != "");
1090 stop.parking = attrs.getOpt<ParkingType>(SUMO_ATTR_PARKING, nullptr, ok, defaultParking ? ParkingType::OFFROAD : ParkingType::ONROAD);
1091 if ((stop.parkingarea != "") && (stop.parking == ParkingType::ONROAD)) {
1092 WRITE_WARNING("Stop at parkingarea overrides attribute 'parking' for stop" + errorSuffix);
1094 }
1095 if (!ok) {
1096 writeError("Invalid bool for 'triggered', 'containerTriggered' or 'parking' for stop" + errorSuffix);
1097 return false;
1098 }
1099 // expected persons
1100 const std::vector<std::string>& expected = attrs.getOpt<std::vector<std::string> >(SUMO_ATTR_EXPECTED, nullptr, ok);
1101 stop.awaitedPersons.insert(expected.begin(), expected.end());
1102 if (stop.awaitedPersons.size() > 0 && (stop.parametersSet & STOP_TRIGGER_SET) == 0) {
1103 stop.triggered = true;
1104 if ((stop.parametersSet & STOP_PARKING_SET) == 0) {
1106 }
1107 }
1108 // permitted transportables
1109 const std::vector<std::string>& permitted = attrs.getOpt<std::vector<std::string> >(SUMO_ATTR_PERMITTED, nullptr, ok);
1110 stop.permitted.insert(permitted.begin(), permitted.end());
1111 // expected containers
1112 const std::vector<std::string>& expectedContainers = attrs.getOpt<std::vector<std::string> >(SUMO_ATTR_EXPECTED_CONTAINERS, nullptr, ok);
1113 stop.awaitedContainers.insert(expectedContainers.begin(), expectedContainers.end());
1114 if (stop.awaitedContainers.size() > 0 && (stop.parametersSet & STOP_CONTAINER_TRIGGER_SET) == 0) {
1115 stop.containerTriggered = true;
1116 if ((stop.parametersSet & STOP_PARKING_SET) == 0) {
1118 }
1119 }
1120 // public transport trip id
1121 stop.tripId = attrs.getOpt<std::string>(SUMO_ATTR_TRIP_ID, nullptr, ok, "");
1122 stop.split = attrs.getOpt<std::string>(SUMO_ATTR_SPLIT, nullptr, ok, "");
1123 stop.join = attrs.getOpt<std::string>(SUMO_ATTR_JOIN, nullptr, ok, "");
1124 stop.line = attrs.getOpt<std::string>(SUMO_ATTR_LINE, nullptr, ok, "");
1125 // index
1126 const std::string idx = attrs.getOpt<std::string>(SUMO_ATTR_INDEX, nullptr, ok, "end");
1127 if (idx == "end") {
1128 stop.index = STOP_INDEX_END;
1129 } else if (idx == "fit") {
1130 stop.index = STOP_INDEX_FIT;
1131 } else {
1132 stop.index = attrs.get<int>(SUMO_ATTR_INDEX, nullptr, ok);
1133 if (!ok || stop.index < 0) {
1134 writeError("Invalid 'index' for stop" + errorSuffix);
1135 return false;
1136 }
1137 }
1138 stop.started = attrs.getOptSUMOTimeReporting(SUMO_ATTR_STARTED, nullptr, ok, -1);
1139 stop.ended = attrs.getOptSUMOTimeReporting(SUMO_ATTR_ENDED, nullptr, ok, -1);
1140 stop.posLat = attrs.getOpt<double>(SUMO_ATTR_POSITION_LAT, nullptr, ok, INVALID_DOUBLE);
1141 stop.actType = attrs.getOpt<std::string>(SUMO_ATTR_ACTTYPE, nullptr, ok, "");
1142 stop.onDemand = attrs.getOpt<bool>(SUMO_ATTR_ONDEMAND, nullptr, ok, false);
1143 stop.jump = attrs.getOptSUMOTimeReporting(SUMO_ATTR_JUMP, nullptr, ok, -1);
1144 return true;
1145}
1146
1147
1148bool
1150 // check conditions
1151 if (attrs.hasAttribute(SUMO_ATTR_ID)) {
1152 return false;
1154 return false;
1156 return false;
1158 return true;
1160 return true;
1161 } else {
1162 return false;
1163 }
1164}
1165
1166
1167void
1168RouteHandler::checkParent(const SumoXMLTag currentTag, const std::vector<SumoXMLTag>& parentTags, bool& ok) {
1169 // check that parent SUMOBaseObject's tag is the parentTag
1171 // set parent string
1172 std::string parentStrings;
1173 for (const auto& tag : parentTags) {
1174 if (tag == parentTags.back()) {
1175 parentStrings.append(toString(tag));
1176 } else {
1177 parentStrings.append(toString(tag) + ", ");
1178 }
1179 }
1180 if ((parent != nullptr) &&
1181 (parentTags.size() > 0) &&
1182 (std::find(parentTags.begin(), parentTags.end(), parent->getTag()) == parentTags.end())) {
1183 const std::string id = parent->hasStringAttribute(SUMO_ATTR_ID) ? ", id: '" + parent->getStringAttribute(SUMO_ATTR_ID) + "'" : "";
1184 writeError("'" + toString(currentTag) + "' must be defined within the definition of a '" + parentStrings + "' (found '" + toString(parent->getTag()) + "'" + id + ").");
1185 ok = false;
1186 }
1187}
1188
1189/****************************************************************************/
long long int SUMOTime
Definition GUI.h:36
#define WRITE_DEBUG(msg)
Definition MsgHandler.h:306
#define WRITE_WARNINGF(...)
Definition MsgHandler.h:296
#define WRITE_ERRORF(...)
Definition MsgHandler.h:305
#define WRITE_ERROR(msg)
Definition MsgHandler.h:304
#define WRITE_WARNING(msg)
Definition MsgHandler.h:295
#define TL(string)
Definition MsgHandler.h:315
#define TLF(string,...)
Definition MsgHandler.h:317
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_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_NOTHING
invalid tag, must be the last one
@ SUMO_TAG_TRANSHIP
@ SUMO_TAG_CONTAINERFLOW
@ SUMO_TAG_ROOTFILE
root file
@ 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
begin/end of the description of a route
@ SUMO_TAG_RIDE
@ SUMO_TAG_VTYPE_DISTRIBUTION
distribution of a vehicle type
@ SUMO_TAG_DEST_PROB_REROUTE
probability of destination of a reroute
@ SUMO_TAG_PARAM
parameter associated to a certain key
@ 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_FROM_JUNCTION
@ SUMO_ATTR_SPEED
@ SUMO_ATTR_STARTED
@ SUMO_ATTR_VALUE
@ 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_TRIGGERED
@ SUMO_ATTR_DURATION
@ SUMO_ATTR_KEY
@ 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
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 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 * 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:195
void parseWalk(const SUMOSAXAttributes &attrs)
parse walk
virtual void buildContainer(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const SUMOVehicleParameter &containerParameters)=0
build container
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)
bool parseNestedCFM(const SumoXMLTag tag, const SUMOSAXAttributes &attrs, CommonXMLStructure::SumoBaseObject *vTypeObject)
parse nested CarFollowingModel
bool beginParseAttributes(SumoXMLTag tag, const SUMOSAXAttributes &attrs)
begin parse attributes
CommonXMLStructure myCommonXMLStructure
common XML Structure
virtual void buildFlowTAZs(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const SUMOVehicleParameter &vehicleParameters, const std::string &fromTAZID, const std::string &toTAZID)=0
build flow (from-to TAZs)
virtual void buildRoute(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const std::string &id, SUMOVehicleClass vClass, const std::vector< std::string > &edgeIDs, const RGBColor &color, const int repeat, const SUMOTime cycleTime, const double probability, const Parameterised::Map &routeParameters)=0
build route
virtual void buildFlowOverRoute(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const SUMOVehicleParameter &vehicleParameters)=0
build a flow over an existent route
bool isErrorCreatingElement() const
get flag for check if a element wasn't created
bool isEmbeddedRoute(const SUMOSAXAttributes &attrs) const
check embedded route
void parsePerson(const SUMOSAXAttributes &attrs)
parse person
virtual void buildEmbeddedRoute(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const std::vector< std::string > &edgeIDs, const RGBColor &color, const int repeat, const SUMOTime cycleTime, const Parameterised::Map &routeParameters)=0
build embedded route
void parseTransport(const SUMOSAXAttributes &attrs)
parse transport
virtual void 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 endParseAttributes()
end parse attributes
virtual void buildFlowJunctions(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const SUMOVehicleParameter &vehicleParameters, const std::string &fromJunctionID, const std::string &toJunctionID)=0
build flow (from-to junctions)
virtual void 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 parseVTypeDistribution(const SUMOSAXAttributes &attrs)
parse vType distribution
virtual void buildTripJunctions(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const SUMOVehicleParameter &vehicleParameters, const std::string &fromJunctionID, const std::string &toJunctionID)=0
build trip (from-to junctions)
void writeErrorInvalidID(const SumoXMLTag tag, const std::string &id)
write error "invalid id"
const std::string myFilename
filename (needed for parsing vTypes)
virtual void buildWalk(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const CommonXMLStructure::PlanParameters &planParameters, const double arrivalPos, const double speed, const SUMOTime duration)=0
build walk
void parseStop(const SUMOSAXAttributes &attrs)
parse stop
void parseContainer(const SUMOSAXAttributes &attrs)
parse container
RouteHandler(const std::string &filename, const bool hardFail)
Constructor.
void parsePersonTrip(const SUMOSAXAttributes &attrs)
parse person trip
virtual void buildTrip(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const SUMOVehicleParameter &vehicleParameters, const std::string &fromEdgeID, const std::string &toEdgeID)=0
build trip (from-to edges)
virtual void buildVType(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const SUMOVTypeParameter &vTypeParameter)=0
build vType
void parseRoute(const SUMOSAXAttributes &attrs)
parse route
virtual void buildVTypeDistribution(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const std::string &id, const int deterministic, const std::vector< std::string > &vTypeIDs, const std::vector< double > &probabilities)=0
build vType distribution
virtual void buildTripTAZs(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const SUMOVehicleParameter &vehicleParameters, const std::string &fromTazID, const std::string &toTazID)=0
build trip (from-to TAZs)
void parseTrip(const SUMOSAXAttributes &attrs)
parse trip
SUMOTime myFlowEndDefault
The default value for flow ends.
virtual ~RouteHandler()
Destructor.
void parseParameters(const SUMOSAXAttributes &attrs)
parse generic parameters
virtual void buildStop(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const CommonXMLStructure::PlanParameters &planParameters, const SUMOVehicleParameter::Stop &stopParameters)=0
build stop
void parseSumoBaseObject(CommonXMLStructure::SumoBaseObject *obj)
parse SumoBaseObject (it's called recursivelly)
virtual void 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
virtual void buildPersonFlow(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const SUMOVehicleParameter &personFlowParameters)=0
build person flow
void parsePersonFlow(const SUMOSAXAttributes &attrs)
parse person flow
void parseInterval(const SUMOSAXAttributes &attrs)
parse interval
bool myErrorCreatingElement
flag for check if a element wasn't created
void parseVType(const SUMOSAXAttributes &attrs)
void writeError(const std::string &error)
write error and enable error creating element
void parseRide(const SUMOSAXAttributes &attrs)
parse ride
virtual void 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
SUMOTime myFlowBeginDefault
The default value for flow begins.
virtual void buildVehicleOverRoute(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const SUMOVehicleParameter &vehicleParameters)=0
build a vehicle over an existent route
void parseVehicle(const SUMOSAXAttributes &attrs)
parse vehicle (including vehicles over routes and vehicles with embedded routes)
void checkParent(const SumoXMLTag currentTag, const std::vector< SumoXMLTag > &parentTags, bool &ok)
check parents
virtual void buildRouteDistribution(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const std::string &id, const std::vector< std::string > &vTypeIDs, const std::vector< double > &probabilities)=0
build route distribution
virtual void buildContainerFlow(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const SUMOVehicleParameter &containerFlowParameters)=0
build container flow
virtual void buildPerson(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const SUMOVehicleParameter &personParameters)=0
build person
bool parseStopParameters(SUMOVehicleParameter::Stop &stop, const SUMOSAXAttributes &attrs)
parse stop parameters
void writeErrorInvalidDistribution(const SumoXMLTag tag, const std::string &id)
write error "invalid distribution"
const bool myHardFail
enable or disable hardFail (stop parsing if parameter aren't correct)
void parseRouteDistribution(const SUMOSAXAttributes &attrs)
parse route distribution
void parseTranship(const SUMOSAXAttributes &attrs)
parse tranship
virtual void buildFlow(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const SUMOVehicleParameter &vehicleParameters, const std::string &fromEdgeID, const std::string &toEdgeID)=0
build flow (from-to edges)
Encapsulated SAX-Attributes.
virtual std::string getString(int id, bool *isPresent=nullptr) const =0
Returns the string-value of the named (by its enum-value) attribute.
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.
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.
static bool isValidVehicleID(const std::string &value)
whether the given string is a valid id for a vehicle or flow
static bool isValidParameterKey(const std::string &value)
whether the given string is a valid key for a parameter