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
27#include <utils/shapes/Shape.h>
31#include <utils/xml/XMLSubSys.h>
32
33#include "RouteHandler.h"
34
35
36// ===========================================================================
37// method definitions
38// ===========================================================================
39
40RouteHandler::RouteHandler(FileBucket* fileBucket, const bool hardFail) :
41 CommonHandler(fileBucket),
42 myHardFail(hardFail),
43 myFlowBeginDefault(string2time(OptionsCont::getOptions().getString("begin"))),
44 myFlowEndDefault(string2time(OptionsCont::getOptions().getString("end"))) {
45}
46
47
49
50
51bool
53 // open SUMOBaseOBject
55 // check tag
56 try {
57 switch (tag) {
58 // vTypes
59 case SUMO_TAG_VTYPE:
60 // continue depeding if we're parsing a vType or a reference
63 parseVTypeRef(attrs);
64 } else {
65 parseVType(attrs);
66 }
67 break;
70 break;
71 // routes
72 case SUMO_TAG_ROUTE: {
73 // continue depeding if we're parsing a basic route, an embedded route, or a distribution ref
74 const auto parentTag = myCommonXMLStructure.getSumoBaseObjectRoot()->getTag();
75 // this is temporal, until #16476
76 if (parentTag != SUMO_TAG_ERROR) {
77 if ((parentTag == SUMO_TAG_VEHICLE) || (parentTag == SUMO_TAG_FLOW)) {
78 parseRouteEmbedded(attrs);
79 } else if ((parentTag == SUMO_TAG_ROUTE_DISTRIBUTION) && attrs.hasAttribute(SUMO_ATTR_REFID)) {
80 parseRouteRef(attrs);
81 } else {
82 parseRoute(attrs);
83 }
84 }
85 break;
86 }
89 break;
90 // vehicles
91 case SUMO_TAG_TRIP:
92 parseTrip(attrs);
93 break;
95 parseVehicle(attrs);
96 break;
97 // flows
98 case SUMO_TAG_FLOW:
99 parseFlow(attrs);
100 break;
101 // stop
102 case SUMO_TAG_STOP:
103 parseStop(attrs);
104 break;
105 // persons
106 case SUMO_TAG_PERSON:
107 parsePerson(attrs);
108 break;
110 parsePersonFlow(attrs);
111 break;
112 // person plans
114 parsePersonTrip(attrs);
115 break;
116 case SUMO_TAG_RIDE:
117 parseRide(attrs);
118 break;
119 case SUMO_TAG_WALK:
120 parseWalk(attrs);
121 break;
122 // container
124 parseContainer(attrs);
125 break;
127 parseContainerFlow(attrs);
128 break;
129 // container plans
131 parseTransport(attrs);
132 break;
134 parseTranship(attrs);
135 break;
136 // parameters
137 case SUMO_TAG_PARAM:
138 parseParameters(attrs);
139 break;
140 // other
141 case SUMO_TAG_INTERVAL: {
142 parseInterval(attrs);
143 break;
144 }
145 default:
146 // get vehicle type Base object
148 // parse embedded car following model information
149 if (vTypeObject && (vTypeObject->getTag() == SUMO_TAG_VTYPE)) {
150 // nested CFM attributes
151 return parseNestedCFM(tag, attrs, vTypeObject);
152 } else {
153 // tag cannot be parsed in routeHandler
155 return false;
156 }
157 }
158 } catch (InvalidArgument& e) {
159 WRITE_ERROR(e.what());
160 }
161 return true;
162}
163
164
165void
167 // get last inserted object
169 // check tag
170 if (obj) {
171 // close SUMOBaseOBject
173 switch (obj->getTag()) {
174 case SUMO_TAG_ROUTE:
175 // special case, because embedded and distribution routes are created within other elements
176 if (obj->getParentSumoBaseObject() == nullptr) {
177 // parse object and all their childrens
179 // delete object (and all of their childrens)
180 delete obj;
181 }
182 break;
184 // parse object and all their childrens
186 // delete object (and all of their childrens)
187 delete obj;
188 break;
190 // parse object and all their childrens
192 // delete object (and all of their childrens)
193 delete obj;
194 break;
195 case SUMO_TAG_VTYPE:
196 // special case, because embedded and distribution routes are created within other elements
197 if (obj->getParentSumoBaseObject() == nullptr) {
198 // parse object and all their childrens
200 // delete object (and all of their childrens)
201 delete obj;
202 }
203 break;
204 case SUMO_TAG_TRIP:
205 case SUMO_TAG_VEHICLE:
206 case SUMO_TAG_FLOW:
207 case SUMO_TAG_PERSON:
211 // parse object and all their childrens
213 // delete object (and all of their childrens)
214 delete obj;
215 break;
216 default:
217 break;
218 }
219 }
220}
221
222
223void
225 // check if loading was aborted
226 if (!myAbortLoading) {
227 // switch tag
228 switch (obj->getTag()) {
229 // vTypes
230 case SUMO_TAG_VTYPE:
231 // check if parse vType or Ref
233 if (buildVTypeRef(obj,
236 obj->markAsCreated();
237 }
238 } else {
239 if (buildVType(obj,
240 obj->getVehicleTypeParameter())) {
241 obj->markAsCreated();
242 }
243 }
244 break;
249 obj->markAsCreated();
250 }
251 break;
252 // route
253 case SUMO_TAG_ROUTE:
254 // embedded routes are created in build<Vehicle/Flow>EmbeddedRoute
256 if (buildRouteRef(obj,
259 obj->markAsCreated();
260 }
261 } else if (obj->hasStringAttribute(SUMO_ATTR_ID)) {
262 if (buildRoute(obj,
264 obj->getVClass(),
270 obj->getParameters())) {
271 obj->markAsCreated();
272 }
273 }
274 break;
278 obj->markAsCreated();
279 }
280 break;
281 // vehicles
282 case SUMO_TAG_TRIP:
283 if (checkVehicleParents(obj)) {
284 if (isOverFromToEdges(obj)) {
285 // build trip with from-to edges
286 if (buildTrip(obj,
287 obj->getVehicleParameter(),
290 obj->markAsCreated();
291 }
292 } else if (isOverFromToJunctions(obj)) {
293 // build trip with from-to junctions
294 if (buildTripJunctions(obj,
295 obj->getVehicleParameter(),
298 obj->markAsCreated();
299 }
300 } else if (isOverFromToTAZs(obj)) {
301 // build trip with from-to TAZs
302 if (buildTripTAZs(obj,
303 obj->getVehicleParameter(),
306 obj->markAsCreated();
307 }
308 }
309 }
310 break;
311 case SUMO_TAG_VEHICLE:
312 if (checkVehicleParents(obj)) {
314 // build vehicle over route
315 if (buildVehicleOverRoute(obj,
316 obj->getVehicleParameter())) {
317 obj->markAsCreated();
318 }
319 } else {
320 const auto embeddedRoute = getEmbeddedRoute(obj);
321 if (embeddedRoute) {
322 // build vehicle with embedded route
324 obj->getVehicleParameter(),
325 embeddedRoute->getStringListAttribute(SUMO_ATTR_EDGES),
326 embeddedRoute->getColorAttribute(SUMO_ATTR_COLOR),
327 embeddedRoute->getIntAttribute(SUMO_ATTR_REPEAT),
328 embeddedRoute->getTimeAttribute(SUMO_ATTR_CYCLETIME),
329 embeddedRoute->getParameters())) {
330 obj->markAsCreated();
331 }
332 }
333 }
334 }
335 break;
336 // flows
337 case SUMO_TAG_FLOW:
338 if (checkVehicleParents(obj)) {
340 // build flow over route
341 if (buildFlowOverRoute(obj,
342 obj->getVehicleParameter())) {
343 obj->markAsCreated();
344 }
345 } else if (isOverFromToEdges(obj)) {
346 // build flow with from-to edges
347 if (buildFlow(obj,
348 obj->getVehicleParameter(),
351 obj->markAsCreated();
352 }
353 } else if (isOverFromToJunctions(obj)) {
354 // build flow with from-to junctions
355 if (buildFlowJunctions(obj,
356 obj->getVehicleParameter(),
359 obj->markAsCreated();
360 }
361 } else if (isOverFromToTAZs(obj)) {
362 // build flow with from-to TAZs
363 if (buildFlowTAZs(obj,
364 obj->getVehicleParameter(),
367 obj->markAsCreated();
368 }
369
370 } else {
371 const auto embeddedRoute = getEmbeddedRoute(obj);
372 if (embeddedRoute) {
373 // build flow with embedded route
375 obj->getVehicleParameter(),
376 embeddedRoute->getStringListAttribute(SUMO_ATTR_EDGES),
377 embeddedRoute->getColorAttribute(SUMO_ATTR_COLOR),
378 embeddedRoute->getIntAttribute(SUMO_ATTR_REPEAT),
379 embeddedRoute->getTimeAttribute(SUMO_ATTR_CYCLETIME),
380 embeddedRoute->getParameters())) {
381 obj->markAsCreated();
382 }
383 }
384 }
385 }
386 break;
387 // persons
388 case SUMO_TAG_PERSON:
389 if (buildPerson(obj,
390 obj->getVehicleParameter())) {
391 obj->markAsCreated();
392 }
393 break;
395 if (buildPersonFlow(obj,
396 obj->getVehicleParameter())) {
397 obj->markAsCreated();
398 }
399 break;
400 // person plans
402 if (checkPersonPlanParents(obj)) {
403 if (buildPersonTrip(obj,
404 obj->getPlanParameters(),
411 obj->markAsCreated();
412 }
413 }
414 break;
415 case SUMO_TAG_RIDE:
416 if (checkPersonPlanParents(obj)) {
417 if (buildRide(obj,
418 obj->getPlanParameters(),
422 obj->markAsCreated();
423 }
424 }
425 break;
426 case SUMO_TAG_WALK:
427 if (checkPersonPlanParents(obj)) {
428 if (buildWalk(obj,
429 obj->getPlanParameters(),
433 obj->markAsCreated();
434 }
435 }
436 break;
437 // container
439 if (buildContainer(obj,
440 obj->getVehicleParameter())) {
441 obj->markAsCreated();
442 }
443 break;
445 if (buildContainerFlow(obj,
446 obj->getVehicleParameter())) {
447 obj->markAsCreated();
448 }
449 break;
450 // container plans
452 if (checkContainerPlanParents(obj)) {
453 if (buildTransport(obj,
454 obj->getPlanParameters(),
458 obj->markAsCreated();
459 }
460 }
461 break;
463 if (checkContainerPlanParents(obj)) {
464 if (buildTranship(obj,
465 obj->getPlanParameters(),
470 obj->markAsCreated();
471 }
472 }
473 break;
474 // stops
475 case SUMO_TAG_STOP:
476 if (checkStopParents(obj)) {
477 if (buildStop(obj,
478 obj->getPlanParameters(),
479 obj->getStopParameter())) {
480 obj->markAsCreated();
481 }
482 }
483 break;
484 default:
485 break;
486 }
487 // now iterate over childrens
488 for (const auto& child : obj->getSumoBaseObjectChildren()) {
489 // call this function recursively
490 parseSumoBaseObject(child);
491 }
492 }
493}
494
495
496void
498 // parse vehicleType
500 if (vehicleTypeParameter) {
501 // set tag
503 // add all attributes
505 // delete vehicleType parameter (because in XMLStructure we have a copy)
506 delete vehicleTypeParameter;
507 } else {
509 }
510}
511
512
513void
515 // declare Ok Flag
516 bool parsedOk = true;
517 // special case for ID
518 const std::string refId = attrs.get<std::string>(SUMO_ATTR_REFID, "", parsedOk);
519 const double probability = attrs.getOpt<double>(SUMO_ATTR_PROB, refId.c_str(), parsedOk, INVALID_DOUBLE);
520 if (parsedOk) {
521 // set tag
523 // add all attributes
526 } else {
528 }
529}
530
531
532void
534 // declare Ok Flag
535 bool parsedOk = true;
536 // needed attributes
537 const std::string id = attrs.get<std::string>(SUMO_ATTR_ID, "", parsedOk);
538 // optional attributes
539 const int deterministic = attrs.getOpt<int>(SUMO_ATTR_DETERMINISTIC, id.c_str(), parsedOk, -1);
540 std::vector<std::string> vTypes = attrs.getOpt<std::vector<std::string> >(SUMO_ATTR_VTYPES, id.c_str(), parsedOk);
541 std::vector<double> probabilities = attrs.getOpt<std::vector<double> >(SUMO_ATTR_PROBS, id.c_str(), parsedOk);
542 // adjust sizes and probabilities
543 adjustTypesAndProbabilities(vTypes, probabilities);
544 // continue if all was parsed ok
545 if (parsedOk) {
546 // set tag
548 // add all attributes
551 // add references
552 for (int i = 0; i < (int)vTypes.size(); i++) {
553 // open SUMOBaseOBject
555 // set tag
557 // add all attributes
560 // close SUMOBaseOBject
562 }
563 } else {
565 }
566}
567
568
569void
571 // declare Ok Flag
572 bool parsedOk = true;
573 // needed attributes
574 const std::string id = attrs.get<std::string>(SUMO_ATTR_ID, "", parsedOk);
575 const std::vector<std::string> edges = attrs.get<std::vector<std::string> >(SUMO_ATTR_EDGES, id.c_str(), parsedOk);
576 // optional attributes
578 const RGBColor color = attrs.getOpt<RGBColor>(SUMO_ATTR_COLOR, id.c_str(), parsedOk, RGBColor::INVISIBLE);
579 const int repeat = attrs.getOpt<int>(SUMO_ATTR_REPEAT, id.c_str(), parsedOk, 0);
580 const SUMOTime cycleTime = attrs.getOptSUMOTimeReporting(SUMO_ATTR_CYCLETIME, id.c_str(), parsedOk, 0);
581 const double probability = attrs.getOpt<double>(SUMO_ATTR_PROB, id.c_str(), parsedOk, 1.0);
582 // check attributes
583 if (!checkNegative(SUMO_TAG_ROUTE, id, SUMO_ATTR_CYCLETIME, cycleTime, true)) {
584 parsedOk = false;
585 }
586 if (!checkNegative(SUMO_TAG_ROUTE, id, SUMO_ATTR_REPEAT, repeat, true)) {
587 parsedOk = false;
588 }
589 if (parsedOk) {
590 // set tag
592 // add all attributes
600 } else {
602 }
603}
604
605
606void
608 // declare Ok Flag
609 bool parsedOk = true;
610 // special case for ID
611 const std::string refId = attrs.get<std::string>(SUMO_ATTR_REFID, "", parsedOk);
612 const double probability = attrs.getOpt<double>(SUMO_ATTR_PROB, refId.c_str(), parsedOk, INVALID_DOUBLE);
613 if (parsedOk) {
614 // set tag
616 // add all attributes
619 } else {
621 }
622}
623
624
625void
627 // first check if this is an embedded route
628 if (attrs.hasAttribute(SUMO_ATTR_ID)) {
629 writeError(TL("an embedded route cannot have their own ID"));
630 } else {
631 // declare Ok Flag
632 bool parsedOk = true;
633 // special case for ID
635 // needed attributes
636 const std::vector<std::string> edges = attrs.get<std::vector<std::string> >(SUMO_ATTR_EDGES, vehicleID.c_str(), parsedOk);
637 // optional attributes
639 const RGBColor color = attrs.getOpt<RGBColor>(SUMO_ATTR_COLOR, vehicleID.c_str(), parsedOk, RGBColor::INVISIBLE);
640 const int repeat = attrs.getOpt<int>(SUMO_ATTR_REPEAT, vehicleID.c_str(), parsedOk, 0);
641 const SUMOTime cycleTime = attrs.getOptSUMOTimeReporting(SUMO_ATTR_CYCLETIME, vehicleID.c_str(), parsedOk, 0);
642 // check attributes
643 if (!checkNegative(SUMO_TAG_ROUTE, vehicleID, SUMO_ATTR_CYCLETIME, cycleTime, true)) {
644 parsedOk = false;
645 }
646 if (!checkNegative(SUMO_TAG_ROUTE, vehicleID, SUMO_ATTR_REPEAT, repeat, true)) {
647 parsedOk = false;
648 }
649 if (parsedOk) {
650 // set tag
652 // add all attributes
658 } else {
660 }
661 }
662}
663
664
665void
667 // declare Ok Flag
668 bool parsedOk = true;
669 // needed attributes
670 const std::string id = attrs.get<std::string>(SUMO_ATTR_ID, "", parsedOk);
671 // optional attributes
672 std::vector<std::string> routes = attrs.getOpt<std::vector<std::string> >(SUMO_ATTR_ROUTES, id.c_str(), parsedOk);
673 std::vector<double> probabilities = attrs.getOpt<std::vector<double> >(SUMO_ATTR_PROBS, id.c_str(), parsedOk);
674 // adjust sizes and probabilities
675 adjustTypesAndProbabilities(routes, probabilities);
676 // continue if all was parsed ok
677 if (parsedOk) {
678 // set tag
680 // add all attributes
682 // add references
683 for (int i = 0; i < (int)routes.size(); i++) {
684 // open SUMOBaseOBject
686 // set tag
688 // add all attributes
691 // close SUMOBaseOBject
693 }
694 } else {
696 }
697}
698
699
700void
702 // declare Ok Flag
703 bool parsedOk = true;
704 // parse vehicle
706 if (tripParameter) {
707 // check from/to edge/junction
709 writeError(TL("Attributes 'from', 'fromJunction' and 'fromTaz' cannot be defined together"));
712 writeError(TL("Attributes 'to', 'toJunction' and 'toTaz' cannot be defined together"));
715 // from-to attributes
716 const std::string fromJunction = attrs.get<std::string>(SUMO_ATTR_FROM_JUNCTION, tripParameter->id.c_str(), parsedOk);
717 const std::string toJunction = attrs.get<std::string>(SUMO_ATTR_TO_JUNCTION, tripParameter->id.c_str(), parsedOk);
718 if (parsedOk) {
719 // set tag
721 // set vehicle parameters
723 // add other attributes
726 } else {
728 }
729 } else if (attrs.hasAttribute(SUMO_ATTR_FROM_TAZ) && attrs.hasAttribute(SUMO_ATTR_TO_TAZ)) {
730 // from-to attributes
731 const std::string fromJunction = attrs.get<std::string>(SUMO_ATTR_FROM_TAZ, tripParameter->id.c_str(), parsedOk);
732 const std::string toJunction = attrs.get<std::string>(SUMO_ATTR_TO_TAZ, tripParameter->id.c_str(), parsedOk);
733 if (parsedOk) {
734 // set tag
736 // set vehicle parameters
738 // add other attributes
741 } else {
743 }
744 } else {
745 // from-to attributes
746 const std::string from = attrs.getOpt<std::string>(SUMO_ATTR_FROM, tripParameter->id.c_str(), parsedOk, "");
747 const std::string to = attrs.getOpt<std::string>(SUMO_ATTR_TO, tripParameter->id.c_str(), parsedOk, "");
748 // optional attributes
749 const std::vector<std::string> via = attrs.getOpt<std::vector<std::string> >(SUMO_ATTR_VIA, tripParameter->id.c_str(), parsedOk);
750 if (parsedOk) {
751 // set tag
753 // set vehicle parameters
755 // add other attributes
759 } else {
761 }
762 }
763 // delete trip parameter (because in XMLStructure we have a copy)
764 delete tripParameter;
765 } else {
767 }
768}
769
770
771void
773 // first parse vehicle
775 if (vehicleParameter) {
776 // set tag
778 // set vehicle parameters
780 // delete vehicle parameter (because in XMLStructure we have a copy)
781 delete vehicleParameter;
782 } else {
784 }
785}
786
787
788void
790 // declare Ok Flag
791 bool parsedOk = true;
792 // first parse flow
794 if (flowParameter) {
795 // set vehicle parameters
797 // check from/to edge/junction
799 writeError(TL("Attributes 'from', 'fromJunction' and 'fromTaz' cannot be defined together"));
802 writeError(TL("Attributes 'to', 'toJunction' and 'toTaz' cannot be defined together"));
804 } else if (attrs.hasAttribute(SUMO_ATTR_FROM) && attrs.hasAttribute(SUMO_ATTR_TO)) {
805 // from-to attributes
806 const std::string from = attrs.get<std::string>(SUMO_ATTR_FROM, flowParameter->id.c_str(), parsedOk);
807 const std::string to = attrs.get<std::string>(SUMO_ATTR_TO, flowParameter->id.c_str(), parsedOk);
808 // optional attributes
809 const std::vector<std::string> via = attrs.getOpt<std::vector<std::string> >(SUMO_ATTR_VIA, flowParameter->id.c_str(), parsedOk);
810 if (parsedOk) {
811 // set tag
813 // add other attributes
817 } else {
819 }
821 // from-to attributes
822 const std::string fromJunction = attrs.get<std::string>(SUMO_ATTR_FROM_JUNCTION, flowParameter->id.c_str(), parsedOk);
823 const std::string toJunction = attrs.get<std::string>(SUMO_ATTR_TO_JUNCTION, flowParameter->id.c_str(), parsedOk);
824 if (parsedOk) {
825 // set tag
827 // add other attributes
830 } else {
832 }
833 } else if (attrs.hasAttribute(SUMO_ATTR_FROM_TAZ) && attrs.hasAttribute(SUMO_ATTR_TO_TAZ)) {
834 // from-to attributes
835 const std::string fromJunction = attrs.get<std::string>(SUMO_ATTR_FROM_TAZ, flowParameter->id.c_str(), parsedOk);
836 const std::string toJunction = attrs.get<std::string>(SUMO_ATTR_TO_TAZ, flowParameter->id.c_str(), parsedOk);
837 if (parsedOk) {
838 // set tag
840 // add other attributes
843 } else {
845 }
846 } else if (attrs.hasAttribute(SUMO_ATTR_ROUTE)) {
847 // from-to attributes
848 const std::string route = attrs.get<std::string>(SUMO_ATTR_ROUTE, flowParameter->id.c_str(), parsedOk);
849 if (parsedOk) {
850 // set tag
852 // add other attributes
854 } else {
856 }
857 } else {
858 // set tag
860 }
861 // delete flow parameter (because in XMLStructure we have a copy)
862 delete flowParameter;
863 } else {
865 }
866}
867
868
869void
871 // declare Ok Flag
872 bool parsedOk = true;
873 // declare stop
875 // plan parameters
876 const auto planParameters = CommonXMLStructure::PlanParameters(myCommonXMLStructure.getCurrentSumoBaseObject(), attrs, parsedOk);
877 // get parents
878 std::vector<SumoXMLTag> stopParents;
879 stopParents.insert(stopParents.end(), NamespaceIDs::routes.begin(), NamespaceIDs::routes.end());
880 stopParents.insert(stopParents.end(), NamespaceIDs::vehicles.begin(), NamespaceIDs::vehicles.end());
881 stopParents.insert(stopParents.end(), NamespaceIDs::persons.begin(), NamespaceIDs::persons.end());
882 stopParents.insert(stopParents.end(), NamespaceIDs::containers.begin(), NamespaceIDs::containers.end());
883 // check parents
884 checkParsedParent(SUMO_TAG_STOP, stopParents, parsedOk);
885 // parse stop
886 if (parsedOk && parseStopParameters(stop, attrs)) {
887 // set tag
889 // add stop attributes
892 } else {
894 }
895}
896
897
898void
900 // first parse vehicle
902 if (personParameter) {
903 // set tag
905 // set vehicle parameter
907 // delete person parameter (because in XMLStructure we have a copy)
908 delete personParameter;
909 } else {
911 }
912}
913
914
915void
917 // first parse flow
919 if (personFlowParameter) {
920 // set tag
922 // set vehicle parameter
924 // delete person flow parameter (because in XMLStructure we have a copy)
925 delete personFlowParameter;
926 } else {
928 }
929}
930
931
932void
934 // declare Ok Flag
935 bool parsedOk = true;
936 // plan parameters
937 const auto planParameters = CommonXMLStructure::PlanParameters(myCommonXMLStructure.getCurrentSumoBaseObject(), attrs, parsedOk);
938 // optional attributes
939 const std::vector<std::string> via = attrs.getOpt<std::vector<std::string> >(SUMO_ATTR_VIA, "", parsedOk);
940 const std::vector<std::string> vTypes = attrs.getOpt<std::vector<std::string> >(SUMO_ATTR_VTYPES, "", parsedOk);
941 const std::vector<std::string> lines = attrs.getOpt<std::vector<std::string> >(SUMO_ATTR_LINES, "", parsedOk);
942 std::vector<std::string> modes = attrs.getOpt<std::vector<std::string> >(SUMO_ATTR_MODES, "", parsedOk);
943 const double departPos = attrs.getOpt<double>(SUMO_ATTR_DEPARTPOS, "", parsedOk, -1);
944 const double arrivalPos = attrs.getOpt<double>(SUMO_ATTR_ARRIVALPOS, "", parsedOk, -1);
945 const double walkFactor = attrs.getOpt<double>(SUMO_ATTR_WALKFACTOR, "", parsedOk, 0);
946 const std::string group = attrs.getOpt<std::string>(SUMO_ATTR_GROUP, "", parsedOk, "");
947 // check modes
948 SVCPermissions dummyModeSet;
949 std::string dummyError;
950 if (!SUMOVehicleParameter::parsePersonModes(toString(modes), toString(SUMO_TAG_PERSONTRIP), "", dummyModeSet, dummyError)) {
951 WRITE_WARNING(dummyError);
952 modes.clear();
953 }
954 // check parents
956 if (parsedOk) {
957 // set tag
959 // add all attributes
968 } else {
970 }
971}
972
973
974void
977 writeError(TL("Speed and duration attributes cannot be defined together in walks"));
979 } else {
980 // declare Ok Flag
981 bool parsedOk = true;
982 // plan parameters
983 const auto planParameters = CommonXMLStructure::PlanParameters(myCommonXMLStructure.getCurrentSumoBaseObject(), attrs, parsedOk);
984 // optional attributes
985 const double departPos = attrs.getOpt<double>(SUMO_ATTR_DEPARTPOS, "", parsedOk, -1);
986 const double arrivalPos = attrs.getOpt<double>(SUMO_ATTR_ARRIVALPOS, "", parsedOk, -1);
987 const double speed = attrs.getOpt<double>(SUMO_ATTR_SPEED, "", parsedOk, 1.39);
988 const SUMOTime duration = attrs.getOptSUMOTimeReporting(SUMO_ATTR_DURATION, "", parsedOk, 0);
989 // check parents
991 if (parsedOk) {
992 // set tag
994 // add all attributes
1000 } else {
1002 }
1003 }
1004}
1005
1006
1007void
1009 // declare Ok Flag
1010 bool parsedOk = true;
1011 // plan parameters
1012 const auto planParameters = CommonXMLStructure::PlanParameters(myCommonXMLStructure.getCurrentSumoBaseObject(), attrs, parsedOk);
1013 // optional attributes
1014 const std::vector<std::string> lines = attrs.getOpt<std::vector<std::string> >(SUMO_ATTR_LINES, "", parsedOk);
1015 const double arrivalPos = attrs.getOpt<double>(SUMO_ATTR_ARRIVALPOS, "", parsedOk, -1);
1016 const std::string group = attrs.getOpt<std::string>(SUMO_ATTR_GROUP, "", parsedOk, "");
1017 // check parents
1019 if (parsedOk) {
1020 // set tag
1022 // add all attributes
1027 } else {
1029 }
1030}
1031
1032
1033void
1035 // first parse container
1037 if (containerParameter) {
1038 // set tag
1040 // set vehicle parameter
1042 // delete container parameter (because in XMLStructure we have a copy)
1043 delete containerParameter;
1044 } else {
1046 }
1047}
1048
1049
1050void
1052 // first parse flow
1054 if (containerFlowParameter) {
1055 // set tag
1057 // set vehicle parameter
1059 // delete container flow parameter (because in XMLStructure we have a copy)
1060 delete containerFlowParameter;
1061 } else {
1063 }
1064}
1065
1066
1067void
1069 // declare Ok Flag
1070 bool parsedOk = true;
1071 // plan parameters
1072 const auto planParameters = CommonXMLStructure::PlanParameters(myCommonXMLStructure.getCurrentSumoBaseObject(), attrs, parsedOk);
1073 // optional attributes
1074 const std::vector<std::string> lines = attrs.getOpt<std::vector<std::string> >(SUMO_ATTR_LINES, "", parsedOk);
1075 const double arrivalPos = attrs.getOpt<double>(SUMO_ATTR_ARRIVALPOS, "", parsedOk, -1);
1076 const std::string group = attrs.getOpt<std::string>(SUMO_ATTR_GROUP, "", parsedOk, "");
1077 // check parents
1079 if (parsedOk) {
1080 // set tag
1082 // add all attributes
1087 } else {
1089 }
1090}
1091
1092
1093void
1096 writeError(TL("Speed and duration attributes cannot be defined together in tranships"));
1098 } else {
1099 // declare Ok Flag
1100 bool parsedOk = true;
1101 // plan parameters
1102 const auto planParameters = CommonXMLStructure::PlanParameters(myCommonXMLStructure.getCurrentSumoBaseObject(), attrs, parsedOk);
1103 // optional attributes
1104 const double arrivalPos = attrs.getOpt<double>(SUMO_ATTR_ARRIVALPOS, "", parsedOk, -1);
1105 const double departPos = attrs.getOpt<double>(SUMO_ATTR_DEPARTPOS, "", parsedOk, -1);
1106 const double speed = attrs.getOpt<double>(SUMO_ATTR_SPEED, "", parsedOk, 1.39);
1107 const SUMOTime duration = attrs.getOptSUMOTimeReporting(SUMO_ATTR_DURATION, "", parsedOk, 0);
1108 // check parents
1110 if (parsedOk) {
1111 // set tag
1113 // add all attributes
1119 } else {
1121 }
1122 }
1123}
1124
1125
1126void
1128 // declare Ok Flag
1129 bool parsedOk = true;
1130 // just parse begin and end default
1131 myFlowBeginDefault = attrs.getSUMOTimeReporting(SUMO_ATTR_BEGIN, nullptr, parsedOk);
1132 myFlowEndDefault = attrs.getSUMOTimeReporting(SUMO_ATTR_END, nullptr, parsedOk);
1133}
1134
1135
1136bool
1138 // write warning info
1139 WRITE_WARNINGF(TL("Defining car-following parameters in a nested element is deprecated in vType '%', use attributes instead!"), vTypeObject->getStringAttribute(SUMO_ATTR_ID));
1140 // get vType to modify it
1141 auto vType = vTypeObject->getVehicleTypeParameter();
1142 // parse nested CFM attributes
1143 if (SUMOVehicleParserHelper::parseCFMParams(&vType, tag, attrs, true)) {
1144 vTypeObject->setVehicleTypeParameter(&vType);
1145 return true;
1146 } else if (myHardFail) {
1147 throw ProcessError(TL("Invalid parsing embedded VType"));
1148 } else {
1149 return writeError(TL("Invalid parsing embedded VType"));
1150 }
1151}
1152
1153
1154bool
1156 // check stop parameters
1157 if (attrs.hasAttribute(SUMO_ATTR_ARRIVAL)) {
1159 }
1160 if (attrs.hasAttribute(SUMO_ATTR_DURATION)) {
1162 }
1163 if (attrs.hasAttribute(SUMO_ATTR_UNTIL)) {
1165 }
1166 if (attrs.hasAttribute(SUMO_ATTR_STARTED)) {
1168 }
1169 if (attrs.hasAttribute(SUMO_ATTR_ENDED)) {
1171 }
1172 if (attrs.hasAttribute(SUMO_ATTR_EXTENSION)) {
1174 }
1175 if (attrs.hasAttribute(SUMO_ATTR_ENDPOS)) {
1177 }
1178 if (attrs.hasAttribute(SUMO_ATTR_STARTPOS)) {
1180 }
1183 }
1184 if (attrs.hasAttribute(SUMO_ATTR_TRIGGERED)) {
1186 }
1187 // legacy attribute
1190 }
1191 if (attrs.hasAttribute(SUMO_ATTR_PARKING)) {
1193 }
1194 if (attrs.hasAttribute(SUMO_ATTR_EXPECTED)) {
1196 }
1197 if (attrs.hasAttribute(SUMO_ATTR_PERMITTED)) {
1199 }
1202 }
1203 if (attrs.hasAttribute(SUMO_ATTR_TRIP_ID)) {
1205 }
1206 if (attrs.hasAttribute(SUMO_ATTR_SPLIT)) {
1208 }
1209 if (attrs.hasAttribute(SUMO_ATTR_JOIN)) {
1211 }
1212 if (attrs.hasAttribute(SUMO_ATTR_LINE)) {
1214 }
1215 if (attrs.hasAttribute(SUMO_ATTR_SPEED)) {
1217 }
1218 if (attrs.hasAttribute(SUMO_ATTR_ONDEMAND)) {
1220 }
1221 if (attrs.hasAttribute(SUMO_ATTR_JUMP)) {
1223 }
1226 }
1227 // get parameters
1228 bool ok = true;
1229 // edge/lane
1230 stop.edge = attrs.getOpt<std::string>(SUMO_ATTR_EDGE, nullptr, ok, "");
1231 stop.lane = attrs.getOpt<std::string>(SUMO_ATTR_LANE, nullptr, ok, stop.busstop);
1232 // check errors
1233 if (!stop.edge.empty() && !stop.lane.empty()) {
1234 return writeError(TL("A stop must be defined either with an edge or with an lane, not both"));
1235 }
1236 // stopping places
1237 stop.busstop = attrs.getOpt<std::string>(SUMO_ATTR_BUS_STOP, nullptr, ok, "");
1238 if (stop.busstop.empty()) {
1239 stop.busstop = attrs.getOpt<std::string>(SUMO_ATTR_TRAIN_STOP, nullptr, ok, stop.busstop);
1240 }
1241 stop.chargingStation = attrs.getOpt<std::string>(SUMO_ATTR_CHARGING_STATION, nullptr, ok, "");
1242 stop.overheadWireSegment = attrs.getOpt<std::string>(SUMO_ATTR_OVERHEAD_WIRE_SEGMENT, nullptr, ok, "");
1243 stop.containerstop = attrs.getOpt<std::string>(SUMO_ATTR_CONTAINER_STOP, nullptr, ok, "");
1244 stop.parkingarea = attrs.getOpt<std::string>(SUMO_ATTR_PARKING_AREA, nullptr, ok, "");
1245 //check stopping places
1246 const int numStoppingPlaces = !stop.busstop.empty() + !stop.chargingStation.empty() + !stop.overheadWireSegment.empty() +
1247 !stop.containerstop.empty() + !stop.parkingarea.empty();
1248 if (numStoppingPlaces > 1) {
1249 return writeError(TL("A stop must be defined only in a StoppingPlace"));
1250 } else if ((numStoppingPlaces == 0) && stop.edge.empty() && stop.lane.empty()) {
1251 return writeError(TL("A stop must be defined in an edge, a lane, or in a StoppingPlace"));
1252 }
1253 // declare error suffix
1254 std::string errorSuffix;
1255 if (stop.busstop != "") {
1256 errorSuffix = " at '" + stop.busstop + "'" + errorSuffix;
1257 } else if (stop.chargingStation != "") {
1258 errorSuffix = " at '" + stop.chargingStation + "'" + errorSuffix;
1259 } else if (stop.overheadWireSegment != "") {
1260 errorSuffix = " at '" + stop.overheadWireSegment + "'" + errorSuffix;
1261 } else if (stop.containerstop != "") {
1262 errorSuffix = " at '" + stop.containerstop + "'" + errorSuffix;
1263 } else if (stop.parkingarea != "") {
1264 errorSuffix = " at '" + stop.parkingarea + "'" + errorSuffix;
1265 } else if (stop.edge != "") {
1266 errorSuffix = " at '" + stop.edge + "'" + errorSuffix;
1267 } else {
1268 errorSuffix = " on lane '" + stop.lane + "'" + errorSuffix;
1269 }
1270 // speed for counting as stopped
1271 stop.speed = attrs.getOpt<double>(SUMO_ATTR_SPEED, nullptr, ok, 0);
1272 if (stop.speed < 0) {
1273 return writeError("Speed cannot be negative for stop" + errorSuffix);
1274 }
1275 // get the standing duration
1276 bool expectTrigger = !attrs.hasAttribute(SUMO_ATTR_DURATION) && !attrs.hasAttribute(SUMO_ATTR_UNTIL) && !attrs.hasAttribute(SUMO_ATTR_SPEED);
1277 std::vector<std::string> triggers = attrs.getOpt<std::vector<std::string> >(SUMO_ATTR_TRIGGERED, nullptr, ok);
1278 // legacy
1279 if (attrs.getOpt<bool>(SUMO_ATTR_CONTAINER_TRIGGERED, nullptr, ok, false)) {
1280 triggers.push_back(toString(SUMO_TAG_CONTAINER));
1281 };
1282 SUMOVehicleParameter::parseStopTriggers(triggers, expectTrigger, stop);
1283 stop.startPos = attrs.getOpt<double>(SUMO_ATTR_STARTPOS, nullptr, ok, 0);
1284 stop.endPos = attrs.getOpt<double>(SUMO_ATTR_ENDPOS, nullptr, ok, 0);
1285 stop.friendlyPos = attrs.getOpt<bool>(SUMO_ATTR_FRIENDLY_POS, nullptr, ok, false);
1286 stop.arrival = attrs.getOptSUMOTimeReporting(SUMO_ATTR_ARRIVAL, nullptr, ok, -1);
1287 stop.duration = attrs.getOptSUMOTimeReporting(SUMO_ATTR_DURATION, nullptr, ok, -1);
1288 stop.until = attrs.getOptSUMOTimeReporting(SUMO_ATTR_UNTIL, nullptr, ok, -1);
1289 if (!expectTrigger && (!ok || (stop.duration < 0 && stop.until < 0 && stop.speed == 0))) {
1290 return writeError("Invalid duration or end time is given for a stop" + errorSuffix);
1291 }
1292 stop.extension = attrs.getOptSUMOTimeReporting(SUMO_ATTR_EXTENSION, nullptr, ok, -1);
1293 const bool defaultParking = (stop.triggered || stop.containerTriggered || stop.parkingarea != "");
1294 stop.parking = attrs.getOpt<ParkingType>(SUMO_ATTR_PARKING, nullptr, ok, defaultParking ? ParkingType::OFFROAD : ParkingType::ONROAD);
1295 if ((stop.parkingarea != "") && (stop.parking == ParkingType::ONROAD)) {
1296 WRITE_WARNING("Stop at parkingarea overrides attribute 'parking' for stop" + errorSuffix);
1298 }
1299 if (!ok) {
1300 return writeError("Invalid bool for 'triggered', 'containerTriggered' or 'parking' for stop" + errorSuffix);
1301 }
1302 // expected persons
1303 const std::vector<std::string>& expected = attrs.getOpt<std::vector<std::string> >(SUMO_ATTR_EXPECTED, nullptr, ok);
1304 stop.awaitedPersons.insert(expected.begin(), expected.end());
1305 if (stop.awaitedPersons.size() > 0 && (stop.parametersSet & STOP_TRIGGER_SET) == 0) {
1306 stop.triggered = true;
1307 if ((stop.parametersSet & STOP_PARKING_SET) == 0) {
1309 }
1310 }
1311 // permitted transportables
1312 const std::vector<std::string>& permitted = attrs.getOpt<std::vector<std::string> >(SUMO_ATTR_PERMITTED, nullptr, ok);
1313 stop.permitted.insert(permitted.begin(), permitted.end());
1314 // expected containers
1315 const std::vector<std::string>& expectedContainers = attrs.getOpt<std::vector<std::string> >(SUMO_ATTR_EXPECTED_CONTAINERS, nullptr, ok);
1316 stop.awaitedContainers.insert(expectedContainers.begin(), expectedContainers.end());
1317 if (stop.awaitedContainers.size() > 0 && (stop.parametersSet & STOP_CONTAINER_TRIGGER_SET) == 0) {
1318 stop.containerTriggered = true;
1319 if ((stop.parametersSet & STOP_PARKING_SET) == 0) {
1321 }
1322 }
1323 // public transport trip id
1324 stop.tripId = attrs.getOpt<std::string>(SUMO_ATTR_TRIP_ID, nullptr, ok, "");
1325 stop.split = attrs.getOpt<std::string>(SUMO_ATTR_SPLIT, nullptr, ok, "");
1326 stop.join = attrs.getOpt<std::string>(SUMO_ATTR_JOIN, nullptr, ok, "");
1327 stop.line = attrs.getOpt<std::string>(SUMO_ATTR_LINE, nullptr, ok, "");
1328 // index
1329 const std::string idx = attrs.getOpt<std::string>(SUMO_ATTR_INDEX, nullptr, ok, "end");
1330 if (idx == "end") {
1331 stop.index = STOP_INDEX_END;
1332 } else if (idx == "fit") {
1333 stop.index = STOP_INDEX_FIT;
1334 } else {
1335 stop.index = attrs.get<int>(SUMO_ATTR_INDEX, nullptr, ok);
1336 if (!ok || stop.index < 0) {
1337 return writeError("Invalid 'index' for stop" + errorSuffix);
1338 }
1339 }
1340 stop.started = attrs.getOptSUMOTimeReporting(SUMO_ATTR_STARTED, nullptr, ok, -1);
1341 stop.ended = attrs.getOptSUMOTimeReporting(SUMO_ATTR_ENDED, nullptr, ok, -1);
1342 stop.posLat = attrs.getOpt<double>(SUMO_ATTR_POSITION_LAT, nullptr, ok, INVALID_DOUBLE);
1343 stop.actType = attrs.getOpt<std::string>(SUMO_ATTR_ACTTYPE, nullptr, ok, "");
1344 stop.onDemand = attrs.getOpt<bool>(SUMO_ATTR_ONDEMAND, nullptr, ok, false);
1345 stop.jump = attrs.getOptSUMOTimeReporting(SUMO_ATTR_JUMP, nullptr, ok, -1);
1346 stop.jumpUntil = attrs.getOptSUMOTimeReporting(SUMO_ATTR_JUMP_UNTIL, nullptr, ok, -1);
1347 return true;
1348}
1349
1350
1351bool
1353 return sumoBaseObject->hasStringAttribute(SUMO_ATTR_FROM) && sumoBaseObject->hasStringAttribute(SUMO_ATTR_TO);
1354}
1355
1356
1357bool
1361
1362
1363bool
1365 return sumoBaseObject->hasStringAttribute(SUMO_ATTR_FROM_TAZ) && sumoBaseObject->hasStringAttribute(SUMO_ATTR_TO_TAZ);
1366}
1367
1368
1369void
1370RouteHandler::adjustTypesAndProbabilities(std::vector<std::string>& vTypes, std::vector<double>& probabilities) {
1371 // add more probabilities
1372 for (size_t i = probabilities.size(); i < vTypes.size(); i++) {
1373 probabilities.push_back(INVALID_DOUBLE);
1374 }
1375 // reduce number of probabilities
1376 while (vTypes.size() < probabilities.size()) {
1377 probabilities.pop_back();
1378 }
1379}
1380
1381/****************************************************************************/
long long int SUMOTime
Definition GUI.h:36
#define WRITE_WARNINGF(...)
Definition MsgHandler.h:287
#define WRITE_ERROR(msg)
Definition MsgHandler.h:295
#define WRITE_WARNING(msg)
Definition MsgHandler.h:286
#define TL(string)
Definition MsgHandler.h:304
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
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
FileBucket * myFileBucket
fileBucket
CommonXMLStructure myCommonXMLStructure
common XML Structure
bool checkVehicleParents(CommonXMLStructure::SumoBaseObject *obj)
check vehicle parents
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 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
const std::string & getFilename() const
get filename
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 adjustTypesAndProbabilities(std::vector< std::string > &vTypes, std::vector< double > &probabilities)
adjust types and probabilities
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.