Eclipse SUMO - Simulation of Urban MObility
MSRouteHandler.cpp
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2001-2019 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials
5 // are made available under the terms of the Eclipse Public License v2.0
6 // which accompanies this distribution, and is available at
7 // http://www.eclipse.org/legal/epl-v20.html
8 // SPDX-License-Identifier: EPL-2.0
9 /****************************************************************************/
18 // Parser and container for routes during their loading
19 /****************************************************************************/
20 
21 
22 // ===========================================================================
23 // included modules
24 // ===========================================================================
25 #include <config.h>
26 
27 #include "MSRouteHandler.h"
28 #include "MSTransportableControl.h"
29 #include <microsim/MSEdge.h>
36 
37 
38 
39 // ===========================================================================
40 // static members
41 // ===========================================================================
42 std::mt19937 MSRouteHandler::myParsingRNG;
43 
44 
45 // ===========================================================================
46 // method definitions
47 // ===========================================================================
48 MSRouteHandler::MSRouteHandler(const std::string& file, bool addVehiclesDirectly) :
49  SUMORouteHandler(file, addVehiclesDirectly ? "" : "routes", true),
50  myActivePlan(nullptr),
51  myActiveContainerPlan(nullptr),
52  myAddVehiclesDirectly(addVehiclesDirectly),
53  myCurrentVTypeDistribution(nullptr),
54  myCurrentRouteDistribution(nullptr),
55  myAmLoadingState(false) {
56  myActiveRoute.reserve(100);
57 }
58 
59 
61 
62 
63 void
65  MSTransportable::MSTransportablePlan::iterator i;
66  if (myActivePlan != nullptr) {
67  for (i = myActivePlan->begin(); i != myActivePlan->end(); i++) {
68  delete *i;
69  }
70  delete myActivePlan;
71  myActivePlan = nullptr;
72  }
73  if (myActiveContainerPlan != nullptr) {
74  for (i = myActiveContainerPlan->begin(); i != myActiveContainerPlan->end(); i++) {
75  delete *i;
76  }
77  delete myActiveContainerPlan;
78  myActivePlan = nullptr;
79  }
80 }
81 
82 
83 void
84 MSRouteHandler::parseFromViaTo(std::string element,
85  const SUMOSAXAttributes& attrs) {
86  myActiveRoute.clear();
87  bool useTaz = OptionsCont::getOptions().getBool("with-taz");
89  WRITE_WARNING("Taz usage was requested but no taz present in " + element + " '" + myVehicleParameter->id + "'!");
90  useTaz = false;
91  }
92  bool ok = true;
94  const MSEdge* fromTaz = MSEdge::dictionary(myVehicleParameter->fromTaz + "-source");
95  if (fromTaz == nullptr) {
96  throw ProcessError("Source taz '" + myVehicleParameter->fromTaz + "' not known for " + element + " '" + myVehicleParameter->id + "'!");
97  } else if (fromTaz->getNumSuccessors() == 0) {
98  throw ProcessError("Source taz '" + myVehicleParameter->fromTaz + "' has no outgoing edges for " + element + " '" + myVehicleParameter->id + "'!");
99  } else {
100  myActiveRoute.push_back(fromTaz);
101  }
102  } else {
103  MSEdge::parseEdgesList(attrs.getOpt<std::string>(SUMO_ATTR_FROM, myVehicleParameter->id.c_str(), ok, "", true),
104  myActiveRoute, "for " + element + " '" + myVehicleParameter->id + "'");
105  }
106  if (!attrs.hasAttribute(SUMO_ATTR_VIA) && !attrs.hasAttribute(SUMO_ATTR_ROUTE)) {
107  myInsertStopEdgesAt = (int)myActiveRoute.size();
108  }
109  MSEdge::parseEdgesList(attrs.getOpt<std::string>(SUMO_ATTR_VIA, myVehicleParameter->id.c_str(), ok, "", true),
110  myActiveRoute, "for " + element + " '" + myVehicleParameter->id + "'");
111  myVehicleParameter->via = StringTokenizer(attrs.getOpt<std::string>(SUMO_ATTR_VIA, myVehicleParameter->id.c_str(), ok, "", true)).getVector();
113  const MSEdge* toTaz = MSEdge::dictionary(myVehicleParameter->toTaz + "-sink");
114  if (toTaz == nullptr) {
115  throw ProcessError("Sink taz '" + myVehicleParameter->toTaz + "' not known for " + element + " '" + myVehicleParameter->id + "'!");
116  } else if (toTaz->getNumPredecessors() == 0) {
117  throw ProcessError("Sink taz '" + myVehicleParameter->toTaz + "' has no incoming edges for " + element + " '" + myVehicleParameter->id + "'!");
118  } else {
119  myActiveRoute.push_back(toTaz);
120  }
121  } else {
122  MSEdge::parseEdgesList(attrs.getOpt<std::string>(SUMO_ATTR_TO, myVehicleParameter->id.c_str(), ok, "", true),
123  myActiveRoute, "for " + element + " '" + myVehicleParameter->id + "'");
124  }
126  if (myVehicleParameter->routeid == "") {
128  }
129 }
130 
131 
132 void
134  const SUMOSAXAttributes& attrs) {
135  SUMORouteHandler::myStartElement(element, attrs);
136  try {
137  switch (element) {
138  case SUMO_TAG_PERSON:
139  case SUMO_TAG_PERSONFLOW:
140  if (!MSNet::getInstance()->getVehicleControl().hasVType(myVehicleParameter->vtypeid)) {
141  const std::string error = "The type '" + myVehicleParameter->vtypeid + "' for person '" + myVehicleParameter->id + "' is not known.";
142  delete myVehicleParameter;
143  myVehicleParameter = nullptr;
144  throw ProcessError(error);
145  }
147  break;
148  case SUMO_TAG_CONTAINER:
150  break;
151  case SUMO_TAG_RIDE: {
152  const std::string pid = myVehicleParameter->id;
153  bool ok = true;
154  MSEdge* from = nullptr;
155  const std::string desc = attrs.get<std::string>(SUMO_ATTR_LINES, pid.c_str(), ok);
156  StringTokenizer st(desc);
157  std::string bsID = attrs.getOpt<std::string>(SUMO_ATTR_BUS_STOP, nullptr, ok, "");
158  MSStoppingPlace* bs = nullptr;
159  MSEdge* to = nullptr;
160  if (bsID != "") {
162  if (bs == nullptr) {
163  throw ProcessError("Unknown bus stop '" + bsID + "' for person '" + myVehicleParameter->id + "'.");
164  }
165  to = &bs->getLane().getEdge();
166  }
167  double arrivalPos = attrs.getOpt<double>(SUMO_ATTR_ARRIVALPOS, myVehicleParameter->id.c_str(), ok,
168  bs == nullptr ? -NUMERICAL_EPS : bs->getEndLanePosition());
169  if (attrs.hasAttribute(SUMO_ATTR_FROM)) {
170  const std::string fromID = attrs.get<std::string>(SUMO_ATTR_FROM, pid.c_str(), ok);
171  from = MSEdge::dictionary(fromID);
172  if (from == nullptr) {
173  throw ProcessError("The from edge '" + fromID + "' within a ride of person '" + pid + "' is not known.");
174  }
175  if (!myActivePlan->empty() && myActivePlan->back()->getDestination() != from) {
176  throw ProcessError("Disconnected plan for person '" + myVehicleParameter->id + "' (" + fromID + "!=" + myActivePlan->back()->getDestination()->getID() + ").");
177  }
178  if (myActivePlan->empty()) {
180  from, nullptr, -1, myVehicleParameter->depart, myVehicleParameter->departPos, "start", true));
181  }
182  } else if (myActivePlan->empty()) {
183  throw ProcessError("The start edge for person '" + pid + "' is not known.");
184  }
185  if (to == nullptr) {
186  const std::string toID = attrs.get<std::string>(SUMO_ATTR_TO, pid.c_str(), ok);
187  to = MSEdge::dictionary(toID);
188  if (to == nullptr) {
189  throw ProcessError("The to edge '" + toID + "' within a ride of person '" + pid + "' is not known.");
190  }
191  }
192  const std::string intendedVeh = attrs.getOpt<std::string>(SUMO_ATTR_INTENDED, nullptr, ok, "");
193  const SUMOTime intendedDepart = attrs.getOptSUMOTimeReporting(SUMO_ATTR_DEPART, nullptr, ok, -1);
194  myActivePlan->push_back(new MSPerson::MSPersonStage_Driving(to, bs, arrivalPos, st.getVector(), intendedVeh, intendedDepart));
195  break;
196  }
197  case SUMO_TAG_TRANSPORT:
198  try {
199  const std::string containerId = myVehicleParameter->id;
200  bool ok = true;
201  MSEdge* from = nullptr;
202  const std::string desc = attrs.get<std::string>(SUMO_ATTR_LINES, containerId.c_str(), ok);
203  StringTokenizer st(desc);
204  std::string csID = attrs.getOpt<std::string>(SUMO_ATTR_CONTAINER_STOP, nullptr, ok, "");
205  MSStoppingPlace* cs = nullptr;
206  if (csID != "") {
208  if (cs == nullptr) {
209  throw ProcessError("Unknown container stop '" + csID + "' for container '" + myVehicleParameter->id + "'.");
210  }
211  }
212  double arrivalPos = attrs.getOpt<double>(SUMO_ATTR_ARRIVALPOS, myVehicleParameter->id.c_str(), ok,
213  cs == nullptr ? -NUMERICAL_EPS : cs->getEndLanePosition());
214  if (attrs.hasAttribute(SUMO_ATTR_FROM)) {
215  const std::string fromID = attrs.get<std::string>(SUMO_ATTR_FROM, containerId.c_str(), ok);
216  from = MSEdge::dictionary(fromID);
217  if (from == nullptr) {
218  throw ProcessError("The from edge '" + fromID + "' within a transport of container '" + containerId + "' is not known.");
219  }
220  if (!myActiveContainerPlan->empty() && myActiveContainerPlan->back()->getDestination() != from) {
221  throw ProcessError("Disconnected plan for container '" + myVehicleParameter->id + "' (" + fromID + "!=" + myActiveContainerPlan->back()->getDestination()->getID() + ").");
222  }
223  if (myActiveContainerPlan->empty()) {
225  from, nullptr, -1, myVehicleParameter->depart, myVehicleParameter->departPos, "start", true));
226  }
227  } else if (myActiveContainerPlan->empty()) {
228  throw ProcessError("The start edge within a transport of container '" + containerId + "' is not known.");
229  }
230  const std::string toID = attrs.get<std::string>(SUMO_ATTR_TO, containerId.c_str(), ok);
231  MSEdge* to = MSEdge::dictionary(toID);
232  if (to == nullptr) {
233  throw ProcessError("The to edge '" + toID + "' within a transport of container '" + containerId + "' is not known.");
234  }
235  myActiveContainerPlan->push_back(new MSContainer::MSContainerStage_Driving(to, cs, arrivalPos, st.getVector()));
236 
237  } catch (ProcessError&) {
239  throw;
240  }
241  break;
242  case SUMO_TAG_TRANSHIP: {
243  myActiveRoute.clear();
244  bool ok = true;
245  double departPos = attrs.getOpt<double>(SUMO_ATTR_DEPARTPOS, myVehicleParameter->id.c_str(), ok, 0);
246  double arrivalPos = attrs.getOpt<double>(SUMO_ATTR_ARRIVALPOS, myVehicleParameter->id.c_str(), ok, -NUMERICAL_EPS);
247  double speed = DEFAULT_CONTAINER_TRANSHIP_SPEED;
249  // need to check for explicitly set speed since we might have // DEFAULT_VEHTYPE
250  if (vtype != nullptr && vtype->wasSet(VTYPEPARS_MAXSPEED_SET)) {
251  speed = vtype->getMaxSpeed();
252  }
253  speed = attrs.getOpt<double>(SUMO_ATTR_SPEED, nullptr, ok, speed);
254  if (speed <= 0) {
255  throw ProcessError("Non-positive tranship speed for container '" + myVehicleParameter->id + "'.");
256  }
257  std::string csID = attrs.getOpt<std::string>(SUMO_ATTR_CONTAINER_STOP, nullptr, ok, "");
258  MSStoppingPlace* cs = nullptr;
259  if (csID != "") {
261  if (cs == nullptr) {
262  throw ProcessError("Unknown container stop '" + csID + "' for container '" + myVehicleParameter->id + "'.");
263  }
264  arrivalPos = cs->getEndLanePosition();
265  }
266  if (attrs.hasAttribute(SUMO_ATTR_EDGES)) {
268  } else {
269  if (attrs.hasAttribute(SUMO_ATTR_FROM) && attrs.hasAttribute(SUMO_ATTR_TO)) {
270  const std::string fromID = attrs.get<std::string>(SUMO_ATTR_FROM, myVehicleParameter->id.c_str(), ok);
271  MSEdge* from = MSEdge::dictionary(fromID);
272  if (from == nullptr) {
273  throw ProcessError("The from edge '" + fromID + "' within a tranship of container '" + myVehicleParameter->id + "' is not known.");
274  }
275  const std::string toID = attrs.get<std::string>(SUMO_ATTR_TO, myVehicleParameter->id.c_str(), ok);
276  MSEdge* to = MSEdge::dictionary(toID);
277  if (to == nullptr) {
278  throw ProcessError("The to edge '" + toID + "' within a tranship of container '" + myVehicleParameter->id + "' is not known.");
279  }
280  //the route of the container's tranship stage consists only of the 'from' and the 'to' edge
281  myActiveRoute.push_back(from);
282  myActiveRoute.push_back(to);
283  if (myActiveRoute.empty()) {
284  const std::string error = "No connection found between '" + from->getID() + "' and '" + to->getID() + "' for container '" + myVehicleParameter->id + "'.";
286  myActiveRoute.push_back(from);
287  } else {
289  }
290  }
291  }
292  }
293  if (myActiveRoute.empty()) {
294  throw ProcessError("No edges to tranship container '" + myVehicleParameter->id + "'.");
295  }
296  if (!myActiveContainerPlan->empty() && myActiveContainerPlan->back()->getDestination() != myActiveRoute.front()) {
297  throw ProcessError("Disconnected plan for container '" + myVehicleParameter->id + "' (" + myActiveRoute.front()->getID() + "!=" + myActiveContainerPlan->back()->getDestination()->getID() + ").");
298  }
299  if (myActiveContainerPlan->empty()) {
301  myActiveRoute.front(), nullptr, -1, myVehicleParameter->depart, departPos, "start", true));
302  }
303  myActiveContainerPlan->push_back(new MSContainer::MSContainerStage_Tranship(myActiveRoute, cs, speed, departPos, arrivalPos));
304  myActiveRoute.clear();
305  break;
306  }
307  case SUMO_TAG_FLOW:
308  parseFromViaTo("flow", attrs);
309  break;
310  case SUMO_TAG_TRIP:
311  parseFromViaTo("trip", attrs);
312  break;
313  default:
314  break;
315  }
316  } catch (ProcessError&) {
317  delete myVehicleParameter;
318  myVehicleParameter = nullptr;
319  throw;
320  }
321 }
322 
323 
324 void
326  bool ok = true;
327  myCurrentVTypeDistributionID = attrs.get<std::string>(SUMO_ATTR_ID, nullptr, ok);
328  if (ok) {
330  if (attrs.hasAttribute(SUMO_ATTR_VTYPES)) {
331  const std::string vTypes = attrs.get<std::string>(SUMO_ATTR_VTYPES, myCurrentVTypeDistributionID.c_str(), ok);
332  StringTokenizer st(vTypes);
333  while (st.hasNext()) {
334  std::string vtypeID = st.next();
336  if (type == nullptr) {
337  throw ProcessError("Unknown vtype '" + vtypeID + "' in distribution '" + myCurrentVTypeDistributionID + "'.");
338  }
340  }
341  }
342  }
343 }
344 
345 
346 void
348  if (myCurrentVTypeDistribution != nullptr) {
349  if (MSGlobals::gStateLoaded && MSNet::getInstance()->getVehicleControl().hasVTypeDistribution(myCurrentVTypeDistributionID)) {
351  return;
352  }
355  throw ProcessError("Vehicle type distribution '" + myCurrentVTypeDistributionID + "' is empty.");
356  }
357  if (!MSNet::getInstance()->getVehicleControl().addVTypeDistribution(myCurrentVTypeDistributionID, myCurrentVTypeDistribution)) {
359  throw ProcessError("Another vehicle type (or distribution) with the id '" + myCurrentVTypeDistributionID + "' exists.");
360  }
361  myCurrentVTypeDistribution = nullptr;
362  }
363 }
364 
365 
366 void
368  myActiveRoute.clear();
369  myInsertStopEdgesAt = -1;
370  // check whether the id is really necessary
371  std::string rid;
372  if (myCurrentRouteDistribution != nullptr) {
374  rid = "distribution '" + myCurrentRouteDistributionID + "'";
375  } else if (myVehicleParameter != nullptr) {
376  // ok, a vehicle is wrapping the route,
377  // we may use this vehicle's id as default
378  myActiveRouteID = "!" + myVehicleParameter->id; // !!! document this
379  if (attrs.hasAttribute(SUMO_ATTR_ID)) {
380  WRITE_WARNING("Ids of internal routes are ignored (vehicle '" + myVehicleParameter->id + "').");
381  }
382  } else {
383  bool ok = true;
384  myActiveRouteID = attrs.get<std::string>(SUMO_ATTR_ID, nullptr, ok, false);
385  if (!ok) {
386  return;
387  }
388  rid = "'" + myActiveRouteID + "'";
389  }
390  if (myVehicleParameter != nullptr) { // have to do this here for nested route distributions
391  rid = "for vehicle '" + myVehicleParameter->id + "'";
392  }
393  bool ok = true;
394  if (attrs.hasAttribute(SUMO_ATTR_EDGES)) {
395  MSEdge::parseEdgesList(attrs.get<std::string>(SUMO_ATTR_EDGES, myActiveRouteID.c_str(), ok), myActiveRoute, rid);
396  }
397  myActiveRouteRefID = attrs.getOpt<std::string>(SUMO_ATTR_REFID, myActiveRouteID.c_str(), ok, "");
399  WRITE_ERROR("Invalid reference to route '" + myActiveRouteRefID + "' in route " + rid + ".");
400  }
403  myCurrentCosts = attrs.getOpt<double>(SUMO_ATTR_COST, myActiveRouteID.c_str(), ok, -1);
404  if (ok && myCurrentCosts != -1 && myCurrentCosts < 0) {
405  WRITE_ERROR("Invalid cost for route '" + myActiveRouteID + "'.");
406  }
407 }
408 
409 
410 void
412  // Currently unused
413 }
414 
415 
416 void
418  // Currently unsued
419 }
420 
421 
422 void
423 MSRouteHandler::closeRoute(const bool mayBeDisconnected) {
424  std::string type = "vehicle";
425  if (mayBeDisconnected) {
427  type = "flow";
428  } else {
429  type = "trip";
430  }
431  }
432 
433  try {
434  if (myActiveRoute.size() == 0) {
435  delete myActiveRouteColor;
436  myActiveRouteColor = nullptr;
437  if (myActiveRouteRefID != "" && myCurrentRouteDistribution != nullptr) {
439  if (route != nullptr) {
441  route->addReference();
442  }
443  }
444  myActiveRouteID = "";
445  myActiveRouteRefID = "";
446  return;
447  }
448  if (myVehicleParameter != nullptr) {
449  throw ProcessError("The route for " + type + " '" + myVehicleParameter->id + "' has no edges.");
450  } else {
451  throw ProcessError("Route '" + myActiveRouteID + "' has no edges.");
452  }
453  }
454  if (myActiveRoute.size() == 1 && myActiveRoute.front()->isTazConnector()) {
455  throw ProcessError("The routing information for " + type + " '" + myVehicleParameter->id + "' is insufficient.");
456  }
460  route->setCosts(myCurrentCosts);
461  myActiveRoute.clear();
462  if (!MSRoute::dictionary(myActiveRouteID, route)) {
463  delete route;
465  if (myVehicleParameter != nullptr) {
466  if (MSNet::getInstance()->getVehicleControl().getVehicle(myVehicleParameter->id) == nullptr) {
467  throw ProcessError("Another route for " + type + " '" + myVehicleParameter->id + "' exists.");
468  } else {
469  throw ProcessError("A vehicle with id '" + myVehicleParameter->id + "' already exists.");
470  }
471  } else {
472  throw ProcessError("Another route (or distribution) with the id '" + myActiveRouteID + "' exists.");
473  }
474  }
475  } else {
476  if (myCurrentRouteDistribution != nullptr) {
478  route->addReference();
479  }
480  }
481  }
482  myActiveRouteID = "";
483  myActiveRouteColor = nullptr;
484  myActiveRouteStops.clear();
485  } catch (ProcessError&) {
486  delete myVehicleParameter;
487  throw;
488  }
489 }
490 
491 
492 void
494  // check whether the id is really necessary
495  bool ok = true;
496  if (myVehicleParameter != nullptr) {
497  // ok, a vehicle is wrapping the route,
498  // we may use this vehicle's id as default
499  myCurrentRouteDistributionID = "!" + myVehicleParameter->id; // !!! document this
500  } else {
501  myCurrentRouteDistributionID = attrs.get<std::string>(SUMO_ATTR_ID, nullptr, ok);
502  if (!ok) {
503  return;
504  }
505  }
507  std::vector<double> probs;
508  if (attrs.hasAttribute(SUMO_ATTR_PROBS)) {
509  bool ok = true;
510  StringTokenizer st(attrs.get<std::string>(SUMO_ATTR_PROBS, myCurrentRouteDistributionID.c_str(), ok));
511  while (st.hasNext()) {
512  probs.push_back(StringUtils::toDoubleSecure(st.next(), 1.0));
513  }
514  }
515  if (attrs.hasAttribute(SUMO_ATTR_ROUTES)) {
516  bool ok = true;
517  StringTokenizer st(attrs.get<std::string>(SUMO_ATTR_ROUTES, myCurrentRouteDistributionID.c_str(), ok));
518  int probIndex = 0;
519  while (st.hasNext()) {
520  std::string routeID = st.next();
521  const MSRoute* route = MSRoute::dictionary(routeID, &myParsingRNG);
522  if (route == nullptr) {
523  throw ProcessError("Unknown route '" + routeID + "' in distribution '" + myCurrentRouteDistributionID + "'.");
524  }
525  const double prob = ((int)probs.size() > probIndex ? probs[probIndex] : 1.0);
526  if (myCurrentRouteDistribution->add(route, prob, false)) {
527  route->addReference();
528  }
529  probIndex++;
530  }
531  if (probs.size() > 0 && probIndex != (int)probs.size()) {
532  WRITE_WARNING("Got " + toString(probs.size()) + " probabilities for " + toString(probIndex) +
533  " routes in routeDistribution '" + myCurrentRouteDistributionID + "'");
534  }
535  }
536 }
537 
538 
539 void
541  if (myCurrentRouteDistribution != nullptr) {
542  const bool haveSameID = MSRoute::dictionary(myCurrentRouteDistributionID, &myParsingRNG) != nullptr;
543  if (MSGlobals::gStateLoaded && haveSameID) {
545  return;
546  }
547  if (haveSameID) {
549  throw ProcessError("Another route (or distribution) with the id '" + myCurrentRouteDistributionID + "' exists.");
550  }
553  throw ProcessError("Route distribution '" + myCurrentRouteDistributionID + "' is empty.");
554  }
556  myCurrentRouteDistribution = nullptr;
557  }
558 }
559 
560 
561 void
563  // get nested route
567  // let's check whether this vehicle had to depart before the simulation starts
569  if (route != nullptr) {
570  route->addReference();
571  route->release();
572  }
573  return;
574  }
575  }
576 
577  // get the vehicle's type
578  MSVehicleType* vtype = nullptr;
579 
580  try {
581  if (myVehicleParameter->vtypeid != "") {
582  vtype = vehControl.getVType(myVehicleParameter->vtypeid, &myParsingRNG);
583  if (vtype == nullptr) {
584  throw ProcessError("The vehicle type '" + myVehicleParameter->vtypeid + "' for vehicle '" + myVehicleParameter->id + "' is not known.");
585  }
586  if (vtype->getVehicleClass() == SVC_PEDESTRIAN) {
587  WRITE_WARNING("Vehicle type '" + vtype->getID() + "' with vClass=pedestrian should only be used for persons and not for vehicle '" + myVehicleParameter->id + "'.");
588  }
589  } else {
590  // there should be one (at least the default one)
591  vtype = vehControl.getVType(DEFAULT_VTYPE_ID, &myParsingRNG);
592  }
594  // if the route id was given, prefer that one
595  if (route != nullptr && !myAmLoadingState) {
596  WRITE_WARNING("Ignoring child element 'route' for vehicle '" + myVehicleParameter->id + "' because attribute 'route' is set.");
597  }
599  }
600  if (route == nullptr) {
601  // nothing found? -> error
602  if (myVehicleParameter->routeid != "") {
603  throw ProcessError("The route '" + myVehicleParameter->routeid + "' for vehicle '" + myVehicleParameter->id + "' is not known.");
604  } else {
605  throw ProcessError("Vehicle '" + myVehicleParameter->id + "' has no route.");
606  }
607  }
608  myActiveRouteID = "";
609 
610  } catch (ProcessError&) {
611  delete myVehicleParameter;
612  throw;
613  }
614 
615  // try to build the vehicle
616  SUMOVehicle* vehicle = nullptr;
617  if (vehControl.getVehicle(myVehicleParameter->id) == nullptr) {
618  try {
619  vehicle = vehControl.buildVehicle(myVehicleParameter, route, vtype, !MSGlobals::gCheckRoutes);
620  } catch (const ProcessError& e) {
622  WRITE_WARNING(e.what());
623  vehControl.deleteVehicle(nullptr, true);
624  myVehicleParameter = nullptr;
625  vehicle = nullptr;
626  return;
627  } else {
628  throw e;
629  }
630  }
631  const SUMOTime origDepart = myVehicleParameter->depart;
632  // maybe we do not want this vehicle to be inserted due to scaling
633  int quota = myAmLoadingState ? 1 : vehControl.getQuota();
634  if (quota > 0) {
637  vehControl.addVehicle(myVehicleParameter->id, vehicle);
638  for (int i = 1; i < quota; i++) {
641  newPars->id = myVehicleParameter->id + "." + toString(i);
643  vehicle = vehControl.buildVehicle(newPars, route, vtype, !MSGlobals::gCheckRoutes);
644  vehControl.addVehicle(newPars->id, vehicle);
645  }
646  myVehicleParameter = nullptr;
647  } else {
648  vehControl.deleteVehicle(vehicle, true);
649  myVehicleParameter = nullptr;
650  vehicle = nullptr;
651  }
652  } else {
653  // strange: another vehicle with the same id already exists
655  // and was not loaded while loading a simulation state
656  // -> error
657  std::string veh_id = myVehicleParameter->id;
658  delete myVehicleParameter;
659  myVehicleParameter = nullptr;
660  throw ProcessError("Another vehicle with the id '" + veh_id + "' exists.");
661  } else {
662  // ok, it seems to be loaded previously while loading a simulation state
663  vehicle = nullptr;
664  }
665  }
666  // check whether the vehicle shall be added directly to the network or
667  // shall stay in the internal buffer
668  if (vehicle != nullptr) {
669  if (vehicle->getParameter().departProcedure == DEPART_GIVEN) {
671  }
672  }
673 }
674 
675 
676 void
678  if (myActivePlan->size() == 0) {
679  const std::string error = "Person '" + myVehicleParameter->id + "' has no plan.";
680  delete myVehicleParameter;
681  myVehicleParameter = nullptr;
683  throw ProcessError(error);
684  }
685  // let's check whether this person had to depart before the simulation starts
688  delete myVehicleParameter;
689  myVehicleParameter = nullptr;
691  return;
692  }
693  // type existence has been checked on opening
696  // @todo: consider myScale?
697  if (MSNet::getInstance()->getPersonControl().add(person)) {
699  } else {
700  ProcessError error("Another person with the id '" + myVehicleParameter->id + "' exists.");
701  delete person;
702  throw error;
703  }
704  myVehicleParameter = nullptr;
705  myActivePlan = nullptr;
706 }
707 
708 
709 void
711  if (myActivePlan->size() == 0) {
712  const std::string error = "personFlow '" + myVehicleParameter->id + "' has no plan.";
713  delete myVehicleParameter;
714  myVehicleParameter = nullptr;
716  throw ProcessError(error);
717  }
718  // let's check whether this person had to depart before the simulation starts
721  delete myVehicleParameter;
722  myVehicleParameter = nullptr;
724  return;
725  }
726  // type existence has been checked on opening
728  // instantiate all persons of this flow
729  int i = 0;
731  std::string baseID = myVehicleParameter->id;
734  throw ProcessError("probabilistic personFlow '" + myVehicleParameter->id + "' must specify end time");
735  } else {
736  for (SUMOTime t = myVehicleParameter->depart; t < myVehicleParameter->repetitionEnd; t += TIME2STEPS(1)) {
738  addFlowPerson(t, type, baseID, i++);
739  }
740  }
741  }
742  } else {
744  for (; i < myVehicleParameter->repetitionNumber; i++) {
745  addFlowPerson(depart, type, baseID, i);
747  }
748  }
749 
750  myVehicleParameter = nullptr;
751  myActivePlan = nullptr;
752 }
753 
754 void
755 MSRouteHandler::addFlowPerson(SUMOTime depart, MSVehicleType* type, const std::string& baseID, int i) {
756  if (i > 0) {
757  // copy parameter and plan because the person takes over responsibility
758  SUMOVehicleParameter* copyParam = new SUMOVehicleParameter();
759  *copyParam = *myVehicleParameter;
760  myVehicleParameter = copyParam;
763  copyPlan->push_back(s->clone());
764  }
765  myActivePlan = copyPlan;
766  }
767  myVehicleParameter->id = baseID + "." + toString(i);
768  myVehicleParameter->depart = depart;
770  if (!MSNet::getInstance()->getPersonControl().add(person)) {
771  ProcessError error("Another person with the id '" + myVehicleParameter->id + "' exists.");
772  delete person;
773  throw error;
774  }
775 }
776 
777 void
780  if (!MSNet::getInstance()->getVehicleControl().addVType(vehType)) {
781  const std::string id = vehType->getID();
782  delete vehType;
784  throw ProcessError("Another vehicle type (or distribution) with the id '" + id + "' exists.");
785  }
786  } else {
787  if (myCurrentVTypeDistribution != nullptr) {
789  }
790  }
791 }
792 
793 
794 void
796  if (myActiveContainerPlan->size() == 0) {
797  throw ProcessError("Container '" + myVehicleParameter->id + "' has no plan.");
798  }
800  if (type == nullptr) {
801  throw ProcessError("The type '" + myVehicleParameter->vtypeid + "' for container '" + myVehicleParameter->id + "' is not known.");
802  }
804  // @todo: consider myScale?
806  if (MSNet::getInstance()->getContainerControl().add(container)) {
808  } else {
809  ProcessError error("Another container with the id '" + myVehicleParameter->id + "' exists.");
810  delete container;
811  throw error;
812  }
813  } else {
814  // warning already given
815  delete container;
816  }
817  myVehicleParameter = nullptr;
818  myActiveContainerPlan = nullptr;
819 }
820 
821 
822 void
824  myInsertStopEdgesAt = -1;
826  delete myVehicleParameter;
827  myVehicleParameter = nullptr;
828  return;
829  }
830  // let's check whether vehicles had to depart before the simulation starts
833  const SUMOTime offsetToBegin = string2time(OptionsCont::getOptions().getString("begin")) - myVehicleParameter->depart;
837  delete myVehicleParameter;
838  myVehicleParameter = nullptr;
839  return;
840  }
841  }
842  }
843  if (MSNet::getInstance()->getVehicleControl().getVType(myVehicleParameter->vtypeid, &myParsingRNG) == nullptr) {
844  throw ProcessError("The vehicle type '" + myVehicleParameter->vtypeid + "' for flow '" + myVehicleParameter->id + "' is not known.");
845  }
848  closeRoute(true);
849  }
851  throw ProcessError("The route '" + myVehicleParameter->routeid + "' for flow '" + myVehicleParameter->id + "' is not known.");
852  }
853  myActiveRouteID = "";
854 
855  // check whether the vehicle shall be added directly to the network or
856  // shall stay in the internal buffer
858  if (MSNet::getInstance()->getInsertionControl().addFlow(myVehicleParameter)) {
860  } else {
861  throw ProcessError("Another flow with the id '" + myVehicleParameter->id + "' exists.");
862  }
863  }
864  myVehicleParameter = nullptr;
865 }
866 
867 
868 void
871  closeRoute(true);
872  closeVehicle();
873 }
874 
875 
876 void
878  std::string errorSuffix;
879  if (myActivePlan != nullptr) {
880  errorSuffix = " in person '" + myVehicleParameter->id + "'.";
881  } else if (myVehicleParameter != nullptr) {
882  errorSuffix = " in vehicle '" + myVehicleParameter->id + "'.";
883  } else if (myActiveContainerPlan != nullptr) {
884  errorSuffix = " in container '" + myVehicleParameter->id + "'.";
885  } else {
886  errorSuffix = " in route '" + myActiveRouteID + "'.";
887  }
889  bool ok = parseStop(stop, attrs, errorSuffix, MsgHandler::getErrorInstance());
890  if (!ok) {
891  return;
892  }
893  const MSEdge* edge = nullptr;
894  MSStoppingPlace* toStop = nullptr;
895  // try to parse the assigned bus stop
896  if (stop.busstop != "") {
897  // ok, we have a bus stop
899  if (bs == nullptr) {
900  WRITE_ERROR("The busStop '" + stop.busstop + "' is not known" + errorSuffix);
901  return;
902  }
903  toStop = bs;
904  const MSLane& l = bs->getLane();
905  stop.lane = l.getID();
906  stop.endPos = bs->getEndLanePosition();
907  stop.startPos = bs->getBeginLanePosition();
908  edge = &l.getEdge();
909  } //try to parse the assigned container stop
910  else if (stop.containerstop != "") {
911  // ok, we have obviously a container stop
913  if (cs == nullptr) {
914  WRITE_ERROR("The containerStop '" + stop.containerstop + "' is not known" + errorSuffix);
915  return;
916  }
917  toStop = cs;
918  const MSLane& l = cs->getLane();
919  stop.lane = l.getID();
920  stop.endPos = cs->getEndLanePosition();
921  stop.startPos = cs->getBeginLanePosition();
922  edge = &l.getEdge();
923  } //try to parse the assigned parking area
924  else if (stop.parkingarea != "") {
925  // ok, we have obviously a parking area
927  if (pa == nullptr) {
928  WRITE_ERROR("The parkingArea '" + stop.parkingarea + "' is not known" + errorSuffix);
929  return;
930  }
931  toStop = pa;
932  const MSLane& l = pa->getLane();
933  stop.lane = l.getID();
934  stop.endPos = pa->getEndLanePosition();
935  stop.startPos = pa->getBeginLanePosition();
936  edge = &l.getEdge();
937  } else if (stop.chargingStation != "") {
938  // ok, we have a charging station
940  if (cs == nullptr) {
941  WRITE_ERROR("The chargingStation '" + stop.chargingStation + "' is not known" + errorSuffix);
942  return;
943  }
944  toStop = cs;
945  const MSLane& l = cs->getLane();
946  stop.lane = l.getID();
947  stop.endPos = cs->getEndLanePosition();
948  stop.startPos = cs->getBeginLanePosition();
949  edge = &l.getEdge();
950  } else {
951  // no, the lane and the position should be given
952  // get the lane
953  stop.lane = attrs.getOpt<std::string>(SUMO_ATTR_LANE, nullptr, ok, "");
954  if (ok && stop.lane != "") {
955  if (MSLane::dictionary(stop.lane) == nullptr) {
956  WRITE_ERROR("The lane '" + stop.lane + "' for a stop is not known" + errorSuffix);
957  return;
958  }
959  } else {
960  if (myActivePlan && !myActivePlan->empty()) {
961  const MSStoppingPlace* bs = myActivePlan->back()->getDestinationStop();
962  if (bs != nullptr) {
963  edge = &bs->getLane().getEdge();
964  stop.lane = bs->getLane().getID();
965  stop.endPos = bs->getEndLanePosition();
966  stop.startPos = bs->getBeginLanePosition();
967  } else {
968  edge = myActivePlan->back()->getDestination();
969  stop.lane = edge->getLanes()[0]->getID();
970  stop.endPos = myActivePlan->back()->getArrivalPos();
971  stop.startPos = MAX2(0., stop.endPos - MIN_STOP_LENGTH);
972  }
973  } else {
974  WRITE_ERROR("A stop must be placed on a busStop, a chargingStation, a containerStop a parkingArea or a lane" + errorSuffix);
975  return;
976  }
977  }
978  edge = &MSLane::dictionary(stop.lane)->getEdge();
979  stop.endPos = attrs.getOpt<double>(SUMO_ATTR_ENDPOS, nullptr, ok, MSLane::dictionary(stop.lane)->getLength());
980  if (attrs.hasAttribute(SUMO_ATTR_POSITION)) {
981  WRITE_WARNING("Deprecated attribute 'pos' in description of stop" + errorSuffix);
982  stop.endPos = attrs.getOpt<double>(SUMO_ATTR_POSITION, nullptr, ok, stop.endPos);
983  }
984  stop.startPos = attrs.getOpt<double>(SUMO_ATTR_STARTPOS, nullptr, ok, MAX2(0., stop.endPos - MIN_STOP_LENGTH));
985  const bool friendlyPos = attrs.getOpt<bool>(SUMO_ATTR_FRIENDLY_POS, nullptr, ok, false);
986  if (!ok || !checkStopPos(stop.startPos, stop.endPos, MSLane::dictionary(stop.lane)->getLength(), POSITION_EPS, friendlyPos)) {
987  WRITE_ERROR("Invalid start or end position for stop on lane '" + stop.lane + "'" + errorSuffix);
988  return;
989  }
990  }
991  if (myActivePlan) {
992  if (myActivePlan->empty()) {
993  double departPos = toStop == nullptr || myVehicleParameter->wasSet(VEHPARS_DEPARTPOS_SET)
995  : (toStop->getBeginLanePosition() + toStop->getEndLanePosition()) / 2;
997  edge, toStop, -1, myVehicleParameter->depart, departPos, "start", true));
998  } else if (myActivePlan->back()->getDestination() != edge) {
999  throw ProcessError("Disconnected plan for person '" + myVehicleParameter->id + "' (" + edge->getID() + "!=" + myActivePlan->back()->getDestination()->getID() + ").");
1000  } else if (myActivePlan->back()->getStageType() == MSTransportable::WAITING
1002  const double start = SUMOVehicleParameter::interpretEdgePos(stop.startPos, edge->getLength(), SUMO_ATTR_STARTPOS, "stopping at " + edge->getID());
1003  const double end = SUMOVehicleParameter::interpretEdgePos(stop.endPos, edge->getLength(), SUMO_ATTR_ENDPOS, "stopping at " + edge->getID());
1004  const double prevAr = myActivePlan->back()->getArrivalPos();
1005  if (start > prevAr + NUMERICAL_EPS || end < prevAr - NUMERICAL_EPS) {
1006  WRITE_WARNING("Disconnected plan for person '" + myVehicleParameter->id
1007  + "' (stop range " + toString(start) + "-" + toString(end) + " does not cover previous arrival position " + toString(prevAr) + + ").");
1008  }
1009  }
1010  std::string actType = attrs.getOpt<std::string>(SUMO_ATTR_ACTTYPE, nullptr, ok, "waiting");
1011  double pos = (stop.startPos + stop.endPos) / 2.;
1012  if (!myActivePlan->empty()) {
1013  pos = myActivePlan->back()->getArrivalPos();
1014  }
1016  &MSLane::dictionary(stop.lane)->getEdge(), toStop, stop.duration, stop.until, pos, actType, false));
1017 
1018  } else if (myActiveContainerPlan) {
1019  if (myActiveContainerPlan->empty()) {
1020  double departPos = toStop == nullptr || myVehicleParameter->wasSet(VEHPARS_DEPARTPOS_SET)
1022  : (toStop->getBeginLanePosition() + toStop->getEndLanePosition()) / 2;
1024  &MSLane::dictionary(stop.lane)->getEdge(), toStop, -1, myVehicleParameter->depart, departPos, "start", true));
1025  } else if (myActiveContainerPlan->back()->getDestination() != &MSLane::dictionary(stop.lane)->getEdge()) {
1026  throw ProcessError("Disconnected plan for container '" + myVehicleParameter->id + "' (" + MSLane::dictionary(stop.lane)->getEdge().getID() + "!=" + myActiveContainerPlan->back()->getDestination()->getID() + ").");
1027  }
1028  std::string actType = attrs.getOpt<std::string>(SUMO_ATTR_ACTTYPE, nullptr, ok, "waiting");
1030  &MSLane::dictionary(stop.lane)->getEdge(), toStop, stop.duration, stop.until, stop.startPos, actType, false));
1031  } else if (myVehicleParameter != nullptr) {
1032  myVehicleParameter->stops.push_back(stop);
1033  } else {
1034  myActiveRouteStops.push_back(stop);
1035  }
1036  if (myInsertStopEdgesAt >= 0) {
1037  //std::cout << " myInsertStopEdgesAt=" << myInsertStopEdgesAt << " edge=" << edge->getID() << " myRoute=" << toString(myActiveRoute) << "\n";
1038  myActiveRoute.insert(myActiveRoute.begin() + myInsertStopEdgesAt, edge);
1040  }
1041 }
1042 
1043 
1044 void
1045 MSRouteHandler::parseWalkPositions(const SUMOSAXAttributes& attrs, const std::string& personID,
1046  const MSEdge* fromEdge, const MSEdge*& toEdge,
1047  double& departPos, double& arrivalPos, MSStoppingPlace*& bs,
1048  const MSTransportable::Stage* const lastStage, bool& ok) {
1049  const std::string description = "person '" + personID + "' walking from " + fromEdge->getID();
1050 
1051  if (attrs.hasAttribute(SUMO_ATTR_DEPARTPOS)) {
1052  WRITE_WARNING("The attribute departPos is no longer supported for walks, please use the person attribute, the arrivalPos of the previous step or explicit stops.");
1053  }
1054  departPos = 0.;
1055  if (lastStage != nullptr) {
1056  if (lastStage->getDestinationStop() != nullptr) {
1057  departPos = lastStage->getDestinationStop()->getAccessPos(fromEdge);
1058  } else if (lastStage->getDestination() == fromEdge) {
1059  departPos = lastStage->getArrivalPos();
1060  } else if (lastStage->getDestination()->getToJunction() == fromEdge->getToJunction()) {
1061  departPos = fromEdge->getLength();
1062  }
1063  }
1064 
1065  std::string bsID = attrs.getOpt<std::string>(SUMO_ATTR_BUS_STOP, nullptr, ok, "");
1066  if (bsID != "") {
1068  if (bs == nullptr) {
1069  throw ProcessError("Unknown bus stop '" + bsID + "' for " + description + ".");
1070  }
1071  arrivalPos = bs->getAccessPos(toEdge != nullptr ? toEdge : &bs->getLane().getEdge());
1072  if (arrivalPos < 0) {
1073  throw ProcessError("Bus stop '" + bsID + "' is not connected to arrival edge '" + toEdge->getID() + "' for " + description + ".");
1074  }
1075  if (attrs.hasAttribute(SUMO_ATTR_ARRIVALPOS)) {
1076  const double length = toEdge != nullptr ? toEdge->getLength() : bs->getLane().getLength();
1077  const double arrPos = SUMOVehicleParserHelper::parseWalkPos(SUMO_ATTR_ARRIVALPOS, myHardFail, description, length,
1078  attrs.get<std::string>(SUMO_ATTR_ARRIVALPOS, description.c_str(), ok), &myParsingRNG);
1079  if (arrPos >= bs->getBeginLanePosition() && arrPos < bs->getEndLanePosition()) {
1080  arrivalPos = arrPos;
1081  } else {
1082  WRITE_WARNING("Ignoring arrivalPos for " + description + " because it is outside the given stop '" + toString(SUMO_ATTR_BUS_STOP) + "'.");
1083  arrivalPos = bs->getAccessPos(&bs->getLane().getEdge());
1084  }
1085  }
1086  } else {
1087  if (toEdge == nullptr) {
1088  throw ProcessError("No destination edge for " + description + ".");
1089  }
1090  if (attrs.hasAttribute(SUMO_ATTR_ARRIVALPOS)) {
1092  attrs.get<std::string>(SUMO_ATTR_ARRIVALPOS, description.c_str(), ok), &myParsingRNG);
1093  } else {
1094  arrivalPos = toEdge->getLength() / 2.;
1095  }
1096  }
1097 }
1098 
1099 
1100 void
1102  myActiveRoute.clear();
1103  bool ok = true;
1105  const char* const id = myVehicleParameter->id.c_str();
1106  const SUMOTime duration = attrs.getOptSUMOTimeReporting(SUMO_ATTR_DURATION, id, ok, -1);
1107  if (attrs.hasAttribute(SUMO_ATTR_DURATION) && duration <= 0) {
1108  throw ProcessError("Non-positive walking duration for '" + myVehicleParameter->id + "'.");
1109  }
1110  const std::string fromID = attrs.getOpt<std::string>(SUMO_ATTR_FROM, id, ok, "");
1111  const MSEdge* from = fromID != "" || myActivePlan->empty() ? MSEdge::dictionary(fromID) : myActivePlan->back()->getDestination();
1112  if (from == nullptr) {
1113  throw ProcessError("The from edge '" + fromID + "' within a walk of person '" + myVehicleParameter->id + "' is not known.");
1114  }
1115  const std::string toID = attrs.getOpt<std::string>(SUMO_ATTR_TO, myVehicleParameter->id.c_str(), ok, "");
1116  const MSEdge* to = MSEdge::dictionary(toID);
1117  if (toID != "" && to == nullptr) {
1118  throw ProcessError("The to edge '" + toID + "' within a walk of person '" + myVehicleParameter->id + "' is not known.");
1119  }
1120  double departPos = 0;
1121  double arrivalPos = 0;
1122  MSStoppingPlace* stoppingPlace = nullptr;
1123  parseWalkPositions(attrs, myVehicleParameter->id, from, to, departPos, arrivalPos, stoppingPlace, nullptr, ok);
1124 
1125  const std::string modes = attrs.getOpt<std::string>(SUMO_ATTR_MODES, id, ok, "");
1126  SVCPermissions modeSet = 0;
1127  std::string errorMsg;
1128  // try to parse person modes
1129  if (!SUMOVehicleParameter::parsePersonModes(modes, "person", id, modeSet, errorMsg)) {
1130  throw InvalidArgument(errorMsg);
1131  }
1132  const std::string types = attrs.getOpt<std::string>(SUMO_ATTR_VTYPES, id, ok, "");
1133  for (StringTokenizer st(types); st.hasNext();) {
1134  const std::string vtypeid = st.next();
1135  if (vehControl.getVType(vtypeid) == nullptr) {
1136  throw InvalidArgument("The vehicle type '" + vtypeid + "' in a trip for person '" + myVehicleParameter->id + "' is not known.");
1137  }
1138  modeSet |= SVC_PASSENGER;
1139  }
1140  const double speed = attrs.getOpt<double>(SUMO_ATTR_SPEED, id, ok, -1.);
1141  if (attrs.hasAttribute(SUMO_ATTR_SPEED) && speed <= 0) {
1142  throw ProcessError("Non-positive walking speed for '" + myVehicleParameter->id + "'.");
1143  }
1144  const double walkFactor = attrs.getOpt<double>(SUMO_ATTR_WALKFACTOR, id, ok, OptionsCont::getOptions().getFloat("persontrip.walkfactor"));
1145  const double departPosLat = attrs.getOpt<double>(SUMO_ATTR_DEPARTPOS_LAT, nullptr, ok, 0);
1146  if (ok) {
1147  if (myActivePlan->empty()) {
1148  double initialDepartPos = myVehicleParameter->departPos;
1150  initialDepartPos = RandHelper::rand(from->getLength(), &myParsingRNG);
1151  }
1152  myActivePlan->push_back(new MSTransportable::Stage_Waiting(from, nullptr, -1, myVehicleParameter->depart, initialDepartPos, "start", true));
1153  }
1155  MSStoppingPlace* fromStop = myActivePlan->empty() ? nullptr : myActivePlan->back()->getDestinationStop();
1156  myActivePlan->push_back(new MSTransportable::Stage_Trip(from, fromStop, to == nullptr ? &stoppingPlace->getLane().getEdge() : to, stoppingPlace, duration, modeSet, types, speed, walkFactor, departPosLat, attrs.hasAttribute(SUMO_ATTR_ARRIVALPOS), arrivalPos));
1157  }
1158  myActiveRoute.clear();
1159 }
1160 
1161 
1162 void
1164  try {
1165  myActiveRoute.clear();
1166  bool ok = true;
1167  const SUMOTime duration = attrs.getOptSUMOTimeReporting(SUMO_ATTR_DURATION, nullptr, ok, -1);
1168  if (attrs.hasAttribute(SUMO_ATTR_DURATION) && duration <= 0) {
1169  throw ProcessError("Non-positive walking duration for '" + myVehicleParameter->id + "'.");
1170  }
1171  double speed = -1; // default to vType speed
1172  if (attrs.hasAttribute(SUMO_ATTR_SPEED)) {
1173  speed = attrs.get<double>(SUMO_ATTR_SPEED, nullptr, ok);
1174  if (speed <= 0) {
1175  throw ProcessError("Non-positive walking speed for '" + myVehicleParameter->id + "'.");
1176  }
1177  }
1178  double departPos = 0;
1179  double arrivalPos = 0;
1180  MSStoppingPlace* bs = nullptr;
1181  if (attrs.hasAttribute(SUMO_ATTR_ROUTE)) {
1182  const std::string routeID = attrs.get<std::string>(SUMO_ATTR_ROUTE, myVehicleParameter->id.c_str(), ok);
1183  const MSRoute* route = MSRoute::dictionary(routeID, &myParsingRNG);
1184  if (route == nullptr) {
1185  throw ProcessError("The route '" + routeID + "' for walk of person '" + myVehicleParameter->id + "' is not known.");
1186  }
1187  myActiveRoute = route->getEdges();
1188  } else {
1190  }
1191  if (myActivePlan->empty()) {
1192  double initialDepartPos = myVehicleParameter->departPos;
1194  initialDepartPos = RandHelper::rand(myActiveRoute.front()->getLength(), &myParsingRNG);
1195  }
1196  myActivePlan->push_back(new MSTransportable::Stage_Waiting(myActiveRoute.front(), nullptr, -1, myVehicleParameter->depart, initialDepartPos, "start", true));
1197  }
1198  parseWalkPositions(attrs, myVehicleParameter->id, myActiveRoute.front(), myActiveRoute.back(), departPos, arrivalPos, bs, myActivePlan->back(), ok);
1199  if (myActiveRoute.empty()) {
1200  throw ProcessError("No edges to walk for person '" + myVehicleParameter->id + "'.");
1201  }
1202  if (myActivePlan->back()->getDestination() != myActiveRoute.front() &&
1203  myActivePlan->back()->getDestination()->getToJunction() != myActiveRoute.front()->getFromJunction() &&
1204  myActivePlan->back()->getDestination()->getToJunction() != myActiveRoute.front()->getToJunction()) {
1205  if (myActivePlan->back()->getDestinationStop() == nullptr || myActivePlan->back()->getDestinationStop()->getAccessPos(myActiveRoute.front()) < 0.) {
1206  throw ProcessError("Disconnected plan for person '" + myVehicleParameter->id + "' (" + myActiveRoute.front()->getID() + " not connected to " + myActivePlan->back()->getDestination()->getID() + ").");
1207  }
1208  }
1209  const double departPosLat = attrs.getOpt<double>(SUMO_ATTR_DEPARTPOS_LAT, nullptr, ok, 0);
1210  myActivePlan->push_back(new MSPerson::MSPersonStage_Walking(myVehicleParameter->id, myActiveRoute, bs, duration, speed, departPos, arrivalPos, departPosLat));
1211  myActiveRoute.clear();
1212  } catch (ProcessError&) {
1214  throw;
1215  }
1216 }
1217 
1218 
1219 void
1221 }
1222 
1223 
1224 void
1226 }
1227 
1228 
1229 void
1231 }
1232 
1233 
1234 void
1236 }
1237 
1238 
1239 void
1241 }
1242 
1243 /****************************************************************************/
MSVehicleType
The car-following model and parameter.
Definition: MSVehicleType.h:66
MSStoppingPlace::getLane
const MSLane & getLane() const
Returns the lane this stop is located at.
Definition: MSStoppingPlace.cpp:58
RandomDistributor::add
bool add(T val, double prob, bool checkDuplicates=true)
Adds a value with an assigned probability to the distribution.
Definition: RandomDistributor.h:71
SVC_PEDESTRIAN
pedestrian
Definition: SUMOVehicleClass.h:157
MSRoute::release
void release() const
deletes the route if there are no further references to it
Definition: MSRoute.cpp:101
MSNet::getStoppingPlace
MSStoppingPlace * getStoppingPlace(const std::string &id, const SumoXMLTag category) const
Returns the named stopping place of the given category.
Definition: MSNet.cpp:899
MSLane::dictionary
static bool dictionary(const std::string &id, MSLane *lane)
Static (sic!) container methods {.
Definition: MSLane.cpp:1855
MSVehicleType::getID
const std::string & getID() const
Returns the name of the vehicle type.
Definition: MSVehicleType.h:94
SUMOVehicleParameter::wasSet
bool wasSet(int what) const
Returns whether the given parameter was set.
Definition: SUMOVehicleParameter.h:306
SUMO_ATTR_DEPART
Definition: SUMOXMLDefinitions.h:432
MSEdge::getNumPredecessors
int getNumPredecessors() const
Returns the number of edges this edge is connected to.
Definition: MSEdge.h:344
MSStoppingPlace
A lane area vehicles can halt at.
Definition: MSStoppingPlace.h:60
SUMOSAXAttributes::hasAttribute
virtual bool hasAttribute(int id) const =0
Returns the information whether the named (by its enum-value) attribute is within the current list.
MSRouteHandler::myActivePlan
MSTransportable::MSTransportablePlan * myActivePlan
The plan of the current person.
Definition: MSRouteHandler.h:176
SUMOVehicleParameter::parametersSet
int parametersSet
Information for the router which parameter were set, TraCI may modify this (whe changing color)
Definition: SUMOVehicleParameter.h:650
SUMORouteHandler::myStartElement
virtual void myStartElement(int element, const SUMOSAXAttributes &attrs)
Called on the opening of a tag;.
Definition: SUMORouteHandler.cpp:92
WRITE_WARNING
#define WRITE_WARNING(msg)
Definition: MsgHandler.h:239
SUMO_ATTR_CONTAINER_STOP
Definition: SUMOXMLDefinitions.h:767
MSLane
Representation of a lane in the micro simulation.
Definition: MSLane.h:83
SUMOVehicleParameter::Stop::lane
std::string lane
The lane to stop at.
Definition: SUMOVehicleParameter.h:580
MSRouteHandler::closeContainer
void closeContainer()
Ends the processing of a container.
Definition: MSRouteHandler.cpp:795
MSVehicleControl::getVType
MSVehicleType * getVType(const std::string &id=DEFAULT_VTYPE_ID, std::mt19937 *rng=nullptr)
Returns the named vehicle type or a sample from the named distribution.
Definition: MSVehicleControl.cpp:348
SUMOVehicle::getParameter
virtual const SUMOVehicleParameter & getParameter() const =0
Returns the vehicle's parameter (including departure definition)
MSStoppingPlace::getEndLanePosition
double getEndLanePosition() const
Returns the end position of this stop.
Definition: MSStoppingPlace.cpp:70
SUMORouteHandler::parseStop
bool parseStop(SUMOVehicleParameter::Stop &stop, const SUMOSAXAttributes &attrs, std::string errorSuffix, MsgHandler *const errorOutput)
parses attributes common to all stops
Definition: SUMORouteHandler.cpp:357
NUMERICAL_EPS
#define NUMERICAL_EPS
Definition: config.h:145
MSRouteHandler::myAmLoadingState
bool myAmLoadingState
whether a state file is being loaded
Definition: MSRouteHandler.h:197
SUMOVehicleParserHelper.h
MSRouteHandler::myCurrentVTypeDistributionID
std::string myCurrentVTypeDistributionID
The id of the currently parsed vehicle type distribution.
Definition: MSRouteHandler.h:188
OptionsCont.h
StringTokenizer::hasNext
bool hasNext()
returns the information whether further substrings exist
Definition: StringTokenizer.cpp:95
MSGlobals::gStateLoaded
static bool gStateLoaded
Information whether a state has been loaded.
Definition: MSGlobals.h:88
MSRouteHandler::closeTrip
void closeTrip()
Ends the processing of a trip.
Definition: MSRouteHandler.cpp:869
MSNet::getContainerControl
virtual MSTransportableControl & getContainerControl()
Returns the container control.
Definition: MSNet.cpp:806
SUMOSAXAttributes::get
T get(int attr, const char *objectid, bool &ok, bool report=true) const
Tries to read given attribute assuming it is an int.
Definition: SUMOSAXAttributes.h:493
SUMOVehicleParameter::vtypeid
std::string vtypeid
The vehicle's type id.
Definition: SUMOVehicleParameter.h:468
SUMOVehicleParameter::departPosProcedure
DepartPosDefinition departPosProcedure
Information how the vehicle shall choose the departure position.
Definition: SUMOVehicleParameter.h:491
VEHPARS_FORCE_REROUTE
const int VEHPARS_FORCE_REROUTE
Definition: SUMOVehicleParameter.h:63
MSRouteHandler::myActiveContainerPlan
MSTransportable::MSTransportablePlan * myActiveContainerPlan
The plan of the current container.
Definition: MSRouteHandler.h:179
SUMOVehicleParameter::repetitionOffset
SUMOTime repetitionOffset
The time offset between vehicle reinsertions.
Definition: SUMOVehicleParameter.h:544
SUMO_TAG_CONTAINER_STOP
A container stop.
Definition: SUMOXMLDefinitions.h:106
MSRouteHandler::addPerson
void addPerson(const SUMOSAXAttributes &attrs)
Processing of a person.
Definition: MSRouteHandler.cpp:1220
MSStoppingPlace::getBeginLanePosition
double getBeginLanePosition() const
Returns the begin position of this stop.
Definition: MSStoppingPlace.cpp:64
SUMOVehicleParameter::Stop::busstop
std::string busstop
(Optional) bus stop if one is assigned to the stop
Definition: SUMOVehicleParameter.h:583
MSNet::getInsertionControl
MSInsertionControl & getInsertionControl()
Returns the insertion control.
Definition: MSNet.h:390
MSRouteHandler::~MSRouteHandler
virtual ~MSRouteHandler()
standard destructor
Definition: MSRouteHandler.cpp:60
MSRouteHandler::openVehicleTypeDistribution
void openVehicleTypeDistribution(const SUMOSAXAttributes &attrs)
opens a type distribution for reading
Definition: MSRouteHandler.cpp:325
SUMO_TAG_PERSON
Definition: SUMOXMLDefinitions.h:296
StringUtils::toDoubleSecure
static double toDoubleSecure(const std::string &sData, const double def)
converts a string into the integer value described by it
Definition: StringUtils.cpp:333
MSRouteHandler::openRoute
void openRoute(const SUMOSAXAttributes &attrs)
opens a route for reading
Definition: MSRouteHandler.cpp:367
MSTransportable::Stage
Definition: MSTransportable.h:74
SUMOTime
long long int SUMOTime
Definition: SUMOTime.h:35
MSRouteHandler::parseFromViaTo
void parseFromViaTo(std::string element, const SUMOSAXAttributes &attrs)
Called for parsing from and to and the corresponding taz attributes.
Definition: MSRouteHandler.cpp:84
SUMOVehicle
Representation of a vehicle.
Definition: SUMOVehicle.h:61
SUMO_ATTR_LINES
Definition: SUMOXMLDefinitions.h:773
MSRouteHandler::addRide
void addRide(const SUMOSAXAttributes &attrs)
Processing of a ride.
Definition: MSRouteHandler.cpp:1230
OptionsCont::getBool
bool getBool(const std::string &name) const
Returns the boolean-value of the named option (only for Option_Bool)
Definition: OptionsCont.cpp:223
SUMO_ATTR_COLOR
A color information.
Definition: SUMOXMLDefinitions.h:701
OptionsCont::getOptions
static OptionsCont & getOptions()
Retrieves the options.
Definition: OptionsCont.cpp:58
SUMOVehicleParameter::departProcedure
DepartDefinition departProcedure
Information how the vehicle shall choose the depart time.
Definition: SUMOVehicleParameter.h:479
MSRoute::setCosts
void setCosts(double costs)
Sets the costs of the route.
Definition: MSRoute.h:176
StringTokenizer::next
std::string next()
returns the next substring when it exists. Otherwise the behaviour is undefined
Definition: StringTokenizer.cpp:100
MSRouteHandler::openTrip
void openTrip(const SUMOSAXAttributes &attrs)
opens a trip for reading
Definition: MSRouteHandler.cpp:417
SUMO_ATTR_SPEED
Definition: SUMOXMLDefinitions.h:385
SUMO_ATTR_ARRIVALPOS
Definition: SUMOXMLDefinitions.h:438
SUMO_ATTR_ID
Definition: SUMOXMLDefinitions.h:379
SUMOVehicleParameter::Stop::parkingarea
std::string parkingarea
(Optional) parking area if one is assigned to the stop
Definition: SUMOVehicleParameter.h:589
SUMOVehicleParameter
Structure representing possible vehicle parameter.
Definition: SUMOVehicleParameter.h:291
MSEdge.h
SUMO_ATTR_LANE
Definition: SUMOXMLDefinitions.h:635
MSTransportable
Definition: MSTransportable.h:59
MSInsertionControl.h
SUMOVehicleParameter::parsePersonModes
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.
Definition: SUMOVehicleParameter.cpp:523
SUMO_ATTR_ENDPOS
Definition: SUMOXMLDefinitions.h:795
MSRouteHandler::closeVType
void closeVType()
Ends the processing of a vehicle type.
Definition: MSRouteHandler.cpp:778
SUMO_TAG_CONTAINER
Definition: SUMOXMLDefinitions.h:317
MSRouteHandler::closeRoute
void closeRoute(const bool mayBeDisconnected=false)
closes (ends) the building of a route.
Definition: MSRouteHandler.cpp:423
SUMO_ATTR_COST
Definition: SUMOXMLDefinitions.h:625
MSRouteHandler::openRouteDistribution
void openRouteDistribution(const SUMOSAXAttributes &attrs)
opens a route distribution for reading
Definition: MSRouteHandler.cpp:493
MSEdge::getLength
double getLength() const
return the length of the edge
Definition: MSEdge.h:582
SUMORouteHandler::myHardFail
const bool myHardFail
flag to enable or disable hard fails
Definition: SUMORouteHandler.h:193
MSRoute
Definition: MSRoute.h:67
SUMOVehicleParameter::depart
SUMOTime depart
Definition: SUMOVehicleParameter.h:476
MSRouteHandler::addContainer
void addContainer(const SUMOSAXAttributes &attrs)
Processing of a container.
Definition: MSRouteHandler.cpp:1225
MSTransportable::Stage::getDestination
const MSEdge * getDestination() const
returns the destination edge
Definition: MSTransportable.cpp:58
SUMORouteHandler::myActiveRouteStops
std::vector< SUMOVehicleParameter::Stop > myActiveRouteStops
List of the stops on the parsed route.
Definition: SUMORouteHandler.h:217
SUMORouteHandler::checkStopPos
static bool checkStopPos(double &startPos, double &endPos, const double laneLength, const double minLength, const bool friendlyPos)
check start and end position of a stop
Definition: SUMORouteHandler.cpp:290
SUMO_ATTR_TO
Definition: SUMOXMLDefinitions.h:638
MAX2
T MAX2(T a, T b)
Definition: StdDefs.h:80
VEHPARS_ROUTE_SET
const int VEHPARS_ROUTE_SET
Definition: SUMOVehicleParameter.h:56
MSInsertionControl::computeRandomDepartOffset
SUMOTime computeRandomDepartOffset() const
compute (optional) random offset to the departure time
Definition: MSInsertionControl.cpp:352
DEFAULT_CONTAINER_TRANSHIP_SPEED
const double DEFAULT_CONTAINER_TRANSHIP_SPEED
MSVehicleControl::buildVehicle
virtual SUMOVehicle * buildVehicle(SUMOVehicleParameter *defs, const MSRoute *route, MSVehicleType *type, const bool ignoreStopErrors, const bool fromRouteFile=true)
Builds a vehicle, increases the number of built vehicles.
Definition: MSVehicleControl.cpp:103
SUMORouteHandler::myActiveRouteRefID
std::string myActiveRouteRefID
The id of the route the current route references to.
Definition: SUMORouteHandler.h:205
RGBColor
Definition: RGBColor.h:40
MSRouteHandler::closePersonFlow
void closePersonFlow()
Ends the processing of a personFlow.
Definition: MSRouteHandler.cpp:710
SUMORouteHandler::checkLastDepart
bool checkLastDepart()
Checks whether the route file is sorted by departure time if needed.
Definition: SUMORouteHandler.cpp:67
MSVehicleControl::addVehicle
virtual bool addVehicle(const std::string &id, SUMOVehicle *v)
Tries to insert the vehicle into the internal vehicle container.
Definition: MSVehicleControl.cpp:210
RandHelper::rand
static double rand(std::mt19937 *rng=0)
Returns a random real number in [0, 1)
Definition: RandHelper.h:60
MSVehicleControl::getVehicle
SUMOVehicle * getVehicle(const std::string &id) const
Returns the vehicle with the given id.
Definition: MSVehicleControl.cpp:235
SUMO_TAG_TRANSPORT
Definition: SUMOXMLDefinitions.h:318
SUMO_TAG_FLOW
a flow definitio nusing a from-to edges instead of a route (used by router)
Definition: SUMOXMLDefinitions.h:150
SUMO_ATTR_PROB
Definition: SUMOXMLDefinitions.h:627
SUMO_ATTR_STARTPOS
Definition: SUMOXMLDefinitions.h:794
SUMO_TAG_CHARGING_STATION
A Charging Station.
Definition: SUMOXMLDefinitions.h:112
MSTransportable::WAITING
Definition: MSTransportable.h:63
MSRouteHandler::myParsingRNG
static std::mt19937 myParsingRNG
A random number generator used to choose from vtype/route distributions and computing the speed facto...
Definition: MSRouteHandler.h:200
MSRouteHandler::myActiveRoute
ConstMSEdgeVector myActiveRoute
The current route.
Definition: MSRouteHandler.h:173
SVCPermissions
int SVCPermissions
bitset where each bit declares whether a certain SVC may use this edge/lane
Definition: SUMOVehicleClass.h:219
MSTransportableControl.h
TIME2STEPS
#define TIME2STEPS(x)
Definition: SUMOTime.h:59
SUMO_TAG_RIDE
Definition: SUMOXMLDefinitions.h:298
MSRouteHandler::deleteActivePlans
void deleteActivePlans()
delete already created MSTransportablePlans if error occurs before handing over responsibility to a M...
Definition: MSRouteHandler.cpp:64
MSRouteHandler::addTranship
void addTranship(const SUMOSAXAttributes &attrs)
Processing of a tranship.
Definition: MSRouteHandler.cpp:1240
SUMOVehicleParameter::Stop::until
SUMOTime until
The time at which the vehicle may continue its journey.
Definition: SUMOVehicleParameter.h:604
StringTokenizer
Definition: StringTokenizer.h:62
DEFAULT_VTYPE_ID
const std::string DEFAULT_VTYPE_ID
SUMO_ATTR_DEPARTPOS_LAT
Definition: SUMOXMLDefinitions.h:435
SUMORouteHandler::myActiveRouteColor
const RGBColor * myActiveRouteColor
The currently parsed route's color.
Definition: SUMORouteHandler.h:211
MSEdge::dictionary
static bool dictionary(const std::string &id, MSEdge *edge)
Inserts edge into the static dictionary Returns true if the key id isn't already in the dictionary....
Definition: MSEdge.cpp:804
SUMO_ATTR_REFID
Definition: SUMOXMLDefinitions.h:380
MSTransportableControl::buildPerson
virtual MSTransportable * buildPerson(const SUMOVehicleParameter *pars, MSVehicleType *vtype, MSTransportable::MSTransportablePlan *plan, std::mt19937 *rng) const
Builds a new person.
Definition: MSTransportableControl.cpp:311
MSRouteHandler::closeVehicle
virtual void closeVehicle()
Ends the processing of a vehicle (note: is virtual because is reimplemented in MSStateHandler)
Definition: MSRouteHandler.cpp:562
SUMORouteHandler::myCurrentCosts
double myCurrentCosts
The currently parsed route costs.
Definition: SUMORouteHandler.h:214
SVC_PASSENGER
vehicle is a passenger car (a "normal" car)
Definition: SUMOVehicleClass.h:160
MSRouteHandler::myCurrentRouteDistribution
RandomDistributor< const MSRoute * > * myCurrentRouteDistribution
The currently parsed distribution of routes (probability->route)
Definition: MSRouteHandler.h:191
SUMOVehicleParameter::id
std::string id
The vehicle's id.
Definition: SUMOVehicleParameter.h:462
SUMO_ATTR_ROUTE
Definition: SUMOXMLDefinitions.h:441
SUMO_ATTR_EDGES
the edges of a route
Definition: SUMOXMLDefinitions.h:428
SUMO_TAG_PARKING_AREA
A parking area.
Definition: SUMOXMLDefinitions.h:108
MSLane::getLength
double getLength() const
Returns the lane's length.
Definition: MSLane.h:541
MSRouteHandler::closeRouteDistribution
void closeRouteDistribution()
closes (ends) the building of a distribution
Definition: MSRouteHandler.cpp:540
SUMOVehicleParameter::repetitionProbability
double repetitionProbability
The probability for emitting a vehicle per second.
Definition: SUMOVehicleParameter.h:547
MSVehicleControl::deleteVehicle
virtual void deleteVehicle(SUMOVehicle *v, bool discard=false)
Deletes the vehicle.
Definition: MSVehicleControl.cpp:245
SUMOVehicleParameter::fromTaz
std::string fromTaz
The vehicle's origin zone (district)
Definition: SUMOVehicleParameter.h:558
ProcessError
Definition: UtilExceptions.h:40
MSRouteHandler::closeVehicleTypeDistribution
void closeVehicleTypeDistribution()
closes (ends) the building of a distribution
Definition: MSRouteHandler.cpp:347
MSRouteHandler::myCurrentVTypeDistribution
RandomDistributor< MSVehicleType * > * myCurrentVTypeDistribution
The currently parsed distribution of vehicle types (probability->vehicle type)
Definition: MSRouteHandler.h:185
SUMOVehicleParameter::repetitionsDone
int repetitionsDone
The number of times the vehicle was already inserted.
Definition: SUMOVehicleParameter.h:541
MSEdge
A road/street connecting two junctions.
Definition: MSEdge.h:76
SUMO_ATTR_INTENDED
Definition: SUMOXMLDefinitions.h:775
SUMOVehicleParameter::Stop::endPos
double endPos
The stopping position end.
Definition: SUMOVehicleParameter.h:598
MSInsertionControl::add
void add(SUMOVehicle *veh)
Adds a single vehicle for departure.
Definition: MSInsertionControl.cpp:71
MSEdge::getToJunction
const MSJunction * getToJunction() const
Definition: MSEdge.h:361
SUMO_ATTR_PROBS
Definition: SUMOXMLDefinitions.h:628
SUMOSAXAttributes::getOpt
T getOpt(int attr, const char *objectid, bool &ok, T defaultValue, bool report=true) const
Tries to read given attribute assuming it is an int.
Definition: SUMOSAXAttributes.h:519
DEPART_POS_RANDOM
The position is chosen randomly.
Definition: SUMOVehicleParameter.h:142
MSGlobals::gCheckRoutes
static bool gCheckRoutes
Definition: MSGlobals.h:79
SUMORouteHandler::myActiveRouteProbability
double myActiveRouteProbability
The probability of the current route.
Definition: SUMORouteHandler.h:208
RandomDistributor::getProbs
const std::vector< double > & getProbs() const
Returns the probabilities assigned to the members of the distribution.
Definition: RandomDistributor.h:160
MSVehicleControl::getQuota
int getQuota(double frac=-1) const
Returns the number of instances of the current vehicle that shall be emitted considering that "frac" ...
Definition: MSVehicleControl.cpp:473
SUMOVehicleParameter::routeid
std::string routeid
The vehicle's route id.
Definition: SUMOVehicleParameter.h:465
MSContainer::MSContainerStage_Driving
Definition: MSContainer.h:70
SUMORouteHandler::myVehicleParameter
SUMOVehicleParameter * myVehicleParameter
Parameter of the current vehicle, trip, person, container or flow.
Definition: SUMORouteHandler.h:196
SUMO_ATTR_FRIENDLY_POS
Definition: SUMOXMLDefinitions.h:762
string2time
SUMOTime string2time(const std::string &r)
Definition: SUMOTime.cpp:42
MSRouteHandler::myCurrentRouteDistributionID
std::string myCurrentRouteDistributionID
The id of the currently parsed route distribution.
Definition: MSRouteHandler.h:194
MSRouteHandler::MSRouteHandler
MSRouteHandler(const std::string &file, bool addVehiclesDirectly)
standard constructor
Definition: MSRouteHandler.cpp:48
MSTransportable::Stage::getArrivalPos
double getArrivalPos() const
Definition: MSTransportable.h:95
SUMO_ATTR_POSITION
Definition: SUMOXMLDefinitions.h:658
RandomDistributor< MSVehicleType * >
MSTransportable::Stage_Waiting
Definition: MSTransportable.h:350
SUMO_ATTR_FROM
Definition: SUMOXMLDefinitions.h:637
SUMOVehicleParameter::Stop::startPos
double startPos
The stopping position start.
Definition: SUMOVehicleParameter.h:595
SUMORouteHandler::registerLastDepart
void registerLastDepart()
save last depart (only to be used if vehicle is not discarded)
Definition: SUMORouteHandler.cpp:79
MSLane::getEdge
MSEdge & getEdge() const
Returns the lane's edge.
Definition: MSLane.h:670
SUMOVehicleParameter::repetitionEnd
SUMOTime repetitionEnd
The time at which the flow ends (only needed when using repetitionProbability)
Definition: SUMOVehicleParameter.h:550
OptionsCont::getFloat
double getFloat(const std::string &name) const
Returns the double-value of the named option (only for Option_Float)
Definition: OptionsCont.cpp:209
toString
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:48
StringUtils.h
SUMO_TAG_BUS_STOP
A bus stop.
Definition: SUMOXMLDefinitions.h:98
MSRouteHandler::myStartElement
virtual void myStartElement(int element, const SUMOSAXAttributes &attrs)
Called on the opening of a tag;.
Definition: MSRouteHandler.cpp:133
MSRouteHandler::closePerson
void closePerson()
Ends the processing of a person.
Definition: MSRouteHandler.cpp:677
MSTransportable::MSTransportablePlan
std::vector< MSTransportable::Stage * > MSTransportablePlan
the structure holding the plan of a transportable
Definition: MSTransportable.h:588
SUMO_ATTR_DURATION
Definition: SUMOXMLDefinitions.h:665
SUMO_TAG_TRANSHIP
Definition: SUMOXMLDefinitions.h:319
SUMO_ATTR_VIA
Definition: SUMOXMLDefinitions.h:720
MSNet::getInstance
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
Definition: MSNet.cpp:168
SUMOSAXAttributes::getOptSUMOTimeReporting
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.
Definition: SUMOSAXAttributes.cpp:91
MSNet::getPersonControl
virtual MSTransportableControl & getPersonControl()
Returns the person control.
Definition: MSNet.cpp:798
SUMOVehicleParameter::via
std::vector< std::string > via
List of the via-edges the vehicle must visit.
Definition: SUMOVehicleParameter.h:641
MSPerson::MSPersonStage_Driving
Definition: MSPerson.h:246
SUMO_ATTR_VTYPES
Definition: SUMOXMLDefinitions.h:630
MSVehicleType::build
static MSVehicleType * build(SUMOVTypeParameter &from)
Builds the microsim vehicle type described by the given parameter.
Definition: MSVehicleType.cpp:282
VEHPARS_DEPARTPOS_SET
const int VEHPARS_DEPARTPOS_SET
Definition: SUMOVehicleParameter.h:49
InvalidArgument
Definition: UtilExceptions.h:57
MSVehicleType::wasSet
bool wasSet(int what) const
Returns whether the given parameter was set.
Definition: MSVehicleType.h:83
VEHPARS_FROM_TAZ_SET
const int VEHPARS_FROM_TAZ_SET
Definition: SUMOVehicleParameter.h:61
MSPerson::MSPersonStage_Walking
Definition: MSPerson.h:71
DEPART_GIVEN
The time is given.
Definition: SUMOVehicleParameter.h:96
MSTransportable::Stage_Trip
Definition: MSTransportable.h:233
SUMO_ATTR_ROUTES
Definition: SUMOXMLDefinitions.h:629
MSRouteHandler::addFlowPerson
void addFlowPerson(SUMOTime depart, MSVehicleType *type, const std::string &baseID, int i)
delete already created MSTransportablePlans if error occurs before handing over responsibility to a M...
Definition: MSRouteHandler.cpp:755
MSStoppingPlace::getAccessPos
double getAccessPos(const MSEdge *edge) const
the position on the given edge which is connected to this stop, -1 on failure
Definition: MSStoppingPlace.cpp:231
MSEdge::parseEdgesList
static void parseEdgesList(const std::string &desc, ConstMSEdgeVector &into, const std::string &rid)
Parses the given string assuming it contains a list of edge ids divided by spaces.
Definition: MSEdge.cpp:861
MSRouteHandler::addPersonTrip
void addPersonTrip(const SUMOSAXAttributes &attrs)
add a routing request for a walking or intermodal person
Definition: MSRouteHandler.cpp:1101
SUMO_ATTR_MODES
Definition: SUMOXMLDefinitions.h:651
MSEdge::getLanes
const std::vector< MSLane * > & getLanes() const
Returns this edge's lanes.
Definition: MSEdge.h:165
SUMOVehicleParserHelper::parseWalkPos
static double parseWalkPos(SumoXMLAttr attr, const bool hardFail, const std::string &id, double maxPos, const std::string &val, std::mt19937 *rng=0)
parse departPos or arrivalPos for a walk
Definition: SUMOVehicleParserHelper.cpp:1366
MSRouteHandler::myAddVehiclesDirectly
bool myAddVehiclesDirectly
Information whether vehicles shall be directly added to the network or kept within the buffer.
Definition: MSRouteHandler.h:182
MSVehicleType::getMaxSpeed
double getMaxSpeed() const
Get vehicle's maximum speed [m/s].
Definition: MSVehicleType.h:162
VEHPARS_TO_TAZ_SET
const int VEHPARS_TO_TAZ_SET
Definition: SUMOVehicleParameter.h:62
GenericSAXHandler::error
void error(const XERCES_CPP_NAMESPACE::SAXParseException &exception)
Handler for XML-errors.
Definition: GenericSAXHandler.cpp:206
SUMORouteHandler
Parser for routes during their loading.
Definition: SUMORouteHandler.h:51
MSEdge::getNumSuccessors
int getNumSuccessors() const
Returns the number of edges that may be reached from this edge.
Definition: MSEdge.h:322
StringTokenizer::getVector
std::vector< std::string > getVector()
return vector of strings
Definition: StringTokenizer.cpp:192
MSRouteHandler::addWalk
void addWalk(const SUMOSAXAttributes &attrs)
add a fully specified walk
Definition: MSRouteHandler.cpp:1163
MSRoute::dictionary
static bool dictionary(const std::string &id, const MSRoute *route)
Adds a route to the dictionary.
Definition: MSRoute.cpp:114
config.h
MSVehicleControl
The class responsible for building and deletion of vehicles.
Definition: MSVehicleControl.h:72
SUMO_TAG_PERSONFLOW
Definition: SUMOXMLDefinitions.h:300
MSRouteHandler::closeFlow
void closeFlow()
Ends the processing of a flow.
Definition: MSRouteHandler.cpp:823
StringTokenizer.h
MSTransportable::Stage::getDestinationStop
MSStoppingPlace * getDestinationStop() const
returns the destination stop (if any)
Definition: MSTransportable.h:86
SUMORouteHandler::myCurrentVType
SUMOVTypeParameter * myCurrentVType
The currently parsed vehicle type.
Definition: SUMORouteHandler.h:220
SUMO_ATTR_DEPARTPOS
Definition: SUMOXMLDefinitions.h:434
SUMOVehicleParameter::toTaz
std::string toTaz
The vehicle's destination zone (district)
Definition: SUMOVehicleParameter.h:561
MSContainer::MSContainerStage_Tranship
Definition: MSContainer.h:108
MSRouteHandler::addTransport
void addTransport(const SUMOSAXAttributes &attrs)
Processing of a transport.
Definition: MSRouteHandler.cpp:1235
SUMOTime_MAX
#define SUMOTime_MAX
Definition: SUMOTime.h:36
MSRoute::addReference
void addReference() const
increments the reference counter for the route
Definition: MSRoute.cpp:95
MSTransportableControl::buildContainer
virtual MSTransportable * buildContainer(const SUMOVehicleParameter *pars, MSVehicleType *vtype, MSTransportable::MSTransportablePlan *plan) const
Builds a new container.
Definition: MSTransportableControl.cpp:319
MsgHandler::getErrorInstance
static MsgHandler * getErrorInstance()
Returns the instance to add errors to.
Definition: MsgHandler.cpp:81
SUMOVehicleParameter::Stop::duration
SUMOTime duration
The stopping duration.
Definition: SUMOVehicleParameter.h:601
SUMOVehicleParameter::repetitionNumber
int repetitionNumber
Definition: SUMOVehicleParameter.h:538
MSVehicleType::getVehicleClass
SUMOVehicleClass getVehicleClass() const
Get this vehicle type's vehicle class.
Definition: MSVehicleType.h:185
SUMO_ATTR_BUS_STOP
Definition: SUMOXMLDefinitions.h:766
MSRouteHandler::openFlow
void openFlow(const SUMOSAXAttributes &attrs)
opens a flow for reading
Definition: MSRouteHandler.cpp:411
SUMOVehicleParameter::stops
std::vector< Stop > stops
List of the stops the vehicle will make, TraCI may add entries here.
Definition: SUMOVehicleParameter.h:638
RandomDistributor::getOverallProb
double getOverallProb() const
Return the sum of the probabilites assigned to the members.
Definition: RandomDistributor.h:131
MSVehicleType::getDefaultProbability
double getDefaultProbability() const
Get the default probability of this vehicle type.
Definition: MSVehicleType.h:176
MSRouteHandler.h
SUMOSAXAttributes
Encapsulated SAX-Attributes.
Definition: SUMOSAXAttributes.h:57
SUMO_ATTR_ACTTYPE
Definition: SUMOXMLDefinitions.h:871
SUMOVehicleParameter::Stop::chargingStation
std::string chargingStation
(Optional) charging station if one is assigned to the stop
Definition: SUMOVehicleParameter.h:592
MSVehicleControl.h
SUMO_ATTR_WALKFACTOR
Definition: SUMOXMLDefinitions.h:652
Named::getID
const std::string & getID() const
Returns the id.
Definition: Named.h:77
DEFAULT_VEH_PROB
const double DEFAULT_VEH_PROB
POSITION_EPS
#define POSITION_EPS
Definition: config.h:169
SUMOVehicleParameter::Stop::containerstop
std::string containerstop
(Optional) container stop if one is assigned to the stop
Definition: SUMOVehicleParameter.h:586
WRITE_ERROR
#define WRITE_ERROR(msg)
Definition: MsgHandler.h:245
MIN_STOP_LENGTH
const double MIN_STOP_LENGTH
Definition: SUMOVehicleParameter.h:84
SUMORouteHandler::myActiveRouteID
std::string myActiveRouteID
The id of the current route.
Definition: SUMORouteHandler.h:202
MSRouteHandler::addStop
void addStop(const SUMOSAXAttributes &attrs)
Processing of a stop.
Definition: MSRouteHandler.cpp:877
VTYPEPARS_MAXSPEED_SET
const int VTYPEPARS_MAXSPEED_SET
Definition: SUMOVTypeParameter.h:48
SUMORouteHandler::myInsertStopEdgesAt
int myInsertStopEdgesAt
where stop edges can be inserted into the current route (-1 means no insertion)
Definition: SUMORouteHandler.h:238
SUMOVehicleParameter::interpretEdgePos
static double interpretEdgePos(double pos, double maximumValue, SumoXMLAttr attr, const std::string &id)
Interprets negative edge positions and fits them onto a given edge.
Definition: SUMOVehicleParameter.cpp:510
MSNet::getVehicleControl
MSVehicleControl & getVehicleControl()
Returns the vehicle control.
Definition: MSNet.h:337
SUMOVehicleParameter::departPos
double departPos
(optional) The position the vehicle shall depart from
Definition: SUMOVehicleParameter.h:488
SUMO_TAG_TRIP
a single trip definition (used by router)
Definition: SUMOXMLDefinitions.h:146
MSRouteHandler::parseWalkPositions
void parseWalkPositions(const SUMOSAXAttributes &attrs, const std::string &personID, const MSEdge *fromEdge, const MSEdge *&toEdge, double &departPos, double &arrivalPos, MSStoppingPlace *&bs, const MSTransportable::Stage *const lastStage, bool &ok)
@ brief parse depart- and arrival positions of a walk
Definition: MSRouteHandler.cpp:1045
SUMOVehicleParameter::Stop
Definition of vehicle stop (position and duration)
Definition: SUMOVehicleParameter.h:566