SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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  if (bsID != "") {
159  bs = MSNet::getInstance()->getBusStop(bsID);
160  if (bs == 0) {
161  throw ProcessError("Unknown bus stop '" + bsID + "' for person '" + myVehicleParameter->id + "'.");
162  }
163  }
164  if (attrs.hasAttribute(SUMO_ATTR_FROM)) {
165  const std::string fromID = attrs.get<std::string>(SUMO_ATTR_FROM, pid.c_str(), ok);
166  from = MSEdge::dictionary(fromID);
167  if (from == 0) {
168  throw ProcessError("The from edge '" + fromID + "' within a ride of person '" + pid + "' is not known.");
169  }
170  if (!myActivePlan->empty() && &myActivePlan->back()->getDestination() != from) {
171  throw ProcessError("Disconnected plan for person '" + myVehicleParameter->id + "' (" + fromID + "!=" + myActivePlan->back()->getDestination().getID() + ").");
172  }
173  if (myActivePlan->empty()) {
175  *from, -1, myVehicleParameter->depart, myVehicleParameter->departPos, "start"));
176  }
177  } else if (myActivePlan->empty()) {
178  throw ProcessError("The start edge within for person '" + pid + "' is not known.");
179  }
180  const std::string toID = attrs.get<std::string>(SUMO_ATTR_TO, pid.c_str(), ok);
181  MSEdge* to = MSEdge::dictionary(toID);
182  if (to == 0) {
183  throw ProcessError("The to edge '" + toID + "' within a ride of person '" + pid + "' is not known.");
184  }
185  myActivePlan->push_back(new MSPerson::MSPersonStage_Driving(*to, bs, st.getVector()));
186  break;
187  }
188  case SUMO_TAG_WALK: {
189  myActiveRoute.clear();
190  bool ok = true;
191  const SUMOTime duration = attrs.getOptSUMOTimeReporting(SUMO_ATTR_DURATION, 0, ok, -1);
192  if (attrs.hasAttribute(SUMO_ATTR_DURATION) && duration <= 0) {
193  throw ProcessError("Non-positive walking duration for '" + myVehicleParameter->id + "'.");
194  }
197  // need to check for explicitly set speed since we might have // DEFAULT_VEHTYPE
198  if (vtype != 0 && vtype->wasSet(VTYPEPARS_MAXSPEED_SET)) {
199  speed = vtype->getMaxSpeed();
200  }
201  speed = attrs.getOpt<SUMOReal>(SUMO_ATTR_SPEED, 0, ok, speed);
202  if (speed <= 0) {
203  throw ProcessError("Non-positive walking speed for '" + myVehicleParameter->id + "'.");
204  }
205  SUMOReal departPos = 0;
206  SUMOReal arrivalPos = 0;
207  MSStoppingPlace* bs = 0;
208  if (attrs.hasAttribute(SUMO_ATTR_EDGES)) {
210  parseWalkPositions(attrs, myVehicleParameter->id, myActiveRoute.front(), myActiveRoute.back(), departPos, arrivalPos, bs, ok);
211  } else {
212  if (attrs.hasAttribute(SUMO_ATTR_FROM) && attrs.hasAttribute(SUMO_ATTR_TO)) {
213  const std::string fromID = attrs.get<std::string>(SUMO_ATTR_FROM, myVehicleParameter->id.c_str(), ok);
214  MSEdge* from = MSEdge::dictionary(fromID);
215  if (from == 0) {
216  throw ProcessError("The from edge '" + fromID + "' within a walk of person '" + myVehicleParameter->id + "' is not known.");
217  }
218  const std::string toID = attrs.get<std::string>(SUMO_ATTR_TO, myVehicleParameter->id.c_str(), ok);
219  MSEdge* to = MSEdge::dictionary(toID);
220  if (to == 0) {
221  throw ProcessError("The to edge '" + toID + "' within a walk of person '" + myVehicleParameter->id + "' is not known.");
222  }
223  parseWalkPositions(attrs, myVehicleParameter->id, from, to, departPos, arrivalPos, bs, ok);
224  MSNet::getInstance()->getPedestrianRouter().compute(from, to, departPos, arrivalPos,
225  speed, 0, 0, myActiveRoute);
226  if (myActiveRoute.empty()) {
227  const std::string error = "No connection found between '" + from->getID() + "' and '" + to->getID() + "' for person '" + myVehicleParameter->id + "'.";
228  if (OptionsCont::getOptions().getBool("ignore-route-errors")) {
229  myActiveRoute.push_back(from);
230  myActiveRoute.push_back(to); // pedestrian will teleport
231  //WRITE_WARNING(error);
232  } else {
233  throw ProcessError(error);
234  }
235  }
236  //std::cout << myVehicleParameter->id << " edges=" << toString(myActiveRoute) << "\n";
237  }
238  }
239  if (myActiveRoute.empty()) {
240  throw ProcessError("No edges to walk for person '" + myVehicleParameter->id + "'.");
241  }
242  if (!myActivePlan->empty() && &myActivePlan->back()->getDestination() != myActiveRoute.front()) {
243  throw ProcessError("Disconnected plan for person '" + myVehicleParameter->id + "' (" + myActiveRoute.front()->getID() + "!=" + myActivePlan->back()->getDestination().getID() + ").");
244  }
245  if (myActivePlan->empty()) {
247  *myActiveRoute.front(), -1, myVehicleParameter->depart, departPos, "start"));
248  }
249  myActivePlan->push_back(new MSPerson::MSPersonStage_Walking(myActiveRoute, bs, duration, speed, departPos, arrivalPos));
250  myActiveRoute.clear();
251  break;
252  }
253  case SUMO_TAG_TRANSPORT: {
254  const std::string containerId = myVehicleParameter->id;
255  bool ok = true;
256  MSEdge* from = 0;
257  const std::string desc = attrs.get<std::string>(SUMO_ATTR_LINES, containerId.c_str(), ok);
258  StringTokenizer st(desc);
259  std::string csID = attrs.getOpt<std::string>(SUMO_ATTR_CONTAINER_STOP, 0, ok, "");
260  MSStoppingPlace* cs = 0;
261  if (csID != "") {
262  cs = MSNet::getInstance()->getContainerStop(csID);
263  if (cs == 0) {
264  throw ProcessError("Unknown container stop '" + csID + "' for container '" + myVehicleParameter->id + "'.");
265  }
266  }
267  if (attrs.hasAttribute(SUMO_ATTR_FROM)) {
268  const std::string fromID = attrs.get<std::string>(SUMO_ATTR_FROM, containerId.c_str(), ok);
269  from = MSEdge::dictionary(fromID);
270  if (from == 0) {
271  throw ProcessError("The from edge '" + fromID + "' within a transport of container '" + containerId + "' is not known.");
272  }
273  if (!myActiveContainerPlan->empty() && &myActiveContainerPlan->back()->getDestination() != from) {
274  throw ProcessError("Disconnected plan for container '" + myVehicleParameter->id + "' (" + fromID + "!=" + myActiveContainerPlan->back()->getDestination().getID() + ").");
275  }
276  if (myActiveContainerPlan->empty()) {
278  *from, -1, myVehicleParameter->depart, myVehicleParameter->departPos, "start"));
279  }
280  } else if (myActiveContainerPlan->empty()) {
281  throw ProcessError("The start edge within a transport of container '" + containerId + "' is not known.");
282  }
283  const std::string toID = attrs.get<std::string>(SUMO_ATTR_TO, containerId.c_str(), ok);
284  MSEdge* to = MSEdge::dictionary(toID);
285  if (to == 0) {
286  throw ProcessError("The to edge '" + toID + "' within a transport of container '" + containerId + "' is not known.");
287  }
288  myActiveContainerPlan->push_back(new MSContainer::MSContainerStage_Driving(*to, cs, st.getVector()));
289  break;
290  }
291  case SUMO_TAG_TRANSHIP: {
292  myActiveRoute.clear();
293  bool ok = true;
294  SUMOReal departPos = attrs.getOpt<SUMOReal>(SUMO_ATTR_DEPARTPOS, myVehicleParameter->id.c_str(), ok, 0);
295  SUMOReal arrivalPos = attrs.getOpt<SUMOReal>(SUMO_ATTR_ARRIVALPOS, myVehicleParameter->id.c_str(), ok, -NUMERICAL_EPS);
298  // need to check for explicitly set speed since we might have // DEFAULT_VEHTYPE
299  if (vtype != 0 && vtype->wasSet(VTYPEPARS_MAXSPEED_SET)) {
300  speed = vtype->getMaxSpeed();
301  }
302  speed = attrs.getOpt<SUMOReal>(SUMO_ATTR_SPEED, 0, ok, speed);
303  if (speed <= 0) {
304  throw ProcessError("Non-positive tranship speed for container '" + myVehicleParameter->id + "'.");
305  }
306  std::string csID = attrs.getOpt<std::string>(SUMO_ATTR_CONTAINER_STOP, 0, ok, "");
307  MSStoppingPlace* cs = 0;
308  if (csID != "") {
309  cs = MSNet::getInstance()->getContainerStop(csID);
310  if (cs == 0) {
311  throw ProcessError("Unknown container stop '" + csID + "' for container '" + myVehicleParameter->id + "'.");
312  }
313  arrivalPos = cs->getEndLanePosition();
314  }
315  if (attrs.hasAttribute(SUMO_ATTR_EDGES)) {
317  } else {
318  if (attrs.hasAttribute(SUMO_ATTR_FROM) && attrs.hasAttribute(SUMO_ATTR_TO)) {
319  const std::string fromID = attrs.get<std::string>(SUMO_ATTR_FROM, myVehicleParameter->id.c_str(), ok);
320  MSEdge* from = MSEdge::dictionary(fromID);
321  if (from == 0) {
322  throw ProcessError("The from edge '" + fromID + "' within a tranship of container '" + myVehicleParameter->id + "' is not known.");
323  }
324  const std::string toID = attrs.get<std::string>(SUMO_ATTR_TO, myVehicleParameter->id.c_str(), ok);
325  MSEdge* to = MSEdge::dictionary(toID);
326  if (to == 0) {
327  throw ProcessError("The to edge '" + toID + "' within a tranship of container '" + myVehicleParameter->id + "' is not known.");
328  }
329  //the route of the container's tranship stage consists only of the 'from' and the 'to' edge
330  myActiveRoute.push_back(from);
331  myActiveRoute.push_back(to);
332  if (myActiveRoute.empty()) {
333  const std::string error = "No connection found between '" + from->getID() + "' and '" + to->getID() + "' for container '" + myVehicleParameter->id + "'.";
334  if (OptionsCont::getOptions().getBool("ignore-route-errors")) {
335  myActiveRoute.push_back(from);
336  } else {
337  WRITE_ERROR(error);
338  }
339  }
340  }
341  }
342  if (myActiveRoute.empty()) {
343  throw ProcessError("No edges to tranship container '" + myVehicleParameter->id + "'.");
344  }
345  if (!myActiveContainerPlan->empty() && &myActiveContainerPlan->back()->getDestination() != myActiveRoute.front()) {
346  throw ProcessError("Disconnected plan for container '" + myVehicleParameter->id + "' (" + myActiveRoute.front()->getID() + "!=" + myActiveContainerPlan->back()->getDestination().getID() + ").");
347  }
348  if (myActiveContainerPlan->empty()) {
350  *myActiveRoute.front(), -1, myVehicleParameter->depart, departPos, "start"));
351  }
352  myActiveContainerPlan->push_back(new MSContainer::MSContainerStage_Tranship(myActiveRoute, cs, speed, departPos, arrivalPos));
353  myActiveRoute.clear();
354  break;
355  }
356  case SUMO_TAG_FLOW:
357  parseFromViaTo("flow", attrs);
358  break;
359  case SUMO_TAG_TRIP:
360  parseFromViaTo("trip", attrs);
361  break;
362  default:
363  break;
364  }
365  // parse embedded vtype information
366  if (myCurrentVType != 0 && element != SUMO_TAG_VTYPE && element != SUMO_TAG_PARAM) {
368  return;
369  }
370 }
371 
372 
373 void
375  bool ok = true;
376  myCurrentVTypeDistributionID = attrs.get<std::string>(SUMO_ATTR_ID, 0, ok);
377  if (ok) {
379  if (attrs.hasAttribute(SUMO_ATTR_VTYPES)) {
380  const std::string vTypes = attrs.get<std::string>(SUMO_ATTR_VTYPES, myCurrentVTypeDistributionID.c_str(), ok);
381  StringTokenizer st(vTypes);
382  while (st.hasNext()) {
383  std::string vtypeID = st.next();
385  if (type == 0) {
386  throw ProcessError("Unknown vtype '" + vtypeID + "' in distribution '" + myCurrentVTypeDistributionID + "'.");
387  }
389  }
390  }
391  }
392 }
393 
394 
395 void
397  if (myCurrentVTypeDistribution != 0) {
398  if (MSGlobals::gStateLoaded && MSNet::getInstance()->getVehicleControl().hasVTypeDistribution(myCurrentVTypeDistributionID)) {
400  return;
401  }
404  throw ProcessError("Vehicle type distribution '" + myCurrentVTypeDistributionID + "' is empty.");
405  }
406  if (!MSNet::getInstance()->getVehicleControl().addVTypeDistribution(myCurrentVTypeDistributionID, myCurrentVTypeDistribution)) {
408  throw ProcessError("Another vehicle type (or distribution) with the id '" + myCurrentVTypeDistributionID + "' exists.");
409  }
411  }
412 }
413 
414 
415 void
417  myActiveRoute.clear();
418  myInsertStopEdgesAt = -1;
419  // check whether the id is really necessary
420  std::string rid;
421  if (myCurrentRouteDistribution != 0) {
423  rid = "distribution '" + myCurrentRouteDistributionID + "'";
424  } else if (myVehicleParameter != 0) {
425  // ok, a vehicle is wrapping the route,
426  // we may use this vehicle's id as default
427  myActiveRouteID = "!" + myVehicleParameter->id; // !!! document this
428  if (attrs.hasAttribute(SUMO_ATTR_ID)) {
429  WRITE_WARNING("Ids of internal routes are ignored (vehicle '" + myVehicleParameter->id + "').");
430  }
431  } else {
432  bool ok = true;
433  myActiveRouteID = attrs.get<std::string>(SUMO_ATTR_ID, 0, ok, false);
434  if (!ok) {
435  return;
436  }
437  rid = "'" + myActiveRouteID + "'";
438  }
439  if (myVehicleParameter != 0) { // have to do this here for nested route distributions
440  rid = "for vehicle '" + myVehicleParameter->id + "'";
441  }
442  bool ok = true;
443  if (attrs.hasAttribute(SUMO_ATTR_EDGES)) {
444  MSEdge::parseEdgesList(attrs.get<std::string>(SUMO_ATTR_EDGES, myActiveRouteID.c_str(), ok), myActiveRoute, rid);
445  }
446  myActiveRouteRefID = attrs.getOpt<std::string>(SUMO_ATTR_REFID, myActiveRouteID.c_str(), ok, "");
448  WRITE_ERROR("Invalid reference to route '" + myActiveRouteRefID + "' in route " + rid + ".");
449  }
452  myCurrentCosts = attrs.getOpt<SUMOReal>(SUMO_ATTR_COST, myActiveRouteID.c_str(), ok, -1);
453  if (ok && myCurrentCosts != -1 && myCurrentCosts < 0) {
454  WRITE_ERROR("Invalid cost for route '" + myActiveRouteID + "'.");
455  }
456 }
457 
458 
459 void
462  switch (element) {
463  case SUMO_TAG_VTYPE: {
465  delete myCurrentVType;
466  myCurrentVType = 0;
467  if (!MSNet::getInstance()->getVehicleControl().addVType(vehType)) {
468  const std::string id = vehType->getID();
469  delete vehType;
471  throw ProcessError("Another vehicle type (or distribution) with the id '" + id + "' exists.");
472  }
473  } else {
474  if (myCurrentVTypeDistribution != 0) {
476  }
477  }
478  }
479  break;
480  case SUMO_TAG_TRIP:
482  closeRoute(true);
483  closeVehicle();
484  delete myVehicleParameter;
485  myVehicleParameter = 0;
486  myInsertStopEdgesAt = -1;
487  break;
488  default:
489  break;
490  }
491 }
492 
493 
494 void
495 MSRouteHandler::closeRoute(const bool mayBeDisconnected) {
496  std::string type = "vehicle";
497  if (mayBeDisconnected) {
499  type = "flow";
500  } else {
501  type = "trip";
502  }
503  }
504  if (myActiveRoute.size() == 0) {
505  delete myActiveRouteColor;
506  myActiveRouteColor = 0;
509  if (route != 0) {
511  route->addReference();
512  }
513  }
514  myActiveRouteID = "";
515  myActiveRouteRefID = "";
516  return;
517  }
518  if (myVehicleParameter != 0) {
519  throw ProcessError("The route for " + type + " '" + myVehicleParameter->id + "' has no edges.");
520  } else {
521  throw ProcessError("Route '" + myActiveRouteID + "' has no edges.");
522  }
523  }
524  if (myActiveRoute.size() == 1 && myActiveRoute.front()->getPurpose() == MSEdge::EDGEFUNCTION_DISTRICT) {
525  throw ProcessError("The routing information for " + type + " '" + myVehicleParameter->id + "' is insufficient.");
526  }
530  route->setCosts(myCurrentCosts);
531  myActiveRoute.clear();
532  if (!MSRoute::dictionary(myActiveRouteID, route)) {
533  delete route;
535  if (myVehicleParameter != 0) {
536  if (MSNet::getInstance()->getVehicleControl().getVehicle(myVehicleParameter->id) == 0) {
537  throw ProcessError("Another route for " + type + " '" + myVehicleParameter->id + "' exists.");
538  } else {
539  throw ProcessError("A vehicle with id '" + myVehicleParameter->id + "' already exists.");
540  }
541  } else {
542  throw ProcessError("Another route (or distribution) with the id '" + myActiveRouteID + "' exists.");
543  }
544  }
545  } else {
546  if (myCurrentRouteDistribution != 0) {
548  route->addReference();
549  }
550  }
551  }
552  myActiveRouteID = "";
553  myActiveRouteColor = 0;
554  myActiveRouteStops.clear();
555 }
556 
557 
558 void
560  // check whether the id is really necessary
561  bool ok = true;
562  if (myVehicleParameter != 0) {
563  // ok, a vehicle is wrapping the route,
564  // we may use this vehicle's id as default
565  myCurrentRouteDistributionID = "!" + myVehicleParameter->id; // !!! document this
566  } else {
567  myCurrentRouteDistributionID = attrs.get<std::string>(SUMO_ATTR_ID, 0, ok);
568  if (!ok) {
569  return;
570  }
571  }
573  std::vector<SUMOReal> probs;
574  if (attrs.hasAttribute(SUMO_ATTR_PROBS)) {
575  bool ok = true;
576  StringTokenizer st(attrs.get<std::string>(SUMO_ATTR_PROBS, myCurrentRouteDistributionID.c_str(), ok));
577  while (st.hasNext()) {
578  probs.push_back(TplConvert::_2SUMORealSec(st.next().c_str(), 1.0));
579  }
580  }
581  if (attrs.hasAttribute(SUMO_ATTR_ROUTES)) {
582  bool ok = true;
583  StringTokenizer st(attrs.get<std::string>(SUMO_ATTR_ROUTES, myCurrentRouteDistributionID.c_str(), ok));
584  size_t probIndex = 0;
585  while (st.hasNext()) {
586  std::string routeID = st.next();
587  const MSRoute* route = MSRoute::dictionary(routeID, &myParsingRNG);
588  if (route == 0) {
589  throw ProcessError("Unknown route '" + routeID + "' in distribution '" + myCurrentRouteDistributionID + "'.");
590  }
591  const SUMOReal prob = (probs.size() > probIndex ? probs[probIndex] : 1.0);
592  if (myCurrentRouteDistribution->add(prob, route, false)) {
593  route->addReference();
594  }
595  probIndex++;
596  }
597  if (probs.size() > 0 && probIndex != probs.size()) {
598  WRITE_WARNING("Got " + toString(probs.size()) + " probabilities for " + toString(probIndex) +
599  " routes in routeDistribution '" + myCurrentRouteDistributionID + "'");
600  }
601  }
602 }
603 
604 
605 void
607  if (myCurrentRouteDistribution != 0) {
608  const bool haveSameID = MSRoute::dictionary(myCurrentRouteDistributionID, &myParsingRNG) != 0;
609  if (MSGlobals::gStateLoaded && haveSameID) {
611  return;
612  }
613  if (haveSameID) {
615  throw ProcessError("Another route (or distribution) with the id '" + myCurrentRouteDistributionID + "' exists.");
616  }
619  throw ProcessError("Route distribution '" + myCurrentRouteDistributionID + "' is empty.");
620  }
623  }
624 }
625 
626 
627 void
629  // get nested route
633  // let's check whether this vehicle had to depart before the simulation starts
635  if (route != 0) {
636  route->addReference();
637  route->release();
638  }
639  return;
640  }
641  }
642  // get the vehicle's type
643  MSVehicleType* vtype = 0;
644  if (myVehicleParameter->vtypeid != "") {
645  vtype = vehControl.getVType(myVehicleParameter->vtypeid, &myParsingRNG);
646  if (vtype == 0) {
647  throw ProcessError("The vehicle type '" + myVehicleParameter->vtypeid + "' for vehicle '" + myVehicleParameter->id + "' is not known.");
648  }
649  } else {
650  // there should be one (at least the default one)
651  vtype = vehControl.getVType(DEFAULT_VTYPE_ID, &myParsingRNG);
652  }
653  if (route == 0) {
654  // if there is no nested route, try via the (hopefully) given route-id
656  }
657  if (route == 0) {
658  // nothing found? -> error
659  if (myVehicleParameter->routeid != "") {
660  throw ProcessError("The route '" + myVehicleParameter->routeid + "' for vehicle '" + myVehicleParameter->id + "' is not known.");
661  } else {
662  throw ProcessError("Vehicle '" + myVehicleParameter->id + "' has no route.");
663  }
664  }
665  myActiveRouteID = "";
666 
667  // try to build the vehicle
668  SUMOVehicle* vehicle = 0;
669  if (vehControl.getVehicle(myVehicleParameter->id) == 0) {
670  const bool ignoreRouteErrors = OptionsCont::getOptions().getBool("ignore-route-errors");
671  try {
672  vehicle = vehControl.buildVehicle(myVehicleParameter, route, vtype, ignoreRouteErrors);
673  } catch (const ProcessError& e) {
674  if (ignoreRouteErrors) {
675  WRITE_WARNING(e.what());
676  vehControl.deleteVehicle(0, true);
677  myVehicleParameter = 0;
678  vehicle = 0;
679  return;
680  } else {
681  throw e;
682  }
683  }
684  // maybe we do not want this vehicle to be inserted due to scaling
685  unsigned int quota = vehControl.getQuota();
686  if (quota > 0) {
687  vehControl.addVehicle(myVehicleParameter->id, vehicle);
689  const MSEdge* const firstEdge = vehicle->getRoute().getEdges()[0];
690  static_cast<MSVehicle*>(vehicle)->setTentativeLaneAndPosition(firstEdge->getLanes()[0], myVehicleParameter->departPos);
691  vehControl.addWaiting(*route->begin(), vehicle);
692  vehControl.registerOneWaitingForPerson();
694  const MSEdge* const firstEdge = vehicle->getRoute().getEdges()[0];
695  static_cast<MSVehicle*>(vehicle)->setTentativeLaneAndPosition(firstEdge->getLanes()[0], myVehicleParameter->departPos);
696  vehControl.addWaiting(*route->begin(), vehicle);
697  vehControl.registerOneWaitingForContainer();
698  } else {
699  // !!! no upscaling for triggered vehicles yet
700  for (unsigned int i = 1; i < quota; i++) {
703  newPars->id = myVehicleParameter->id + "." + toString(i);
704  vehicle = vehControl.buildVehicle(newPars, route, vtype, OptionsCont::getOptions().getBool("ignore-route-errors"));
705  vehControl.addVehicle(newPars->id, vehicle);
706  }
707  }
709  myVehicleParameter = 0;
710  } else {
711  vehControl.deleteVehicle(vehicle, true);
712  myVehicleParameter = 0;
713  vehicle = 0;
714  }
715  } else {
716  // strange: another vehicle with the same id already exists
718  // and was not loaded while loading a simulation state
719  // -> error
720  throw ProcessError("Another vehicle with the id '" + myVehicleParameter->id + "' exists.");
721  } else {
722  // ok, it seems to be loaded previously while loading a simulation state
723  vehicle = 0;
724  }
725  }
726  // check whether the vehicle shall be added directly to the network or
727  // shall stay in the internal buffer
728  if (vehicle != 0) {
729  if (vehicle->getParameter().departProcedure == DEPART_GIVEN) {
731  }
732  }
733 }
734 
735 
736 void
738  if (myActivePlan->size() == 0) {
739  throw ProcessError("Person '" + myVehicleParameter->id + "' has no plan.");
740  }
742  if (type == 0) {
743  throw ProcessError("The type '" + myVehicleParameter->vtypeid + "' for person '" + myVehicleParameter->id + "' is not known.");
744  }
746  // @todo: consider myScale?
748  if (MSNet::getInstance()->getPersonControl().add(myVehicleParameter->id, person)) {
751  } else {
752  ProcessError error("Another person with the id '" + myVehicleParameter->id + "' exists.");
753  delete person;
754  throw error;
755  }
756  } else {
757  // warning already given
758  delete person;
759  }
760  myVehicleParameter = 0;
761  myActivePlan = 0;
762 }
763 
764 void
766  if (myActiveContainerPlan->size() == 0) {
767  throw ProcessError("Container '" + myVehicleParameter->id + "' has no plan.");
768  }
770  if (type == 0) {
771  throw ProcessError("The type '" + myVehicleParameter->vtypeid + "' for container '" + myVehicleParameter->id + "' is not known.");
772  }
774  // @todo: consider myScale?
776  if (MSNet::getInstance()->getContainerControl().add(myVehicleParameter->id, container)) {
779  } else {
780  ProcessError error("Another container with the id '" + myVehicleParameter->id + "' exists.");
781  delete container;
782  throw error;
783  }
784  } else {
785  // warning already given
786  delete container;
787  }
788  myVehicleParameter = 0;
790 }
791 
792 void
795  return;
796  }
797  // let's check whether vehicles had to depart before the simulation starts
800  const SUMOTime offsetToBegin = string2time(OptionsCont::getOptions().getString("begin")) - myVehicleParameter->depart;
804  return;
805  }
806  }
807  }
808  if (MSNet::getInstance()->getVehicleControl().getVType(myVehicleParameter->vtypeid, &myParsingRNG) == 0) {
809  throw ProcessError("The vehicle type '" + myVehicleParameter->vtypeid + "' for flow '" + myVehicleParameter->id + "' is not known.");
810  }
813  closeRoute(true);
814  }
816  throw ProcessError("The route '" + myVehicleParameter->routeid + "' for flow '" + myVehicleParameter->id + "' is not known.");
817  }
818  myActiveRouteID = "";
819 
820  // check whether the vehicle shall be added directly to the network or
821  // shall stay in the internal buffer
823  if (MSNet::getInstance()->getInsertionControl().add(myVehicleParameter)) {
825  } else {
826  throw ProcessError("Another flow with the id '" + myVehicleParameter->id + "' exists.");
827  }
828  }
829  myVehicleParameter = 0;
830  myInsertStopEdgesAt = -1;
831 }
832 
833 
834 void
836  std::string errorSuffix;
837  if (myActivePlan != 0) {
838  errorSuffix = " in person '" + myVehicleParameter->id + "'.";
839  } else if (myVehicleParameter != 0) {
840  errorSuffix = " in vehicle '" + myVehicleParameter->id + "'.";
841  } else if (myActiveContainerPlan != 0) {
842  errorSuffix = " in container '" + myVehicleParameter->id + "'.";
843  } else {
844  errorSuffix = " in route '" + myActiveRouteID + "'.";
845  }
847  bool ok = parseStop(stop, attrs, errorSuffix, MsgHandler::getErrorInstance());
848  if (!ok) {
849  return;
850  }
851  MSEdge* edge = 0;
852  // try to parse the assigned bus stop
853  if (stop.busstop != "") {
854  // ok, we have a bus stop
856  if (bs == 0) {
857  WRITE_ERROR("The bus stop '" + stop.busstop + "' is not known" + errorSuffix);
858  return;
859  }
860  const MSLane& l = bs->getLane();
861  stop.lane = l.getID();
862  stop.endPos = bs->getEndLanePosition();
863  stop.startPos = bs->getBeginLanePosition();
864  edge = &l.getEdge();
865  } //try to parse the assigned container stop
866  else if (stop.containerstop != "") {
867  // ok, we have obviously a container stop
869  if (cs == 0) {
870  WRITE_ERROR("The container stop '" + stop.containerstop + "' is not known" + errorSuffix);
871  return;
872  }
873  const MSLane& l = cs->getLane();
874  stop.lane = l.getID();
875  stop.endPos = cs->getEndLanePosition();
876  stop.startPos = cs->getBeginLanePosition();
877  edge = &l.getEdge();
878  } else if (stop.chrgStn != "") {
879  // ok, we have a Charging station
881  if (cs != 0) {
882  const MSLane& l = cs->getLane();
883  stop.lane = l.getID();
884  stop.endPos = cs->getEndLanePosition();
885  stop.startPos = cs->getBeginLanePosition();
886  } else {
887  WRITE_ERROR("The charging station '" + stop.chrgStn + "' is not known" + errorSuffix);
888  return;
889  }
890  } else {
891  // no, the lane and the position should be given
892  // get the lane
893  stop.lane = attrs.getOpt<std::string>(SUMO_ATTR_LANE, 0, ok, "");
894  if (ok && stop.lane != "") {
895  if (MSLane::dictionary(stop.lane) == 0) {
896  WRITE_ERROR("The lane '" + stop.lane + "' for a stop is not known" + errorSuffix);
897  return;
898  }
899  } else {
900  WRITE_ERROR("A stop must be placed on a bus stop, a container stop or a lane" + errorSuffix);
901  return;
902  }
903  edge = &MSLane::dictionary(stop.lane)->getEdge();
904  if (myActivePlan &&
905  !myActivePlan->empty() &&
906  &myActivePlan->back()->getDestination() != edge) {
907  throw ProcessError("Disconnected plan for person '" + myVehicleParameter->id + "' (" + edge->getID() + "!=" + myActivePlan->back()->getDestination().getID() + ").");
908  }
909  if (myActivePlan && myActivePlan->empty()) {
911  *edge, -1, myVehicleParameter->depart, myVehicleParameter->departPos, "start"));
912  }
913  if (myActiveContainerPlan &&
914  !myActiveContainerPlan->empty() &&
915  &myActiveContainerPlan->back()->getDestination() != &MSLane::dictionary(stop.lane)->getEdge()) {
916  throw ProcessError("Disconnected plan for container '" + myVehicleParameter->id + "' (" + MSLane::dictionary(stop.lane)->getEdge().getID() + "!=" + myActiveContainerPlan->back()->getDestination().getID() + ").");
917  }
920  MSLane::dictionary(stop.lane)->getEdge(), -1, myVehicleParameter->depart, myVehicleParameter->departPos, "start"));
921  }
922  stop.endPos = attrs.getOpt<SUMOReal>(SUMO_ATTR_ENDPOS, 0, ok, MSLane::dictionary(stop.lane)->getLength());
923  if (attrs.hasAttribute(SUMO_ATTR_POSITION)) {
924  WRITE_WARNING("Deprecated attribute 'pos' in description of stop" + errorSuffix);
925  stop.endPos = attrs.getOpt<SUMOReal>(SUMO_ATTR_POSITION, 0, ok, stop.endPos);
926  }
927  stop.startPos = attrs.getOpt<SUMOReal>(SUMO_ATTR_STARTPOS, 0, ok, MAX2((SUMOReal)0., stop.endPos - 2 * POSITION_EPS));
928  const bool friendlyPos = attrs.getOpt<bool>(SUMO_ATTR_FRIENDLY_POS, 0, ok, false);
929  if (!ok || !checkStopPos(stop.startPos, stop.endPos, MSLane::dictionary(stop.lane)->getLength(), POSITION_EPS, friendlyPos)) {
930  WRITE_ERROR("Invalid start or end position for stop on lane '" + stop.lane + "'" + errorSuffix);
931  return;
932  }
933  }
934  if (myActivePlan != 0) {
935  std::string actType = attrs.getOpt<std::string>(SUMO_ATTR_ACTTYPE, 0, ok, "waiting");
937  MSLane::dictionary(stop.lane)->getEdge(), stop.duration, stop.until, stop.startPos, actType));
938  } else if (myActiveContainerPlan != 0) {
939  std::string actType = attrs.getOpt<std::string>(SUMO_ATTR_ACTTYPE, 0, ok, "waiting");
941  MSLane::dictionary(stop.lane)->getEdge(), stop.duration, stop.until, stop.startPos, actType));
942  } else if (myVehicleParameter != 0) {
943  myVehicleParameter->stops.push_back(stop);
944  } else {
945  myActiveRouteStops.push_back(stop);
946  }
947  if (myInsertStopEdgesAt >= 0) {
948  myActiveRoute.insert(myActiveRoute.begin() + myInsertStopEdgesAt, edge);
950  }
951 }
952 
953 
954 void
955 MSRouteHandler::parseWalkPositions(const SUMOSAXAttributes& attrs, const std::string& personID,
956  const MSEdge* fromEdge, const MSEdge* toEdge,
957  SUMOReal& departPos, SUMOReal& arrivalPos, MSStoppingPlace*& bs, bool& ok) {
958  const std::string description = "person '" + personID + "' walking from " + fromEdge->getID();
959 
960  departPos = parseWalkPos(SUMO_ATTR_DEPARTPOS, description, fromEdge,
961  attrs.getOpt<std::string>(SUMO_ATTR_DEPARTPOS, description.c_str(), ok, "0"));
962 
963  std::string bsID = attrs.getOpt<std::string>(SUMO_ATTR_BUS_STOP, 0, ok, "");
964  if (bsID != "") {
965  if (attrs.hasAttribute(SUMO_ATTR_ARRIVALPOS)) {
967  + "' for " + description + " because '" + toString(SUMO_ATTR_BUS_STOP) + "' is given.");
968  }
969  bs = MSNet::getInstance()->getBusStop(bsID);
970  if (bs == 0) {
971  throw ProcessError("Unknown bus stop '" + bsID + "' for " + description + ".");
972  }
973  arrivalPos = bs->getEndLanePosition();
974  } else {
975  if (attrs.hasAttribute(SUMO_ATTR_ARRIVALPOS)) {
976  arrivalPos = parseWalkPos(SUMO_ATTR_ARRIVALPOS, description, toEdge,
977  attrs.getOpt<std::string>(SUMO_ATTR_ARRIVALPOS, description.c_str(), ok, toString(-POSITION_EPS)));
978  } else {
979  arrivalPos = -NUMERICAL_EPS;
980  }
981  }
982 }
983 
984 
985 SUMOReal
986 MSRouteHandler::parseWalkPos(SumoXMLAttr attr, const std::string& id, const MSEdge* edge, const std::string& val) {
987  SUMOReal result;
988  std::string error;
990  // only supports 'random' and 'max'
991  if (!SUMOVehicleParameter::parseArrivalPos(val, toString(SUMO_TAG_WALK), id, result, proc, error)) {
992  throw ProcessError(error);
993  }
994  if (proc == ARRIVAL_POS_RANDOM) {
995  result = myParsingRNG.rand(edge->getLength());
996  } else if (proc == ARRIVAL_POS_MAX) {
997  result = edge->getLength();
998  }
999  return SUMOVehicleParameter::interpretEdgePos(result, edge->getLength(), attr, id);
1000 }
1001 
1002 
1003 /****************************************************************************/
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].
const int VEHPARS_FORCE_REROUTE
const SUMOReal DEFAULT_CONTAINER_TRANSHIP_SPEED
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 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-&gt;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:880
SUMOReal getEndLanePosition() const
Returns the end position of this stop.
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:74
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:553
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)
MSChrgStn * getChrgStn(const std::string &id) const
Returns the named charging station.
Definition: MSNet.cpp:823
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:60
A road/street connecting two junctions.
Definition: MSEdge.h:81
std::vector< MSTransportable::Stage * > MSTransportablePlan
the structure holding the plan of a container
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-&gt;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:775
void closeRouteDistribution()
std::string routeid
The vehicle&#39;s route id.
Representation of a vehicle.
Definition: SUMOVehicle.h:65
Encapsulated SAX-Attributes.
bool wasSet(int what) const
Returns whether the given parameter was set.
SUMOReal endPos
The stopping position end.
virtual MSContainerControl & getContainerControl()
Returns the container control.
Definition: MSNet.cpp:693
void closeContainer()
Ends the processing of a container.
MSVehicleControl & getVehicleControl()
Returns the vehicle control.
Definition: MSNet.h:304
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:189
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 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:890
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:685
MSInsertionControl & getInsertionControl()
Returns the insertion control.
Definition: MSNet.h:345
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:799
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:215
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:162
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.
std::string chrgStn
(Optional) charging station if one is assigned to the stop
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:616
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 &quot;frac&quot; ...
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.