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