SUMO - Simulation of Urban MObility
RORouteHandler.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 <iostream>
47 #include <utils/xml/XMLSubSys.h>
49 #include "RONet.h"
50 #include "ROLane.h"
51 #include "RORouteHandler.h"
52 
53 #ifdef CHECK_MEMORY_LEAKS
54 #include <foreign/nvwa/debug_new.h>
55 #endif // CHECK_MEMORY_LEAKS
56 
57 
58 // ===========================================================================
59 // method definitions
60 // ===========================================================================
61 RORouteHandler::RORouteHandler(RONet& net, const std::string& file,
62  const bool tryRepair,
63  const bool emptyDestinationsAllowed,
64  const bool ignoreErrors) :
65  SUMORouteHandler(file),
66  myPedestrianRouter(0),
67  myNet(net),
68  myActivePlan(0),
69  myActiveContainerPlan(0),
70  myActivePlanSize(0),
71  myActiveContainerPlanSize(0),
72  myTryRepair(tryRepair),
73  myEmptyDestinationsAllowed(emptyDestinationsAllowed),
74  myErrorOutput(ignoreErrors ? MsgHandler::getWarningInstance() : MsgHandler::getErrorInstance()),
75  myCurrentVTypeDistribution(0),
76  myCurrentAlternatives(0) {
77  myActiveRoute.reserve(100);
78 }
79 
80 
82  delete myPedestrianRouter;
83 }
84 
85 
86 void
87 RORouteHandler::parseFromViaTo(std::string element,
88  const SUMOSAXAttributes& attrs) {
89  myActiveRoute.clear();
90  bool useTaz = OptionsCont::getOptions().getBool("with-taz");
92  WRITE_WARNING("Taz usage was requested but no taz present in " + element + " '" + myVehicleParameter->id + "'!");
93  useTaz = false;
94  }
95  bool ok = true;
97  const ROEdge* fromTaz = myNet.getEdge(myVehicleParameter->fromTaz + "-source");
98  if (fromTaz == 0) {
99  myErrorOutput->inform("Source taz '" + myVehicleParameter->fromTaz + "' not known for " + element + " '" + myVehicleParameter->id + "'!");
100  } else if (fromTaz->getNumSuccessors() == 0) {
101  myErrorOutput->inform("Source taz '" + myVehicleParameter->fromTaz + "' has no outgoing edges for " + element + " '" + myVehicleParameter->id + "'!");
102  } else {
103  myActiveRoute.push_back(fromTaz);
104  }
105  } else {
106  parseEdges(attrs.getOpt<std::string>(SUMO_ATTR_FROM, myVehicleParameter->id.c_str(), ok, "", true),
107  myActiveRoute, "for " + element + " '" + myVehicleParameter->id + "'");
108  }
109  if (!attrs.hasAttribute(SUMO_ATTR_VIA)) {
110  myInsertStopEdgesAt = (int)myActiveRoute.size();
111  }
112  parseEdges(attrs.getOpt<std::string>(SUMO_ATTR_VIA, myVehicleParameter->id.c_str(), ok, "", true),
113  myActiveRoute, "for " + element + " '" + myVehicleParameter->id + "'");
115  const ROEdge* toTaz = myNet.getEdge(myVehicleParameter->toTaz + "-sink");
116  if (toTaz == 0) {
117  myErrorOutput->inform("Sink taz '" + myVehicleParameter->toTaz + "' not known for " + element + " '" + myVehicleParameter->id + "'!");
118  } else if (toTaz->getNumPredecessors() == 0) {
119  myErrorOutput->inform("Sink taz '" + myVehicleParameter->toTaz + "' has no incoming edges for " + element + " '" + myVehicleParameter->id + "'!");
120  } else {
121  myActiveRoute.push_back(toTaz);
122  }
123  } else {
124  parseEdges(attrs.getOpt<std::string>(SUMO_ATTR_TO, myVehicleParameter->id.c_str(), ok, "", true),
125  myActiveRoute, "for " + element + " '" + myVehicleParameter->id + "'");
126  }
128  if (myVehicleParameter->routeid == "") {
130  }
131 }
132 
133 
134 void
136  const SUMOSAXAttributes& attrs) {
137  SUMORouteHandler::myStartElement(element, attrs);
138  switch (element) {
139  case SUMO_TAG_PERSON:
140  myActivePlan = new OutputDevice_String(false, 1);
141  myActivePlanSize = 0;
143  (*myActivePlan) << attrs;
144  break;
145  case SUMO_TAG_RIDE: {
147  (*myActivePlan) << attrs;
150  break;
151  }
152  case SUMO_TAG_WALK: {
153  if (attrs.hasAttribute(SUMO_ATTR_EDGES)) {
154  // copy walk as it is
155  // XXX allow --repair?
157  (*myActivePlan) << attrs;
160  } else {
161  routePedestrian(attrs, *myActivePlan);
162  }
163  break;
164  }
165  case SUMO_TAG_CONTAINER:
169  (*myActiveContainerPlan) << attrs;
170  break;
171  case SUMO_TAG_TRANSPORT: {
173  (*myActiveContainerPlan) << attrs;
176  break;
177  }
178  case SUMO_TAG_TRANSHIP: {
179  if (attrs.hasAttribute(SUMO_ATTR_EDGES)) {
180  // copy walk as it is
181  // XXX allow --repair?
183  (*myActiveContainerPlan) << attrs;
186  } else {
188  }
189  break;
190  }
191  case SUMO_TAG_FLOW:
193  parseFromViaTo("flow", attrs);
194  break;
195  case SUMO_TAG_TRIP: {
197  parseFromViaTo("trip", attrs);
198  }
199  break;
200  default:
201  break;
202  }
203  // parse embedded vtype information
204  if (myCurrentVType != 0 && element != SUMO_TAG_VTYPE && element != SUMO_TAG_PARAM) {
206  return;
207  }
208 }
209 
210 
211 void
213  bool ok = true;
214  myCurrentVTypeDistributionID = attrs.get<std::string>(SUMO_ATTR_ID, 0, ok);
215  if (ok) {
217  if (attrs.hasAttribute(SUMO_ATTR_VTYPES)) {
218  const std::string vTypes = attrs.get<std::string>(SUMO_ATTR_VTYPES, myCurrentVTypeDistributionID.c_str(), ok);
219  StringTokenizer st(vTypes);
220  while (st.hasNext()) {
221  SUMOVTypeParameter* type = myNet.getVehicleTypeSecure(st.next());
222  myCurrentVTypeDistribution->add(1., type);
223  }
224  }
225  }
226 }
227 
228 
229 void
231  if (myCurrentVTypeDistribution != 0) {
234  myErrorOutput->inform("Vehicle type distribution '" + myCurrentVTypeDistributionID + "' is empty.");
237  myErrorOutput->inform("Another vehicle type (or distribution) with the id '" + myCurrentVTypeDistributionID + "' exists.");
238  }
240  }
241 }
242 
243 
244 void
246  myActiveRoute.clear();
247  myInsertStopEdgesAt = -1;
248  // check whether the id is really necessary
249  std::string rid;
250  if (myCurrentAlternatives != 0) {
252  rid = "distribution '" + myCurrentAlternatives->getID() + "'";
253  } else if (myVehicleParameter != 0) {
254  // ok, a vehicle is wrapping the route,
255  // we may use this vehicle's id as default
256  myVehicleParameter->routeid = myActiveRouteID = "!" + myVehicleParameter->id; // !!! document this
257  if (attrs.hasAttribute(SUMO_ATTR_ID)) {
258  WRITE_WARNING("Ids of internal routes are ignored (vehicle '" + myVehicleParameter->id + "').");
259  }
260  } else {
261  bool ok = true;
262  myActiveRouteID = attrs.get<std::string>(SUMO_ATTR_ID, 0, ok);
263  if (!ok) {
264  return;
265  }
266  rid = "'" + myActiveRouteID + "'";
267  }
268  if (myVehicleParameter != 0) { // have to do this here for nested route distributions
269  rid = "for vehicle '" + myVehicleParameter->id + "'";
270  }
271  bool ok = true;
272  if (attrs.hasAttribute(SUMO_ATTR_EDGES)) {
273  parseEdges(attrs.get<std::string>(SUMO_ATTR_EDGES, myActiveRouteID.c_str(), ok), myActiveRoute, rid);
274  }
275  myActiveRouteRefID = attrs.getOpt<std::string>(SUMO_ATTR_REFID, myActiveRouteID.c_str(), ok, "");
277  myErrorOutput->inform("Invalid reference to route '" + myActiveRouteRefID + "' in route " + rid + ".");
278  }
279  if (myCurrentAlternatives != 0 && !attrs.hasAttribute(SUMO_ATTR_PROB)) {
280  WRITE_WARNING("No probability for a route in '" + rid + "', using default.");
281  }
283  if (ok && myActiveRouteProbability < 0) {
284  myErrorOutput->inform("Invalid probability for route '" + myActiveRouteID + "'.");
285  }
287  ok = true;
288  myCurrentCosts = attrs.getOpt<SUMOReal>(SUMO_ATTR_COST, myActiveRouteID.c_str(), ok, -1);
289  if (ok && myCurrentCosts != -1 && myCurrentCosts < 0) {
290  myErrorOutput->inform("Invalid cost for route '" + myActiveRouteID + "'.");
291  }
292 }
293 
294 
295 void
298  switch (element) {
299  case SUMO_TAG_VTYPE:
301  if (myCurrentVTypeDistribution != 0) {
303  }
304  }
305  myCurrentVType = 0;
306  break;
307  case SUMO_TAG_TRIP:
308  closeRoute(true);
309  closeVehicle();
310  delete myVehicleParameter;
311  myVehicleParameter = 0;
312  myInsertStopEdgesAt = -1;
313  break;
314  default:
315  break;
316  }
317 }
318 
319 
320 void
321 RORouteHandler::closeRoute(const bool mayBeDisconnected) {
322  if (myActiveRoute.size() == 0) {
323  if (myActiveRouteRefID != "" && myCurrentAlternatives != 0) {
325  myActiveRouteID = "";
326  myActiveRouteRefID = "";
327  return;
328  }
329  if (myVehicleParameter != 0) {
330  myErrorOutput->inform("The route for vehicle '" + myVehicleParameter->id + "' has no edges.");
331  } else {
332  myErrorOutput->inform("Route '" + myActiveRouteID + "' has no edges.");
333  }
334  myActiveRouteID = "";
335  myActiveRouteStops.clear();
336  return;
337  }
338  if (myActiveRoute.size() == 1 && myActiveRoute.front()->getType() == ROEdge::ET_DISTRICT) {
339  myErrorOutput->inform("The routing information for vehicle '" + myVehicleParameter->id + "' is insufficient.");
340  myActiveRouteID = "";
341  myActiveRouteStops.clear();
342  return;
343  }
346  myActiveRoute.clear();
347  if (myCurrentAlternatives == 0) {
348  if (myNet.getRouteDef(myActiveRouteID) != 0) {
349  delete route;
350  if (myVehicleParameter != 0) {
351  myErrorOutput->inform("Another route for vehicle '" + myVehicleParameter->id + "' exists.");
352  } else {
353  myErrorOutput->inform("Another route (or distribution) with the id '" + myActiveRouteID + "' exists.");
354  }
355  myActiveRouteID = "";
356  myActiveRouteStops.clear();
357  return;
358  } else {
359  myCurrentAlternatives = new RORouteDef(myActiveRouteID, 0, mayBeDisconnected || myTryRepair, mayBeDisconnected);
363  }
364  } else {
366  }
367  myActiveRouteID = "";
368  myActiveRouteStops.clear();
369 }
370 
371 
372 void
374  // check whether the id is really necessary
375  bool ok = true;
376  std::string id;
377  if (myVehicleParameter != 0) {
378  // ok, a vehicle is wrapping the route,
379  // we may use this vehicle's id as default
380  myVehicleParameter->routeid = id = "!" + myVehicleParameter->id; // !!! document this
381  if (attrs.hasAttribute(SUMO_ATTR_ID)) {
382  WRITE_WARNING("Ids of internal route distributions are ignored (vehicle '" + myVehicleParameter->id + "').");
383  }
384  } else {
385  id = attrs.get<std::string>(SUMO_ATTR_ID, 0, ok);
386  if (!ok) {
387  return;
388  }
389  }
390  // try to get the index of the last element
391  int index = attrs.get<int>(SUMO_ATTR_LAST, id.c_str(), ok);
392  if (ok && index < 0) {
393  myErrorOutput->inform("Negative index of a route alternative (id='" + id + "').");
394  return;
395  }
396  // build the alternative cont
397  myCurrentAlternatives = new RORouteDef(id, index, myTryRepair, false);
398  if (attrs.hasAttribute(SUMO_ATTR_ROUTES)) {
399  ok = true;
400  StringTokenizer st(attrs.get<std::string>(SUMO_ATTR_ROUTES, id.c_str(), ok));
401  while (st.hasNext()) {
402  const std::string routeID = st.next();
403  const RORouteDef* route = myNet.getRouteDef(routeID);
404  if (route == 0) {
405  myErrorOutput->inform("Unknown route '" + routeID + "' in distribution '" + id + "'.");
406  } else {
408  }
409  }
410  }
411 }
412 
413 
414 void
416  if (myCurrentAlternatives != 0) {
418  myErrorOutput->inform("Route distribution '" + myCurrentAlternatives->getID() + "' is empty.");
419  delete myCurrentAlternatives;
420  } else if (!myNet.addRouteDef(myCurrentAlternatives)) {
421  myErrorOutput->inform("Another route (or distribution) with the id '" + myCurrentAlternatives->getID() + "' exists.");
422  delete myCurrentAlternatives;
423  }
425  }
426 }
427 
428 
429 void
431  // get the vehicle id
433  return;
434  }
435  // get vehicle type
437  if (type == 0) {
438  myErrorOutput->inform("The vehicle type '" + myVehicleParameter->vtypeid + "' for vehicle '" + myVehicleParameter->id + "' is not known.");
440  } else {
441  // fix the type id in case we used a distribution
442  myVehicleParameter->vtypeid = type->id;
443  }
444  // get the route
446  if (route == 0) {
447  myErrorOutput->inform("The route of the vehicle '" + myVehicleParameter->id + "' is not known.");
448  return;
449  }
450  if (route->getID()[0] != '!') {
451  route = route->copy("!" + myVehicleParameter->id);
452  }
453  // build the vehicle
454  if (!MsgHandler::getErrorInstance()->wasInformed()) {
455  ROVehicle* veh = new ROVehicle(*myVehicleParameter, route, type, &myNet);
456  if (myNet.addVehicle(myVehicleParameter->id, veh)) {
458  }
459  }
460 }
461 
462 
463 void
466  if (myActivePlanSize > 0) {
469  } else {
470  WRITE_WARNING("Discarding person '" + myVehicleParameter->id + "' because it's plan is empty");
471  }
472  delete myVehicleParameter;
473  myVehicleParameter = 0;
474  delete myActivePlan;
475  myActivePlan = 0;
476  myActivePlanSize = 0;
477 }
478 
479 void
482  if (myActiveContainerPlanSize > 0) {
485  } else {
486  WRITE_WARNING("Discarding container '" + myVehicleParameter->id + "' because it's plan is empty");
487  }
488  delete myVehicleParameter;
489  myVehicleParameter = 0;
490  delete myActiveContainerPlan;
493 }
494 
495 
496 void
498  // @todo: consider myScale?
500  delete myVehicleParameter;
501  myVehicleParameter = 0;
502  return;
503  }
504  // let's check whether vehicles had to depart before the simulation starts
506  const SUMOTime offsetToBegin = string2time(OptionsCont::getOptions().getString("begin")) - myVehicleParameter->depart;
510  delete myVehicleParameter;
511  myVehicleParameter = 0;
512  return;
513  }
514  }
516  myErrorOutput->inform("The vehicle type '" + myVehicleParameter->vtypeid + "' for flow '" + myVehicleParameter->id + "' is not known.");
517  }
519  closeRoute(true);
520  }
522  myErrorOutput->inform("The route '" + myVehicleParameter->routeid + "' for flow '" + myVehicleParameter->id + "' is not known.");
523  delete myVehicleParameter;
524  myVehicleParameter = 0;
525  return;
526  }
527  myActiveRouteID = "";
528  if (!MsgHandler::getErrorInstance()->wasInformed()) {
529  if (myNet.addFlow(myVehicleParameter, OptionsCont::getOptions().getBool("randomize-flows"))) {
531  } else {
532  myErrorOutput->inform("Another flow with the id '" + myVehicleParameter->id + "' exists.");
533  }
534  }
535  myVehicleParameter = 0;
536  myInsertStopEdgesAt = -1;
537 }
538 
539 
540 void
542  if (myActivePlan) {
544  (*myActivePlan) << attrs;
547  return;
548  }
549  if (myActiveContainerPlan) {
551  (*myActiveContainerPlan) << attrs;
554  return;
555  }
556  std::string errorSuffix;
557  if (myVehicleParameter != 0) {
558  errorSuffix = " in vehicle '" + myVehicleParameter->id + "'.";
559  } else {
560  errorSuffix = " in route '" + myActiveRouteID + "'.";
561  }
563  bool ok = parseStop(stop, attrs, errorSuffix, myErrorOutput);
564  if (!ok) {
565  return;
566  }
567  // try to parse the assigned bus stop
568  ROEdge* edge = 0;
569  if (stop.busstop != "") {
570  const SUMOVehicleParameter::Stop* busstop = myNet.getBusStop(stop.busstop);
571  if (busstop == 0) {
572  myErrorOutput->inform("Unknown bus stop '" + stop.busstop + "'" + errorSuffix);
573  return;
574  }
575  stop.lane = busstop->lane;
576  stop.endPos = busstop->endPos;
577  stop.startPos = busstop->startPos;
578  edge = myNet.getEdge(stop.lane.substr(0, stop.lane.rfind('_')));
579  } // try to parse the assigned container stop
580  else if (stop.containerstop != "") {
581  const SUMOVehicleParameter::Stop* containerstop = myNet.getContainerStop(stop.containerstop);
582  if (containerstop == 0) {
583  myErrorOutput->inform("Unknown container stop '" + stop.containerstop + "'" + errorSuffix);
584  }
585  stop.lane = containerstop->lane;
586  stop.endPos = containerstop->endPos;
587  stop.startPos = containerstop->startPos;
588  edge = myNet.getEdge(stop.lane.substr(0, stop.lane.rfind('_')));
589  } else {
590  // no, the lane and the position should be given
591  stop.lane = attrs.getOpt<std::string>(SUMO_ATTR_LANE, 0, ok, "");
592  if (!ok || stop.lane == "") {
593  myErrorOutput->inform("A stop must be placed on a bus stop, a container stop or a lane" + errorSuffix);
594  return;
595  }
596  edge = myNet.getEdge(stop.lane.substr(0, stop.lane.rfind('_')));
597  if (edge == 0) {
598  myErrorOutput->inform("The lane '" + stop.lane + "' for a stop is not known" + errorSuffix);
599  return;
600  }
601  stop.endPos = attrs.getOpt<SUMOReal>(SUMO_ATTR_ENDPOS, 0, ok, edge->getLength());
602  stop.startPos = attrs.getOpt<SUMOReal>(SUMO_ATTR_STARTPOS, 0, ok, stop.endPos - 2 * POSITION_EPS);
603  const bool friendlyPos = attrs.getOpt<bool>(SUMO_ATTR_FRIENDLY_POS, 0, ok, false);
604  if (!ok || !checkStopPos(stop.startPos, stop.endPos, edge->getLength(), POSITION_EPS, friendlyPos)) {
605  myErrorOutput->inform("Invalid start or end position for stop" + errorSuffix);
606  return;
607  }
608  }
609  if (myVehicleParameter != 0) {
610  myVehicleParameter->stops.push_back(stop);
611  } else {
612  myActiveRouteStops.push_back(stop);
613  }
614  if (myInsertStopEdgesAt >= 0) {
615  myActiveRoute.insert(myActiveRoute.begin() + myInsertStopEdgesAt, edge);
617  }
618 }
619 
620 
621 void
622 RORouteHandler::parseEdges(const std::string& desc, ConstROEdgeVector& into,
623  const std::string& rid) {
624  if (desc[0] == BinaryFormatter::BF_ROUTE) {
625  std::istringstream in(desc, std::ios::binary);
626  char c;
627  in >> c;
628  FileHelpers::readEdgeVector(in, into, rid);
629  } else {
630  for (StringTokenizer st(desc); st.hasNext();) {
631  const std::string id = st.next();
632  const ROEdge* edge = myNet.getEdge(id);
633  if (edge == 0) {
634  myErrorOutput->inform("The edge '" + id + "' within the route " + rid + " is not known.");
635  } else {
636  into.push_back(edge);
637  }
638  }
639  }
640 }
641 
642 
643 bool
645  bool ok = true;
646  const char* id = myVehicleParameter->id.c_str();
647  SUMOReal departPos = attrs.getOpt<SUMOReal>(SUMO_ATTR_DEPARTPOS, id, ok, 0);
648  SUMOReal arrivalPos = attrs.getOpt<SUMOReal>(SUMO_ATTR_ARRIVALPOS, id, ok, -NUMERICAL_EPS);
649  assert(!attrs.hasAttribute(SUMO_ATTR_EDGES));
650  assert(myActiveRoute.size() == 0);
651  const std::string fromID = attrs.get<std::string>(SUMO_ATTR_FROM, id, ok);
652  const std::string toID = attrs.get<std::string>(SUMO_ATTR_TO, id, ok);
653  const ROEdge* from = myNet.getEdge(fromID);
654  if (from == 0) {
655  myErrorOutput->inform("The edge '" + fromID + "' within a walk of " + myVehicleParameter->id + " is not known."
656  + "\n The route can not be build.");
657  ok = false;
658  }
659  const ROEdge* to = myNet.getEdge(toID);
660  if (to == 0) {
661  myErrorOutput->inform("The edge '" + toID + "' within a walk of " + myVehicleParameter->id + " is not known."
662  + "\n The route can not be build.");
663  ok = false;
664  }
665  if (ok) {
666  if (myPedestrianRouter == 0) {
668  }
669  myPedestrianRouter->compute(from, to,
670  SUMOVehicleParameter::interpretEdgePos(departPos, from->getLength(), SUMO_ATTR_DEPARTPOS, "person walking from " + fromID),
671  SUMOVehicleParameter::interpretEdgePos(arrivalPos, to->getLength(), SUMO_ATTR_ARRIVALPOS, "person walking to " + toID),
673  if (myActiveRoute.empty()) {
674  myErrorOutput->inform("No connection found between '" + fromID + "' and '" + toID + "' for person '" + myVehicleParameter->id + "'.");
675  return false;
676  }
678  if (attrs.hasAttribute(SUMO_ATTR_DEPARTPOS)) {
679  plan.writeAttr(SUMO_ATTR_DEPARTPOS, attrs.get<SUMOReal>(SUMO_ATTR_DEPARTPOS, id, ok));
680  }
681  if (attrs.hasAttribute(SUMO_ATTR_ARRIVALPOS)) {
682  plan.writeAttr(SUMO_ATTR_ARRIVALPOS, attrs.get<SUMOReal>(SUMO_ATTR_ARRIVALPOS, id, ok));
683  }
684  if (attrs.hasAttribute(SUMO_ATTR_DURATION)) {
686  }
687  if (attrs.hasAttribute(SUMO_ATTR_SPEED)) {
688  plan.writeAttr(SUMO_ATTR_SPEED, attrs.get<SUMOReal>(SUMO_ATTR_SPEED, id, ok));
689  }
690  if (attrs.hasAttribute(SUMO_ATTR_BUS_STOP)) {
691  plan.writeAttr(SUMO_ATTR_BUS_STOP, attrs.get<std::string>(SUMO_ATTR_BUS_STOP, id, ok));
692  }
696  }
697  myActiveRoute.clear();
698  return ok;
699 }
700 
701 
702 /****************************************************************************/
const int VEHPARS_TO_TAZ_SET
RORouteDef * myCurrentAlternatives
The currently parsed route alternatives.
OutputDevice & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
Definition: OutputDevice.h:257
static MsgHandler * getErrorInstance()
Returns the instance to add errors to.
Definition: MsgHandler.cpp:80
SUMOReal myCurrentCosts
The currently parsed route costs.
virtual void myEndElement(int element)
Called when a closing tag occurs.
void closeVehicleTypeDistribution()
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.
void closePerson()
Ends the processing of a person.
std::string vtypeid
The vehicle's type id.
void openRouteDistribution(const SUMOSAXAttributes &attrs)
unsigned int getNumSuccessors() const
Returns the number of edges this edge is connected to.
Definition: ROEdge.cpp:207
static void parseVTypeEmbedded(SUMOVTypeParameter &into, int element, const SUMOSAXAttributes &attrs, bool fromVType=false)
Parses an element embedded in vtype definition.
SUMOVehicleParameter * myVehicleParameter
Parameter of the current vehicle, trip, person, container or flow.
ROPedestrianRouterDijkstra * myPedestrianRouter
Structure representing possible vehicle parameter.
bool add(SUMOReal prob, T val, bool checkDuplicates=true)
Adds a value with an assigned probability to the distribution.
ConstROEdgeVector myActiveRoute
The current route.
void addAlternativeDef(const RORouteDef *alternative)
Adds an alternative loaded from the file.
Definition: RORouteDef.cpp:86
ROEdge * getEdge(const std::string &name) const
Retrieves an edge from the network.
Definition: RONet.h:138
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
SUMOVTypeParameter * myCurrentVType
The currently parsed vehicle type.
int repetitionsDone
The number of times the vehicle was already inserted.
virtual void myStartElement(int element, const SUMOSAXAttributes &attrs)
Called on the opening of a tag;.
const SUMOReal DEFAULT_PEDESTRIAN_SPEED
MsgHandler *const myErrorOutput
Depending on the "ignore-errors" option different outputs are used.
const SUMOVehicleParameter::Stop * getContainerStop(const std::string &id) const
Retrieves a container stop from the network.
Definition: RONet.h:206
const SUMOReal DEFAULT_VEH_PROB
SUMOReal myActiveRouteProbability
The probability of the current route.
virtual void myEndElement(int element)
Called when a closing tag occurs.
void registerLastDepart()
save last depart (only to be used if vehicle is not discarded)
int myActiveContainerPlanSize
The number of stages in myActiveContainerPlan.
std::vector< const ROEdge * > ConstROEdgeVector
Definition: ROEdge.h:59
void openVehicleTypeDistribution(const SUMOSAXAttributes &attrs)
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
void closeVehicle()
Ends the processing of a vehicle.
virtual bool hasAttribute(int id) const =0
Returns the information whether the named (by its enum-value) attribute is within the current list...
#define WRITE_WARNING(msg)
Definition: MsgHandler.h:200
virtual bool addVehicleType(SUMOVTypeParameter *type)
Adds a read vehicle type definition to the network.
Definition: RONet.cpp:259
RandomDistributor< SUMOVTypeParameter * > * myCurrentVTypeDistribution
The currently parsed distribution of vehicle types (probability->vehicle type)
virtual bool addVehicle(const std::string &id, ROVehicle *veh)
Definition: RONet.cpp:282
static OptionsCont & getOptions()
Retrieves the options.
Definition: OptionsCont.cpp:67
std::string toTaz
The vehicle's destination zone (district)
std::vector< Stop > stops
List of the stops the vehicle will make.
RORouteHandler(RONet &net, const std::string &file, const bool tryRepair, const bool emptyDestinationsAllowed, const bool ignoreErrors)
standard constructor
RONet & myNet
The current route.
static SUMOReal interpretEdgePos(SUMOReal pos, SUMOReal maximumValue, SumoXMLAttr attr, const std::string &id)
Interprets negative edge positions and fits them onto a given edge.
const SUMOVehicleParameter::Stop * getBusStop(const std::string &id) const
Retrieves a bus stop from the network.
Definition: RONet.h:192
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
bool addVTypeDistribution(const std::string &id, RandomDistributor< SUMOVTypeParameter * > *vehTypeDistribution)
Adds a vehicle type distribution.
Definition: RONet.cpp:272
A vehicle as used by router.
Definition: ROVehicle.h:60
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...
bool addRouteDef(RORouteDef *def)
Definition: RONet.cpp:166
SUMOReal startPos
The stopping position start.
the edges of a route
std::string routeid
The vehicle's route id.
Encapsulated SAX-Attributes.
bool wasSet(int what) const
Returns whether the given parameter was set.
SUMOReal endPos
The stopping position end.
void addContainer(const SUMOTime depart, const std::string desc)
Definition: RONet.cpp:313
void parseEdges(const std::string &desc, ConstROEdgeVector &into, const std::string &rid)
Parse edges from strings.
SUMOTime depart
The vehicle's departure time.
void addPerson(const SUMOTime depart, const std::string desc)
Definition: RONet.cpp:308
DepartDefinition departProcedure
Information how the vehicle shall choose the depart time.
SUMOTime string2time(const std::string &r)
Definition: SUMOTime.cpp:48
void addStop(const SUMOSAXAttributes &attrs)
Processing of a stop.
std::string getString()
Returns the current content as a string.
int myActivePlanSize
The number of stages in myActivePlan.
#define POSITION_EPS
Definition: config.h:189
std::string fromTaz
The vehicle's origin zone (district)
An edge representing a whole district.
Definition: ROEdge.h:83
PedestrianRouterDijkstra< ROEdge, ROLane, RONode > ROPedestrianRouterDijkstra
the router for pedestrians
SUMOTime getSUMOTimeReporting(int attr, const char *objectid, bool &ok, bool report=true) const
Tries to read given attribute assuming it is a SUMOTime.
A basic edge for routing applications.
Definition: ROEdge.h:73
const int VEHPARS_FROM_TAZ_SET
std::string lane
The lane to stop at.
Parser for routes during their loading.
void closeContainer()
Ends the processing of a container.
SUMOReal getOverallProb() const
Return the sum of the probabilites assigned to the members.
std::vector< SUMOVehicleParameter::Stop > myActiveRouteStops
List of the stops on the parsed route.
The router's network representation.
Definition: RONet.h:72
void openRoute(const SUMOSAXAttributes &attrs)
virtual void myStartElement(int element, const SUMOSAXAttributes &attrs)
Called on the opening of a tag;.
SUMOReal getLength() const
Returns the length of the edge.
Definition: ROEdge.h:183
RORouteDef * copy(const std::string &id) const
Returns a deep copy of the route definition.
Definition: RORouteDef.cpp:368
SUMOReal defaultProbability
The probability when being added to a distribution without an explicit probability.
Definition of vehicle stop (position and duration)
bool parseStop(SUMOVehicleParameter::Stop &stop, const SUMOSAXAttributes &attrs, std::string errorSuffix, MsgHandler *const errorOutput)
parses attributes common to all stops
const bool myTryRepair
Information whether routes shall be repaired.
void inform(std::string msg, bool addType=true)
adds a new error to the list
Definition: MsgHandler.cpp:89
OutputDevice_String * myActiveContainerPlan
The plan of the current container.
Base class for a vehicle's route definition.
Definition: RORouteDef.h:63
unsigned int getNumPredecessors() const
Returns the number of edges connected to this edge.
Definition: ROEdge.cpp:216
std::string id
The vehicle type's id.
int SUMOTime
Definition: SUMOTime.h:43
void addLoadedAlternative(RORoute *alternative)
Adds a single alternative loaded from the file An alternative may also be generated during DUA...
Definition: RORouteDef.cpp:80
void closeRoute(const bool mayBeDisconnected=false)
OutputDevice_String * myActivePlan
The plan of the current person.
const RGBColor * myActiveRouteColor
The currently parsed route's color.
virtual ~RORouteHandler()
standard destructor
static void readEdgeVector(std::istream &in, std::vector< const E * > &edges, const std::string &rid)
Reads an edge vector binary.
Definition: FileHelpers.h:283
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:71
bool closeTag()
Closes the most recently opened tag.
#define SUMOReal
Definition: config.h:218
SUMOVTypeParameter * getVehicleTypeSecure(const std::string &id)
Retrieves the named vehicle type.
Definition: RONet.cpp:217
#define NUMERICAL_EPS
Definition: config.h:162
bool routePedestrian(const SUMOSAXAttributes &attrs, OutputDevice &plan)
route a walking person and write the corresponding walk element (return whether sucessful) ...
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.
void closeFlow()
Ends the processing of a flow.
T get(int attr, const char *objectid, bool &ok, bool report=true) const
Tries to read given attribute assuming it is an int.
bool addFlow(SUMOVehicleParameter *flow, const bool randomize)
Definition: RONet.cpp:294
std::string myActiveRouteRefID
The id of the route the current route references to.
A color information.
void parseFromViaTo(std::string element, const SUMOSAXAttributes &attrs)
Called for parsing from and to and the corresponding taz attributes.
RORouteDef * getRouteDef(const std::string &name) const
Returns the named route definition.
Definition: RONet.h:290
SUMOReal getOverallProb() const
Returns the sum of the probablities of the contained routes.
Definition: RORouteDef.cpp:380
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
A complete router's route.
Definition: RORoute.h:62
An output device that encapsulates an ofstream.
void closeRouteDistribution()
std::string myCurrentVTypeDistributionID
The id of the currently parsed vehicle type distribution.
std::string id
The vehicle's id.