SUMO - Simulation of Urban MObility
MSRouteHandler.cpp
Go to the documentation of this file.
1 /****************************************************************************/
10 // Parser and container for routes during their loading
11 /****************************************************************************/
12 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
13 // Copyright (C) 2001-2015 DLR (http://www.dlr.de/) and contributors
14 /****************************************************************************/
15 //
16 // This file is part of SUMO.
17 // SUMO is free software: you can redistribute it and/or modify
18 // it under the terms of the GNU General Public License as published by
19 // the Free Software Foundation, either version 3 of the License, or
20 // (at your option) any later version.
21 //
22 /****************************************************************************/
23 
24 
25 // ===========================================================================
26 // included modules
27 // ===========================================================================
28 #ifdef _MSC_VER
29 #include <windows_config.h>
30 #else
31 #include <config.h>
32 #endif
33 
34 #include <string>
35 #include <map>
36 #include <vector>
37 #include <microsim/MSRoute.h>
38 #include <microsim/MSEdge.h>
39 #include <microsim/MSJunction.h>
40 #include <microsim/MSVehicleType.h>
41 #include <microsim/MSVehicle.h>
44 #include <microsim/MSLane.h>
45 #include "MSRouteHandler.h"
46 #include "MSPersonControl.h"
47 #include "MSContainerControl.h"
55 #include "MSNet.h"
56 
58 #include <microsim/MSGlobals.h>
60 
61 #ifdef CHECK_MEMORY_LEAKS
62 #include <foreign/nvwa/debug_new.h>
63 #endif // CHECK_MEMORY_LEAKS
64 
65 
66 // ===========================================================================
67 // static members
68 // ===========================================================================
70 
71 
72 // ===========================================================================
73 // method definitions
74 // ===========================================================================
75 MSRouteHandler::MSRouteHandler(const std::string& file,
76  bool addVehiclesDirectly) :
77  SUMORouteHandler(file),
78  myActivePlan(0),
79  myActiveContainerPlan(0),
80  myAddVehiclesDirectly(addVehiclesDirectly),
81  myCurrentVTypeDistribution(0),
82  myCurrentRouteDistribution(0) {
83  myActiveRoute.reserve(100);
84 }
85 
86 
88 }
89 
90 
91 void
92 MSRouteHandler::parseFromViaTo(std::string element,
93  const SUMOSAXAttributes& attrs) {
94  myActiveRoute.clear();
95  bool useTaz = OptionsCont::getOptions().getBool("with-taz");
97  WRITE_WARNING("Taz usage was requested but no taz present in " + element + " '" + myVehicleParameter->id + "'!");
98  useTaz = false;
99  }
100  bool ok = true;
102  const MSEdge* fromTaz = MSEdge::dictionary(myVehicleParameter->fromTaz + "-source");
103  if (fromTaz == 0) {
104  throw ProcessError("Source taz '" + myVehicleParameter->fromTaz + "' not known for " + element + " '" + myVehicleParameter->id + "'!");
105  } else if (fromTaz->getNumSuccessors() == 0) {
106  throw ProcessError("Source taz '" + myVehicleParameter->fromTaz + "' has no outgoing edges for " + element + " '" + myVehicleParameter->id + "'!");
107  } else {
108  myActiveRoute.push_back(fromTaz);
109  }
110  } else {
111  MSEdge::parseEdgesList(attrs.getOpt<std::string>(SUMO_ATTR_FROM, myVehicleParameter->id.c_str(), ok, "", true),
112  myActiveRoute, "for " + element + " '" + myVehicleParameter->id + "'");
113  }
114  if (!attrs.hasAttribute(SUMO_ATTR_VIA) && !attrs.hasAttribute(SUMO_ATTR_ROUTE)) {
115  myInsertStopEdgesAt = (int)myActiveRoute.size();
116  }
117  MSEdge::parseEdgesList(attrs.getOpt<std::string>(SUMO_ATTR_VIA, myVehicleParameter->id.c_str(), ok, "", true),
118  myActiveRoute, "for " + element + " '" + myVehicleParameter->id + "'");
120  const MSEdge* toTaz = MSEdge::dictionary(myVehicleParameter->toTaz + "-sink");
121  if (toTaz == 0) {
122  throw ProcessError("Sink taz '" + myVehicleParameter->toTaz + "' not known for " + element + " '" + myVehicleParameter->id + "'!");
123  } else if (toTaz->getNumPredecessors() == 0) {
124  throw ProcessError("Sink taz '" + myVehicleParameter->toTaz + "' has no incoming edges for " + element + " '" + myVehicleParameter->id + "'!");
125  } else {
126  myActiveRoute.push_back(toTaz);
127  }
128  } else {
129  MSEdge::parseEdgesList(attrs.getOpt<std::string>(SUMO_ATTR_TO, myVehicleParameter->id.c_str(), ok, "", true),
130  myActiveRoute, "for " + element + " '" + myVehicleParameter->id + "'");
131  }
133  if (myVehicleParameter->routeid == "") {
135  }
136 }
137 
138 
139 void
141  const SUMOSAXAttributes& attrs) {
142  SUMORouteHandler::myStartElement(element, attrs);
143  switch (element) {
144  case SUMO_TAG_PERSON:
146  break;
147  case SUMO_TAG_CONTAINER:
149  break;
150  case SUMO_TAG_RIDE: {
151  const std::string pid = myVehicleParameter->id;
152  bool ok = true;
153  MSEdge* from = 0;
154  const std::string desc = attrs.get<std::string>(SUMO_ATTR_LINES, pid.c_str(), ok);
155  StringTokenizer st(desc);
156  std::string bsID = attrs.getOpt<std::string>(SUMO_ATTR_BUS_STOP, 0, ok, "");
157  MSStoppingPlace* bs = 0;
158  MSEdge* to = 0;
159  if (bsID != "") {
160  bs = MSNet::getInstance()->getBusStop(bsID);
161  if (bs == 0) {
162  throw ProcessError("Unknown bus stop '" + bsID + "' for person '" + myVehicleParameter->id + "'.");
163  }
164  to = &bs->getLane().getEdge();
165  }
166  if (attrs.hasAttribute(SUMO_ATTR_FROM)) {
167  const std::string fromID = attrs.get<std::string>(SUMO_ATTR_FROM, pid.c_str(), ok);
168  from = MSEdge::dictionary(fromID);
169  if (from == 0) {
170  throw ProcessError("The from edge '" + fromID + "' within a ride of person '" + pid + "' is not known.");
171  }
172  if (!myActivePlan->empty() && &myActivePlan->back()->getDestination() != from) {
173  throw ProcessError("Disconnected plan for person '" + myVehicleParameter->id + "' (" + fromID + "!=" + myActivePlan->back()->getDestination().getID() + ").");
174  }
175  if (myActivePlan->empty()) {
177  *from, -1, myVehicleParameter->depart, myVehicleParameter->departPos, "start"));
178  }
179  } else if (myActivePlan->empty()) {
180  throw ProcessError("The start edge within for person '" + pid + "' is not known.");
181  }
182  if (to == 0) {
183  const std::string toID = attrs.get<std::string>(SUMO_ATTR_TO, pid.c_str(), ok);
184  to = MSEdge::dictionary(toID);
185  if (to == 0) {
186  throw ProcessError("The to edge '" + toID + "' within a ride of person '" + pid + "' is not known.");
187  }
188  }
189  myActivePlan->push_back(new MSPerson::MSPersonStage_Driving(*to, bs, -NUMERICAL_EPS, st.getVector()));
190  break;
191  }
192  case SUMO_TAG_WALK: {
193  myActiveRoute.clear();
194  bool ok = true;
195  const SUMOTime duration = attrs.getOptSUMOTimeReporting(SUMO_ATTR_DURATION, 0, ok, -1);
196  if (attrs.hasAttribute(SUMO_ATTR_DURATION) && duration <= 0) {
197  throw ProcessError("Non-positive walking duration for '" + myVehicleParameter->id + "'.");
198  }
201  // need to check for explicitly set speed since we might have // DEFAULT_VEHTYPE
202  if (vtype != 0 && vtype->wasSet(VTYPEPARS_MAXSPEED_SET)) {
203  speed = vtype->getMaxSpeed();
204  }
205  speed = attrs.getOpt<SUMOReal>(SUMO_ATTR_SPEED, 0, ok, speed);
206  if (speed <= 0) {
207  throw ProcessError("Non-positive walking speed for '" + myVehicleParameter->id + "'.");
208  }
209  SUMOReal departPos = 0;
210  SUMOReal arrivalPos = 0;
211  MSStoppingPlace* bs = 0;
212  if (attrs.hasAttribute(SUMO_ATTR_EDGES)) {
214  parseWalkPositions(attrs, myVehicleParameter->id, myActiveRoute.front(), myActiveRoute.back(), departPos, arrivalPos, bs, ok);
215  } else {
216  const std::string fromID = attrs.getOpt<std::string>(SUMO_ATTR_FROM, myVehicleParameter->id.c_str(), ok, "");
217  const MSEdge* from = fromID != "" || myActivePlan->empty() ? MSEdge::dictionary(fromID) : &myActivePlan->back()->getDestination();
218  if (from == 0) {
219  throw ProcessError("The from edge '" + fromID + "' within a walk of person '" + myVehicleParameter->id + "' is not known.");
220  }
221  const std::string toID = attrs.getOpt<std::string>(SUMO_ATTR_TO, myVehicleParameter->id.c_str(), ok, "");
222  const MSEdge* to = MSEdge::dictionary(toID);
223  if (toID != "" && to == 0) {
224  throw ProcessError("The to edge '" + toID + "' within a walk of person '" + myVehicleParameter->id + "' is not known.");
225  }
226  parseWalkPositions(attrs, myVehicleParameter->id, from, to, departPos, arrivalPos, bs, ok);
227  MSNet::getInstance()->getPedestrianRouter().compute(from, to, departPos, arrivalPos,
228  speed, 0, 0, myActiveRoute);
229  if (myActiveRoute.empty()) {
230  const std::string error = "No connection found between '" + from->getID() + "' and '" + to->getID() + "' for person '" + myVehicleParameter->id + "'.";
232  myActiveRoute.push_back(from);
233  myActiveRoute.push_back(to); // pedestrian will teleport
234  //WRITE_WARNING(error);
235  } else {
236  throw ProcessError(error);
237  }
238  }
239  //std::cout << myVehicleParameter->id << " edges=" << toString(myActiveRoute) << "\n";
240  }
241  if (myActiveRoute.empty()) {
242  throw ProcessError("No edges to walk for person '" + myVehicleParameter->id + "'.");
243  }
244  if (!myActivePlan->empty() && &myActivePlan->back()->getDestination() != myActiveRoute.front()) {
245  throw ProcessError("Disconnected plan for person '" + myVehicleParameter->id + "' (" + myActiveRoute.front()->getID() + "!=" + myActivePlan->back()->getDestination().getID() + ").");
246  }
247  if (myActivePlan->empty()) {
249  *myActiveRoute.front(), -1, myVehicleParameter->depart, departPos, "start"));
250  }
251  myActivePlan->push_back(new MSPerson::MSPersonStage_Walking(myActiveRoute, bs, duration, speed, departPos, arrivalPos));
252  myActiveRoute.clear();
253  break;
254  }
255  case SUMO_TAG_TRANSPORT: {
256  const std::string containerId = myVehicleParameter->id;
257  bool ok = true;
258  MSEdge* from = 0;
259  const std::string desc = attrs.get<std::string>(SUMO_ATTR_LINES, containerId.c_str(), ok);
260  StringTokenizer st(desc);
261  std::string csID = attrs.getOpt<std::string>(SUMO_ATTR_CONTAINER_STOP, 0, ok, "");
262  MSStoppingPlace* cs = 0;
263  if (csID != "") {
264  cs = MSNet::getInstance()->getContainerStop(csID);
265  if (cs == 0) {
266  throw ProcessError("Unknown container stop '" + csID + "' for container '" + myVehicleParameter->id + "'.");
267  }
268  }
269  if (attrs.hasAttribute(SUMO_ATTR_FROM)) {
270  const std::string fromID = attrs.get<std::string>(SUMO_ATTR_FROM, containerId.c_str(), ok);
271  from = MSEdge::dictionary(fromID);
272  if (from == 0) {
273  throw ProcessError("The from edge '" + fromID + "' within a transport of container '" + containerId + "' is not known.");
274  }
275  if (!myActiveContainerPlan->empty() && &myActiveContainerPlan->back()->getDestination() != from) {
276  throw ProcessError("Disconnected plan for container '" + myVehicleParameter->id + "' (" + fromID + "!=" + myActiveContainerPlan->back()->getDestination().getID() + ").");
277  }
278  if (myActiveContainerPlan->empty()) {
280  *from, -1, myVehicleParameter->depart, myVehicleParameter->departPos, "start"));
281  }
282  } else if (myActiveContainerPlan->empty()) {
283  throw ProcessError("The start edge within a transport of container '" + containerId + "' is not known.");
284  }
285  const std::string toID = attrs.get<std::string>(SUMO_ATTR_TO, containerId.c_str(), ok);
286  MSEdge* to = MSEdge::dictionary(toID);
287  if (to == 0) {
288  throw ProcessError("The to edge '" + toID + "' within a transport of container '" + containerId + "' is not known.");
289  }
290  myActiveContainerPlan->push_back(new MSContainer::MSContainerStage_Driving(*to, cs, -NUMERICAL_EPS, st.getVector()));
291  break;
292  }
293  case SUMO_TAG_TRANSHIP: {
294  myActiveRoute.clear();
295  bool ok = true;
296  SUMOReal departPos = attrs.getOpt<SUMOReal>(SUMO_ATTR_DEPARTPOS, myVehicleParameter->id.c_str(), ok, 0);
297  SUMOReal arrivalPos = attrs.getOpt<SUMOReal>(SUMO_ATTR_ARRIVALPOS, myVehicleParameter->id.c_str(), ok, -NUMERICAL_EPS);
300  // need to check for explicitly set speed since we might have // DEFAULT_VEHTYPE
301  if (vtype != 0 && vtype->wasSet(VTYPEPARS_MAXSPEED_SET)) {
302  speed = vtype->getMaxSpeed();
303  }
304  speed = attrs.getOpt<SUMOReal>(SUMO_ATTR_SPEED, 0, ok, speed);
305  if (speed <= 0) {
306  throw ProcessError("Non-positive tranship speed for container '" + myVehicleParameter->id + "'.");
307  }
308  std::string csID = attrs.getOpt<std::string>(SUMO_ATTR_CONTAINER_STOP, 0, ok, "");
309  MSStoppingPlace* cs = 0;
310  if (csID != "") {
311  cs = MSNet::getInstance()->getContainerStop(csID);
312  if (cs == 0) {
313  throw ProcessError("Unknown container stop '" + csID + "' for container '" + myVehicleParameter->id + "'.");
314  }
315  arrivalPos = cs->getEndLanePosition();
316  }
317  if (attrs.hasAttribute(SUMO_ATTR_EDGES)) {
319  } else {
320  if (attrs.hasAttribute(SUMO_ATTR_FROM) && attrs.hasAttribute(SUMO_ATTR_TO)) {
321  const std::string fromID = attrs.get<std::string>(SUMO_ATTR_FROM, myVehicleParameter->id.c_str(), ok);
322  MSEdge* from = MSEdge::dictionary(fromID);
323  if (from == 0) {
324  throw ProcessError("The from edge '" + fromID + "' within a tranship of container '" + myVehicleParameter->id + "' is not known.");
325  }
326  const std::string toID = attrs.get<std::string>(SUMO_ATTR_TO, myVehicleParameter->id.c_str(), ok);
327  MSEdge* to = MSEdge::dictionary(toID);
328  if (to == 0) {
329  throw ProcessError("The to edge '" + toID + "' within a tranship of container '" + myVehicleParameter->id + "' is not known.");
330  }
331  //the route of the container's tranship stage consists only of the 'from' and the 'to' edge
332  myActiveRoute.push_back(from);
333  myActiveRoute.push_back(to);
334  if (myActiveRoute.empty()) {
335  const std::string error = "No connection found between '" + from->getID() + "' and '" + to->getID() + "' for container '" + myVehicleParameter->id + "'.";
337  myActiveRoute.push_back(from);
338  } else {
339  WRITE_ERROR(error);
340  }
341  }
342  }
343  }
344  if (myActiveRoute.empty()) {
345  throw ProcessError("No edges to tranship container '" + myVehicleParameter->id + "'.");
346  }
347  if (!myActiveContainerPlan->empty() && &myActiveContainerPlan->back()->getDestination() != myActiveRoute.front()) {
348  throw ProcessError("Disconnected plan for container '" + myVehicleParameter->id + "' (" + myActiveRoute.front()->getID() + "!=" + myActiveContainerPlan->back()->getDestination().getID() + ").");
349  }
350  if (myActiveContainerPlan->empty()) {
352  *myActiveRoute.front(), -1, myVehicleParameter->depart, departPos, "start"));
353  }
354  myActiveContainerPlan->push_back(new MSContainer::MSContainerStage_Tranship(myActiveRoute, cs, speed, departPos, arrivalPos));
355  myActiveRoute.clear();
356  break;
357  }
358  case SUMO_TAG_FLOW:
359  parseFromViaTo("flow", attrs);
360  break;
361  case SUMO_TAG_TRIP:
362  parseFromViaTo("trip", attrs);
363  break;
364  default:
365  break;
366  }
367  // parse embedded vtype information
368  if (myCurrentVType != 0 && element != SUMO_TAG_VTYPE && element != SUMO_TAG_PARAM) {
370  return;
371  }
372 }
373 
374 
375 void
377  bool ok = true;
378  myCurrentVTypeDistributionID = attrs.get<std::string>(SUMO_ATTR_ID, 0, ok);
379  if (ok) {
381  if (attrs.hasAttribute(SUMO_ATTR_VTYPES)) {
382  const std::string vTypes = attrs.get<std::string>(SUMO_ATTR_VTYPES, myCurrentVTypeDistributionID.c_str(), ok);
383  StringTokenizer st(vTypes);
384  while (st.hasNext()) {
385  std::string vtypeID = st.next();
387  if (type == 0) {
388  throw ProcessError("Unknown vtype '" + vtypeID + "' in distribution '" + myCurrentVTypeDistributionID + "'.");
389  }
391  }
392  }
393  }
394 }
395 
396 
397 void
399  if (myCurrentVTypeDistribution != 0) {
400  if (MSGlobals::gStateLoaded && MSNet::getInstance()->getVehicleControl().hasVTypeDistribution(myCurrentVTypeDistributionID)) {
402  return;
403  }
406  throw ProcessError("Vehicle type distribution '" + myCurrentVTypeDistributionID + "' is empty.");
407  }
408  if (!MSNet::getInstance()->getVehicleControl().addVTypeDistribution(myCurrentVTypeDistributionID, myCurrentVTypeDistribution)) {
410  throw ProcessError("Another vehicle type (or distribution) with the id '" + myCurrentVTypeDistributionID + "' exists.");
411  }
413  }
414 }
415 
416 
417 void
419  myActiveRoute.clear();
420  myInsertStopEdgesAt = -1;
421  // check whether the id is really necessary
422  std::string rid;
423  if (myCurrentRouteDistribution != 0) {
425  rid = "distribution '" + myCurrentRouteDistributionID + "'";
426  } else if (myVehicleParameter != 0) {
427  // ok, a vehicle is wrapping the route,
428  // we may use this vehicle's id as default
429  myActiveRouteID = "!" + myVehicleParameter->id; // !!! document this
430  if (attrs.hasAttribute(SUMO_ATTR_ID)) {
431  WRITE_WARNING("Ids of internal routes are ignored (vehicle '" + myVehicleParameter->id + "').");
432  }
433  } else {
434  bool ok = true;
435  myActiveRouteID = attrs.get<std::string>(SUMO_ATTR_ID, 0, ok, false);
436  if (!ok) {
437  return;
438  }
439  rid = "'" + myActiveRouteID + "'";
440  }
441  if (myVehicleParameter != 0) { // have to do this here for nested route distributions
442  rid = "for vehicle '" + myVehicleParameter->id + "'";
443  }
444  bool ok = true;
445  if (attrs.hasAttribute(SUMO_ATTR_EDGES)) {
446  MSEdge::parseEdgesList(attrs.get<std::string>(SUMO_ATTR_EDGES, myActiveRouteID.c_str(), ok), myActiveRoute, rid);
447  }
448  myActiveRouteRefID = attrs.getOpt<std::string>(SUMO_ATTR_REFID, myActiveRouteID.c_str(), ok, "");
450  WRITE_ERROR("Invalid reference to route '" + myActiveRouteRefID + "' in route " + rid + ".");
451  }
454  myCurrentCosts = attrs.getOpt<SUMOReal>(SUMO_ATTR_COST, myActiveRouteID.c_str(), ok, -1);
455  if (ok && myCurrentCosts != -1 && myCurrentCosts < 0) {
456  WRITE_ERROR("Invalid cost for route '" + myActiveRouteID + "'.");
457  }
458 }
459 
460 
461 void
464  switch (element) {
465  case SUMO_TAG_VTYPE: {
467  delete myCurrentVType;
468  myCurrentVType = 0;
469  if (!MSNet::getInstance()->getVehicleControl().addVType(vehType)) {
470  const std::string id = vehType->getID();
471  delete vehType;
473  throw ProcessError("Another vehicle type (or distribution) with the id '" + id + "' exists.");
474  }
475  } else {
476  if (myCurrentVTypeDistribution != 0) {
478  }
479  }
480  }
481  break;
482  case SUMO_TAG_TRIP:
484  closeRoute(true);
485  closeVehicle();
486  delete myVehicleParameter;
487  myVehicleParameter = 0;
488  myInsertStopEdgesAt = -1;
489  break;
490  default:
491  break;
492  }
493 }
494 
495 
496 void
497 MSRouteHandler::closeRoute(const bool mayBeDisconnected) {
498  std::string type = "vehicle";
499  if (mayBeDisconnected) {
501  type = "flow";
502  } else {
503  type = "trip";
504  }
505  }
506  if (myActiveRoute.size() == 0) {
507  delete myActiveRouteColor;
508  myActiveRouteColor = 0;
511  if (route != 0) {
513  route->addReference();
514  }
515  }
516  myActiveRouteID = "";
517  myActiveRouteRefID = "";
518  return;
519  }
520  if (myVehicleParameter != 0) {
521  throw ProcessError("The route for " + type + " '" + myVehicleParameter->id + "' has no edges.");
522  } else {
523  throw ProcessError("Route '" + myActiveRouteID + "' has no edges.");
524  }
525  }
526  if (myActiveRoute.size() == 1 && myActiveRoute.front()->getPurpose() == MSEdge::EDGEFUNCTION_DISTRICT) {
527  throw ProcessError("The routing information for " + type + " '" + myVehicleParameter->id + "' is insufficient.");
528  }
532  route->setCosts(myCurrentCosts);
533  myActiveRoute.clear();
534  if (!MSRoute::dictionary(myActiveRouteID, route)) {
535  delete route;
537  if (myVehicleParameter != 0) {
538  if (MSNet::getInstance()->getVehicleControl().getVehicle(myVehicleParameter->id) == 0) {
539  throw ProcessError("Another route for " + type + " '" + myVehicleParameter->id + "' exists.");
540  } else {
541  throw ProcessError("A vehicle with id '" + myVehicleParameter->id + "' already exists.");
542  }
543  } else {
544  throw ProcessError("Another route (or distribution) with the id '" + myActiveRouteID + "' exists.");
545  }
546  }
547  } else {
548  if (myCurrentRouteDistribution != 0) {
550  route->addReference();
551  }
552  }
553  }
554  myActiveRouteID = "";
555  myActiveRouteColor = 0;
556  myActiveRouteStops.clear();
557 }
558 
559 
560 void
562  // check whether the id is really necessary
563  bool ok = true;
564  if (myVehicleParameter != 0) {
565  // ok, a vehicle is wrapping the route,
566  // we may use this vehicle's id as default
567  myCurrentRouteDistributionID = "!" + myVehicleParameter->id; // !!! document this
568  } else {
569  myCurrentRouteDistributionID = attrs.get<std::string>(SUMO_ATTR_ID, 0, ok);
570  if (!ok) {
571  return;
572  }
573  }
575  std::vector<SUMOReal> probs;
576  if (attrs.hasAttribute(SUMO_ATTR_PROBS)) {
577  bool ok = true;
578  StringTokenizer st(attrs.get<std::string>(SUMO_ATTR_PROBS, myCurrentRouteDistributionID.c_str(), ok));
579  while (st.hasNext()) {
580  probs.push_back(TplConvert::_2SUMORealSec(st.next().c_str(), 1.0));
581  }
582  }
583  if (attrs.hasAttribute(SUMO_ATTR_ROUTES)) {
584  bool ok = true;
585  StringTokenizer st(attrs.get<std::string>(SUMO_ATTR_ROUTES, myCurrentRouteDistributionID.c_str(), ok));
586  size_t probIndex = 0;
587  while (st.hasNext()) {
588  std::string routeID = st.next();
589  const MSRoute* route = MSRoute::dictionary(routeID, &myParsingRNG);
590  if (route == 0) {
591  throw ProcessError("Unknown route '" + routeID + "' in distribution '" + myCurrentRouteDistributionID + "'.");
592  }
593  const SUMOReal prob = (probs.size() > probIndex ? probs[probIndex] : 1.0);
594  if (myCurrentRouteDistribution->add(prob, route, false)) {
595  route->addReference();
596  }
597  probIndex++;
598  }
599  if (probs.size() > 0 && probIndex != probs.size()) {
600  WRITE_WARNING("Got " + toString(probs.size()) + " probabilities for " + toString(probIndex) +
601  " routes in routeDistribution '" + myCurrentRouteDistributionID + "'");
602  }
603  }
604 }
605 
606 
607 void
609  if (myCurrentRouteDistribution != 0) {
610  const bool haveSameID = MSRoute::dictionary(myCurrentRouteDistributionID, &myParsingRNG) != 0;
611  if (MSGlobals::gStateLoaded && haveSameID) {
613  return;
614  }
615  if (haveSameID) {
617  throw ProcessError("Another route (or distribution) with the id '" + myCurrentRouteDistributionID + "' exists.");
618  }
621  throw ProcessError("Route distribution '" + myCurrentRouteDistributionID + "' is empty.");
622  }
625  }
626 }
627 
628 
629 void
631  // get nested route
635  // let's check whether this vehicle had to depart before the simulation starts
637  if (route != 0) {
638  route->addReference();
639  route->release();
640  }
641  return;
642  }
643  }
644  // get the vehicle's type
645  MSVehicleType* vtype = 0;
646  if (myVehicleParameter->vtypeid != "") {
647  vtype = vehControl.getVType(myVehicleParameter->vtypeid, &myParsingRNG);
648  if (vtype == 0) {
649  throw ProcessError("The vehicle type '" + myVehicleParameter->vtypeid + "' for vehicle '" + myVehicleParameter->id + "' is not known.");
650  }
651  } else {
652  // there should be one (at least the default one)
653  vtype = vehControl.getVType(DEFAULT_VTYPE_ID, &myParsingRNG);
654  }
655  if (route == 0) {
656  // if there is no nested route, try via the (hopefully) given route-id
658  }
659  if (route == 0) {
660  // nothing found? -> error
661  if (myVehicleParameter->routeid != "") {
662  throw ProcessError("The route '" + myVehicleParameter->routeid + "' for vehicle '" + myVehicleParameter->id + "' is not known.");
663  } else {
664  throw ProcessError("Vehicle '" + myVehicleParameter->id + "' has no route.");
665  }
666  }
667  myActiveRouteID = "";
668 
669  // try to build the vehicle
670  SUMOVehicle* vehicle = 0;
671  if (vehControl.getVehicle(myVehicleParameter->id) == 0) {
672  try {
673  vehicle = vehControl.buildVehicle(myVehicleParameter, route, vtype, !MSGlobals::gCheckRoutes);
674  } catch (const ProcessError& e) {
676  WRITE_WARNING(e.what());
677  vehControl.deleteVehicle(0, true);
678  myVehicleParameter = 0;
679  vehicle = 0;
680  return;
681  } else {
682  throw e;
683  }
684  }
685  // maybe we do not want this vehicle to be inserted due to scaling
686  unsigned int quota = vehControl.getQuota();
687  if (quota > 0) {
688  vehControl.addVehicle(myVehicleParameter->id, vehicle);
690  const MSEdge* const firstEdge = vehicle->getRoute().getEdges()[0];
691  static_cast<MSVehicle*>(vehicle)->setTentativeLaneAndPosition(firstEdge->getLanes()[0], myVehicleParameter->departPos);
692  vehControl.addWaiting(*route->begin(), vehicle);
693  vehControl.registerOneWaitingForPerson();
695  const MSEdge* const firstEdge = vehicle->getRoute().getEdges()[0];
696  static_cast<MSVehicle*>(vehicle)->setTentativeLaneAndPosition(firstEdge->getLanes()[0], myVehicleParameter->departPos);
697  vehControl.addWaiting(*route->begin(), vehicle);
698  vehControl.registerOneWaitingForContainer();
699  } else {
700  // !!! no upscaling for triggered vehicles yet
701  for (unsigned int i = 1; i < quota; i++) {
704  newPars->id = myVehicleParameter->id + "." + toString(i);
705  vehicle = vehControl.buildVehicle(newPars, route, vtype, !MSGlobals::gCheckRoutes);
706  vehControl.addVehicle(newPars->id, vehicle);
707  }
708  }
710  myVehicleParameter = 0;
711  } else {
712  vehControl.deleteVehicle(vehicle, true);
713  myVehicleParameter = 0;
714  vehicle = 0;
715  }
716  } else {
717  // strange: another vehicle with the same id already exists
719  // and was not loaded while loading a simulation state
720  // -> error
721  throw ProcessError("Another vehicle with the id '" + myVehicleParameter->id + "' exists.");
722  } else {
723  // ok, it seems to be loaded previously while loading a simulation state
724  vehicle = 0;
725  }
726  }
727  // check whether the vehicle shall be added directly to the network or
728  // shall stay in the internal buffer
729  if (vehicle != 0) {
730  if (vehicle->getParameter().departProcedure == DEPART_GIVEN) {
732  }
733  }
734 }
735 
736 
737 void
739  if (myActivePlan->size() == 0) {
740  throw ProcessError("Person '" + myVehicleParameter->id + "' has no plan.");
741  }
743  if (type == 0) {
744  throw ProcessError("The type '" + myVehicleParameter->vtypeid + "' for person '" + myVehicleParameter->id + "' is not known.");
745  }
747  // @todo: consider myScale?
749  if (MSNet::getInstance()->getPersonControl().add(myVehicleParameter->id, person)) {
752  } else {
753  ProcessError error("Another person with the id '" + myVehicleParameter->id + "' exists.");
754  delete person;
755  throw error;
756  }
757  } else {
758  // warning already given
759  delete person;
760  }
761  myVehicleParameter = 0;
762  myActivePlan = 0;
763 }
764 
765 void
767  if (myActiveContainerPlan->size() == 0) {
768  throw ProcessError("Container '" + myVehicleParameter->id + "' has no plan.");
769  }
771  if (type == 0) {
772  throw ProcessError("The type '" + myVehicleParameter->vtypeid + "' for container '" + myVehicleParameter->id + "' is not known.");
773  }
775  // @todo: consider myScale?
777  if (MSNet::getInstance()->getContainerControl().add(myVehicleParameter->id, container)) {
780  } else {
781  ProcessError error("Another container with the id '" + myVehicleParameter->id + "' exists.");
782  delete container;
783  throw error;
784  }
785  } else {
786  // warning already given
787  delete container;
788  }
789  myVehicleParameter = 0;
791 }
792 
793 void
796  return;
797  }
798  // let's check whether vehicles had to depart before the simulation starts
801  const SUMOTime offsetToBegin = string2time(OptionsCont::getOptions().getString("begin")) - myVehicleParameter->depart;
805  return;
806  }
807  }
808  }
809  if (MSNet::getInstance()->getVehicleControl().getVType(myVehicleParameter->vtypeid, &myParsingRNG) == 0) {
810  throw ProcessError("The vehicle type '" + myVehicleParameter->vtypeid + "' for flow '" + myVehicleParameter->id + "' is not known.");
811  }
814  closeRoute(true);
815  }
817  throw ProcessError("The route '" + myVehicleParameter->routeid + "' for flow '" + myVehicleParameter->id + "' is not known.");
818  }
819  myActiveRouteID = "";
820 
821  // check whether the vehicle shall be added directly to the network or
822  // shall stay in the internal buffer
824  if (MSNet::getInstance()->getInsertionControl().add(myVehicleParameter)) {
826  } else {
827  throw ProcessError("Another flow with the id '" + myVehicleParameter->id + "' exists.");
828  }
829  }
830  myVehicleParameter = 0;
831  myInsertStopEdgesAt = -1;
832 }
833 
834 
835 void
837  std::string errorSuffix;
838  if (myActivePlan != 0) {
839  errorSuffix = " in person '" + myVehicleParameter->id + "'.";
840  } else if (myVehicleParameter != 0) {
841  errorSuffix = " in vehicle '" + myVehicleParameter->id + "'.";
842  } else if (myActiveContainerPlan != 0) {
843  errorSuffix = " in container '" + myVehicleParameter->id + "'.";
844  } else {
845  errorSuffix = " in route '" + myActiveRouteID + "'.";
846  }
848  bool ok = parseStop(stop, attrs, errorSuffix, MsgHandler::getErrorInstance());
849  if (!ok) {
850  return;
851  }
852  const MSEdge* edge = 0;
853  // try to parse the assigned bus stop
854  if (stop.busstop != "") {
855  // ok, we have a bus stop
857  if (bs == 0) {
858  WRITE_ERROR("The bus stop '" + stop.busstop + "' is not known" + errorSuffix);
859  return;
860  }
861  const MSLane& l = bs->getLane();
862  stop.lane = l.getID();
863  stop.endPos = bs->getEndLanePosition();
864  stop.startPos = bs->getBeginLanePosition();
865  edge = &l.getEdge();
866  } //try to parse the assigned container stop
867  else if (stop.containerstop != "") {
868  // ok, we have obviously a container stop
870  if (cs == 0) {
871  WRITE_ERROR("The container stop '" + stop.containerstop + "' is not known" + errorSuffix);
872  return;
873  }
874  const MSLane& l = cs->getLane();
875  stop.lane = l.getID();
876  stop.endPos = cs->getEndLanePosition();
877  stop.startPos = cs->getBeginLanePosition();
878  edge = &l.getEdge();
879  } else if (stop.chargingStation != "") {
880  // ok, we have a Charging station
882  if (cs != 0) {
883  const MSLane& l = cs->getLane();
884  stop.lane = l.getID();
885  stop.endPos = cs->getEndLanePosition();
886  stop.startPos = cs->getBeginLanePosition();
887  } else {
888  WRITE_ERROR("The charging station '" + stop.chargingStation + "' is not known" + errorSuffix);
889  return;
890  }
891  } else {
892  // no, the lane and the position should be given
893  // get the lane
894  stop.lane = attrs.getOpt<std::string>(SUMO_ATTR_LANE, 0, ok, "");
895  if (ok && stop.lane != "") {
896  if (MSLane::dictionary(stop.lane) == 0) {
897  WRITE_ERROR("The lane '" + stop.lane + "' for a stop is not known" + errorSuffix);
898  return;
899  }
900  } else {
901  if (myActivePlan && !myActivePlan->empty()) {
902  const MSStoppingPlace* bs = myActivePlan->back()->getDestinationStop();
903  if (bs != 0) {
904  edge = &bs->getLane().getEdge();
905  stop.lane = bs->getLane().getID();
906  stop.endPos = bs->getEndLanePosition();
907  stop.startPos = bs->getBeginLanePosition();
908  } else {
909  edge = &myActivePlan->back()->getDestination();
910  stop.lane = edge->getLanes()[0]->getID();
911  stop.endPos = myActivePlan->back()->getArrivalPos();
912  stop.startPos = stop.endPos - POSITION_EPS;
913  }
914  } else {
915  WRITE_ERROR("A stop must be placed on a bus stop, a container stop or a lane" + errorSuffix);
916  return;
917  }
918  }
919  edge = &MSLane::dictionary(stop.lane)->getEdge();
920  if (myActivePlan &&
921  !myActivePlan->empty() &&
922  &myActivePlan->back()->getDestination() != edge) {
923  throw ProcessError("Disconnected plan for person '" + myVehicleParameter->id + "' (" + edge->getID() + "!=" + myActivePlan->back()->getDestination().getID() + ").");
924  }
925  if (myActivePlan && myActivePlan->empty()) {
927  *edge, -1, myVehicleParameter->depart, myVehicleParameter->departPos, "start"));
928  }
929  if (myActiveContainerPlan &&
930  !myActiveContainerPlan->empty() &&
931  &myActiveContainerPlan->back()->getDestination() != &MSLane::dictionary(stop.lane)->getEdge()) {
932  throw ProcessError("Disconnected plan for container '" + myVehicleParameter->id + "' (" + MSLane::dictionary(stop.lane)->getEdge().getID() + "!=" + myActiveContainerPlan->back()->getDestination().getID() + ").");
933  }
936  MSLane::dictionary(stop.lane)->getEdge(), -1, myVehicleParameter->depart, myVehicleParameter->departPos, "start"));
937  }
938  stop.endPos = attrs.getOpt<SUMOReal>(SUMO_ATTR_ENDPOS, 0, ok, MSLane::dictionary(stop.lane)->getLength());
939  if (attrs.hasAttribute(SUMO_ATTR_POSITION)) {
940  WRITE_WARNING("Deprecated attribute 'pos' in description of stop" + errorSuffix);
941  stop.endPos = attrs.getOpt<SUMOReal>(SUMO_ATTR_POSITION, 0, ok, stop.endPos);
942  }
943  stop.startPos = attrs.getOpt<SUMOReal>(SUMO_ATTR_STARTPOS, 0, ok, MAX2((SUMOReal)0., stop.endPos - 2 * POSITION_EPS));
944  const bool friendlyPos = attrs.getOpt<bool>(SUMO_ATTR_FRIENDLY_POS, 0, ok, false);
945  if (!ok || !checkStopPos(stop.startPos, stop.endPos, MSLane::dictionary(stop.lane)->getLength(), POSITION_EPS, friendlyPos)) {
946  WRITE_ERROR("Invalid start or end position for stop on lane '" + stop.lane + "'" + errorSuffix);
947  return;
948  }
949  }
950  if (myActivePlan != 0) {
951  std::string actType = attrs.getOpt<std::string>(SUMO_ATTR_ACTTYPE, 0, ok, "waiting");
952  SUMOReal pos = (stop.startPos + stop.endPos) / 2.;
953  if (!myActivePlan->empty()) {
954  pos = myActivePlan->back()->getArrivalPos();
955  }
957  MSLane::dictionary(stop.lane)->getEdge(), stop.duration, stop.until, pos, actType));
958  } else if (myActiveContainerPlan != 0) {
959  std::string actType = attrs.getOpt<std::string>(SUMO_ATTR_ACTTYPE, 0, ok, "waiting");
961  MSLane::dictionary(stop.lane)->getEdge(), stop.duration, stop.until, stop.startPos, actType));
962  } else if (myVehicleParameter != 0) {
963  myVehicleParameter->stops.push_back(stop);
964  } else {
965  myActiveRouteStops.push_back(stop);
966  }
967  if (myInsertStopEdgesAt >= 0) {
968  myActiveRoute.insert(myActiveRoute.begin() + myInsertStopEdgesAt, edge);
970  }
971 }
972 
973 
974 void
975 MSRouteHandler::parseWalkPositions(const SUMOSAXAttributes& attrs, const std::string& personID,
976  const MSEdge* fromEdge, const MSEdge*& toEdge,
977  SUMOReal& departPos, SUMOReal& arrivalPos, MSStoppingPlace*& bs, bool& ok) {
978  const std::string description = "person '" + personID + "' walking from " + fromEdge->getID();
979 
980  departPos = parseWalkPos(SUMO_ATTR_DEPARTPOS, description, fromEdge,
981  attrs.getOpt<std::string>(SUMO_ATTR_DEPARTPOS, description.c_str(), ok, "0"));
982 
983  std::string bsID = attrs.getOpt<std::string>(SUMO_ATTR_BUS_STOP, 0, ok, "");
984  if (bsID != "") {
985  bs = MSNet::getInstance()->getBusStop(bsID);
986  if (bs == 0) {
987  throw ProcessError("Unknown bus stop '" + bsID + "' for " + description + ".");
988  }
989  if (toEdge == 0) {
990  toEdge = &bs->getLane().getEdge();
991  }
992  arrivalPos = (bs->getBeginLanePosition() + bs->getEndLanePosition()) / 2.;
993  if (attrs.hasAttribute(SUMO_ATTR_ARRIVALPOS)) {
994  const SUMOReal arrPos = parseWalkPos(SUMO_ATTR_ARRIVALPOS, description, toEdge,
995  attrs.get<std::string>(SUMO_ATTR_ARRIVALPOS, description.c_str(), ok));
996  if (arrPos >= bs->getBeginLanePosition() && arrPos < bs->getEndLanePosition()) {
997  arrivalPos = arrPos;
998  } else {
999  WRITE_WARNING("Ignoring arrivalPos for " + description + " because it is outside the given stop '" + toString(SUMO_ATTR_BUS_STOP) + "'.");
1000  }
1001  }
1002  } else {
1003  if (toEdge == 0) {
1004  throw ProcessError("No destination edge for " + description + ".");
1005  }
1006  if (attrs.hasAttribute(SUMO_ATTR_ARRIVALPOS)) {
1007  arrivalPos = parseWalkPos(SUMO_ATTR_ARRIVALPOS, description, toEdge,
1008  attrs.get<std::string>(SUMO_ATTR_ARRIVALPOS, description.c_str(), ok));
1009  } else {
1010  arrivalPos = -NUMERICAL_EPS;
1011  }
1012  }
1013 }
1014 
1015 
1016 SUMOReal
1017 MSRouteHandler::parseWalkPos(SumoXMLAttr attr, const std::string& id, const MSEdge* edge, const std::string& val) {
1018  SUMOReal result;
1019  std::string error;
1020  ArrivalPosDefinition proc;
1021  // only supports 'random' and 'max'
1022  if (!SUMOVehicleParameter::parseArrivalPos(val, toString(SUMO_TAG_WALK), id, result, proc, error)) {
1023  throw ProcessError(error);
1024  }
1025  if (proc == ARRIVAL_POS_RANDOM) {
1026  result = myParsingRNG.rand(edge->getLength());
1027  } else if (proc == ARRIVAL_POS_MAX) {
1028  result = edge->getLength();
1029  }
1030  return SUMOVehicleParameter::interpretEdgePos(result, edge->getLength(), attr, id);
1031 }
1032 
1033 
1034 /****************************************************************************/
The departure is person triggered.
void addStop(const SUMOSAXAttributes &attrs)
Processing of a stop.
const int VTYPEPARS_MAXSPEED_SET
const int VEHPARS_TO_TAZ_SET
MSRouteHandler(const std::string &file, bool addVehiclesDirectly)
standard constructor
bool wasSet(int what) const
Returns whether the given parameter was set.
Definition: MSVehicleType.h:91
SUMOReal repetitionProbability
The probability for emitting a vehicle per second.
void addWaiting(const MSEdge *const edge, SUMOVehicle *vehicle)
Adds a vehicle to the list of waiting vehiclse to a given edge.
static MsgHandler * getErrorInstance()
Returns the instance to add errors to.
Definition: MsgHandler.cpp:80
SUMOReal myCurrentCosts
The currently parsed route costs.
MSEdge & getEdge() const
Returns the lane&#39;s edge.
Definition: MSLane.h:461
double rand()
virtual void myEndElement(int element)
Called when a closing tag occurs.
ConstMSEdgeVector myActiveRoute
The current route.
Representation of a vehicle in the micro simulation.
Definition: MSVehicle.h:80
virtual void deleteVehicle(SUMOVehicle *v, bool discard=false)
Deletes the vehicle.
SUMOReal getMaxSpeed() const
Get vehicle&#39;s maximum speed [m/s].
long long int SUMOTime
Definition: SUMOTime.h:43
const int VEHPARS_FORCE_REROUTE
const SUMOReal DEFAULT_CONTAINER_TRANSHIP_SPEED
void parseFromViaTo(std::string element, const SUMOSAXAttributes &attrs)
Called for parsing from and to and the corresponding taz attributes.
RandomDistributor< const MSRoute * > * myCurrentRouteDistribution
The currently parsed distribution of routes (probability->route)
const std::vector< SUMOReal > & getProbs() const
Returns the probabilities assigned to the members of the distribution.
The time is given.
std::string next()
std::string containerstop
(Optional) container stop if one is assigned to the stop
int repetitionNumber
The number of times the vehicle shall be repeatedly inserted.
std::string vtypeid
The vehicle&#39;s type id.
void closeVehicle()
Ends the processing of a vehicle.
static bool parseArrivalPos(const std::string &val, const std::string &element, const std::string &id, SUMOReal &pos, ArrivalPosDefinition &apd, std::string &error)
Validates a given arrivalPos value.
virtual MSPerson * buildPerson(const SUMOVehicleParameter *pars, const MSVehicleType *vtype, MSTransportable::MSTransportablePlan *plan) const
Builds a new person.
static MTRand myParsingRNG
A random number generator used to choose from vtype/route distributions and computing the speed facto...
static void parseVTypeEmbedded(SUMOVTypeParameter &into, int element, const SUMOSAXAttributes &attrs, bool fromVType=false)
Parses an element embedded in vtype definition.
virtual MSContainer * buildContainer(const SUMOVehicleParameter *pars, const MSVehicleType *vtype, MSTransportable::MSTransportablePlan *plan) const
Builds a new container.
virtual const MSRoute & getRoute() const =0
Returns the current route.
A lane area vehicles can halt at.
bool myAddVehiclesDirectly
Information whether vehicles shall be directly added to the network or kept within the buffer...
SUMOTime duration
The stopping duration.
const std::vector< MSLane * > & getLanes() const
Returns this edge&#39;s lanes.
Definition: MSEdge.h:186
SUMOVehicleParameter * myVehicleParameter
Parameter of the current vehicle, trip, person, container or flow.
The departure is container triggered.
unsigned int getNumPredecessors() const
Returns the number of edges this edge is connected to.
Definition: MSEdge.h:331
bool add(SUMOReal prob, T val, bool checkDuplicates=true)
Adds a value with an assigned probability to the distribution.
bool getBool(const std::string &name) const
Returns the boolean-value of the named option (only for Option_Bool)
static bool checkStopPos(SUMOReal &startPos, SUMOReal &endPos, const SUMOReal laneLength, const SUMOReal minLength, const bool friendlyPos)
check start and end position of a stop
static bool gStateLoaded
Information whether a state has been loaded.
Definition: MSGlobals.h:86
SUMOVTypeParameter * myCurrentVType
The currently parsed vehicle type.
void closePerson()
Ends the processing of a person.
int repetitionsDone
The number of times the vehicle was already inserted.
const SUMOReal DEFAULT_PEDESTRIAN_SPEED
void openRoute(const SUMOSAXAttributes &attrs)
MSPedestrianRouterDijkstra & getPedestrianRouter(const MSEdgeVector &prohibited=MSEdgeVector()) const
Definition: MSNet.cpp:891
SUMOReal getEndLanePosition() const
Returns the end position of this stop.
MSChargingStation * getChargingStation(const std::string &id) const
Returns the named charging station.
Definition: MSNet.cpp:834
static SUMOReal _2SUMORealSec(const E *const data, SUMOReal def)
Definition: TplConvert.h:365
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
Definition: MSNet.cpp:162
T MAX2(T a, T b)
Definition: StdDefs.h:79
void setCosts(SUMOReal costs)
Sets the costs of the route.
Definition: MSRoute.h:170
const SUMOReal DEFAULT_VEH_PROB
SUMOReal myActiveRouteProbability
The probability of the current route.
void setDeparture(SUMOTime time, MSTransportable *container)
sets the arrival time for a waiting container
static bool dictionary(const std::string &id, MSEdge *edge)
Inserts edge into the static dictionary Returns true if the key id isn&#39;t already in the dictionary...
Definition: MSEdge.cpp:579
SUMOTime until
The time at which the vehicle may continue its journey.
virtual bool addVehicle(const std::string &id, SUMOVehicle *v)
Tries to insert the vehicle into the internal vehicle container.
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
void registerLastDepart()
save last depart (only to be used if vehicle is not discarded)
std::string myActiveRouteID
The id of the current route.
int myInsertStopEdgesAt
where stop edges can be inserted into the current route (-1 means no insertion)
SUMOReal repetitionOffset
The time offset between vehicle reinsertions.
const std::string DEFAULT_VTYPE_ID
virtual bool hasAttribute(int id) const =0
Returns the information whether the named (by its enum-value) attribute is within the current list...
static MSVehicleType * build(SUMOVTypeParameter &from)
Builds the microsim vehicle type described by the given parameter.
void error(const XERCES_CPP_NAMESPACE::SAXParseException &exception)
Handler for XML-errors.
#define WRITE_WARNING(msg)
Definition: MsgHandler.h:200
The car-following model and parameter.
Definition: MSVehicleType.h:74
static OptionsCont & getOptions()
Retrieves the options.
Definition: OptionsCont.cpp:69
std::string toTaz
The vehicle&#39;s destination zone (district)
std::vector< Stop > stops
List of the stops the vehicle will make.
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.
static SUMOReal interpretEdgePos(SUMOReal pos, SUMOReal maximumValue, SumoXMLAttr attr, const std::string &id)
Interprets negative edge positions and fits them onto a given edge.
std::string busstop
(Optional) bus stop if one is assigned to the stop
const std::string & getID() const
Returns the id.
Definition: Named.h:65
A road/street connecting two junctions.
Definition: MSEdge.h:81
std::vector< MSTransportable::Stage * > MSTransportablePlan
the structure holding the plan of a transportable
void compute(const E *from, const E *to, SUMOReal departPos, SUMOReal arrivalPos, SUMOReal speed, SUMOTime msTime, const N *onlyNode, std::vector< const E * > &into, bool allEdges=false)
Builds the route between the given edges using the minimum effort at the given time The definition of...
SUMOReal getLength() const
return the length of the edge
Definition: MSEdge.h:535
RandomDistributor< MSVehicleType * > * myCurrentVTypeDistribution
The currently parsed distribution of vehicle types (probability->vehicle type)
const MSLane & getLane() const
Returns the lane this stop is located at.
SUMOReal startPos
The stopping position start.
The edge is a district edge.
Definition: MSEdge.h:100
the edges of a route
MSStoppingPlace * getBusStop(const std::string &id) const
Returns the named bus stop.
Definition: MSNet.cpp:786
void closeRouteDistribution()
std::string routeid
The vehicle&#39;s route id.
Representation of a vehicle.
Definition: SUMOVehicle.h:65
static bool gCheckRoutes
Definition: MSGlobals.h:80
Encapsulated SAX-Attributes.
bool wasSet(int what) const
Returns whether the given parameter was set.
std::string chargingStation
(Optional) charging station if one is assigned to the stop
SUMOReal endPos
The stopping position end.
virtual MSContainerControl & getContainerControl()
Returns the container control.
Definition: MSNet.cpp:704
void closeContainer()
Ends the processing of a container.
MSVehicleControl & getVehicleControl()
Returns the vehicle control.
Definition: MSNet.h:308
void closeVehicleTypeDistribution()
SUMOReal parseWalkPos(SumoXMLAttr attr, const std::string &id, const MSEdge *edge, const std::string &val)
virtual SUMOVehicle * buildVehicle(SUMOVehicleParameter *defs, const MSRoute *route, const MSVehicleType *type, const bool ignoreStopErrors, const bool fromRouteFile=true)
Builds a vehicle, increases the number of built vehicles.
SUMOTime depart
The vehicle&#39;s departure time.
const ConstMSEdgeVector & getEdges() const
Definition: MSRoute.h:124
DepartDefinition departProcedure
Information how the vehicle shall choose the depart time.
SUMOTime string2time(const std::string &r)
Definition: SUMOTime.cpp:48
#define POSITION_EPS
Definition: config.h:188
std::string fromTaz
The vehicle&#39;s origin zone (district)
std::string toString(const T &t, std::streamsize accuracy=OUTPUT_ACCURACY)
Definition: ToString.h:53
virtual void myStartElement(int element, const SUMOSAXAttributes &attrs)
Called on the opening of a tag;.
void addReference() const
increments the reference counter for the route
Definition: MSRoute.cpp:100
const int VEHPARS_FROM_TAZ_SET
void registerOneWaitingForPerson()
increases the count of vehicles waiting for a person to allow recogniztion of person related deadlock...
MSTransportable::MSTransportablePlan * myActivePlan
The plan of the current person.
std::string lane
The lane to stop at.
Parser for routes during their loading.
std::string myCurrentRouteDistributionID
The id of the currently parsed route distribution.
void parseWalkPositions(const SUMOSAXAttributes &attrs, const std::string &personID, const MSEdge *fromEdge, const MSEdge *&toEdge, SUMOReal &departPos, SUMOReal &arrivalPos, MSStoppingPlace *&bs, bool &ok)
@ brief parse depart- and arrival positions of a walk
void openRouteDistribution(const SUMOSAXAttributes &attrs)
#define WRITE_ERROR(msg)
Definition: MsgHandler.h:205
virtual void myEndElement(int element)
Called when a closing tag occurs.
SUMOReal getOverallProb() const
Return the sum of the probabilites assigned to the members.
static bool dictionary(const std::string &id, MSLane *lane)
Static (sic!) container methods {.
Definition: MSLane.cpp:884
void registerOneWaitingForContainer()
increases the count of vehicles waiting for a container to allow recogniztion of container related de...
std::vector< SUMOVehicleParameter::Stop > myActiveRouteStops
List of the stops on the parsed route.
Structure representing possible vehicle parameter.
virtual void myStartElement(int element, const SUMOSAXAttributes &attrs)
Called on the opening of a tag;.
virtual MSPersonControl & getPersonControl()
Returns the person control.
Definition: MSNet.cpp:696
MSInsertionControl & getInsertionControl()
Returns the insertion control.
Definition: MSNet.h:349
int setParameter
Information for the router which parameter were set.
virtual const SUMOVehicleParameter & getParameter() const =0
Returns the vehicle&#39;s parameter (including departure definition)
std::string myCurrentVTypeDistributionID
The id of the currently parsed vehicle type distribution.
Definition of vehicle stop (position and duration)
SUMOReal getBeginLanePosition() const
Returns the begin position of this stop.
bool parseStop(SUMOVehicleParameter::Stop &stop, const SUMOSAXAttributes &attrs, std::string errorSuffix, MsgHandler *const errorOutput)
parses attributes common to all stops
SUMOReal getDefaultProbability() const
Get the default probability of this vehicle type.
MSStoppingPlace * getContainerStop(const std::string &id) const
Returns the named container stop.
Definition: MSNet.cpp:810
const std::string & getID() const
Returns the name of the vehicle type.
void setDeparture(SUMOTime time, MSPerson *person)
sets the arrival time for a waiting or walking person
SUMOReal departPos
(optional) The position the vehicle shall depart from
SUMOVehicle * getVehicle(const std::string &id) const
Returns the vehicle with the given id.
const RGBColor * myActiveRouteColor
The currently parsed route&#39;s color.
#define SUMOReal
Definition: config.h:214
ArrivalPosDefinition
Possible ways to choose the arrival position.
unsigned int getNumSuccessors() const
Returns the number of edges that may be reached from this edge.
Definition: MSEdge.h:308
#define NUMERICAL_EPS
Definition: config.h:161
virtual ~MSRouteHandler()
standard destructor
void openVehicleTypeDistribution(const SUMOSAXAttributes &attrs)
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.
The class responsible for building and deletion of vehicles.
T get(int attr, const char *objectid, bool &ok, bool report=true) const
Tries to read given attribute assuming it is an int.
void release() const
deletes the route if there are no further references to it
Definition: MSRoute.cpp:106
MSVehicleType * getVType(const std::string &id=DEFAULT_VTYPE_ID, MTRand *rng=0)
Returns the named vehicle type or a sample from the named distribution.
void add(SUMOVehicle *veh)
Adds a single vehicle for departure.
bool checkLastDepart()
Checks whether the route file is sorted by departure time if needed.
std::string myActiveRouteRefID
The id of the route the current route references to.
Representation of a lane in the micro simulation.
Definition: MSLane.h:77
A color information.
The maximum arrival position is used.
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:642
void closeRoute(const bool mayBeDisconnected=false)
unsigned int getQuota(SUMOReal frac=-1) const
Returns the number of instances of the current vehicle that shall be emitted considering that "frac" ...
MSRouteIterator begin() const
Returns the begin of the list of edges to pass.
Definition: MSRoute.cpp:75
void closeFlow()
Ends the processing of a flow.
MSTransportable::MSTransportablePlan * myActiveContainerPlan
The plan of the current container.
std::string id
The vehicle&#39;s id.
static bool dictionary(const std::string &id, const MSRoute *route)
Adds a route to the dictionary.
Definition: MSRoute.cpp:116
The arrival position is chosen randomly.