Eclipse SUMO - Simulation of Urban MObility
RouteHandler.cpp
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3 // Copyright (C) 2001-2024 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials are made available under the
5 // terms of the Eclipse Public License 2.0 which is available at
6 // https://www.eclipse.org/legal/epl-2.0/
7 // This Source Code may also be made available under the following Secondary
8 // Licenses when the conditions for such availability set forth in the Eclipse
9 // Public License 2.0 are satisfied: GNU General Public License, version 2
10 // or later which is available at
11 // https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12 // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13 /****************************************************************************/
18 // The XML-Handler for route elements loading
19 /****************************************************************************/
20 #include <config.h>
21 
23 #include <utils/common/RGBColor.h>
26 #include <utils/shapes/Shape.h>
29 #include <utils/xml/XMLSubSys.h>
30 #include <utils/xml/NamespaceIDs.h>
31 
32 #include "RouteHandler.h"
33 
34 
35 // ===========================================================================
36 // method definitions
37 // ===========================================================================
38 
39 RouteHandler::RouteHandler(const std::string& filename, const bool hardFail) :
40  myFilename(filename),
41  myHardFail(hardFail),
42  myFlowBeginDefault(string2time(OptionsCont::getOptions().getString("begin"))),
43  myFlowEndDefault(string2time(OptionsCont::getOptions().getString("end"))) {
44 }
45 
46 
48 
49 
50 bool
52  // open SUMOBaseOBject
54  // check tag
55  try {
56  switch (tag) {
57  // vTypes
58  case SUMO_TAG_VTYPE:
59  parseVType(attrs);
60  break;
63  break;
64  // routes
65  case SUMO_TAG_ROUTE:
66  parseRoute(attrs);
67  break;
70  break;
71  // vehicles
72  case SUMO_TAG_TRIP:
73  parseTrip(attrs);
74  break;
75  case SUMO_TAG_VEHICLE:
76  parseVehicle(attrs);
77  break;
78  // flows
79  case SUMO_TAG_FLOW:
80  parseFlow(attrs);
81  break;
82  // stop
83  case SUMO_TAG_STOP:
84  parseStop(attrs);
85  break;
86  // persons
87  case SUMO_TAG_PERSON:
88  parsePerson(attrs);
89  break;
91  parsePersonFlow(attrs);
92  break;
93  // person plans
95  parsePersonTrip(attrs);
96  break;
97  case SUMO_TAG_RIDE:
98  parseRide(attrs);
99  break;
100  case SUMO_TAG_WALK:
101  parseWalk(attrs);
102  break;
103  // container
104  case SUMO_TAG_CONTAINER:
105  parseContainer(attrs);
106  break;
108  parseContainerFlow(attrs);
109  break;
110  // container plans
111  case SUMO_TAG_TRANSPORT:
112  parseTransport(attrs);
113  break;
114  case SUMO_TAG_TRANSHIP:
115  parseTranship(attrs);
116  break;
117  // parameters
118  case SUMO_TAG_PARAM:
119  parseParameters(attrs);
120  break;
121  // other
122  case SUMO_TAG_INTERVAL: {
123  parseInterval(attrs);
124  break;
125  }
126  default:
127  // nested CFM attributes
128  return parseNestedCFM(tag, attrs);
129  }
130  } catch (InvalidArgument& e) {
131  WRITE_ERROR(e.what());
132  }
133  return true;
134 }
135 
136 
137 void
139  // get last inserted object
141  // close SUMOBaseOBject
143  // check tag
144  if (obj) {
145  switch (obj->getTag()) {
146  // specia case for route (because can be embedded)
147  case SUMO_TAG_ROUTE:
148  // only parse non-embedded and without distributionsroutes
149  if ((obj->getStringAttribute(SUMO_ATTR_ID).size() > 0) &&
150  obj->getParentSumoBaseObject() &&
152  // parse route and all their childrens
153  parseSumoBaseObject(obj);
154  // delete object (and all of their childrens)
155  delete obj;
156  }
157  break;
158  // demand elements
159  case SUMO_TAG_VTYPE:
160  // only parse vTypes without distributions
161  if (obj->getParentSumoBaseObject() &&
163  // parse vType and all their childrens
164  parseSumoBaseObject(obj);
165  // delete object (and all of their childrens)
166  delete obj;
167  }
168  break;
171  case SUMO_TAG_TRIP:
172  case SUMO_TAG_VEHICLE:
173  case SUMO_TAG_FLOW:
174  case SUMO_TAG_PERSON:
175  case SUMO_TAG_PERSONFLOW:
176  case SUMO_TAG_CONTAINER:
178  // parse object and all their childrens
179  parseSumoBaseObject(obj);
180  // delete object (and all of their childrens)
181  delete obj;
182  break;
183  default:
184  break;
185  }
186  }
187 }
188 
189 
190 void
192  // switch tag
193  switch (obj->getTag()) {
194  // vTypes
195  case SUMO_TAG_VTYPE:
196  buildVType(obj,
197  obj->getVehicleTypeParameter());
198  break;
205  break;
206  // route
207  case SUMO_TAG_ROUTE:
208  if (obj->getStringAttribute(SUMO_ATTR_ID).empty()) {
209  buildEmbeddedRoute(obj,
214  obj->getParameters());
215  } else {
216  buildRoute(obj,
218  obj->getVClass(),
224  obj->getParameters());
225  }
226  break;
232  break;
233  // vehicles
234  case SUMO_TAG_TRIP:
237  // build trip with from-to edges
238  buildTrip(obj,
239  obj->getVehicleParameter(),
242  } else if (obj->hasStringAttribute(SUMO_ATTR_FROM_JUNCTION) &&
244  // build trip with from-to junctions
245  buildTripJunctions(obj,
246  obj->getVehicleParameter(),
249  } else if (obj->hasStringAttribute(SUMO_ATTR_FROM_TAZ) &&
251  // build trip with from-to TAZs
252  buildTripTAZs(obj,
253  obj->getVehicleParameter(),
256  } else {
257  throw ProcessError("Invalid from-to values in trips");
258  }
259  break;
260  case SUMO_TAG_VEHICLE:
263  obj->getVehicleParameter());
264  }
265  break;
266  // flows
267  case SUMO_TAG_FLOW:
269  // build flow over route
270  buildFlowOverRoute(obj,
271  obj->getVehicleParameter());
272  } else if (obj->hasStringAttribute(SUMO_ATTR_FROM) &&
274  // build flow with from-to edges
275  buildFlow(obj,
276  obj->getVehicleParameter(),
279  } else if (obj->hasStringAttribute(SUMO_ATTR_FROM_JUNCTION) &&
281  // build flow with from-to junctions
282  buildFlowJunctions(obj,
283  obj->getVehicleParameter(),
286  } else if (obj->hasStringAttribute(SUMO_ATTR_FROM_TAZ) &&
288  // build flow with from-to TAZs
289  buildFlowTAZs(obj,
290  obj->getVehicleParameter(),
293  }
294  break;
295  // persons
296  case SUMO_TAG_PERSON:
297  buildPerson(obj,
298  obj->getVehicleParameter());
299  break;
300  case SUMO_TAG_PERSONFLOW:
301  buildPersonFlow(obj,
302  obj->getVehicleParameter());
303  break;
304  // person plans
305  case SUMO_TAG_PERSONTRIP:
306  buildPersonTrip(obj,
307  obj->getPlanParameters(),
314  break;
315  case SUMO_TAG_RIDE:
316  buildRide(obj,
317  obj->getPlanParameters(),
321  break;
322  case SUMO_TAG_WALK:
323  buildWalk(obj,
324  obj->getPlanParameters(),
328  break;
329  // container
330  case SUMO_TAG_CONTAINER:
331  buildContainer(obj,
332  obj->getVehicleParameter());
333  break;
335  buildContainerFlow(obj,
336  obj->getVehicleParameter());
337  break;
338  // container plans
339  case SUMO_TAG_TRANSPORT:
340  buildTransport(obj,
341  obj->getPlanParameters(),
345  break;
346  case SUMO_TAG_TRANSHIP:
347  buildTranship(obj,
348  obj->getPlanParameters(),
353  break;
354  // stopss
355  case SUMO_TAG_STOP:
356  buildStop(obj,
357  obj->getPlanParameters(),
358  obj->getStopParameter());
359  break;
360  default:
361  break;
362  }
363  // now iterate over childrens
364  for (const auto& child : obj->getSumoBaseObjectChildren()) {
365  // call this function recursively
366  parseSumoBaseObject(child);
367  }
368 }
369 
370 
371 bool
373  return myErrorCreatingElement;
374 }
375 
376 
377 void
378 RouteHandler::writeError(const std::string& error) {
379  WRITE_ERROR(error);
380  myErrorCreatingElement = true;
381 }
382 
383 
384 void
385 RouteHandler::writeErrorInvalidID(const SumoXMLTag tag, const std::string& id) {
386  WRITE_ERRORF(TL("Could not build % with ID '%' in netedit; ID contains invalid characters."), toString(tag), id);
387  myErrorCreatingElement = true;
388 }
389 
390 
391 void
392 RouteHandler::writeErrorInvalidDistribution(const SumoXMLTag tag, const std::string& id) {
393  WRITE_ERRORF(TL("Could not build % with ID '%' in netedit; Distinct number of distribution values and probabilities."), toString(tag), id);
394  myErrorCreatingElement = true;
395 }
396 
397 
398 void
400  // parse vehicleType
402  if (vehicleTypeParameter) {
403  // set tag
405  // add all attributes
407  // delete vehicleType parameter (because in XMLStructure we have a copy)
408  delete vehicleTypeParameter;
409  }
410 }
411 
412 
413 void
415  // declare Ok Flag
416  bool parsedOk = true;
417  // needed attributes
418  const std::string id = attrs.get<std::string>(SUMO_ATTR_ID, "", parsedOk);
419  // optional attributes
420  const int deterministic = attrs.getOpt<int>(SUMO_ATTR_DETERMINISTIC, id.c_str(), parsedOk, -1);
421  const std::vector<std::string> vTypes = attrs.getOpt<std::vector<std::string> >(SUMO_ATTR_VTYPES, id.c_str(), parsedOk);
422  const std::vector<double> probabilities = attrs.getOpt<std::vector<double> >(SUMO_ATTR_PROBS, id.c_str(), parsedOk);
423  if (parsedOk) {
426  } else if (vTypes.size() != probabilities.size()) {
428  } else {
429  // set tag
431  // add all attributes
436  }
437  }
438 }
439 
440 
441 void
443  // get embedded route flag
444  const bool embeddedRoute = isEmbeddedRoute(attrs);
445  // first check if this is an embedded route
446  if ((embeddedRoute && attrs.hasAttribute(SUMO_ATTR_ID)) || (!embeddedRoute && !attrs.hasAttribute(SUMO_ATTR_ID))) {
447  writeError(TL("a route must be defined either within a vehicle/flow or with an ID attribute"));
448  } else {
449  // declare Ok Flag
450  bool parsedOk = true;
451  // special case for ID
452  const std::string id = attrs.getOpt<std::string>(SUMO_ATTR_ID, "", parsedOk, "");
453  // needed attributes
454  const std::vector<std::string> edges = attrs.get<std::vector<std::string> >(SUMO_ATTR_EDGES, id.c_str(), parsedOk);
455  // optional attributes
457  const RGBColor color = attrs.getOpt<RGBColor>(SUMO_ATTR_COLOR, id.c_str(), parsedOk, RGBColor::INVISIBLE);
458  const int repeat = attrs.getOpt<int>(SUMO_ATTR_REPEAT, id.c_str(), parsedOk, 0);
459  const SUMOTime cycleTime = attrs.getOptSUMOTimeReporting(SUMO_ATTR_CYCLETIME, id.c_str(), parsedOk, 0);
460  const double probability = attrs.getOpt<double>(SUMO_ATTR_PROB, id.c_str(), parsedOk, 0);
461  if (parsedOk) {
462  if (!id.empty() && !SUMOXMLDefinitions::isValidVehicleID(id)) {
464  } else if (cycleTime < 0) {
465  writeError(TLF("cycleTime of % must be equal or greater than 0", toString(SUMO_TAG_DEST_PROB_REROUTE)));
466  } else {
467  // set tag
469  // add all attributes
477  }
478  }
479  }
480 }
481 
482 
483 void
485  // declare Ok Flag
486  bool parsedOk = true;
487  // needed attributes
488  const std::string id = attrs.get<std::string>(SUMO_ATTR_ID, "", parsedOk);
489  // optional attributes
490  const std::vector<std::string> routes = attrs.getOpt<std::vector<std::string> >(SUMO_ATTR_ROUTES, id.c_str(), parsedOk);
491  const std::vector<double> probabilities = attrs.getOpt<std::vector<double> >(SUMO_ATTR_PROBS, id.c_str(), parsedOk);
492  if (parsedOk) {
495  } else if (routes.size() != probabilities.size()) {
497  } else {
498  // set tag
500  // add all attributes
504  }
505  }
506 }
507 
508 
509 void
511  // declare Ok Flag
512  bool parsedOk = true;
513  // parse vehicle
515  if (tripParameter) {
516  // check from/to edge/junction
518  writeError(TL("Attributes 'from', 'fromJunction' and 'fromTaz' cannot be defined together"));
519  } else if ((attrs.hasAttribute(SUMO_ATTR_TO) + attrs.hasAttribute(SUMO_ATTR_TO_JUNCTION) + attrs.hasAttribute(SUMO_ATTR_TO_TAZ)) > 1) {
520  writeError(TL("Attributes 'to', 'toJunction' and 'toTaz' cannot be defined together"));
521  } else if (attrs.hasAttribute(SUMO_ATTR_FROM) && attrs.hasAttribute(SUMO_ATTR_TO)) {
522  // from-to attributes
523  const std::string from = attrs.getOpt<std::string>(SUMO_ATTR_FROM, tripParameter->id.c_str(), parsedOk, "");
524  const std::string to = attrs.getOpt<std::string>(SUMO_ATTR_TO, tripParameter->id.c_str(), parsedOk, "");
525  // optional attributes
526  const std::vector<std::string> via = attrs.getOpt<std::vector<std::string> >(SUMO_ATTR_VIA, tripParameter->id.c_str(), parsedOk);
527  if (parsedOk) {
528  // set tag
530  // set vehicle parameters
532  // add other attributes
536  }
538  // from-to attributes
539  const std::string fromJunction = attrs.getOpt<std::string>(SUMO_ATTR_FROM_JUNCTION, tripParameter->id.c_str(), parsedOk, "");
540  const std::string toJunction = attrs.getOpt<std::string>(SUMO_ATTR_TO_JUNCTION, tripParameter->id.c_str(), parsedOk, "");
541  if (parsedOk) {
542  // set tag
544  // set vehicle parameters
546  // add other attributes
549  }
550  } else if (attrs.hasAttribute(SUMO_ATTR_FROM_TAZ) && attrs.hasAttribute(SUMO_ATTR_TO_TAZ)) {
551  // from-to attributes
552  const std::string fromJunction = attrs.getOpt<std::string>(SUMO_ATTR_FROM_TAZ, tripParameter->id.c_str(), parsedOk, "");
553  const std::string toJunction = attrs.getOpt<std::string>(SUMO_ATTR_TO_TAZ, tripParameter->id.c_str(), parsedOk, "");
554  if (parsedOk) {
555  // set tag
557  // set vehicle parameters
559  // add other attributes
562  }
563  } else {
564  writeError(TL("trip definition needs either 'from/to' or 'fromJunction/toJunction' or 'fromTaz/toTaz'"));
565  }
566  // delete trip parameter (because in XMLStructure we have a copy)
567  delete tripParameter;
568  }
569 }
570 
571 
572 void
574  // first parse vehicle
576  if (vehicleParameter) {
577  // set tag
579  // set vehicle parameters
581  // delete vehicle parameter (because in XMLStructure we have a copy)
582  delete vehicleParameter;
583  }
584 }
585 
586 
587 void
589  // declare Ok Flag
590  bool parsedOk = true;
591  // first parse flow
593  if (flowParameter) {
594  // set vehicle parameters
596  // check from/to edge/junction
598  writeError(TL("Attributes 'from', 'fromJunction' and 'fromTaz' cannot be defined together"));
599  } else if ((attrs.hasAttribute(SUMO_ATTR_TO) + attrs.hasAttribute(SUMO_ATTR_TO_JUNCTION) + attrs.hasAttribute(SUMO_ATTR_TO_TAZ)) > 1) {
600  writeError(TL("Attributes 'to', 'toJunction' and 'toTaz' cannot be defined together"));
601  } else if (attrs.hasAttribute(SUMO_ATTR_FROM) && attrs.hasAttribute(SUMO_ATTR_TO)) {
602  // from-to attributes
603  const std::string from = attrs.get<std::string>(SUMO_ATTR_FROM, flowParameter->id.c_str(), parsedOk);
604  const std::string to = attrs.get<std::string>(SUMO_ATTR_TO, flowParameter->id.c_str(), parsedOk);
605  // optional attributes
606  const std::vector<std::string> via = attrs.getOpt<std::vector<std::string> >(SUMO_ATTR_VIA, flowParameter->id.c_str(), parsedOk);
607  if (parsedOk) {
608  // set tag
610  // add other attributes
614  }
616  // from-to attributes
617  const std::string fromJunction = attrs.get<std::string>(SUMO_ATTR_FROM_JUNCTION, flowParameter->id.c_str(), parsedOk);
618  const std::string toJunction = attrs.get<std::string>(SUMO_ATTR_TO_JUNCTION, flowParameter->id.c_str(), parsedOk);
619  if (parsedOk) {
620  // set tag
622  // add other attributes
625  }
626  } else if (attrs.hasAttribute(SUMO_ATTR_FROM_TAZ) && attrs.hasAttribute(SUMO_ATTR_TO_TAZ)) {
627  // from-to attributes
628  const std::string fromJunction = attrs.get<std::string>(SUMO_ATTR_FROM_TAZ, flowParameter->id.c_str(), parsedOk);
629  const std::string toJunction = attrs.get<std::string>(SUMO_ATTR_TO_TAZ, flowParameter->id.c_str(), parsedOk);
630  if (parsedOk) {
631  // set tag
633  // add other attributes
636  }
637  } else if (attrs.hasAttribute(SUMO_ATTR_ROUTE)) {
638  // from-to attributes
639  const std::string route = attrs.get<std::string>(SUMO_ATTR_ROUTE, flowParameter->id.c_str(), parsedOk);
640  if (parsedOk) {
641  // set tag
643  // add other attributes
645  }
646  } else {
647  // set tag
649  }
650  // delete flow parameter (because in XMLStructure we have a copy)
651  delete flowParameter;
652  }
653 }
654 
655 
656 void
658  // declare Ok Flag
659  bool parsedOk = true;
660  // declare stop
662  // plan parameters
663  const auto planParameters = CommonXMLStructure::PlanParameters(myCommonXMLStructure.getCurrentSumoBaseObject(), attrs, parsedOk);
664  // get parents
665  std::vector<SumoXMLTag> stopParents;
666  stopParents.insert(stopParents.end(), NamespaceIDs::vehicles.begin(), NamespaceIDs::vehicles.end());
667  stopParents.insert(stopParents.end(), NamespaceIDs::routes.begin(), NamespaceIDs::routes.end());
668  stopParents.insert(stopParents.end(), NamespaceIDs::persons.begin(), NamespaceIDs::persons.end());
669  stopParents.insert(stopParents.end(), NamespaceIDs::containers.begin(), NamespaceIDs::containers.end());
670  // check parents
671  checkParent(SUMO_TAG_STOP, stopParents, parsedOk);
672  // parse stop
673  if (parsedOk && parseStopParameters(stop, attrs)) {
674  // set tag
676  // add stop attributes
679  }
680 }
681 
682 
683 void
685  // first parse vehicle
687  if (personParameter) {
688  // set tag
690  // set vehicle parameter
692  // delete person parameter (because in XMLStructure we have a copy)
693  delete personParameter;
694  }
695 }
696 
697 
698 void
700  // first parse flow
702  if (personFlowParameter) {
703  // set tag
705  // set vehicle parameter
707  // delete person flow parameter (because in XMLStructure we have a copy)
708  delete personFlowParameter;
709  }
710 }
711 
712 
713 void
715  // declare Ok Flag
716  bool parsedOk = true;
717  // plan parameters
718  const auto planParameters = CommonXMLStructure::PlanParameters(myCommonXMLStructure.getCurrentSumoBaseObject(), attrs, parsedOk);
719  // optional attributes
720  const std::vector<std::string> via = attrs.getOpt<std::vector<std::string> >(SUMO_ATTR_VIA, "", parsedOk);
721  const std::vector<std::string> vTypes = attrs.getOpt<std::vector<std::string> >(SUMO_ATTR_VTYPES, "", parsedOk);
722  const std::vector<std::string> lines = attrs.getOpt<std::vector<std::string> >(SUMO_ATTR_LINES, "", parsedOk);
723  std::vector<std::string> modes = attrs.getOpt<std::vector<std::string> >(SUMO_ATTR_MODES, "", parsedOk);
724  const double departPos = attrs.getOpt<double>(SUMO_ATTR_DEPARTPOS, "", parsedOk, -1);
725  const double arrivalPos = attrs.getOpt<double>(SUMO_ATTR_ARRIVALPOS, "", parsedOk, -1);
726  const double walkFactor = attrs.getOpt<double>(SUMO_ATTR_WALKFACTOR, "", parsedOk, 0);
727  const std::string group = attrs.getOpt<std::string>(SUMO_ATTR_GROUP, "", parsedOk, "");
728  // check modes
729  SVCPermissions dummyModeSet;
730  std::string dummyError;
731  if (!SUMOVehicleParameter::parsePersonModes(toString(modes), toString(SUMO_TAG_PERSONTRIP), "", dummyModeSet, dummyError)) {
732  WRITE_WARNING(dummyError);
733  modes.clear();
734  }
735  if (parsedOk) {
736  // set tag
738  // add all attributes
747  }
748 }
749 
750 
751 void
754  WRITE_ERROR(TL("Speed and duration attributes cannot be defined together in walks"));
755  } else {
756  // declare Ok Flag
757  bool parsedOk = true;
758  // plan parameters
759  const auto planParameters = CommonXMLStructure::PlanParameters(myCommonXMLStructure.getCurrentSumoBaseObject(), attrs, parsedOk);
760  // optional attributes
761  const double departPos = attrs.getOpt<double>(SUMO_ATTR_DEPARTPOS, "", parsedOk, -1);
762  const double arrivalPos = attrs.getOpt<double>(SUMO_ATTR_ARRIVALPOS, "", parsedOk, -1);
763  const double speed = attrs.getOpt<double>(SUMO_ATTR_SPEED, "", parsedOk, 1.39);
764  const SUMOTime duration = attrs.getOptSUMOTimeReporting(SUMO_ATTR_DURATION, "", parsedOk, 0);
765  if (parsedOk) {
766  // set tag
768  // add all attributes
774  }
775  }
776 }
777 
778 
779 void
781  // declare Ok Flag
782  bool parsedOk = true;
783  // plan parameters
784  const auto planParameters = CommonXMLStructure::PlanParameters(myCommonXMLStructure.getCurrentSumoBaseObject(), attrs, parsedOk);
785  // optional attributes
786  const std::vector<std::string> lines = attrs.getOpt<std::vector<std::string> >(SUMO_ATTR_LINES, "", parsedOk);
787  const double arrivalPos = attrs.getOpt<double>(SUMO_ATTR_ARRIVALPOS, "", parsedOk, -1);
788  const std::string group = attrs.getOpt<std::string>(SUMO_ATTR_GROUP, "", parsedOk, "");
789  if (parsedOk) {
790  // set tag
792  // add all attributes
797  }
798 }
799 
800 
801 void
803  // first parse container
805  if (containerParameter) {
806  // set tag
808  // set vehicle parameter
810  // delete container parameter (because in XMLStructure we have a copy)
811  delete containerParameter;
812  }
813 }
814 
815 
816 void
818  // first parse flow
820  if (containerFlowParameter) {
821  // set tag
823  // set vehicle parameter
825  // delete container flow parameter (because in XMLStructure we have a copy)
826  delete containerFlowParameter;
827  }
828 }
829 
830 
831 void
833  // declare Ok Flag
834  bool parsedOk = true;
835  // plan parameters
836  const auto planParameters = CommonXMLStructure::PlanParameters(myCommonXMLStructure.getCurrentSumoBaseObject(), attrs, parsedOk);
837  // optional attributes
838  const std::vector<std::string> lines = attrs.getOpt<std::vector<std::string> >(SUMO_ATTR_LINES, "", parsedOk);
839  const double arrivalPos = attrs.getOpt<double>(SUMO_ATTR_ARRIVALPOS, "", parsedOk, -1);
840  const std::string group = attrs.getOpt<std::string>(SUMO_ATTR_GROUP, "", parsedOk, "");
841  if (parsedOk) {
842  // set tag
844  // add all attributes
849  }
850 }
851 
852 
853 void
856  WRITE_ERROR(TL("Speed and duration attributes cannot be defined together in walks"));
857  } else {
858  // declare Ok Flag
859  bool parsedOk = true;
860  // plan parameters
861  const auto planParameters = CommonXMLStructure::PlanParameters(myCommonXMLStructure.getCurrentSumoBaseObject(), attrs, parsedOk);
862  // optional attributes
863  const double arrivalPos = attrs.getOpt<double>(SUMO_ATTR_ARRIVALPOS, "", parsedOk, -1);
864  const double departPos = attrs.getOpt<double>(SUMO_ATTR_DEPARTPOS, "", parsedOk, -1);
865  const double speed = attrs.getOpt<double>(SUMO_ATTR_SPEED, "", parsedOk, 1.39);
866  const SUMOTime duration = attrs.getOptSUMOTimeReporting(SUMO_ATTR_DURATION, "", parsedOk, 0);
867  if (parsedOk) {
868  // set tag
870  // add all attributes
876  }
877  }
878 }
879 
880 
881 void
883  // declare Ok Flag
884  bool parsedOk = true;
885  // just parse begin and end default
886  myFlowBeginDefault = attrs.getSUMOTimeReporting(SUMO_ATTR_BEGIN, nullptr, parsedOk);
887  myFlowEndDefault = attrs.getSUMOTimeReporting(SUMO_ATTR_END, nullptr, parsedOk);
888 }
889 
890 
891 void
893  // declare Ok Flag
894  bool parsedOk = true;
895  // get key
896  const std::string key = attrs.get<std::string>(SUMO_ATTR_KEY, nullptr, parsedOk);
897  // get SumoBaseObject parent
899  // check parent
900  if (SumoBaseObjectParent == nullptr) {
901  writeError(TL("Parameters must be defined within an object"));
902  } else if (SumoBaseObjectParent->getTag() == SUMO_TAG_ROOTFILE) {
903  writeError(TL("Parameters cannot be defined in the additional file's root."));
904  } else if (SumoBaseObjectParent->getTag() == SUMO_TAG_PARAM) {
905  writeError(TL("Parameters cannot be defined within another parameter."));
906  } else if (parsedOk) {
907  // get tag str
908  const std::string parentTagStr = toString(SumoBaseObjectParent->getTag());
909  // circumventing empty string value
910  const std::string value = attrs.hasAttribute(SUMO_ATTR_VALUE) ? attrs.getString(SUMO_ATTR_VALUE) : "";
911  // show warnings if values are invalid
912  if (key.empty()) {
913  WRITE_WARNINGF(TL("Error parsing key from % generic parameter. Key cannot be empty"), parentTagStr);
914  } else if (!SUMOXMLDefinitions::isValidParameterKey(key)) {
915  WRITE_WARNINGF(TL("Error parsing key from % generic parameter. Key contains invalid characters"), parentTagStr);
916  } else {
917  WRITE_DEBUG("Inserting generic parameter '" + key + "|" + value + "' into " + parentTagStr);
918  // insert parameter in SumoBaseObjectParent
919  SumoBaseObjectParent->addParameter(key, value);
920  }
921  }
922 }
923 
924 
925 bool
927  // get vehicle type Base object
929  // parse embedded car following model information
930  if (vTypeObject && (vTypeObject->getTag() == SUMO_TAG_VTYPE)) {
931  WRITE_WARNINGF(TL("Defining car-following parameters in a nested element is deprecated in vType '%', use attributes instead!"), vTypeObject->getStringAttribute(SUMO_ATTR_ID));
932  // get vType to modify it
933  auto vType = vTypeObject->getVehicleTypeParameter();
934  // parse nested CFM attributes
935  if (SUMOVehicleParserHelper::parseCFMParams(&vType, tag, attrs, true)) {
936  vTypeObject->setVehicleTypeParameter(&vType);
937  return true;
938  } else if (myHardFail) {
939  throw ProcessError(TL("Invalid parsing embedded VType"));
940  } else {
941  writeError(TL("Invalid parsing embedded VType"));
942  }
943  }
944  return false;
945 }
946 
947 
948 bool
950  // check stop parameters
951  if (attrs.hasAttribute(SUMO_ATTR_ARRIVAL)) {
953  }
954  if (attrs.hasAttribute(SUMO_ATTR_DURATION)) {
956  }
957  if (attrs.hasAttribute(SUMO_ATTR_UNTIL)) {
959  }
960  if (attrs.hasAttribute(SUMO_ATTR_STARTED)) {
962  }
963  if (attrs.hasAttribute(SUMO_ATTR_ENDED)) {
965  }
966  if (attrs.hasAttribute(SUMO_ATTR_EXTENSION)) {
968  }
969  if (attrs.hasAttribute(SUMO_ATTR_ENDPOS)) {
970  stop.parametersSet |= STOP_END_SET;
971  }
972  if (attrs.hasAttribute(SUMO_ATTR_STARTPOS)) {
974  }
977  }
978  if (attrs.hasAttribute(SUMO_ATTR_TRIGGERED)) {
980  }
981  // legacy attribute
984  }
985  if (attrs.hasAttribute(SUMO_ATTR_PARKING)) {
987  }
988  if (attrs.hasAttribute(SUMO_ATTR_EXPECTED)) {
990  }
991  if (attrs.hasAttribute(SUMO_ATTR_PERMITTED)) {
993  }
996  }
997  if (attrs.hasAttribute(SUMO_ATTR_TRIP_ID)) {
999  }
1000  if (attrs.hasAttribute(SUMO_ATTR_SPLIT)) {
1001  stop.parametersSet |= STOP_SPLIT_SET;
1002  }
1003  if (attrs.hasAttribute(SUMO_ATTR_JOIN)) {
1004  stop.parametersSet |= STOP_JOIN_SET;
1005  }
1006  if (attrs.hasAttribute(SUMO_ATTR_LINE)) {
1007  stop.parametersSet |= STOP_LINE_SET;
1008  }
1009  if (attrs.hasAttribute(SUMO_ATTR_SPEED)) {
1010  stop.parametersSet |= STOP_SPEED_SET;
1011  }
1012  if (attrs.hasAttribute(SUMO_ATTR_ONDEMAND)) {
1014  }
1015  if (attrs.hasAttribute(SUMO_ATTR_JUMP)) {
1016  stop.parametersSet |= STOP_JUMP_SET;
1017  }
1018  // get parameters
1019  bool ok = true;
1020  // edge/lane
1021  stop.edge = attrs.getOpt<std::string>(SUMO_ATTR_EDGE, nullptr, ok, "");
1022  stop.lane = attrs.getOpt<std::string>(SUMO_ATTR_LANE, nullptr, ok, stop.busstop);
1023  // check errors
1024  if (!stop.edge.empty() && !stop.lane.empty()) {
1025  writeError(TL("A stop must be defined either with an edge or with an lane, not both"));
1026  return false;
1027  }
1028  // stopping places
1029  stop.busstop = attrs.getOpt<std::string>(SUMO_ATTR_BUS_STOP, nullptr, ok, "");
1030  if (stop.busstop.empty()) {
1031  stop.busstop = attrs.getOpt<std::string>(SUMO_ATTR_TRAIN_STOP, nullptr, ok, stop.busstop);
1032  }
1033  stop.chargingStation = attrs.getOpt<std::string>(SUMO_ATTR_CHARGING_STATION, nullptr, ok, "");
1034  stop.overheadWireSegment = attrs.getOpt<std::string>(SUMO_ATTR_OVERHEAD_WIRE_SEGMENT, nullptr, ok, "");
1035  stop.containerstop = attrs.getOpt<std::string>(SUMO_ATTR_CONTAINER_STOP, nullptr, ok, "");
1036  stop.parkingarea = attrs.getOpt<std::string>(SUMO_ATTR_PARKING_AREA, nullptr, ok, "");
1037  //check stopping places
1038  const int numStoppingPlaces = !stop.busstop.empty() + !stop.chargingStation.empty() + !stop.overheadWireSegment.empty() +
1039  !stop.containerstop.empty() + !stop.parkingarea.empty();
1040  if (numStoppingPlaces > 1) {
1041  writeError(TL("A stop must be defined only in a StoppingPlace"));
1042  return false;
1043  } else if ((numStoppingPlaces == 0) && stop.edge.empty() && stop.lane.empty()) {
1044  writeError(TL("A stop must be defined in an edge, a lane, or in a StoppingPlace"));
1045  return false;
1046  }
1047  // declare error suffix
1048  std::string errorSuffix;
1049  if (stop.busstop != "") {
1050  errorSuffix = " at '" + stop.busstop + "'" + errorSuffix;
1051  } else if (stop.chargingStation != "") {
1052  errorSuffix = " at '" + stop.chargingStation + "'" + errorSuffix;
1053  } else if (stop.overheadWireSegment != "") {
1054  errorSuffix = " at '" + stop.overheadWireSegment + "'" + errorSuffix;
1055  } else if (stop.containerstop != "") {
1056  errorSuffix = " at '" + stop.containerstop + "'" + errorSuffix;
1057  } else if (stop.parkingarea != "") {
1058  errorSuffix = " at '" + stop.parkingarea + "'" + errorSuffix;
1059  } else if (stop.edge != "") {
1060  errorSuffix = " at '" + stop.edge + "'" + errorSuffix;
1061  } else {
1062  errorSuffix = " on lane '" + stop.lane + "'" + errorSuffix;
1063  }
1064  // speed for counting as stopped
1065  stop.speed = attrs.getOpt<double>(SUMO_ATTR_SPEED, nullptr, ok, 0);
1066  if (stop.speed < 0) {
1067  writeError("Speed cannot be negative for stop" + errorSuffix);
1068  return false;
1069  }
1070  // get the standing duration
1071  bool expectTrigger = !attrs.hasAttribute(SUMO_ATTR_DURATION) && !attrs.hasAttribute(SUMO_ATTR_UNTIL) && !attrs.hasAttribute(SUMO_ATTR_SPEED);
1072  std::vector<std::string> triggers = attrs.getOpt<std::vector<std::string> >(SUMO_ATTR_TRIGGERED, nullptr, ok);
1073  // legacy
1074  if (attrs.getOpt<bool>(SUMO_ATTR_CONTAINER_TRIGGERED, nullptr, ok, false)) {
1075  triggers.push_back(toString(SUMO_TAG_CONTAINER));
1076  };
1077  SUMOVehicleParameter::parseStopTriggers(triggers, expectTrigger, stop);
1078  stop.startPos = attrs.getOpt<double>(SUMO_ATTR_STARTPOS, nullptr, ok, 0);
1079  stop.endPos = attrs.getOpt<double>(SUMO_ATTR_ENDPOS, nullptr, ok, 0);
1080  stop.friendlyPos = attrs.getOpt<bool>(SUMO_ATTR_FRIENDLY_POS, nullptr, ok, false);
1081  stop.arrival = attrs.getOptSUMOTimeReporting(SUMO_ATTR_ARRIVAL, nullptr, ok, -1);
1082  stop.duration = attrs.getOptSUMOTimeReporting(SUMO_ATTR_DURATION, nullptr, ok, -1);
1083  stop.until = attrs.getOptSUMOTimeReporting(SUMO_ATTR_UNTIL, nullptr, ok, -1);
1084  if (!expectTrigger && (!ok || (stop.duration < 0 && stop.until < 0 && stop.speed == 0))) {
1085  writeError("Invalid duration or end time is given for a stop" + errorSuffix);
1086  return false;
1087  }
1088  stop.extension = attrs.getOptSUMOTimeReporting(SUMO_ATTR_EXTENSION, nullptr, ok, -1);
1089  const bool defaultParking = (stop.triggered || stop.containerTriggered || stop.parkingarea != "");
1090  stop.parking = attrs.getOpt<ParkingType>(SUMO_ATTR_PARKING, nullptr, ok, defaultParking ? ParkingType::OFFROAD : ParkingType::ONROAD);
1091  if ((stop.parkingarea != "") && (stop.parking == ParkingType::ONROAD)) {
1092  WRITE_WARNING("Stop at parkingarea overrides attribute 'parking' for stop" + errorSuffix);
1094  }
1095  if (!ok) {
1096  writeError("Invalid bool for 'triggered', 'containerTriggered' or 'parking' for stop" + errorSuffix);
1097  return false;
1098  }
1099  // expected persons
1100  const std::vector<std::string>& expected = attrs.getOpt<std::vector<std::string> >(SUMO_ATTR_EXPECTED, nullptr, ok);
1101  stop.awaitedPersons.insert(expected.begin(), expected.end());
1102  if (stop.awaitedPersons.size() > 0 && (stop.parametersSet & STOP_TRIGGER_SET) == 0) {
1103  stop.triggered = true;
1104  if ((stop.parametersSet & STOP_PARKING_SET) == 0) {
1106  }
1107  }
1108  // permitted transportables
1109  const std::vector<std::string>& permitted = attrs.getOpt<std::vector<std::string> >(SUMO_ATTR_PERMITTED, nullptr, ok);
1110  stop.permitted.insert(permitted.begin(), permitted.end());
1111  // expected containers
1112  const std::vector<std::string>& expectedContainers = attrs.getOpt<std::vector<std::string> >(SUMO_ATTR_EXPECTED_CONTAINERS, nullptr, ok);
1113  stop.awaitedContainers.insert(expectedContainers.begin(), expectedContainers.end());
1114  if (stop.awaitedContainers.size() > 0 && (stop.parametersSet & STOP_CONTAINER_TRIGGER_SET) == 0) {
1115  stop.containerTriggered = true;
1116  if ((stop.parametersSet & STOP_PARKING_SET) == 0) {
1118  }
1119  }
1120  // public transport trip id
1121  stop.tripId = attrs.getOpt<std::string>(SUMO_ATTR_TRIP_ID, nullptr, ok, "");
1122  stop.split = attrs.getOpt<std::string>(SUMO_ATTR_SPLIT, nullptr, ok, "");
1123  stop.join = attrs.getOpt<std::string>(SUMO_ATTR_JOIN, nullptr, ok, "");
1124  stop.line = attrs.getOpt<std::string>(SUMO_ATTR_LINE, nullptr, ok, "");
1125  // index
1126  const std::string idx = attrs.getOpt<std::string>(SUMO_ATTR_INDEX, nullptr, ok, "end");
1127  if (idx == "end") {
1128  stop.index = STOP_INDEX_END;
1129  } else if (idx == "fit") {
1130  stop.index = STOP_INDEX_FIT;
1131  } else {
1132  stop.index = attrs.get<int>(SUMO_ATTR_INDEX, nullptr, ok);
1133  if (!ok || stop.index < 0) {
1134  writeError("Invalid 'index' for stop" + errorSuffix);
1135  return false;
1136  }
1137  }
1138  stop.started = attrs.getOptSUMOTimeReporting(SUMO_ATTR_STARTED, nullptr, ok, -1);
1139  stop.ended = attrs.getOptSUMOTimeReporting(SUMO_ATTR_ENDED, nullptr, ok, -1);
1140  stop.posLat = attrs.getOpt<double>(SUMO_ATTR_POSITION_LAT, nullptr, ok, INVALID_DOUBLE);
1141  stop.actType = attrs.getOpt<std::string>(SUMO_ATTR_ACTTYPE, nullptr, ok, "");
1142  stop.onDemand = attrs.getOpt<bool>(SUMO_ATTR_ONDEMAND, nullptr, ok, false);
1143  stop.jump = attrs.getOptSUMOTimeReporting(SUMO_ATTR_JUMP, nullptr, ok, -1);
1144  return true;
1145 }
1146 
1147 
1148 bool
1150  // check conditions
1151  if (attrs.hasAttribute(SUMO_ATTR_ID)) {
1152  return false;
1154  return false;
1156  return false;
1158  return true;
1160  return true;
1161  } else {
1162  return false;
1163  }
1164 }
1165 
1166 
1167 void
1168 RouteHandler::checkParent(const SumoXMLTag currentTag, const std::vector<SumoXMLTag>& parentTags, bool& ok) {
1169  // check that parent SUMOBaseObject's tag is the parentTag
1171  // set parent string
1172  std::string parentStrings;
1173  for (const auto& tag : parentTags) {
1174  if (tag == parentTags.back()) {
1175  parentStrings.append(toString(tag));
1176  } else {
1177  parentStrings.append(toString(tag) + ", ");
1178  }
1179  }
1180  if ((parent != nullptr) &&
1181  (parentTags.size() > 0) &&
1182  (std::find(parentTags.begin(), parentTags.end(), parent->getTag()) == parentTags.end())) {
1183  const std::string id = parent->hasStringAttribute(SUMO_ATTR_ID) ? ", id: '" + parent->getStringAttribute(SUMO_ATTR_ID) + "'" : "";
1184  writeError("'" + toString(currentTag) + "' must be defined within the definition of a '" + parentStrings + "' (found '" + toString(parent->getTag()) + "'" + id + ").");
1185  ok = false;
1186  }
1187 }
1188 
1189 /****************************************************************************/
long long int SUMOTime
Definition: GUI.h:35
#define WRITE_DEBUG(msg)
Definition: MsgHandler.h:306
#define WRITE_WARNINGF(...)
Definition: MsgHandler.h:296
#define WRITE_ERRORF(...)
Definition: MsgHandler.h:305
#define WRITE_ERROR(msg)
Definition: MsgHandler.h:304
#define WRITE_WARNING(msg)
Definition: MsgHandler.h:295
#define TL(string)
Definition: MsgHandler.h:315
#define TLF(string,...)
Definition: MsgHandler.h:317
SUMOTime string2time(const std::string &r)
convert string to SUMOTime
Definition: SUMOTime.cpp:46
long long int SVCPermissions
bitset where each bit declares whether a certain SVC may use this edge/lane
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types.
const int STOP_ARRIVAL_SET
const int STOP_DURATION_SET
const int STOP_INDEX_END
const int STOP_POSLAT_SET
const int STOP_EXPECTED_SET
const int STOP_SPEED_SET
const int STOP_UNTIL_SET
const int STOP_LINE_SET
const int STOP_PARKING_SET
const int STOP_TRIP_ID_SET
const int STOP_PERMITTED_SET
const int STOP_SPLIT_SET
const int STOP_START_SET
const int STOP_JOIN_SET
const int STOP_CONTAINER_TRIGGER_SET
const int STOP_EXTENSION_SET
const int STOP_INDEX_FIT
const int STOP_ENDED_SET
const int STOP_TRIGGER_SET
const int STOP_JUMP_SET
const int STOP_ONDEMAND_SET
const int STOP_END_SET
const int STOP_STARTED_SET
const int STOP_EXPECTED_CONTAINERS_SET
SumoXMLTag
Numbers representing SUMO-XML - element names.
@ SUMO_TAG_INTERVAL
an aggreagated-output interval
@ SUMO_TAG_VTYPE
description of a vehicle/person/container type
@ SUMO_TAG_WALK
@ SUMO_TAG_TRANSHIP
@ SUMO_TAG_CONTAINERFLOW
@ SUMO_TAG_ROOTFILE
root file
@ SUMO_TAG_STOP
stop for vehicles
@ SUMO_TAG_VEHICLE
description of a vehicle
@ SUMO_TAG_ROUTE_DISTRIBUTION
distribution of a route
@ SUMO_TAG_FLOW
a flow definition using from and to edges or a route
@ SUMO_TAG_TRANSPORT
@ SUMO_TAG_CONTAINER
@ SUMO_TAG_ROUTE
begin/end of the description of a route
@ SUMO_TAG_RIDE
@ SUMO_TAG_VTYPE_DISTRIBUTION
distribution of a vehicle type
@ SUMO_TAG_DEST_PROB_REROUTE
probability of destination of a reroute
@ SUMO_TAG_PARAM
parameter associated to a certain key
@ SUMO_TAG_PERSON
@ SUMO_TAG_PERSONTRIP
@ SUMO_TAG_PERSONFLOW
@ SUMO_TAG_TRIP
a single trip definition (used by router)
ParkingType
Numbers representing special SUMO-XML-attribute values Information on whether a car is parking on the...
@ SUMO_ATTR_CONTAINER_TRIGGERED
@ SUMO_ATTR_STARTPOS
@ SUMO_ATTR_PARKING
@ SUMO_ATTR_EXTENSION
@ SUMO_ATTR_LINES
@ SUMO_ATTR_LANE
@ SUMO_ATTR_FROM_JUNCTION
@ SUMO_ATTR_SPEED
@ SUMO_ATTR_STARTED
@ SUMO_ATTR_VALUE
@ SUMO_ATTR_VIA
@ SUMO_ATTR_CONTAINER_STOP
@ SUMO_ATTR_PARKING_AREA
@ SUMO_ATTR_EDGE
@ SUMO_ATTR_BUS_STOP
@ SUMO_ATTR_TRAIN_STOP
@ SUMO_ATTR_ENDPOS
@ SUMO_ATTR_TO_JUNCTION
@ SUMO_ATTR_ARRIVALPOS
@ SUMO_ATTR_SPLIT
@ SUMO_ATTR_ACTTYPE
@ SUMO_ATTR_PROBS
@ SUMO_ATTR_BEGIN
weights: time range begin
@ SUMO_ATTR_EDGES
the edges of a route
@ SUMO_ATTR_POSITION_LAT
@ SUMO_ATTR_EXPECTED
@ SUMO_ATTR_LINE
@ SUMO_ATTR_CHARGING_STATION
@ SUMO_ATTR_ROUTES
@ SUMO_ATTR_MODES
@ SUMO_ATTR_VTYPES
@ SUMO_ATTR_OVERHEAD_WIRE_SEGMENT
@ SUMO_ATTR_DEPARTPOS
@ SUMO_ATTR_GROUP
@ SUMO_ATTR_ENDED
@ SUMO_ATTR_ONDEMAND
@ SUMO_ATTR_INDEX
@ SUMO_ATTR_ARRIVAL
@ SUMO_ATTR_TO_TAZ
@ SUMO_ATTR_TRIP_ID
@ SUMO_ATTR_TO
@ SUMO_ATTR_FROM
@ SUMO_ATTR_END
weights: time range end
@ SUMO_ATTR_PERMITTED
@ SUMO_ATTR_FROM_TAZ
@ SUMO_ATTR_JOIN
@ SUMO_ATTR_JUMP
@ SUMO_ATTR_PROB
@ SUMO_ATTR_FRIENDLY_POS
@ SUMO_ATTR_WALKFACTOR
@ SUMO_ATTR_DETERMINISTIC
@ SUMO_ATTR_EXPECTED_CONTAINERS
@ SUMO_ATTR_ROUTE
@ SUMO_ATTR_COLOR
A color information.
@ SUMO_ATTR_ID
@ SUMO_ATTR_UNTIL
@ SUMO_ATTR_TRIGGERED
@ SUMO_ATTR_DURATION
@ SUMO_ATTR_KEY
@ SUMO_ATTR_REPEAT
@ SUMO_ATTR_CYCLETIME
const double INVALID_DOUBLE
invalid double
Definition: StdDefs.h:64
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:46
plan parameters (used for group all from-to parameters related with plans)
void addDoubleListAttribute(const SumoXMLAttr attr, const std::vector< double > &value)
add double list attribute into current SumoBaseObject node
const std::vector< double > & getDoubleListAttribute(const SumoXMLAttr attr) const
get double list attribute
void addIntAttribute(const SumoXMLAttr attr, const int value)
add int attribute into current SumoBaseObject node
void setVehicleTypeParameter(const SUMOVTypeParameter *vehicleTypeParameter)
set vehicle type parameters
const SUMOVehicleParameter::Stop & getStopParameter() const
get stop parameters
const RGBColor & getColorAttribute(const SumoXMLAttr attr) const
get color attribute
SUMOTime getTimeAttribute(const SumoXMLAttr attr) const
get time attribute
bool hasStringAttribute(const SumoXMLAttr attr) const
has function
void setTag(const SumoXMLTag tag)
set SumoBaseObject tag
SumoBaseObject * getParentSumoBaseObject() const
get pointer to mySumoBaseObjectParent SumoBaseObject (if is null, then is the root)
const CommonXMLStructure::PlanParameters & getPlanParameters() const
get plan parameteres
const std::map< std::string, std::string > & getParameters() const
get parameters
SUMOVehicleClass getVClass() const
vehicle class
void setPlanParameters(const CommonXMLStructure::PlanParameters &planParameters)
set plan parmeter
const SUMOVTypeParameter & getVehicleTypeParameter() const
get current vType
SumoXMLTag getTag() const
get XML myTag
void addTimeAttribute(const SumoXMLAttr attr, const SUMOTime value)
add time attribute into current SumoBaseObject node
void addStringListAttribute(const SumoXMLAttr attr, const std::vector< std::string > &value)
add string list attribute into current SumoBaseObject node
int getIntAttribute(const SumoXMLAttr attr) const
get int attribute
void addDoubleAttribute(const SumoXMLAttr attr, const double value)
add double attribute into current SumoBaseObject node
void setVClass(SUMOVehicleClass vClass)
set vehicle class
void setVehicleParameter(const SUMOVehicleParameter *vehicleParameter)
set vehicle parameters
void addStringAttribute(const SumoXMLAttr attr, const std::string &value)
add string attribute into current SumoBaseObject node
void setStopParameter(const SUMOVehicleParameter::Stop &stopParameter)
add stop parameters
double getDoubleAttribute(const SumoXMLAttr attr) const
get double attribute
const SUMOVehicleParameter & getVehicleParameter() const
get vehicle parameters
const std::vector< std::string > & getStringListAttribute(const SumoXMLAttr attr) const
get string list attribute
void addColorAttribute(const SumoXMLAttr attr, const RGBColor &value)
add color attribute into current SumoBaseObject node
const std::string & getStringAttribute(const SumoXMLAttr attr) const
get string attribute
const std::vector< SumoBaseObject * > & getSumoBaseObjectChildren() const
get SumoBaseObject children
CommonXMLStructure::SumoBaseObject * getCurrentSumoBaseObject() const
get current editedSumoBaseObject
void openSUMOBaseOBject()
open SUMOBaseOBject
void closeSUMOBaseOBject()
close myTag
static const std::vector< SumoXMLTag > vehicles
vehicles namespace
Definition: NamespaceIDs.h:59
static const std::vector< SumoXMLTag > routes
route namespace
Definition: NamespaceIDs.h:56
static const std::vector< SumoXMLTag > persons
persons namespace
Definition: NamespaceIDs.h:62
static const std::vector< SumoXMLTag > containers
containers namespace
Definition: NamespaceIDs.h:65
A storage for options typed value containers)
Definition: OptionsCont.h:89
static const RGBColor INVISIBLE
Definition: RGBColor.h:195
void parseWalk(const SUMOSAXAttributes &attrs)
parse walk
virtual void buildContainer(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const SUMOVehicleParameter &containerParameters)=0
build container
void parseContainerFlow(const SUMOSAXAttributes &attrs)
parse container flow
void parseFlow(const SUMOSAXAttributes &attrs)
parse flow (including flows, flows over routes and flows with embedded routes)
bool beginParseAttributes(SumoXMLTag tag, const SUMOSAXAttributes &attrs)
begin parse attributes
CommonXMLStructure myCommonXMLStructure
common XML Structure
Definition: RouteHandler.h:165
virtual void buildFlowTAZs(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const SUMOVehicleParameter &vehicleParameters, const std::string &fromTAZID, const std::string &toTAZID)=0
build flow (from-to TAZs)
virtual void buildRoute(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const std::string &id, SUMOVehicleClass vClass, const std::vector< std::string > &edgeIDs, const RGBColor &color, const int repeat, const SUMOTime cycleTime, const double probability, const Parameterised::Map &routeParameters)=0
build route
virtual void buildFlowOverRoute(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const SUMOVehicleParameter &vehicleParameters)=0
build a flow over an existent route
bool isErrorCreatingElement() const
get flag for check if a element wasn't created
bool isEmbeddedRoute(const SUMOSAXAttributes &attrs) const
check embedded route
void parsePerson(const SUMOSAXAttributes &attrs)
parse person
virtual void buildEmbeddedRoute(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const std::vector< std::string > &edgeIDs, const RGBColor &color, const int repeat, const SUMOTime cycleTime, const Parameterised::Map &routeParameters)=0
build embedded route
void parseTransport(const SUMOSAXAttributes &attrs)
parse transport
virtual void buildTransport(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const CommonXMLStructure::PlanParameters &planParameters, const double arrivalPos, const std::vector< std::string > &lines, const std::string &group)=0
build transport
void endParseAttributes()
end parse attributes
virtual void buildFlowJunctions(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const SUMOVehicleParameter &vehicleParameters, const std::string &fromJunctionID, const std::string &toJunctionID)=0
build flow (from-to junctions)
virtual void buildTranship(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const CommonXMLStructure::PlanParameters &planParameters, const double arrivalPosition, const double departPosition, const double speed, const SUMOTime duration)=0
build tranship
void parseVTypeDistribution(const SUMOSAXAttributes &attrs)
parse vType distribution
virtual void buildTripJunctions(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const SUMOVehicleParameter &vehicleParameters, const std::string &fromJunctionID, const std::string &toJunctionID)=0
build trip (from-to junctions)
void writeErrorInvalidID(const SumoXMLTag tag, const std::string &id)
write error "invalid id"
const std::string myFilename
filename (needed for parsing vTypes)
Definition: RouteHandler.h:153
virtual void buildWalk(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const CommonXMLStructure::PlanParameters &planParameters, const double arrivalPos, const double speed, const SUMOTime duration)=0
build walk
void parseStop(const SUMOSAXAttributes &attrs)
parse stop
void parseContainer(const SUMOSAXAttributes &attrs)
parse container
RouteHandler(const std::string &filename, const bool hardFail)
Constructor.
void parsePersonTrip(const SUMOSAXAttributes &attrs)
parse person trip
virtual void buildTrip(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const SUMOVehicleParameter &vehicleParameters, const std::string &fromEdgeID, const std::string &toEdgeID)=0
build trip (from-to edges)
virtual void buildVType(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const SUMOVTypeParameter &vTypeParameter)=0
build vType
void parseRoute(const SUMOSAXAttributes &attrs)
parse route
virtual void buildVTypeDistribution(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const std::string &id, const int deterministic, const std::vector< std::string > &vTypeIDs, const std::vector< double > &probabilities)=0
build vType distribution
virtual void buildTripTAZs(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const SUMOVehicleParameter &vehicleParameters, const std::string &fromTazID, const std::string &toTazID)=0
build trip (from-to TAZs)
void parseTrip(const SUMOSAXAttributes &attrs)
parse trip
SUMOTime myFlowEndDefault
The default value for flow ends.
Definition: RouteHandler.h:162
virtual ~RouteHandler()
Destructor.
void parseParameters(const SUMOSAXAttributes &attrs)
parse generic parameters
virtual void buildStop(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const CommonXMLStructure::PlanParameters &planParameters, const SUMOVehicleParameter::Stop &stopParameters)=0
build stop
void parseSumoBaseObject(CommonXMLStructure::SumoBaseObject *obj)
parse SumoBaseObject (it's called recursivelly)
virtual void buildRide(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const CommonXMLStructure::PlanParameters &planParameters, const double arrivalPos, const std::vector< std::string > &lines, const std::string &group)=0
build ride
virtual void buildPersonFlow(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const SUMOVehicleParameter &personFlowParameters)=0
build person flow
void parsePersonFlow(const SUMOSAXAttributes &attrs)
parse person flow
void parseInterval(const SUMOSAXAttributes &attrs)
parse interval
bool myErrorCreatingElement
flag for check if a element wasn't created
Definition: RouteHandler.h:168
void parseVType(const SUMOSAXAttributes &attrs)
void writeError(const std::string &error)
write error and enable error creating element
void parseRide(const SUMOSAXAttributes &attrs)
parse ride
bool parseNestedCFM(const SumoXMLTag tag, const SUMOSAXAttributes &attrs)
parse nested CarFollowingModel
virtual void buildPersonTrip(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const CommonXMLStructure::PlanParameters &planParameters, const double arrivalPos, const std::vector< std::string > &types, const std::vector< std::string > &modes, const std::vector< std::string > &lines, const double walkFactor, const std::string &group)=0
build person trip
SUMOTime myFlowBeginDefault
The default value for flow begins.
Definition: RouteHandler.h:159
virtual void buildVehicleOverRoute(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const SUMOVehicleParameter &vehicleParameters)=0
build a vehicle over an existent route
void parseVehicle(const SUMOSAXAttributes &attrs)
parse vehicle (including vehicles over routes and vehicles with embedded routes)
void checkParent(const SumoXMLTag currentTag, const std::vector< SumoXMLTag > &parentTags, bool &ok)
check parents
virtual void buildRouteDistribution(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const std::string &id, const std::vector< std::string > &vTypeIDs, const std::vector< double > &probabilities)=0
build route distribution
virtual void buildContainerFlow(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const SUMOVehicleParameter &containerFlowParameters)=0
build container flow
virtual void buildPerson(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const SUMOVehicleParameter &personParameters)=0
build person
bool parseStopParameters(SUMOVehicleParameter::Stop &stop, const SUMOSAXAttributes &attrs)
parse stop parameters
void writeErrorInvalidDistribution(const SumoXMLTag tag, const std::string &id)
write error "invalid distribution"
const bool myHardFail
enable or disable hardFail (stop parsing if parameter aren't correct)
Definition: RouteHandler.h:156
void parseRouteDistribution(const SUMOSAXAttributes &attrs)
parse route distribution
void parseTranship(const SUMOSAXAttributes &attrs)
parse tranship
virtual void buildFlow(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const SUMOVehicleParameter &vehicleParameters, const std::string &fromEdgeID, const std::string &toEdgeID)=0
build flow (from-to edges)
Encapsulated SAX-Attributes.
virtual std::string getString(int id, bool *isPresent=nullptr) const =0
Returns the string-value of the named (by its enum-value) attribute.
T getOpt(int attr, const char *objectid, bool &ok, T defaultValue=T(), bool report=true) const
Tries to read given attribute assuming it is an int.
SUMOTime getOptSUMOTimeReporting(int attr, const char *objectid, bool &ok, SUMOTime defaultValue, bool report=true) const
Tries to read given attribute assuming it is a SUMOTime.
T get(int attr, const char *objectid, bool &ok, bool report=true) const
Tries to read given attribute assuming it is an int.
virtual bool hasAttribute(int id) const =0
Returns the information whether the named (by its enum-value) attribute is within the current list.
SUMOTime getSUMOTimeReporting(int attr, const char *objectid, bool &ok, bool report=true) const
Tries to read given attribute assuming it is a SUMOTime.
Structure representing possible vehicle parameter.
Definition of vehicle stop (position and duration)
SUMOTime started
the time at which this stop was reached
std::string edge
The edge to stop at.
ParkingType parking
whether the vehicle is removed from the net while stopping
std::string lane
The lane to stop at.
SUMOTime extension
The maximum time extension for boarding / loading.
bool friendlyPos
enable or disable friendly position (used by netedit)
double speed
the speed at which this stop counts as reached (waypoint mode)
std::string parkingarea
(Optional) parking area if one is assigned to the stop
std::string split
the id of the vehicle (train portion) that splits of upon reaching this stop
double startPos
The stopping position start.
std::string line
the new line id of the trip within a cyclical public transport route
double posLat
the lateral offset when stopping
bool onDemand
whether the stop may be skipped
std::string chargingStation
(Optional) charging station if one is assigned to the stop
std::string overheadWireSegment
(Optional) overhead line segment if one is assigned to the stop
std::set< std::string > permitted
IDs of persons or containers that may board/load at this stop.
int parametersSet
Information for the output which parameter were set.
int index
at which position in the stops list
SUMOTime jump
transfer time if there shall be a jump from this stop to the next route edge
std::string join
the id of the vehicle (train portion) to which this vehicle shall be joined
SUMOTime until
The time at which the vehicle may continue its journey.
std::string actType
act Type (only used by Persons) (used by netedit)
bool triggered
whether an arriving person lets the vehicle continue
SUMOTime ended
the time at which this stop was ended
double endPos
The stopping position end.
std::set< std::string > awaitedPersons
IDs of persons the vehicle has to wait for until departing.
std::set< std::string > awaitedContainers
IDs of containers the vehicle has to wait for until departing.
std::string busstop
(Optional) bus stop if one is assigned to the stop
std::string tripId
id of the trip within a cyclical public transport route
std::string containerstop
(Optional) container stop if one is assigned to the stop
bool containerTriggered
whether an arriving container lets the vehicle continue
SUMOTime arrival
The (expected) time at which the vehicle reaches the stop.
SUMOTime duration
The stopping duration.
Structure representing possible vehicle parameter.
std::string id
The vehicle's id.
static bool parsePersonModes(const std::string &modes, const std::string &element, const std::string &id, SVCPermissions &modeSet, std::string &error)
Validates a given person modes value.
static void parseStopTriggers(const std::vector< std::string > &triggers, bool expectTrigger, Stop &stop)
parses stop trigger values
static SUMOVTypeParameter * beginVTypeParsing(const SUMOSAXAttributes &attrs, const bool hardFail, const std::string &file)
Starts to parse a vehicle type.
static bool parseCFMParams(SUMOVTypeParameter *into, const SumoXMLTag element, const SUMOSAXAttributes &attrs, const bool nestedCFM)
Parses Car Following Mode params.
static SUMOVehicleParameter * parseVehicleAttributes(int element, const SUMOSAXAttributes &attrs, const bool hardFail, const bool optionalID=false, const bool skipDepart=false, const bool allowInternalRoutes=false)
Parses a vehicle's attributes.
static SUMOVehicleClass parseVehicleClass(const SUMOSAXAttributes &attrs, const std::string &id)
Parses the vehicle class.
static SUMOVehicleParameter * parseFlowAttributes(SumoXMLTag tag, const SUMOSAXAttributes &attrs, const bool hardFail, const bool needID, const SUMOTime beginDefault, const SUMOTime endDefault, const bool allowInternalRoutes=false)
Parses a flow's attributes.
static bool isValidVehicleID(const std::string &value)
whether the given string is a valid id for a vehicle or flow
static bool isValidParameterKey(const std::string &value)
whether the given string is a valid key for a parameter