Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
RouteHandler.cpp
Go to the documentation of this file.
1/****************************************************************************/
2// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3// Copyright (C) 2001-2025 German Aerospace Center (DLR) and others.
4// This program and the accompanying materials are made available under the
5// terms of the Eclipse Public License 2.0 which is available at
6// https://www.eclipse.org/legal/epl-2.0/
7// This Source Code may also be made available under the following Secondary
8// Licenses when the conditions for such availability set forth in the Eclipse
9// Public License 2.0 are satisfied: GNU General Public License, version 2
10// or later which is available at
11// https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13/****************************************************************************/
18// The XML-Handler for route elements loading
19/****************************************************************************/
20#include <config.h>
21
26#include <utils/shapes/Shape.h>
29#include <utils/xml/XMLSubSys.h>
31
32#include "RouteHandler.h"
33
34
35// ===========================================================================
36// method definitions
37// ===========================================================================
38
39RouteHandler::RouteHandler(const std::string& filename, const bool hardFail) :
40 CommonHandler(filename),
41 myHardFail(hardFail),
42 myFlowBeginDefault(string2time(OptionsCont::getOptions().getString("begin"))),
43 myFlowEndDefault(string2time(OptionsCont::getOptions().getString("end"))) {
44}
45
46
48
49
50bool
52 // open SUMOBaseOBject
54 // check tag
55 try {
56 switch (tag) {
57 // vTypes
58 case SUMO_TAG_VTYPE:
59 // continue depeding if we're parsing a vType or a reference
62 parseVTypeRef(attrs);
63 } else {
64 parseVType(attrs);
65 }
66 break;
69 break;
70 // routes
71 case SUMO_TAG_ROUTE: {
72 // continue depeding if we're parsing a basic route, an embedded route, or a distribution ref
73 const auto parentTag = myCommonXMLStructure.getSumoBaseObjectRoot()->getTag();
74 // this is temporal, until #16476
75 if (parentTag != SUMO_TAG_ERROR) {
76 if ((parentTag == SUMO_TAG_VEHICLE) || (parentTag == SUMO_TAG_FLOW)) {
77 parseRouteEmbedded(attrs);
78 } else if ((parentTag == SUMO_TAG_ROUTE_DISTRIBUTION) && attrs.hasAttribute(SUMO_ATTR_REFID)) {
79 parseRouteRef(attrs);
80 } else {
81 parseRoute(attrs);
82 }
83 }
84 break;
85 }
88 break;
89 // vehicles
90 case SUMO_TAG_TRIP:
91 parseTrip(attrs);
92 break;
94 parseVehicle(attrs);
95 break;
96 // flows
97 case SUMO_TAG_FLOW:
98 parseFlow(attrs);
99 break;
100 // stop
101 case SUMO_TAG_STOP:
102 parseStop(attrs);
103 break;
104 // persons
105 case SUMO_TAG_PERSON:
106 parsePerson(attrs);
107 break;
109 parsePersonFlow(attrs);
110 break;
111 // person plans
113 parsePersonTrip(attrs);
114 break;
115 case SUMO_TAG_RIDE:
116 parseRide(attrs);
117 break;
118 case SUMO_TAG_WALK:
119 parseWalk(attrs);
120 break;
121 // container
123 parseContainer(attrs);
124 break;
126 parseContainerFlow(attrs);
127 break;
128 // container plans
130 parseTransport(attrs);
131 break;
133 parseTranship(attrs);
134 break;
135 // parameters
136 case SUMO_TAG_PARAM:
137 parseParameters(attrs);
138 break;
139 // other
140 case SUMO_TAG_INTERVAL: {
141 parseInterval(attrs);
142 break;
143 }
144 default:
145 // get vehicle type Base object
147 // parse embedded car following model information
148 if (vTypeObject && (vTypeObject->getTag() == SUMO_TAG_VTYPE)) {
149 // nested CFM attributes
150 return parseNestedCFM(tag, attrs, vTypeObject);
151 } else {
152 // tag cannot be parsed in routeHandler
154 return false;
155 }
156 }
157 } catch (InvalidArgument& e) {
158 WRITE_ERROR(e.what());
159 }
160 return true;
161}
162
163
164void
166 // get last inserted object
168 // check tag
169 if (obj) {
170 // close SUMOBaseOBject
172 switch (obj->getTag()) {
173 case SUMO_TAG_ROUTE:
174 // special case, because embedded and distribution routes are created within other elements
175 if (obj->getParentSumoBaseObject() == nullptr) {
176 // parse object and all their childrens
178 // delete object (and all of their childrens)
179 delete obj;
180 }
181 break;
183 // parse object and all their childrens
185 // delete object (and all of their childrens)
186 delete obj;
187 break;
189 // parse object and all their childrens
191 // delete object (and all of their childrens)
192 delete obj;
193 break;
194 case SUMO_TAG_VTYPE:
195 // special case, because embedded and distribution routes are created within other elements
196 if (obj->getParentSumoBaseObject() == nullptr) {
197 // parse object and all their childrens
199 // delete object (and all of their childrens)
200 delete obj;
201 }
202 break;
203 case SUMO_TAG_TRIP:
204 case SUMO_TAG_VEHICLE:
205 case SUMO_TAG_FLOW:
206 case SUMO_TAG_PERSON:
210 // parse object and all their childrens
212 // delete object (and all of their childrens)
213 delete obj;
214 break;
215 default:
216 break;
217 }
218 }
219}
220
221
222void
224 // check if loading was aborted
225 if (!myAbortLoading) {
226 // switch tag
227 switch (obj->getTag()) {
228 // vTypes
229 case SUMO_TAG_VTYPE:
230 // check if parse vType or Ref
232 if (buildVTypeRef(obj,
235 obj->markAsCreated();
236 }
237 } else {
238 if (buildVType(obj,
239 obj->getVehicleTypeParameter())) {
240 obj->markAsCreated();
241 }
242 }
243 break;
248 obj->markAsCreated();
249 }
250 break;
251 // route
252 case SUMO_TAG_ROUTE:
253 // embedded routes are created in build<Vehicle/Flow>EmbeddedRoute
255 if (buildRouteRef(obj,
258 obj->markAsCreated();
259 }
260 } else if (obj->hasStringAttribute(SUMO_ATTR_ID)) {
261 if (buildRoute(obj,
263 obj->getVClass(),
269 obj->getParameters())) {
270 obj->markAsCreated();
271 }
272 }
273 break;
277 obj->markAsCreated();
278 }
279 break;
280 // vehicles
281 case SUMO_TAG_TRIP:
282 if (checkVehicleParents(obj)) {
283 if (isOverFromToEdges(obj)) {
284 // build trip with from-to edges
285 if (buildTrip(obj,
286 obj->getVehicleParameter(),
289 obj->markAsCreated();
290 }
291 } else if (isOverFromToJunctions(obj)) {
292 // build trip with from-to junctions
293 if (buildTripJunctions(obj,
294 obj->getVehicleParameter(),
297 obj->markAsCreated();
298 }
299 } else if (isOverFromToTAZs(obj)) {
300 // build trip with from-to TAZs
301 if (buildTripTAZs(obj,
302 obj->getVehicleParameter(),
305 obj->markAsCreated();
306 }
307 }
308 }
309 break;
310 case SUMO_TAG_VEHICLE:
311 if (checkVehicleParents(obj)) {
313 // build vehicle over route
314 if (buildVehicleOverRoute(obj,
315 obj->getVehicleParameter())) {
316 obj->markAsCreated();
317 }
318 } else {
319 const auto embeddedRoute = getEmbeddedRoute(obj);
320 if (embeddedRoute) {
321 // build vehicle with embedded route
323 obj->getVehicleParameter(),
324 embeddedRoute->getStringListAttribute(SUMO_ATTR_EDGES),
325 embeddedRoute->getColorAttribute(SUMO_ATTR_COLOR),
326 embeddedRoute->getIntAttribute(SUMO_ATTR_REPEAT),
327 embeddedRoute->getTimeAttribute(SUMO_ATTR_CYCLETIME),
328 embeddedRoute->getParameters())) {
329 obj->markAsCreated();
330 }
331 }
332 }
333 }
334 break;
335 // flows
336 case SUMO_TAG_FLOW:
337 if (checkVehicleParents(obj)) {
339 // build flow over route
340 if (buildFlowOverRoute(obj,
341 obj->getVehicleParameter())) {
342 obj->markAsCreated();
343 }
344 } else if (isOverFromToEdges(obj)) {
345 // build flow with from-to edges
346 if (buildFlow(obj,
347 obj->getVehicleParameter(),
350 obj->markAsCreated();
351 }
352 } else if (isOverFromToJunctions(obj)) {
353 // build flow with from-to junctions
354 if (buildFlowJunctions(obj,
355 obj->getVehicleParameter(),
358 obj->markAsCreated();
359 }
360 } else if (isOverFromToTAZs(obj)) {
361 // build flow with from-to TAZs
362 if (buildFlowTAZs(obj,
363 obj->getVehicleParameter(),
366 obj->markAsCreated();
367 }
368
369 } else {
370 const auto embeddedRoute = getEmbeddedRoute(obj);
371 if (embeddedRoute) {
372 // build flow with embedded route
374 obj->getVehicleParameter(),
375 embeddedRoute->getStringListAttribute(SUMO_ATTR_EDGES),
376 embeddedRoute->getColorAttribute(SUMO_ATTR_COLOR),
377 embeddedRoute->getIntAttribute(SUMO_ATTR_REPEAT),
378 embeddedRoute->getTimeAttribute(SUMO_ATTR_CYCLETIME),
379 embeddedRoute->getParameters())) {
380 obj->markAsCreated();
381 }
382 }
383 }
384 }
385 break;
386 // persons
387 case SUMO_TAG_PERSON:
388 if (buildPerson(obj,
389 obj->getVehicleParameter())) {
390 obj->markAsCreated();
391 }
392 break;
394 if (buildPersonFlow(obj,
395 obj->getVehicleParameter())) {
396 obj->markAsCreated();
397 }
398 break;
399 // person plans
401 if (checkPersonPlanParents(obj)) {
402 if (buildPersonTrip(obj,
403 obj->getPlanParameters(),
410 obj->markAsCreated();
411 }
412 }
413 break;
414 case SUMO_TAG_RIDE:
415 if (checkPersonPlanParents(obj)) {
416 if (buildRide(obj,
417 obj->getPlanParameters(),
421 obj->markAsCreated();
422 }
423 }
424 break;
425 case SUMO_TAG_WALK:
426 if (checkPersonPlanParents(obj)) {
427 if (buildWalk(obj,
428 obj->getPlanParameters(),
432 obj->markAsCreated();
433 }
434 }
435 break;
436 // container
438 if (buildContainer(obj,
439 obj->getVehicleParameter())) {
440 obj->markAsCreated();
441 }
442 break;
444 if (buildContainerFlow(obj,
445 obj->getVehicleParameter())) {
446 obj->markAsCreated();
447 }
448 break;
449 // container plans
451 if (checkContainerPlanParents(obj)) {
452 if (buildTransport(obj,
453 obj->getPlanParameters(),
457 obj->markAsCreated();
458 }
459 }
460 break;
462 if (checkContainerPlanParents(obj)) {
463 if (buildTranship(obj,
464 obj->getPlanParameters(),
469 obj->markAsCreated();
470 }
471 }
472 break;
473 // stops
474 case SUMO_TAG_STOP:
475 if (checkStopParents(obj)) {
476 if (buildStop(obj,
477 obj->getPlanParameters(),
478 obj->getStopParameter())) {
479 obj->markAsCreated();
480 }
481 }
482 break;
483 default:
484 break;
485 }
486 // now iterate over childrens
487 for (const auto& child : obj->getSumoBaseObjectChildren()) {
488 // call this function recursively
489 parseSumoBaseObject(child);
490 }
491 }
492}
493
494
495void
497 // parse vehicleType
499 if (vehicleTypeParameter) {
500 // set tag
502 // add all attributes
504 // delete vehicleType parameter (because in XMLStructure we have a copy)
505 delete vehicleTypeParameter;
506 } else {
508 }
509}
510
511
512void
514 // declare Ok Flag
515 bool parsedOk = true;
516 // special case for ID
517 const std::string refId = attrs.get<std::string>(SUMO_ATTR_REFID, "", parsedOk);
518 const double probability = attrs.getOpt<double>(SUMO_ATTR_PROB, refId.c_str(), parsedOk, INVALID_DOUBLE);
519 if (parsedOk) {
520 // set tag
522 // add all attributes
525 } else {
527 }
528}
529
530
531void
533 // declare Ok Flag
534 bool parsedOk = true;
535 // needed attributes
536 const std::string id = attrs.get<std::string>(SUMO_ATTR_ID, "", parsedOk);
537 // optional attributes
538 const int deterministic = attrs.getOpt<int>(SUMO_ATTR_DETERMINISTIC, id.c_str(), parsedOk, -1);
539 std::vector<std::string> vTypes = attrs.getOpt<std::vector<std::string> >(SUMO_ATTR_VTYPES, id.c_str(), parsedOk);
540 std::vector<double> probabilities = attrs.getOpt<std::vector<double> >(SUMO_ATTR_PROBS, id.c_str(), parsedOk);
541 // adjust sizes and probabilities
542 adjustTypesAndProbabilities(vTypes, probabilities);
543 // continue if all was parsed ok
544 if (parsedOk) {
545 // set tag
547 // add all attributes
550 // add references
551 for (int i = 0; i < (int)vTypes.size(); i++) {
552 // open SUMOBaseOBject
554 // set tag
556 // add all attributes
559 // close SUMOBaseOBject
561 }
562 } else {
564 }
565}
566
567
568void
570 // declare Ok Flag
571 bool parsedOk = true;
572 // needed attributes
573 const std::string id = attrs.get<std::string>(SUMO_ATTR_ID, "", parsedOk);
574 const std::vector<std::string> edges = attrs.get<std::vector<std::string> >(SUMO_ATTR_EDGES, id.c_str(), parsedOk);
575 // optional attributes
577 const RGBColor color = attrs.getOpt<RGBColor>(SUMO_ATTR_COLOR, id.c_str(), parsedOk, RGBColor::INVISIBLE);
578 const int repeat = attrs.getOpt<int>(SUMO_ATTR_REPEAT, id.c_str(), parsedOk, 0);
579 const SUMOTime cycleTime = attrs.getOptSUMOTimeReporting(SUMO_ATTR_CYCLETIME, id.c_str(), parsedOk, 0);
580 const double probability = attrs.getOpt<double>(SUMO_ATTR_PROB, id.c_str(), parsedOk, 1.0);
581 // check attributes
582 if (!checkNegative(SUMO_TAG_ROUTE, id, SUMO_ATTR_CYCLETIME, cycleTime, true)) {
583 parsedOk = false;
584 }
585 if (!checkNegative(SUMO_TAG_ROUTE, id, SUMO_ATTR_REPEAT, repeat, true)) {
586 parsedOk = false;
587 }
588 if (parsedOk) {
589 // set tag
591 // add all attributes
599 } else {
601 }
602}
603
604
605void
607 // declare Ok Flag
608 bool parsedOk = true;
609 // special case for ID
610 const std::string refId = attrs.get<std::string>(SUMO_ATTR_REFID, "", parsedOk);
611 const double probability = attrs.getOpt<double>(SUMO_ATTR_PROB, refId.c_str(), parsedOk, INVALID_DOUBLE);
612 if (parsedOk) {
613 // set tag
615 // add all attributes
618 } else {
620 }
621}
622
623
624void
626 // first check if this is an embedded route
627 if (attrs.hasAttribute(SUMO_ATTR_ID)) {
628 writeError(TL("an embedded route cannot have their own ID"));
629 } else {
630 // declare Ok Flag
631 bool parsedOk = true;
632 // special case for ID
634 // needed attributes
635 const std::vector<std::string> edges = attrs.get<std::vector<std::string> >(SUMO_ATTR_EDGES, vehicleID.c_str(), parsedOk);
636 // optional attributes
638 const RGBColor color = attrs.getOpt<RGBColor>(SUMO_ATTR_COLOR, vehicleID.c_str(), parsedOk, RGBColor::INVISIBLE);
639 const int repeat = attrs.getOpt<int>(SUMO_ATTR_REPEAT, vehicleID.c_str(), parsedOk, 0);
640 const SUMOTime cycleTime = attrs.getOptSUMOTimeReporting(SUMO_ATTR_CYCLETIME, vehicleID.c_str(), parsedOk, 0);
641 // check attributes
642 if (!checkNegative(SUMO_TAG_ROUTE, vehicleID, SUMO_ATTR_CYCLETIME, cycleTime, true)) {
643 parsedOk = false;
644 }
645 if (!checkNegative(SUMO_TAG_ROUTE, vehicleID, SUMO_ATTR_REPEAT, repeat, true)) {
646 parsedOk = false;
647 }
648 if (parsedOk) {
649 // set tag
651 // add all attributes
657 } else {
659 }
660 }
661}
662
663
664void
666 // declare Ok Flag
667 bool parsedOk = true;
668 // needed attributes
669 const std::string id = attrs.get<std::string>(SUMO_ATTR_ID, "", parsedOk);
670 // optional attributes
671 std::vector<std::string> routes = attrs.getOpt<std::vector<std::string> >(SUMO_ATTR_ROUTES, id.c_str(), parsedOk);
672 std::vector<double> probabilities = attrs.getOpt<std::vector<double> >(SUMO_ATTR_PROBS, id.c_str(), parsedOk);
673 // adjust sizes and probabilities
674 adjustTypesAndProbabilities(routes, probabilities);
675 // continue if all was parsed ok
676 if (parsedOk) {
677 // set tag
679 // add all attributes
681 // add references
682 for (int i = 0; i < (int)routes.size(); i++) {
683 // open SUMOBaseOBject
685 // set tag
687 // add all attributes
690 // close SUMOBaseOBject
692 }
693 } else {
695 }
696}
697
698
699void
701 // declare Ok Flag
702 bool parsedOk = true;
703 // parse vehicle
705 if (tripParameter) {
706 // check from/to edge/junction
708 writeError(TL("Attributes 'from', 'fromJunction' and 'fromTaz' cannot be defined together"));
711 writeError(TL("Attributes 'to', 'toJunction' and 'toTaz' cannot be defined together"));
714 // from-to attributes
715 const std::string fromJunction = attrs.get<std::string>(SUMO_ATTR_FROM_JUNCTION, tripParameter->id.c_str(), parsedOk);
716 const std::string toJunction = attrs.get<std::string>(SUMO_ATTR_TO_JUNCTION, tripParameter->id.c_str(), parsedOk);
717 if (parsedOk) {
718 // set tag
720 // set vehicle parameters
722 // add other attributes
725 } else {
727 }
728 } else if (attrs.hasAttribute(SUMO_ATTR_FROM_TAZ) && attrs.hasAttribute(SUMO_ATTR_TO_TAZ)) {
729 // from-to attributes
730 const std::string fromJunction = attrs.get<std::string>(SUMO_ATTR_FROM_TAZ, tripParameter->id.c_str(), parsedOk);
731 const std::string toJunction = attrs.get<std::string>(SUMO_ATTR_TO_TAZ, tripParameter->id.c_str(), parsedOk);
732 if (parsedOk) {
733 // set tag
735 // set vehicle parameters
737 // add other attributes
740 } else {
742 }
743 } else {
744 // from-to attributes
745 const std::string from = attrs.getOpt<std::string>(SUMO_ATTR_FROM, tripParameter->id.c_str(), parsedOk, "");
746 const std::string to = attrs.getOpt<std::string>(SUMO_ATTR_TO, tripParameter->id.c_str(), parsedOk, "");
747 // optional attributes
748 const std::vector<std::string> via = attrs.getOpt<std::vector<std::string> >(SUMO_ATTR_VIA, tripParameter->id.c_str(), parsedOk);
749 if (parsedOk) {
750 // set tag
752 // set vehicle parameters
754 // add other attributes
758 } else {
760 }
761 }
762 // delete trip parameter (because in XMLStructure we have a copy)
763 delete tripParameter;
764 } else {
766 }
767}
768
769
770void
772 // first parse vehicle
774 if (vehicleParameter) {
775 // set tag
777 // set vehicle parameters
779 // delete vehicle parameter (because in XMLStructure we have a copy)
780 delete vehicleParameter;
781 } else {
783 }
784}
785
786
787void
789 // declare Ok Flag
790 bool parsedOk = true;
791 // first parse flow
793 if (flowParameter) {
794 // set vehicle parameters
796 // check from/to edge/junction
798 writeError(TL("Attributes 'from', 'fromJunction' and 'fromTaz' cannot be defined together"));
801 writeError(TL("Attributes 'to', 'toJunction' and 'toTaz' cannot be defined together"));
803 } else if (attrs.hasAttribute(SUMO_ATTR_FROM) && attrs.hasAttribute(SUMO_ATTR_TO)) {
804 // from-to attributes
805 const std::string from = attrs.get<std::string>(SUMO_ATTR_FROM, flowParameter->id.c_str(), parsedOk);
806 const std::string to = attrs.get<std::string>(SUMO_ATTR_TO, flowParameter->id.c_str(), parsedOk);
807 // optional attributes
808 const std::vector<std::string> via = attrs.getOpt<std::vector<std::string> >(SUMO_ATTR_VIA, flowParameter->id.c_str(), parsedOk);
809 if (parsedOk) {
810 // set tag
812 // add other attributes
816 } else {
818 }
820 // from-to attributes
821 const std::string fromJunction = attrs.get<std::string>(SUMO_ATTR_FROM_JUNCTION, flowParameter->id.c_str(), parsedOk);
822 const std::string toJunction = attrs.get<std::string>(SUMO_ATTR_TO_JUNCTION, flowParameter->id.c_str(), parsedOk);
823 if (parsedOk) {
824 // set tag
826 // add other attributes
829 } else {
831 }
832 } else if (attrs.hasAttribute(SUMO_ATTR_FROM_TAZ) && attrs.hasAttribute(SUMO_ATTR_TO_TAZ)) {
833 // from-to attributes
834 const std::string fromJunction = attrs.get<std::string>(SUMO_ATTR_FROM_TAZ, flowParameter->id.c_str(), parsedOk);
835 const std::string toJunction = attrs.get<std::string>(SUMO_ATTR_TO_TAZ, flowParameter->id.c_str(), parsedOk);
836 if (parsedOk) {
837 // set tag
839 // add other attributes
842 } else {
844 }
845 } else if (attrs.hasAttribute(SUMO_ATTR_ROUTE)) {
846 // from-to attributes
847 const std::string route = attrs.get<std::string>(SUMO_ATTR_ROUTE, flowParameter->id.c_str(), parsedOk);
848 if (parsedOk) {
849 // set tag
851 // add other attributes
853 } else {
855 }
856 } else {
857 // set tag
859 }
860 // delete flow parameter (because in XMLStructure we have a copy)
861 delete flowParameter;
862 } else {
864 }
865}
866
867
868void
870 // declare Ok Flag
871 bool parsedOk = true;
872 // declare stop
874 // plan parameters
875 const auto planParameters = CommonXMLStructure::PlanParameters(myCommonXMLStructure.getCurrentSumoBaseObject(), attrs, parsedOk);
876 // get parents
877 std::vector<SumoXMLTag> stopParents;
878 stopParents.insert(stopParents.end(), NamespaceIDs::routes.begin(), NamespaceIDs::routes.end());
879 stopParents.insert(stopParents.end(), NamespaceIDs::vehicles.begin(), NamespaceIDs::vehicles.end());
880 stopParents.insert(stopParents.end(), NamespaceIDs::persons.begin(), NamespaceIDs::persons.end());
881 stopParents.insert(stopParents.end(), NamespaceIDs::containers.begin(), NamespaceIDs::containers.end());
882 // check parents
883 checkParsedParent(SUMO_TAG_STOP, stopParents, parsedOk);
884 // parse stop
885 if (parsedOk && parseStopParameters(stop, attrs)) {
886 // set tag
888 // add stop attributes
891 } else {
893 }
894}
895
896
897void
899 // first parse vehicle
901 if (personParameter) {
902 // set tag
904 // set vehicle parameter
906 // delete person parameter (because in XMLStructure we have a copy)
907 delete personParameter;
908 } else {
910 }
911}
912
913
914void
916 // first parse flow
918 if (personFlowParameter) {
919 // set tag
921 // set vehicle parameter
923 // delete person flow parameter (because in XMLStructure we have a copy)
924 delete personFlowParameter;
925 } else {
927 }
928}
929
930
931void
933 // declare Ok Flag
934 bool parsedOk = true;
935 // plan parameters
936 const auto planParameters = CommonXMLStructure::PlanParameters(myCommonXMLStructure.getCurrentSumoBaseObject(), attrs, parsedOk);
937 // optional attributes
938 const std::vector<std::string> via = attrs.getOpt<std::vector<std::string> >(SUMO_ATTR_VIA, "", parsedOk);
939 const std::vector<std::string> vTypes = attrs.getOpt<std::vector<std::string> >(SUMO_ATTR_VTYPES, "", parsedOk);
940 const std::vector<std::string> lines = attrs.getOpt<std::vector<std::string> >(SUMO_ATTR_LINES, "", parsedOk);
941 std::vector<std::string> modes = attrs.getOpt<std::vector<std::string> >(SUMO_ATTR_MODES, "", parsedOk);
942 const double departPos = attrs.getOpt<double>(SUMO_ATTR_DEPARTPOS, "", parsedOk, -1);
943 const double arrivalPos = attrs.getOpt<double>(SUMO_ATTR_ARRIVALPOS, "", parsedOk, -1);
944 const double walkFactor = attrs.getOpt<double>(SUMO_ATTR_WALKFACTOR, "", parsedOk, 0);
945 const std::string group = attrs.getOpt<std::string>(SUMO_ATTR_GROUP, "", parsedOk, "");
946 // check modes
947 SVCPermissions dummyModeSet;
948 std::string dummyError;
949 if (!SUMOVehicleParameter::parsePersonModes(toString(modes), toString(SUMO_TAG_PERSONTRIP), "", dummyModeSet, dummyError)) {
950 WRITE_WARNING(dummyError);
951 modes.clear();
952 }
953 // check parents
955 if (parsedOk) {
956 // set tag
958 // add all attributes
967 } else {
969 }
970}
971
972
973void
976 writeError(TL("Speed and duration attributes cannot be defined together in walks"));
978 } else {
979 // declare Ok Flag
980 bool parsedOk = true;
981 // plan parameters
982 const auto planParameters = CommonXMLStructure::PlanParameters(myCommonXMLStructure.getCurrentSumoBaseObject(), attrs, parsedOk);
983 // optional attributes
984 const double departPos = attrs.getOpt<double>(SUMO_ATTR_DEPARTPOS, "", parsedOk, -1);
985 const double arrivalPos = attrs.getOpt<double>(SUMO_ATTR_ARRIVALPOS, "", parsedOk, -1);
986 const double speed = attrs.getOpt<double>(SUMO_ATTR_SPEED, "", parsedOk, 1.39);
987 const SUMOTime duration = attrs.getOptSUMOTimeReporting(SUMO_ATTR_DURATION, "", parsedOk, 0);
988 // check parents
990 if (parsedOk) {
991 // set tag
993 // add all attributes
999 } else {
1001 }
1002 }
1003}
1004
1005
1006void
1008 // declare Ok Flag
1009 bool parsedOk = true;
1010 // plan parameters
1011 const auto planParameters = CommonXMLStructure::PlanParameters(myCommonXMLStructure.getCurrentSumoBaseObject(), attrs, parsedOk);
1012 // optional attributes
1013 const std::vector<std::string> lines = attrs.getOpt<std::vector<std::string> >(SUMO_ATTR_LINES, "", parsedOk);
1014 const double arrivalPos = attrs.getOpt<double>(SUMO_ATTR_ARRIVALPOS, "", parsedOk, -1);
1015 const std::string group = attrs.getOpt<std::string>(SUMO_ATTR_GROUP, "", parsedOk, "");
1016 // check parents
1018 if (parsedOk) {
1019 // set tag
1021 // add all attributes
1026 } else {
1028 }
1029}
1030
1031
1032void
1034 // first parse container
1036 if (containerParameter) {
1037 // set tag
1039 // set vehicle parameter
1041 // delete container parameter (because in XMLStructure we have a copy)
1042 delete containerParameter;
1043 } else {
1045 }
1046}
1047
1048
1049void
1051 // first parse flow
1053 if (containerFlowParameter) {
1054 // set tag
1056 // set vehicle parameter
1058 // delete container flow parameter (because in XMLStructure we have a copy)
1059 delete containerFlowParameter;
1060 } else {
1062 }
1063}
1064
1065
1066void
1068 // declare Ok Flag
1069 bool parsedOk = true;
1070 // plan parameters
1071 const auto planParameters = CommonXMLStructure::PlanParameters(myCommonXMLStructure.getCurrentSumoBaseObject(), attrs, parsedOk);
1072 // optional attributes
1073 const std::vector<std::string> lines = attrs.getOpt<std::vector<std::string> >(SUMO_ATTR_LINES, "", parsedOk);
1074 const double arrivalPos = attrs.getOpt<double>(SUMO_ATTR_ARRIVALPOS, "", parsedOk, -1);
1075 const std::string group = attrs.getOpt<std::string>(SUMO_ATTR_GROUP, "", parsedOk, "");
1076 // check parents
1078 if (parsedOk) {
1079 // set tag
1081 // add all attributes
1086 } else {
1088 }
1089}
1090
1091
1092void
1095 writeError(TL("Speed and duration attributes cannot be defined together in tranships"));
1097 } else {
1098 // declare Ok Flag
1099 bool parsedOk = true;
1100 // plan parameters
1101 const auto planParameters = CommonXMLStructure::PlanParameters(myCommonXMLStructure.getCurrentSumoBaseObject(), attrs, parsedOk);
1102 // optional attributes
1103 const double arrivalPos = attrs.getOpt<double>(SUMO_ATTR_ARRIVALPOS, "", parsedOk, -1);
1104 const double departPos = attrs.getOpt<double>(SUMO_ATTR_DEPARTPOS, "", parsedOk, -1);
1105 const double speed = attrs.getOpt<double>(SUMO_ATTR_SPEED, "", parsedOk, 1.39);
1106 const SUMOTime duration = attrs.getOptSUMOTimeReporting(SUMO_ATTR_DURATION, "", parsedOk, 0);
1107 // check parents
1109 if (parsedOk) {
1110 // set tag
1112 // add all attributes
1118 } else {
1120 }
1121 }
1122}
1123
1124
1125void
1127 // declare Ok Flag
1128 bool parsedOk = true;
1129 // just parse begin and end default
1130 myFlowBeginDefault = attrs.getSUMOTimeReporting(SUMO_ATTR_BEGIN, nullptr, parsedOk);
1131 myFlowEndDefault = attrs.getSUMOTimeReporting(SUMO_ATTR_END, nullptr, parsedOk);
1132}
1133
1134
1135bool
1137 // write warning info
1138 WRITE_WARNINGF(TL("Defining car-following parameters in a nested element is deprecated in vType '%', use attributes instead!"), vTypeObject->getStringAttribute(SUMO_ATTR_ID));
1139 // get vType to modify it
1140 auto vType = vTypeObject->getVehicleTypeParameter();
1141 // parse nested CFM attributes
1142 if (SUMOVehicleParserHelper::parseCFMParams(&vType, tag, attrs, true)) {
1143 vTypeObject->setVehicleTypeParameter(&vType);
1144 return true;
1145 } else if (myHardFail) {
1146 throw ProcessError(TL("Invalid parsing embedded VType"));
1147 } else {
1148 return writeError(TL("Invalid parsing embedded VType"));
1149 }
1150}
1151
1152
1153bool
1155 // check stop parameters
1156 if (attrs.hasAttribute(SUMO_ATTR_ARRIVAL)) {
1158 }
1159 if (attrs.hasAttribute(SUMO_ATTR_DURATION)) {
1161 }
1162 if (attrs.hasAttribute(SUMO_ATTR_UNTIL)) {
1164 }
1165 if (attrs.hasAttribute(SUMO_ATTR_STARTED)) {
1167 }
1168 if (attrs.hasAttribute(SUMO_ATTR_ENDED)) {
1170 }
1171 if (attrs.hasAttribute(SUMO_ATTR_EXTENSION)) {
1173 }
1174 if (attrs.hasAttribute(SUMO_ATTR_ENDPOS)) {
1176 }
1177 if (attrs.hasAttribute(SUMO_ATTR_STARTPOS)) {
1179 }
1182 }
1183 if (attrs.hasAttribute(SUMO_ATTR_TRIGGERED)) {
1185 }
1186 // legacy attribute
1189 }
1190 if (attrs.hasAttribute(SUMO_ATTR_PARKING)) {
1192 }
1193 if (attrs.hasAttribute(SUMO_ATTR_EXPECTED)) {
1195 }
1196 if (attrs.hasAttribute(SUMO_ATTR_PERMITTED)) {
1198 }
1201 }
1202 if (attrs.hasAttribute(SUMO_ATTR_TRIP_ID)) {
1204 }
1205 if (attrs.hasAttribute(SUMO_ATTR_SPLIT)) {
1207 }
1208 if (attrs.hasAttribute(SUMO_ATTR_JOIN)) {
1210 }
1211 if (attrs.hasAttribute(SUMO_ATTR_LINE)) {
1213 }
1214 if (attrs.hasAttribute(SUMO_ATTR_SPEED)) {
1216 }
1217 if (attrs.hasAttribute(SUMO_ATTR_ONDEMAND)) {
1219 }
1220 if (attrs.hasAttribute(SUMO_ATTR_JUMP)) {
1222 }
1225 }
1226 // get parameters
1227 bool ok = true;
1228 // edge/lane
1229 stop.edge = attrs.getOpt<std::string>(SUMO_ATTR_EDGE, nullptr, ok, "");
1230 stop.lane = attrs.getOpt<std::string>(SUMO_ATTR_LANE, nullptr, ok, stop.busstop);
1231 // check errors
1232 if (!stop.edge.empty() && !stop.lane.empty()) {
1233 return writeError(TL("A stop must be defined either with an edge or with an lane, not both"));
1234 }
1235 // stopping places
1236 stop.busstop = attrs.getOpt<std::string>(SUMO_ATTR_BUS_STOP, nullptr, ok, "");
1237 if (stop.busstop.empty()) {
1238 stop.busstop = attrs.getOpt<std::string>(SUMO_ATTR_TRAIN_STOP, nullptr, ok, stop.busstop);
1239 }
1240 stop.chargingStation = attrs.getOpt<std::string>(SUMO_ATTR_CHARGING_STATION, nullptr, ok, "");
1241 stop.overheadWireSegment = attrs.getOpt<std::string>(SUMO_ATTR_OVERHEAD_WIRE_SEGMENT, nullptr, ok, "");
1242 stop.containerstop = attrs.getOpt<std::string>(SUMO_ATTR_CONTAINER_STOP, nullptr, ok, "");
1243 stop.parkingarea = attrs.getOpt<std::string>(SUMO_ATTR_PARKING_AREA, nullptr, ok, "");
1244 //check stopping places
1245 const int numStoppingPlaces = !stop.busstop.empty() + !stop.chargingStation.empty() + !stop.overheadWireSegment.empty() +
1246 !stop.containerstop.empty() + !stop.parkingarea.empty();
1247 if (numStoppingPlaces > 1) {
1248 return writeError(TL("A stop must be defined only in a StoppingPlace"));
1249 } else if ((numStoppingPlaces == 0) && stop.edge.empty() && stop.lane.empty()) {
1250 return writeError(TL("A stop must be defined in an edge, a lane, or in a StoppingPlace"));
1251 }
1252 // declare error suffix
1253 std::string errorSuffix;
1254 if (stop.busstop != "") {
1255 errorSuffix = " at '" + stop.busstop + "'" + errorSuffix;
1256 } else if (stop.chargingStation != "") {
1257 errorSuffix = " at '" + stop.chargingStation + "'" + errorSuffix;
1258 } else if (stop.overheadWireSegment != "") {
1259 errorSuffix = " at '" + stop.overheadWireSegment + "'" + errorSuffix;
1260 } else if (stop.containerstop != "") {
1261 errorSuffix = " at '" + stop.containerstop + "'" + errorSuffix;
1262 } else if (stop.parkingarea != "") {
1263 errorSuffix = " at '" + stop.parkingarea + "'" + errorSuffix;
1264 } else if (stop.edge != "") {
1265 errorSuffix = " at '" + stop.edge + "'" + errorSuffix;
1266 } else {
1267 errorSuffix = " on lane '" + stop.lane + "'" + errorSuffix;
1268 }
1269 // speed for counting as stopped
1270 stop.speed = attrs.getOpt<double>(SUMO_ATTR_SPEED, nullptr, ok, 0);
1271 if (stop.speed < 0) {
1272 return writeError("Speed cannot be negative for stop" + errorSuffix);
1273 }
1274 // get the standing duration
1275 bool expectTrigger = !attrs.hasAttribute(SUMO_ATTR_DURATION) && !attrs.hasAttribute(SUMO_ATTR_UNTIL) && !attrs.hasAttribute(SUMO_ATTR_SPEED);
1276 std::vector<std::string> triggers = attrs.getOpt<std::vector<std::string> >(SUMO_ATTR_TRIGGERED, nullptr, ok);
1277 // legacy
1278 if (attrs.getOpt<bool>(SUMO_ATTR_CONTAINER_TRIGGERED, nullptr, ok, false)) {
1279 triggers.push_back(toString(SUMO_TAG_CONTAINER));
1280 };
1281 SUMOVehicleParameter::parseStopTriggers(triggers, expectTrigger, stop);
1282 stop.startPos = attrs.getOpt<double>(SUMO_ATTR_STARTPOS, nullptr, ok, 0);
1283 stop.endPos = attrs.getOpt<double>(SUMO_ATTR_ENDPOS, nullptr, ok, 0);
1284 stop.friendlyPos = attrs.getOpt<bool>(SUMO_ATTR_FRIENDLY_POS, nullptr, ok, false);
1285 stop.arrival = attrs.getOptSUMOTimeReporting(SUMO_ATTR_ARRIVAL, nullptr, ok, -1);
1286 stop.duration = attrs.getOptSUMOTimeReporting(SUMO_ATTR_DURATION, nullptr, ok, -1);
1287 stop.until = attrs.getOptSUMOTimeReporting(SUMO_ATTR_UNTIL, nullptr, ok, -1);
1288 if (!expectTrigger && (!ok || (stop.duration < 0 && stop.until < 0 && stop.speed == 0))) {
1289 return writeError("Invalid duration or end time is given for a stop" + errorSuffix);
1290 }
1291 stop.extension = attrs.getOptSUMOTimeReporting(SUMO_ATTR_EXTENSION, nullptr, ok, -1);
1292 const bool defaultParking = (stop.triggered || stop.containerTriggered || stop.parkingarea != "");
1293 stop.parking = attrs.getOpt<ParkingType>(SUMO_ATTR_PARKING, nullptr, ok, defaultParking ? ParkingType::OFFROAD : ParkingType::ONROAD);
1294 if ((stop.parkingarea != "") && (stop.parking == ParkingType::ONROAD)) {
1295 WRITE_WARNING("Stop at parkingarea overrides attribute 'parking' for stop" + errorSuffix);
1297 }
1298 if (!ok) {
1299 return writeError("Invalid bool for 'triggered', 'containerTriggered' or 'parking' for stop" + errorSuffix);
1300 }
1301 // expected persons
1302 const std::vector<std::string>& expected = attrs.getOpt<std::vector<std::string> >(SUMO_ATTR_EXPECTED, nullptr, ok);
1303 stop.awaitedPersons.insert(expected.begin(), expected.end());
1304 if (stop.awaitedPersons.size() > 0 && (stop.parametersSet & STOP_TRIGGER_SET) == 0) {
1305 stop.triggered = true;
1306 if ((stop.parametersSet & STOP_PARKING_SET) == 0) {
1308 }
1309 }
1310 // permitted transportables
1311 const std::vector<std::string>& permitted = attrs.getOpt<std::vector<std::string> >(SUMO_ATTR_PERMITTED, nullptr, ok);
1312 stop.permitted.insert(permitted.begin(), permitted.end());
1313 // expected containers
1314 const std::vector<std::string>& expectedContainers = attrs.getOpt<std::vector<std::string> >(SUMO_ATTR_EXPECTED_CONTAINERS, nullptr, ok);
1315 stop.awaitedContainers.insert(expectedContainers.begin(), expectedContainers.end());
1316 if (stop.awaitedContainers.size() > 0 && (stop.parametersSet & STOP_CONTAINER_TRIGGER_SET) == 0) {
1317 stop.containerTriggered = true;
1318 if ((stop.parametersSet & STOP_PARKING_SET) == 0) {
1320 }
1321 }
1322 // public transport trip id
1323 stop.tripId = attrs.getOpt<std::string>(SUMO_ATTR_TRIP_ID, nullptr, ok, "");
1324 stop.split = attrs.getOpt<std::string>(SUMO_ATTR_SPLIT, nullptr, ok, "");
1325 stop.join = attrs.getOpt<std::string>(SUMO_ATTR_JOIN, nullptr, ok, "");
1326 stop.line = attrs.getOpt<std::string>(SUMO_ATTR_LINE, nullptr, ok, "");
1327 // index
1328 const std::string idx = attrs.getOpt<std::string>(SUMO_ATTR_INDEX, nullptr, ok, "end");
1329 if (idx == "end") {
1330 stop.index = STOP_INDEX_END;
1331 } else if (idx == "fit") {
1332 stop.index = STOP_INDEX_FIT;
1333 } else {
1334 stop.index = attrs.get<int>(SUMO_ATTR_INDEX, nullptr, ok);
1335 if (!ok || stop.index < 0) {
1336 return writeError("Invalid 'index' for stop" + errorSuffix);
1337 }
1338 }
1339 stop.started = attrs.getOptSUMOTimeReporting(SUMO_ATTR_STARTED, nullptr, ok, -1);
1340 stop.ended = attrs.getOptSUMOTimeReporting(SUMO_ATTR_ENDED, nullptr, ok, -1);
1341 stop.posLat = attrs.getOpt<double>(SUMO_ATTR_POSITION_LAT, nullptr, ok, INVALID_DOUBLE);
1342 stop.actType = attrs.getOpt<std::string>(SUMO_ATTR_ACTTYPE, nullptr, ok, "");
1343 stop.onDemand = attrs.getOpt<bool>(SUMO_ATTR_ONDEMAND, nullptr, ok, false);
1344 stop.jump = attrs.getOptSUMOTimeReporting(SUMO_ATTR_JUMP, nullptr, ok, -1);
1345 stop.jumpUntil = attrs.getOptSUMOTimeReporting(SUMO_ATTR_JUMP_UNTIL, nullptr, ok, -1);
1346 return true;
1347}
1348
1349
1350bool
1352 return sumoBaseObject->hasStringAttribute(SUMO_ATTR_FROM) && sumoBaseObject->hasStringAttribute(SUMO_ATTR_TO);
1353}
1354
1355
1356bool
1360
1361
1362bool
1364 return sumoBaseObject->hasStringAttribute(SUMO_ATTR_FROM_TAZ) && sumoBaseObject->hasStringAttribute(SUMO_ATTR_TO_TAZ);
1365}
1366
1367
1368void
1369RouteHandler::adjustTypesAndProbabilities(std::vector<std::string>& vTypes, std::vector<double>& probabilities) {
1370 // add more probabilities
1371 for (size_t i = probabilities.size(); i < vTypes.size(); i++) {
1372 probabilities.push_back(INVALID_DOUBLE);
1373 }
1374 // reduce number of probabilities
1375 while (vTypes.size() < probabilities.size()) {
1376 probabilities.pop_back();
1377 }
1378}
1379
1380/****************************************************************************/
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
The XML-Handler for network loading.
bool checkStopParents(CommonXMLStructure::SumoBaseObject *obj)
check stop parents
CommonXMLStructure::SumoBaseObject * getEmbeddedRoute(const CommonXMLStructure::SumoBaseObject *sumoBaseObject) const
get embedded route from children
void checkParsedParent(const SumoXMLTag currentTag, const std::vector< SumoXMLTag > &parentTags, bool &ok)
check parsed parents
bool checkContainerPlanParents(CommonXMLStructure::SumoBaseObject *obj)
check container plan parents
bool writeError(const std::string &error)
write error and enable error creating element
bool myAbortLoading
abort loading
void parseParameters(const SUMOSAXAttributes &attrs)
parse generic parameters
CommonXMLStructure myCommonXMLStructure
common XML Structure
bool checkVehicleParents(CommonXMLStructure::SumoBaseObject *obj)
check vehicle parents
const std::string myFilename
filename
bool checkNegative(const SumoXMLTag tag, const std::string &id, const SumoXMLAttr attribute, const int value, const bool canBeZero)
check if the given int value is NOT negative
bool checkPersonPlanParents(CommonXMLStructure::SumoBaseObject *obj)
check person plan parents
plan parameters (used for group all from-to parameters related with plans)
void addIntAttribute(const SumoXMLAttr attr, const int value)
add int attribute into current SumoBaseObject node
void setVehicleTypeParameter(const SUMOVTypeParameter *vehicleTypeParameter)
set vehicle type parameters
const SUMOVehicleParameter::Stop & getStopParameter() const
get stop parameters
const RGBColor & getColorAttribute(const SumoXMLAttr attr) const
get color attribute
SUMOTime getTimeAttribute(const SumoXMLAttr attr) const
get time attribute
bool hasStringAttribute(const SumoXMLAttr attr) const
has function
void setTag(const SumoXMLTag tag)
set SumoBaseObject tag
SumoBaseObject * getParentSumoBaseObject() const
get pointer to mySumoBaseObjectParent SumoBaseObject (if is null, then is the root)
const CommonXMLStructure::PlanParameters & getPlanParameters() const
get plan parameteres
const std::map< std::string, std::string > & getParameters() const
get parameters
SUMOVehicleClass getVClass() const
vehicle class
void setPlanParameters(const CommonXMLStructure::PlanParameters &planParameters)
set plan parmeter
const SUMOVTypeParameter & getVehicleTypeParameter() const
get current vType
SumoXMLTag getTag() const
get XML myTag
void markAsCreated()
mark as successfully created
void addTimeAttribute(const SumoXMLAttr attr, const SUMOTime value)
add time attribute into current SumoBaseObject node
void addStringListAttribute(const SumoXMLAttr attr, const std::vector< std::string > &value)
add string list attribute into current SumoBaseObject node
int getIntAttribute(const SumoXMLAttr attr) const
get int attribute
void addDoubleAttribute(const SumoXMLAttr attr, const double value)
add double attribute into current SumoBaseObject node
void setVClass(SUMOVehicleClass vClass)
set vehicle class
void setVehicleParameter(const SUMOVehicleParameter *vehicleParameter)
set vehicle parameters
void addStringAttribute(const SumoXMLAttr attr, const std::string &value)
add string attribute into current SumoBaseObject node
void setStopParameter(const SUMOVehicleParameter::Stop &stopParameter)
add stop parameters
double getDoubleAttribute(const SumoXMLAttr attr) const
get double attribute
const SUMOVehicleParameter & getVehicleParameter() const
get vehicle parameters
const std::vector< std::string > & getStringListAttribute(const SumoXMLAttr attr) const
get string list attribute
void addColorAttribute(const SumoXMLAttr attr, const RGBColor &value)
add color attribute into current SumoBaseObject node
const std::string & getStringAttribute(const SumoXMLAttr attr) const
get string attribute
const std::vector< SumoBaseObject * > & getSumoBaseObjectChildren() const
get SumoBaseObject children
void abortSUMOBaseOBject()
abort SUMOBaseOBject
CommonXMLStructure::SumoBaseObject * getSumoBaseObjectRoot() const
get SumoBaseObject root
CommonXMLStructure::SumoBaseObject * getCurrentSumoBaseObject() const
get current editedSumoBaseObject
void openSUMOBaseOBject()
open SUMOBaseOBject
void closeSUMOBaseOBject()
close SUMOBaseOBject
static const std::vector< SumoXMLTag > vehicles
vehicles namespace
static const std::vector< SumoXMLTag > routes
route namespace
static const std::vector< SumoXMLTag > persons
persons namespace
static const std::vector< SumoXMLTag > containers
containers namespace
A storage for options typed value containers)
Definition OptionsCont.h:89
static const RGBColor INVISIBLE
Definition RGBColor.h:198
void parseWalk(const SUMOSAXAttributes &attrs)
parse walk
virtual bool buildTranship(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const CommonXMLStructure::PlanParameters &planParameters, const double arrivalPosition, const double departPosition, const double speed, const SUMOTime duration)=0
build tranship
void parseContainerFlow(const SUMOSAXAttributes &attrs)
parse container flow
void parseFlow(const SUMOSAXAttributes &attrs)
parse flow (including flows, flows over routes and flows with embedded routes)
virtual bool buildRouteRef(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const std::string &routeID, const double probability)=0
build route ref
bool parseNestedCFM(const SumoXMLTag tag, const SUMOSAXAttributes &attrs, CommonXMLStructure::SumoBaseObject *vTypeObject)
parse nested CarFollowingModel
bool isOverFromToJunctions(const CommonXMLStructure::SumoBaseObject *sumoBaseObject) const
check if element is defined over from-to junctions
bool beginParseAttributes(SumoXMLTag tag, const SUMOSAXAttributes &attrs)
begin parse attributes
virtual bool buildFlow(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const SUMOVehicleParameter &vehicleParameters, const std::string &fromEdgeID, const std::string &toEdgeID)=0
build flow (from-to edges)
void parsePerson(const SUMOSAXAttributes &attrs)
parse person
void parseTransport(const SUMOSAXAttributes &attrs)
parse transport
void parseRouteRef(const SUMOSAXAttributes &attrs)
parse route reference
void 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.