Eclipse SUMO - Simulation of Urban MObility
RORouteHandler.cpp
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2001-2019 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials
5 // are made available under the terms of the Eclipse Public License v2.0
6 // which accompanies this distribution, and is available at
7 // http://www.eclipse.org/legal/epl-v20.html
8 // SPDX-License-Identifier: EPL-2.0
9 /****************************************************************************/
18 // Parser and container for routes during their loading
19 /****************************************************************************/
20 
21 
22 // ===========================================================================
23 // included modules
24 // ===========================================================================
25 #include <config.h>
26 
27 #include <string>
28 #include <map>
29 #include <vector>
30 #include <iostream>
41 #include <utils/xml/XMLSubSys.h>
43 #include "ROPerson.h"
44 #include "RONet.h"
45 #include "ROEdge.h"
46 #include "ROLane.h"
47 #include "RORouteDef.h"
48 #include "RORouteHandler.h"
49 
50 
51 // ===========================================================================
52 // method definitions
53 // ===========================================================================
54 RORouteHandler::RORouteHandler(RONet& net, const std::string& file,
55  const bool tryRepair,
56  const bool emptyDestinationsAllowed,
57  const bool ignoreErrors,
58  const bool checkSchema) :
59  SUMORouteHandler(file, checkSchema ? "routes" : "", true),
60  myNet(net),
61  myActivePerson(nullptr),
62  myActiveContainerPlan(nullptr),
63  myActiveContainerPlanSize(0),
64  myTryRepair(tryRepair),
65  myEmptyDestinationsAllowed(emptyDestinationsAllowed),
66  myErrorOutput(ignoreErrors ? MsgHandler::getWarningInstance() : MsgHandler::getErrorInstance()),
67  myBegin(string2time(OptionsCont::getOptions().getString("begin"))),
68  myKeepVTypeDist(OptionsCont::getOptions().getBool("keep-vtype-distributions")),
69  myCurrentVTypeDistribution(nullptr),
70  myCurrentAlternatives(nullptr),
71  myLaneTree(nullptr) {
72  myActiveRoute.reserve(100);
73 }
74 
75 
77 }
78 
79 
80 void
81 RORouteHandler::parseFromViaTo(std::string element,
82  const SUMOSAXAttributes& attrs) {
83  myActiveRoute.clear();
84  bool useTaz = OptionsCont::getOptions().getBool("with-taz");
86  WRITE_WARNING("Taz usage was requested but no taz present in " + element + " '" + myVehicleParameter->id + "'!");
87  useTaz = false;
88  }
89  bool ok = true;
90  const std::string rid = "for " + element + " '" + myVehicleParameter->id + "'";
92  const ROEdge* fromTaz = myNet.getEdge(myVehicleParameter->fromTaz + "-source");
93  if (fromTaz == nullptr) {
94  myErrorOutput->inform("Source taz '" + myVehicleParameter->fromTaz + "' not known for " + element + " '" + myVehicleParameter->id + "'!");
95  } else if (fromTaz->getNumSuccessors() == 0) {
96  myErrorOutput->inform("Source taz '" + myVehicleParameter->fromTaz + "' has no outgoing edges for " + element + " '" + myVehicleParameter->id + "'!");
97  } else {
98  myActiveRoute.push_back(fromTaz);
99  }
100  } else if (attrs.hasAttribute(SUMO_ATTR_FROMXY)) {
101  parseGeoEdges(attrs.get<PositionVector>(SUMO_ATTR_FROMXY, myVehicleParameter->id.c_str(), ok, true), false, myActiveRoute, rid);
102  } else if (attrs.hasAttribute(SUMO_ATTR_FROMLONLAT)) {
104  } else {
105  parseEdges(attrs.getOpt<std::string>(SUMO_ATTR_FROM, myVehicleParameter->id.c_str(), ok, "", true), myActiveRoute, rid);
106  }
108  myInsertStopEdgesAt = (int)myActiveRoute.size();
109  }
110  ConstROEdgeVector viaEdges;
111  if (attrs.hasAttribute(SUMO_ATTR_VIAXY)) {
112  parseGeoEdges(attrs.get<PositionVector>(SUMO_ATTR_VIAXY, myVehicleParameter->id.c_str(), ok, true), false, viaEdges, rid);
113  } else if (attrs.hasAttribute(SUMO_ATTR_VIALONLAT)) {
114  parseGeoEdges(attrs.get<PositionVector>(SUMO_ATTR_VIALONLAT, myVehicleParameter->id.c_str(), ok, true), true, viaEdges, rid);
115  } else {
116  parseEdges(attrs.getOpt<std::string>(SUMO_ATTR_VIA, myVehicleParameter->id.c_str(), ok, "", true), viaEdges, rid);
117  }
118  for (ConstROEdgeVector::const_iterator i = viaEdges.begin(); i != viaEdges.end(); ++i) {
119  myActiveRoute.push_back(*i);
120  myVehicleParameter->via.push_back((*i)->getID());
121  }
122 
124  const ROEdge* toTaz = myNet.getEdge(myVehicleParameter->toTaz + "-sink");
125  if (toTaz == nullptr) {
126  myErrorOutput->inform("Sink taz '" + myVehicleParameter->toTaz + "' not known for " + element + " '" + myVehicleParameter->id + "'!");
127  } else if (toTaz->getNumPredecessors() == 0) {
128  myErrorOutput->inform("Sink taz '" + myVehicleParameter->toTaz + "' has no incoming edges for " + element + " '" + myVehicleParameter->id + "'!");
129  } else {
130  myActiveRoute.push_back(toTaz);
131  }
132  } else if (attrs.hasAttribute(SUMO_ATTR_TOXY)) {
133  parseGeoEdges(attrs.get<PositionVector>(SUMO_ATTR_TOXY, myVehicleParameter->id.c_str(), ok, true), false, myActiveRoute, rid);
134  } else if (attrs.hasAttribute(SUMO_ATTR_TOLONLAT)) {
135  parseGeoEdges(attrs.get<PositionVector>(SUMO_ATTR_TOLONLAT, myVehicleParameter->id.c_str(), ok, true), true, myActiveRoute, rid);
136  } else {
137  parseEdges(attrs.getOpt<std::string>(SUMO_ATTR_TO, myVehicleParameter->id.c_str(), ok, "", true), myActiveRoute, rid);
138  }
140  if (myVehicleParameter->routeid == "") {
142  }
143 }
144 
145 
146 void
148  const SUMOSAXAttributes& attrs) {
149  SUMORouteHandler::myStartElement(element, attrs);
150  switch (element) {
151  case SUMO_TAG_PERSON:
152  case SUMO_TAG_PERSONFLOW: {
154  if (type == nullptr) {
155  myErrorOutput->inform("The vehicle type '" + myVehicleParameter->vtypeid + "' for person '" + myVehicleParameter->id + "' is not known.");
157  }
159  break;
160  }
161  case SUMO_TAG_RIDE: {
162  std::vector<ROPerson::PlanItem*>& plan = myActivePerson->getPlan();
163  const std::string pid = myVehicleParameter->id;
164  bool ok = true;
165  ROEdge* from = nullptr;
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 = myNet.getEdge(fromID);
169  if (from == nullptr) {
170  throw ProcessError("The from edge '" + fromID + "' within a ride of person '" + pid + "' is not known.");
171  }
172  if (!plan.empty() && plan.back()->getDestination() != from) {
173  throw ProcessError("Disconnected plan for person '" + myVehicleParameter->id + "' (" + fromID + "!=" + plan.back()->getDestination()->getID() + ").");
174  }
175  } else if (plan.empty()) {
176  throw ProcessError("The start edge for person '" + pid + "' is not known.");
177  }
178  ROEdge* to = nullptr;
179  const SUMOVehicleParameter::Stop* stop = nullptr;
180  const std::string toID = attrs.getOpt<std::string>(SUMO_ATTR_TO, pid.c_str(), ok, "");
181  const std::string busStopID = attrs.getOpt<std::string>(SUMO_ATTR_BUS_STOP, pid.c_str(), ok, "");
182  if (toID != "") {
183  to = myNet.getEdge(toID);
184  if (to == nullptr) {
185  throw ProcessError("The to edge '" + toID + "' within a ride of person '" + pid + "' is not known.");
186  }
187  } else if (busStopID != "") {
188  stop = myNet.getStoppingPlace(busStopID, SUMO_TAG_BUS_STOP);
189  if (stop == nullptr) {
190  throw ProcessError("Unknown bus stop '" + busStopID + "' within a ride of '" + myVehicleParameter->id + "'.");
191  }
193  } else {
194  throw ProcessError("The to edge '' within a ride of '" + myVehicleParameter->id + "' is not known.");
195  }
196  double arrivalPos = attrs.getOpt<double>(SUMO_ATTR_ARRIVALPOS, myVehicleParameter->id.c_str(), ok,
197  stop == nullptr ? -NUMERICAL_EPS : stop->endPos);
198  const std::string desc = attrs.get<std::string>(SUMO_ATTR_LINES, pid.c_str(), ok);
199  myActivePerson->addRide(from, to, desc, arrivalPos, busStopID);
200  break;
201  }
202  case SUMO_TAG_CONTAINER:
206  (*myActiveContainerPlan) << attrs;
207  break;
208  case SUMO_TAG_TRANSPORT: {
210  (*myActiveContainerPlan) << attrs;
213  break;
214  }
215  case SUMO_TAG_TRANSHIP: {
216  if (attrs.hasAttribute(SUMO_ATTR_EDGES)) {
217  // copy walk as it is
218  // XXX allow --repair?
220  (*myActiveContainerPlan) << attrs;
223  } else {
224  //routePerson(attrs, *myActiveContainerPlan);
225  }
226  break;
227  }
228  case SUMO_TAG_FLOW:
230  parseFromViaTo("flow", attrs);
231  break;
232  case SUMO_TAG_TRIP:
234  parseFromViaTo("trip", attrs);
235  break;
236  default:
237  break;
238  }
239 }
240 
241 
242 void
244  bool ok = true;
245  myCurrentVTypeDistributionID = attrs.get<std::string>(SUMO_ATTR_ID, nullptr, ok);
246  if (ok) {
248  if (attrs.hasAttribute(SUMO_ATTR_VTYPES)) {
249  const std::string vTypes = attrs.get<std::string>(SUMO_ATTR_VTYPES, myCurrentVTypeDistributionID.c_str(), ok);
250  StringTokenizer st(vTypes);
251  while (st.hasNext()) {
252  const std::string typeID = st.next();
253  SUMOVTypeParameter* const type = myNet.getVehicleTypeSecure(typeID);
254  if (type == nullptr) {
255  myErrorOutput->inform("Unknown vehicle type '" + typeID + "' in distribution '" + myCurrentVTypeDistributionID + "'.");
256  } else {
257  myCurrentVTypeDistribution->add(type, 1.);
258  }
259  }
260  }
261  }
262 }
263 
264 
265 void
267  if (myCurrentVTypeDistribution != nullptr) {
270  myErrorOutput->inform("Vehicle type distribution '" + myCurrentVTypeDistributionID + "' is empty.");
273  myErrorOutput->inform("Another vehicle type (or distribution) with the id '" + myCurrentVTypeDistributionID + "' exists.");
274  }
275  myCurrentVTypeDistribution = nullptr;
276  }
277 }
278 
279 
280 void
282  myActiveRoute.clear();
283  myInsertStopEdgesAt = -1;
284  // check whether the id is really necessary
285  std::string rid;
286  if (myCurrentAlternatives != nullptr) {
288  rid = "distribution '" + myCurrentAlternatives->getID() + "'";
289  } else if (myVehicleParameter != nullptr) {
290  // ok, a vehicle is wrapping the route,
291  // we may use this vehicle's id as default
292  myVehicleParameter->routeid = myActiveRouteID = "!" + myVehicleParameter->id; // !!! document this
293  if (attrs.hasAttribute(SUMO_ATTR_ID)) {
294  WRITE_WARNING("Ids of internal routes are ignored (vehicle '" + myVehicleParameter->id + "').");
295  }
296  } else {
297  bool ok = true;
298  myActiveRouteID = attrs.get<std::string>(SUMO_ATTR_ID, nullptr, ok);
299  if (!ok) {
300  return;
301  }
302  rid = "'" + myActiveRouteID + "'";
303  }
304  if (myVehicleParameter != nullptr) { // have to do this here for nested route distributions
305  rid = "for vehicle '" + myVehicleParameter->id + "'";
306  }
307  bool ok = true;
308  if (attrs.hasAttribute(SUMO_ATTR_EDGES)) {
309  parseEdges(attrs.get<std::string>(SUMO_ATTR_EDGES, myActiveRouteID.c_str(), ok), myActiveRoute, rid);
310  }
311  myActiveRouteRefID = attrs.getOpt<std::string>(SUMO_ATTR_REFID, myActiveRouteID.c_str(), ok, "");
312  if (myActiveRouteRefID != "" && myNet.getRouteDef(myActiveRouteRefID) == nullptr) {
313  myErrorOutput->inform("Invalid reference to route '" + myActiveRouteRefID + "' in route " + rid + ".");
314  }
315  if (myCurrentAlternatives != nullptr && !attrs.hasAttribute(SUMO_ATTR_PROB)) {
316  WRITE_WARNING("No probability for a route in '" + rid + "', using default.");
317  }
319  if (ok && myActiveRouteProbability < 0) {
320  myErrorOutput->inform("Invalid probability for route '" + myActiveRouteID + "'.");
321  }
323  ok = true;
324  myCurrentCosts = attrs.getOpt<double>(SUMO_ATTR_COST, myActiveRouteID.c_str(), ok, -1);
325  if (ok && myCurrentCosts != -1 && myCurrentCosts < 0) {
326  myErrorOutput->inform("Invalid cost for route '" + myActiveRouteID + "'.");
327  }
328 }
329 
330 
331 void
333  // currently unused
334 }
335 
336 
337 void
339  // currently unused
340 }
341 
342 
343 void
344 RORouteHandler::closeRoute(const bool mayBeDisconnected) {
345  if (myActiveRoute.size() == 0) {
346  if (myActiveRouteRefID != "" && myCurrentAlternatives != nullptr) {
348  myActiveRouteID = "";
349  myActiveRouteRefID = "";
350  return;
351  }
352  if (myVehicleParameter != nullptr) {
353  myErrorOutput->inform("The route for vehicle '" + myVehicleParameter->id + "' has no edges.");
354  } else {
355  myErrorOutput->inform("Route '" + myActiveRouteID + "' has no edges.");
356  }
357  myActiveRouteID = "";
358  myActiveRouteStops.clear();
359  return;
360  }
361  if (myActiveRoute.size() == 1 && myActiveRoute.front()->isTazConnector()) {
362  myErrorOutput->inform("The routing information for vehicle '" + myVehicleParameter->id + "' is insufficient.");
363  myActiveRouteID = "";
364  myActiveRouteStops.clear();
365  return;
366  }
367  if (!mayBeDisconnected && OptionsCont::getOptions().exists("no-internal-links") && !OptionsCont::getOptions().getBool("no-internal-links")) {
368  // fix internal edges which did not get parsed
369  const ROEdge* last = nullptr;
370  ConstROEdgeVector fullRoute;
371  for (const ROEdge* roe : myActiveRoute) {
372  if (last != nullptr) {
373  for (const ROEdge* intern : last->getSuccessors()) {
374  if (intern->isInternal() && intern->getSuccessors().size() == 1 && intern->getSuccessors().front() == roe) {
375  fullRoute.push_back(intern);
376  }
377  }
378  }
379  fullRoute.push_back(roe);
380  last = roe;
381  }
382  myActiveRoute = fullRoute;
383  }
386  myActiveRoute.clear();
387  if (myCurrentAlternatives == nullptr) {
388  if (myNet.getRouteDef(myActiveRouteID) != nullptr) {
389  delete route;
390  if (myVehicleParameter != nullptr) {
391  myErrorOutput->inform("Another route for vehicle '" + myVehicleParameter->id + "' exists.");
392  } else {
393  myErrorOutput->inform("Another route (or distribution) with the id '" + myActiveRouteID + "' exists.");
394  }
395  myActiveRouteID = "";
396  myActiveRouteStops.clear();
397  return;
398  } else {
399  myCurrentAlternatives = new RORouteDef(myActiveRouteID, 0, mayBeDisconnected || myTryRepair, mayBeDisconnected);
402  myCurrentAlternatives = nullptr;
403  }
404  } else {
406  }
407  myActiveRouteID = "";
408  myActiveRouteStops.clear();
409 }
410 
411 
412 void
414  // check whether the id is really necessary
415  bool ok = true;
416  std::string id;
417  if (myVehicleParameter != nullptr) {
418  // ok, a vehicle is wrapping the route,
419  // we may use this vehicle's id as default
420  myVehicleParameter->routeid = id = "!" + myVehicleParameter->id; // !!! document this
421  if (attrs.hasAttribute(SUMO_ATTR_ID)) {
422  WRITE_WARNING("Ids of internal route distributions are ignored (vehicle '" + myVehicleParameter->id + "').");
423  }
424  } else {
425  id = attrs.get<std::string>(SUMO_ATTR_ID, nullptr, ok);
426  if (!ok) {
427  return;
428  }
429  }
430  // try to get the index of the last element
431  int index = attrs.getOpt<int>(SUMO_ATTR_LAST, id.c_str(), ok, 0);
432  if (ok && index < 0) {
433  myErrorOutput->inform("Negative index of a route alternative (id='" + id + "').");
434  return;
435  }
436  // build the alternative cont
437  myCurrentAlternatives = new RORouteDef(id, index, myTryRepair, false);
438  if (attrs.hasAttribute(SUMO_ATTR_ROUTES)) {
439  ok = true;
440  StringTokenizer st(attrs.get<std::string>(SUMO_ATTR_ROUTES, id.c_str(), ok));
441  while (st.hasNext()) {
442  const std::string routeID = st.next();
443  const RORouteDef* route = myNet.getRouteDef(routeID);
444  if (route == nullptr) {
445  myErrorOutput->inform("Unknown route '" + routeID + "' in distribution '" + id + "'.");
446  } else {
448  }
449  }
450  }
451 }
452 
453 
454 void
456  if (myCurrentAlternatives != nullptr) {
458  myErrorOutput->inform("Route distribution '" + myCurrentAlternatives->getID() + "' is empty.");
459  delete myCurrentAlternatives;
460  } else if (!myNet.addRouteDef(myCurrentAlternatives)) {
461  myErrorOutput->inform("Another route (or distribution) with the id '" + myCurrentAlternatives->getID() + "' exists.");
462  delete myCurrentAlternatives;
463  }
464  myCurrentAlternatives = nullptr;
465  }
466 }
467 
468 
469 void
471  // get the vehicle id
473  return;
474  }
475  // get vehicle type
477  if (type == nullptr) {
478  myErrorOutput->inform("The vehicle type '" + myVehicleParameter->vtypeid + "' for vehicle '" + myVehicleParameter->id + "' is not known.");
480  } else {
481  if (!myKeepVTypeDist) {
482  // fix the type id in case we used a distribution
483  myVehicleParameter->vtypeid = type->id;
484  }
485  }
486  if (type->vehicleClass == SVC_PEDESTRIAN) {
487  WRITE_WARNING("Vehicle type '" + type->id + "' with vClass=pedestrian should only be used for persons and not for vehicle '" + myVehicleParameter->id + "'.");
488  }
489  // get the route
491  if (route == nullptr) {
492  myErrorOutput->inform("The route of the vehicle '" + myVehicleParameter->id + "' is not known.");
493  return;
494  }
495  if (route->getID()[0] != '!') {
496  route = route->copy("!" + myVehicleParameter->id, myVehicleParameter->depart);
497  }
498  // build the vehicle
499  if (!MsgHandler::getErrorInstance()->wasInformed()) {
500  ROVehicle* veh = new ROVehicle(*myVehicleParameter, route, type, &myNet, myErrorOutput);
501  if (myNet.addVehicle(myVehicleParameter->id, veh)) {
503  }
504  }
505 }
506 
507 
508 void
511  if (myCurrentVTypeDistribution != nullptr) {
513  }
514  }
515  myCurrentVType = nullptr;
516 }
517 
518 
519 void
521  if (myActivePerson->getPlan().empty()) {
522  WRITE_WARNING("Discarding person '" + myVehicleParameter->id + "' because it's plan is empty");
523  } else {
526  }
527  }
528  delete myVehicleParameter;
529  myVehicleParameter = nullptr;
530  myActivePerson = nullptr;
531 }
532 
533 
534 void
536  if (myActivePerson->getPlan().empty()) {
537  WRITE_WARNING("Discarding person '" + myVehicleParameter->id + "' because it's plan is empty");
538  } else {
539  // instantiate all persons of this flow
540  int i = 0;
541  std::string baseID = myVehicleParameter->id;
544  throw ProcessError("probabilistic personFlow '" + myVehicleParameter->id + "' must specify end time");
545  } else {
546  for (SUMOTime t = myVehicleParameter->depart; t < myVehicleParameter->repetitionEnd; t += TIME2STEPS(1)) {
548  addFlowPerson(t, baseID, i++);
549  }
550  }
551  }
552  } else {
554  for (; i < myVehicleParameter->repetitionNumber; i++) {
555  addFlowPerson(depart, baseID, i);
557  }
558  }
559  }
560  delete myVehicleParameter;
561  myVehicleParameter = nullptr;
562  myActivePerson = nullptr;
563 }
564 
565 
566 void
567 RORouteHandler::addFlowPerson(SUMOTime depart, const std::string& baseID, int i) {
569  pars.id = baseID + "." + toString(i);
570  pars.depart = depart;
571  ROPerson* copyPerson = new ROPerson(pars, myActivePerson->getType());
572  for (ROPerson::PlanItem* item : myActivePerson->getPlan()) {
573  copyPerson->getPlan().push_back(item->clone());
574  }
575  if (i == 0) {
576  delete myActivePerson;
577  }
578  myActivePerson = copyPerson;
580  if (i == 0) {
582  }
583  }
584 }
585 
586 void
589  if (myActiveContainerPlanSize > 0) {
592  } else {
593  WRITE_WARNING("Discarding container '" + myVehicleParameter->id + "' because it's plan is empty");
594  }
595  delete myVehicleParameter;
596  myVehicleParameter = nullptr;
597  delete myActiveContainerPlan;
598  myActiveContainerPlan = nullptr;
600 }
601 
602 
603 void
605  // @todo: consider myScale?
607  delete myVehicleParameter;
608  myVehicleParameter = nullptr;
609  return;
610  }
611  // let's check whether vehicles had to depart before the simulation starts
613  const SUMOTime offsetToBegin = myBegin - myVehicleParameter->depart;
617  delete myVehicleParameter;
618  myVehicleParameter = nullptr;
619  return;
620  }
621  }
623  myErrorOutput->inform("The vehicle type '" + myVehicleParameter->vtypeid + "' for flow '" + myVehicleParameter->id + "' is not known.");
624  }
625  if (myVehicleParameter->routeid[0] == '!' && myNet.getRouteDef(myVehicleParameter->routeid) == nullptr) {
626  closeRoute(true);
627  }
628  if (myNet.getRouteDef(myVehicleParameter->routeid) == nullptr) {
629  myErrorOutput->inform("The route '" + myVehicleParameter->routeid + "' for flow '" + myVehicleParameter->id + "' is not known.");
630  delete myVehicleParameter;
631  myVehicleParameter = nullptr;
632  return;
633  }
634  myActiveRouteID = "";
635  if (!MsgHandler::getErrorInstance()->wasInformed()) {
636  if (myNet.addFlow(myVehicleParameter, OptionsCont::getOptions().getBool("randomize-flows"))) {
638  } else {
639  myErrorOutput->inform("Another flow with the id '" + myVehicleParameter->id + "' exists.");
640  }
641  } else {
642  delete myVehicleParameter;
643  }
644  myVehicleParameter = nullptr;
645  myInsertStopEdgesAt = -1;
646 }
647 
648 
649 void
651  closeRoute(true);
652  closeVehicle();
653 }
654 
655 
656 void
658  if (myActiveContainerPlan != nullptr) {
660  (*myActiveContainerPlan) << attrs;
663  return;
664  }
665  std::string errorSuffix;
666  if (myVehicleParameter != nullptr) {
667  errorSuffix = " in vehicle '" + myVehicleParameter->id + "'.";
668  } else {
669  errorSuffix = " in route '" + myActiveRouteID + "'.";
670  }
672  bool ok = parseStop(stop, attrs, errorSuffix, myErrorOutput);
673  if (!ok) {
674  return;
675  }
676  // try to parse the assigned bus stop
677  ROEdge* edge = nullptr;
678  if (stop.busstop != "") {
680  if (busstop == nullptr) {
681  myErrorOutput->inform("Unknown bus stop '" + stop.busstop + "'" + errorSuffix);
682  return;
683  }
684  stop.lane = busstop->lane;
685  stop.endPos = busstop->endPos;
686  stop.startPos = busstop->startPos;
687  edge = myNet.getEdge(stop.lane.substr(0, stop.lane.rfind('_')));
688  } // try to parse the assigned container stop
689  else if (stop.containerstop != "") {
691  if (containerstop == nullptr) {
692  myErrorOutput->inform("Unknown container stop '" + stop.containerstop + "'" + errorSuffix);
693  return;
694  }
695  stop.lane = containerstop->lane;
696  stop.endPos = containerstop->endPos;
697  stop.startPos = containerstop->startPos;
698  edge = myNet.getEdge(stop.lane.substr(0, stop.lane.rfind('_')));
699  } // try to parse the assigned parking area
700  else if (stop.parkingarea != "") {
702  if (parkingarea == nullptr) {
703  myErrorOutput->inform("Unknown parking area '" + stop.parkingarea + "'" + errorSuffix);
704  return;
705  }
706  stop.lane = parkingarea->lane;
707  stop.endPos = parkingarea->endPos;
708  stop.startPos = parkingarea->startPos;
709  edge = myNet.getEdge(stop.lane.substr(0, stop.lane.rfind('_')));
710  } else {
711  // no, the lane and the position should be given
712  stop.lane = attrs.getOpt<std::string>(SUMO_ATTR_LANE, nullptr, ok, "");
713  if (!ok || stop.lane == "") {
714  myErrorOutput->inform("A stop must be placed on a bus stop, a container stop, a parking area or a lane" + errorSuffix);
715  return;
716  }
717  edge = myNet.getEdge(stop.lane.substr(0, stop.lane.rfind('_')));
718  if (edge == nullptr) {
719  myErrorOutput->inform("The lane '" + stop.lane + "' for a stop is not known" + errorSuffix);
720  return;
721  }
722  stop.endPos = attrs.getOpt<double>(SUMO_ATTR_ENDPOS, nullptr, ok, edge->getLength());
723  stop.startPos = attrs.getOpt<double>(SUMO_ATTR_STARTPOS, nullptr, ok, stop.endPos - 2 * POSITION_EPS);
724  const bool friendlyPos = attrs.getOpt<bool>(SUMO_ATTR_FRIENDLY_POS, nullptr, ok, false);
725  const double endPosOffset = edge->isInternal() ? edge->getNormalBefore()->getLength() : 0;
726  if (!ok || !checkStopPos(stop.startPos, stop.endPos, edge->getLength() + endPosOffset, POSITION_EPS, friendlyPos)) {
727  myErrorOutput->inform("Invalid start or end position for stop" + errorSuffix);
728  return;
729  }
730  }
731  if (myActivePerson != nullptr) {
732  myActivePerson->addStop(stop, edge);
733  } else if (myVehicleParameter != nullptr) {
734  myVehicleParameter->stops.push_back(stop);
735  } else {
736  myActiveRouteStops.push_back(stop);
737  }
738  if (myInsertStopEdgesAt >= 0) {
739  myActiveRoute.insert(myActiveRoute.begin() + myInsertStopEdgesAt, edge);
741  }
742 }
743 
744 
745 void
747 }
748 
749 
750 void
752 }
753 
754 
755 void
757 }
758 
759 
760 void
762 }
763 
764 
765 void
767 }
768 
769 
770 void
771 RORouteHandler::parseEdges(const std::string& desc, ConstROEdgeVector& into,
772  const std::string& rid) {
773  if (desc[0] == BinaryFormatter::BF_ROUTE) {
774  std::istringstream in(desc, std::ios::binary);
775  char c;
776  in >> c;
777  FileHelpers::readEdgeVector(in, into, rid);
778  } else {
779  for (StringTokenizer st(desc); st.hasNext();) {
780  const std::string id = st.next();
781  const ROEdge* edge = myNet.getEdge(id);
782  if (edge == nullptr) {
783  myErrorOutput->inform("The edge '" + id + "' within the route " + rid + " is not known.");
784  } else {
785  into.push_back(edge);
786  }
787  }
788  }
789 }
790 
791 void
793  ConstROEdgeVector& into, const std::string& rid) {
794  const double range = 100;
795  NamedRTree* t = getLaneTree();
796  if (geo && !GeoConvHelper::getFinal().usingGeoProjection()) {
797  WRITE_ERROR("Cannot convert geo-positions because the network has no geo-reference");
798  return;
799  }
802  if (type != nullptr) {
803  vClass = type->vehicleClass;
804  }
805  for (Position pos : positions) {
806  Position orig = pos;
807  if (geo) {
809  }
810  Boundary b;
811  b.add(pos);
812  b.grow(range);
813  const float cmin[2] = {(float) b.xmin(), (float) b.ymin()};
814  const float cmax[2] = {(float) b.xmax(), (float) b.ymax()};
815  std::set<const Named*> lanes;
816  Named::StoringVisitor sv(lanes);
817  t->Search(cmin, cmax, sv);
818  // use closest
819  double minDist = std::numeric_limits<double>::max();
820  const ROLane* best = nullptr;
821  for (const Named* o : lanes) {
822  const ROLane* cand = static_cast<const ROLane*>(o);
823  if (!cand->allowsVehicleClass(vClass)) {
824  continue;
825  }
826  double dist = cand->getShape().distance2D(pos);
827  if (dist < minDist) {
828  minDist = dist;
829  best = cand;
830  }
831  }
832  if (best == nullptr) {
833  myErrorOutput->inform("No edge found near position " + toString(orig, geo ? gPrecisionGeo : gPrecision) + " within the route " + rid + ".");
834  } else {
835  const ROEdge* bestEdge = &best->getEdge();
836  while (bestEdge->isInternal()) {
837  bestEdge = bestEdge->getSuccessors().front();
838  }
839  into.push_back(bestEdge);
840  }
841  }
842 }
843 
844 
845 void
847  bool ok = true;
848  const char* const id = myVehicleParameter->id.c_str();
849  assert(!attrs.hasAttribute(SUMO_ATTR_EDGES));
850  const std::string fromID = attrs.getOpt<std::string>(SUMO_ATTR_FROM, id, ok, "");
851  std::string toID = attrs.getOpt<std::string>(SUMO_ATTR_TO, id, ok, "");
852  const std::string busStopID = attrs.getOpt<std::string>(SUMO_ATTR_BUS_STOP, id, ok, "");
853 
854  const ROEdge* from = fromID != "" || myActivePerson->getPlan().empty() ? myNet.getEdge(fromID) : myActivePerson->getPlan().back()->getDestination();
855  if (from == nullptr) {
856  myErrorOutput->inform("The edge '" + fromID + "' within a walk or personTrip of '" + myVehicleParameter->id + "' is not known."
857  + "\n The route can not be build.");
858  ok = false;
859  }
860  double arrivalPos = 0;
861  const ROEdge* to = myNet.getEdge(toID);
862  if (toID != "" && to == nullptr) {
863  myErrorOutput->inform("The edge '" + toID + "' within a walk or personTrip of '" + myVehicleParameter->id + "' is not known."
864  + "\n The route can not be build.");
865  ok = false;
866  }
867  if (toID == "" && busStopID == "") {
868  myErrorOutput->inform("Either a destination edge or busStop must be define within a walk or personTrip of '" + myVehicleParameter->id + "'."
869  + "\n The route can not be build.");
870  ok = false;
871  }
872 
873  if (toID == "") {
875  if (stop == nullptr) {
876  myErrorOutput->inform("Unknown bus stop '" + busStopID + "' within a walk or personTrip of '" + myVehicleParameter->id + "'.");
877  ok = false;
878  } else {
879  to = myNet.getEdge(stop->lane.substr(0, stop->lane.rfind('_')));
880  arrivalPos = (stop->startPos + stop->endPos) / 2;
881  }
882  }
883 
884  double departPos = myActivePerson->getParameter().departPos;
885  if (!myActivePerson->getPlan().empty()) {
886  departPos = myActivePerson->getPlan().back()->getDestinationPos();
887  }
888 
889  if (attrs.hasAttribute(SUMO_ATTR_DEPARTPOS)) {
890  WRITE_WARNING("The attribute departPos is no longer supported for walks, please use the person attribute, the arrivalPos of the previous step or explicit stops.");
891  }
892  if (to != nullptr && attrs.hasAttribute(SUMO_ATTR_ARRIVALPOS)) {
893  arrivalPos = SUMOVehicleParserHelper::parseWalkPos(SUMO_ATTR_ARRIVALPOS, myHardFail, id, to->getLength(), attrs.get<std::string>(SUMO_ATTR_ARRIVALPOS, id, ok));
894  }
895 
896  const std::string modes = attrs.getOpt<std::string>(SUMO_ATTR_MODES, id, ok, "");
897  SVCPermissions modeSet = 0;
898  for (StringTokenizer st(modes); st.hasNext();) {
899  const std::string mode = st.next();
900  if (mode == "car") {
901  modeSet |= SVC_PASSENGER;
902  } else if (mode == "bicycle") {
903  modeSet |= SVC_BICYCLE;
904  } else if (mode == "public") {
905  modeSet |= SVC_BUS;
906  } else {
907  throw InvalidArgument("Unknown person mode '" + mode + "'.");
908  }
909  }
910  const std::string types = attrs.getOpt<std::string>(SUMO_ATTR_VTYPES, id, ok, "");
911  double walkFactor = attrs.getOpt<double>(SUMO_ATTR_WALKFACTOR, id, ok, OptionsCont::getOptions().getFloat("persontrip.walkfactor"));
912  if (ok) {
913  myActivePerson->addTrip(from, to, modeSet, types, departPos, arrivalPos, busStopID, walkFactor);
914  }
915 }
916 
917 
918 void
920  // XXX allow --repair?
921  bool ok = true;
922  if (attrs.hasAttribute(SUMO_ATTR_ROUTE)) {
923  const std::string routeID = attrs.get<std::string>(SUMO_ATTR_ROUTE, myVehicleParameter->id.c_str(), ok);
924  RORouteDef* routeDef = myNet.getRouteDef(routeID);
925  const RORoute* route = routeDef != nullptr ? routeDef->getFirstRoute() : nullptr;
926  if (route == nullptr) {
927  throw ProcessError("The route '" + routeID + "' for walk of person '" + myVehicleParameter->id + "' is not known.");
928  }
929  myActiveRoute = route->getEdgeVector();
930  } else {
931  myActiveRoute.clear();
932  parseEdges(attrs.get<std::string>(SUMO_ATTR_EDGES, myVehicleParameter->id.c_str(), ok), myActiveRoute, " walk for person '" + myVehicleParameter->id + "'");
933  }
934  const char* const objId = myVehicleParameter->id.c_str();
935  const double duration = attrs.getOpt<double>(SUMO_ATTR_DURATION, objId, ok, -1);
936  if (attrs.hasAttribute(SUMO_ATTR_DURATION) && duration <= 0) {
937  throw ProcessError("Non-positive walking duration for '" + myVehicleParameter->id + "'.");
938  }
939  const double speed = attrs.getOpt<double>(SUMO_ATTR_SPEED, objId, ok, -1.);
940  if (attrs.hasAttribute(SUMO_ATTR_SPEED) && speed <= 0) {
941  throw ProcessError("Non-positive walking speed for '" + myVehicleParameter->id + "'.");
942  }
943  double departPos = 0.;
944  double arrivalPos = 0.;
945  if (attrs.hasAttribute(SUMO_ATTR_DEPARTPOS)) {
946  WRITE_WARNING("The attribute departPos is no longer supported for walks, please use the person attribute, the arrivalPos of the previous step or explicit stops.");
947  }
948  if (attrs.hasAttribute(SUMO_ATTR_ARRIVALPOS)) {
949  arrivalPos = SUMOVehicleParserHelper::parseWalkPos(SUMO_ATTR_ARRIVALPOS, myHardFail, objId, myActiveRoute.back()->getLength(), attrs.get<std::string>(SUMO_ATTR_ARRIVALPOS, objId, ok));
950  }
951  const std::string busStop = attrs.getOpt<std::string>(SUMO_ATTR_BUS_STOP, objId, ok, "");
952  if (ok) {
953  myActivePerson->addWalk(myActiveRoute, duration, speed, departPos, arrivalPos, busStop);
954  }
955 }
956 
957 
958 NamedRTree*
960  if (myLaneTree == nullptr) {
961  myLaneTree = new NamedRTree();
962  for (const auto& edgeItem : myNet.getEdgeMap()) {
963  for (ROLane* lane : edgeItem.second->getLanes()) {
964  Boundary b = lane->getShape().getBoxBoundary();
965  const float cmin[2] = {(float) b.xmin(), (float) b.ymin()};
966  const float cmax[2] = {(float) b.xmax(), (float) b.ymax()};
967  myLaneTree->Insert(cmin, cmax, lane);
968  }
969  }
970  }
971  return myLaneTree;
972 }
973 
974 
975 /****************************************************************************/
static double parseWalkPos(SumoXMLAttr attr, const bool hardFail, const std::string &id, double maxPos, const std::string &val, std::mt19937 *rng=0)
parse departPos or arrivalPos for a walk
RORouteDef * copy(const std::string &id, const SUMOTime stopOffset) const
Returns a deep copy of the route definition.
Definition: RORouteDef.cpp:386
const int VEHPARS_TO_TAZ_SET
RORouteDef * myCurrentAlternatives
The currently parsed route alternatives.
void Insert(const float a_min[2], const float a_max[2], Named *const &a_data)
Insert entry.
Definition: NamedRTree.h:82
SUMOTime repetitionEnd
The time at which the flow ends (only needed when using repetitionProbability)
void parseGeoEdges(const PositionVector &positions, bool geo, ConstROEdgeVector &into, const std::string &rid)
Parse edges from coordinates.
void addTransport(const SUMOSAXAttributes &attrs)
Processing of a transport.
double ymin() const
Returns minimum y-coordinate.
Definition: Boundary.cpp:131
static MsgHandler * getErrorInstance()
Returns the instance to add errors to.
Definition: MsgHandler.cpp:81
double xmax() const
Returns maximum x-coordinate.
Definition: Boundary.cpp:125
void addContainer(const SUMOSAXAttributes &attrs)
Processing of a container.
NamedRTree * getLaneTree()
initialize lane-RTree
std::string lane
The lane to stop at.
long long int SUMOTime
Definition: SUMOTime.h:35
void closeVehicleTypeDistribution()
closes (ends) the building of a distribution
The time is given.
A single lane the router may use.
Definition: ROLane.h:51
std::string next()
returns the next substring when it exists. Otherwise the behaviour is undefined
double distance2D(const Position &p, bool perpendicular=false) const
closest 2D-distance to point p (or -1 if perpendicular is true and the point is beyond this vector) ...
void closePerson()
Ends the processing of a person.
std::string vtypeid
The vehicle&#39;s type id.
int getNumSuccessors() const
Returns the number of edges this edge is connected to.
Definition: ROEdge.cpp:245
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types...
void openRouteDistribution(const SUMOSAXAttributes &attrs)
opens a route distribution for reading
a flow definitio nusing a from-to edges instead of a route (used by router)
Represents a generic random distribution.
SUMOVehicleParameter * myVehicleParameter
Parameter of the current vehicle, trip, person, container or flow.
static void readEdgeVector(std::istream &in, std::vector< const E *> &edges, const std::string &rid)
Reads an edge vector binary.
Definition: FileHelpers.h:256
Structure representing possible vehicle parameter.
int gPrecision
the precision for floating point outputs
Definition: StdDefs.cpp:27
const SUMOVehicleParameter & getParameter() const
Returns the definition of the vehicle / person parameter.
Definition: RORoutable.h:74
ConstROEdgeVector myActiveRoute
The current route.
void addAlternativeDef(const RORouteDef *alternative)
Adds an alternative loaded from the file.
Definition: RORouteDef.cpp:75
double defaultProbability
The probability when being added to a distribution without an explicit probability.
vehicle is a bicycle
std::string getString() const
Returns the current content as a string.
int SVCPermissions
bitset where each bit declares whether a certain SVC may use this edge/lane
double repetitionProbability
The probability for emitting a vehicle per second.
static double rand(std::mt19937 *rng=0)
Returns a random real number in [0, 1)
Definition: RandHelper.h:60
void addWalk(const SUMOSAXAttributes &attrs)
add a fully specified walk
SUMOVTypeParameter * myCurrentVType
The currently parsed vehicle type.
A RT-tree for efficient storing of SUMO&#39;s Named objects.
Definition: NamedRTree.h:64
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;.
SUMOVehicleClass vehicleClass
The vehicle&#39;s class.
double myActiveRouteProbability
The probability of the current route.
std::string busstop
(Optional) bus stop if one is assigned to the stop
MsgHandler *const myErrorOutput
Depending on the "ignore-errors" option different outputs are used.
void closePersonFlow()
Ends the processing of a personFlow.
double getLength() const
Returns the length of the edge.
Definition: ROEdge.h:203
void registerLastDepart()
save last depart (only to be used if vehicle is not discarded)
const double DEFAULT_VEH_PROB
int myActiveContainerPlanSize
The number of stages in myActiveContainerPlan.
std::vector< const ROEdge * > ConstROEdgeVector
Definition: ROEdge.h:57
bool getBool(const std::string &name) const
Returns the boolean-value of the named option (only for Option_Bool)
void openVehicleTypeDistribution(const SUMOSAXAttributes &attrs)
opens a type distribution for reading
const std::string & getID() const
Returns the id.
Definition: Named.h:77
#define TIME2STEPS(x)
Definition: SUMOTime.h:59
bool hasNext()
returns the information whether further substrings exist
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)
std::string parkingarea
(Optional) parking area if one is assigned to the stop
const std::string DEFAULT_VTYPE_ID
ROEdge & getEdge() const
Returns the lane&#39;s edge.
Definition: ROLane.h:95
Every person has a plan comprising of multiple planItems.
Definition: ROPerson.h:80
const SUMOTime myBegin
The begin time.
double getOverallProb() const
Returns the sum of the probablities of the contained routes.
Definition: RORouteDef.cpp:400
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...
RORouteDef * getRouteDef(const std::string &name) const
Returns the named route definition.
Definition: RONet.h:294
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:42
#define WRITE_WARNING(msg)
Definition: MsgHandler.h:239
virtual bool addVehicleType(SUMOVTypeParameter *type)
Adds a read vehicle type definition to the network.
Definition: RONet.cpp:334
RandomDistributor< SUMOVTypeParameter * > * myCurrentVTypeDistribution
The currently parsed distribution of vehicle types (probability->vehicle type)
SUMOTime repetitionOffset
The time offset between vehicle reinsertions.
virtual bool addVehicle(const std::string &id, ROVehicle *veh)
Definition: RONet.cpp:357
static OptionsCont & getOptions()
Retrieves the options.
Definition: OptionsCont.cpp:58
std::string toTaz
The vehicle&#39;s destination zone (district)
std::vector< Stop > stops
List of the stops the vehicle will make, TraCI may add entries here.
RONet & myNet
The current route.
int getNumPredecessors() const
Returns the number of edges connected to this edge.
Definition: ROEdge.cpp:254
bool addVTypeDistribution(const std::string &id, RandomDistributor< SUMOVTypeParameter *> *vehTypeDistribution)
Adds a vehicle type distribution.
Definition: RONet.cpp:347
A vehicle as used by router.
Definition: ROVehicle.h:53
bool addRouteDef(RORouteDef *def)
Definition: RONet.cpp:209
ROPerson * myActivePerson
The plan of the current person.
the edges of a route
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:48
std::string routeid
The vehicle&#39;s route id.
Encapsulated SAX-Attributes.
T get(int attr, const char *objectid, bool &ok, bool report=true) const
Tries to read given attribute assuming it is an int.
void openFlow(const SUMOSAXAttributes &attrs)
opens a flow for reading
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:39
const SUMOVehicleParameter::Stop * getStoppingPlace(const std::string &id, const SumoXMLTag category) const
Retrieves a stopping place from the network.
Definition: RONet.h:208
std::vector< PlanItem * > & getPlan()
Definition: ROPerson.h:377
int gPrecisionGeo
Definition: StdDefs.cpp:28
void addContainer(const SUMOTime depart, const std::string desc)
Definition: RONet.cpp:403
A list of positions.
void parseEdges(const std::string &desc, ConstROEdgeVector &into, const std::string &rid)
Parse edges from strings.
void addStop(const SUMOVehicleParameter::Stop &stopPar, const ROEdge *const stopEdge)
Definition: ROPerson.cpp:119
const PositionVector & getShape() const
Definition: ROLane.h:117
DepartDefinition departProcedure
Information how the vehicle shall choose the depart time.
SUMOTime string2time(const std::string &r)
Definition: SUMOTime.cpp:42
double xmin() const
Returns minimum x-coordinate.
Definition: Boundary.cpp:119
A person as used by router.
Definition: ROPerson.h:51
void addStop(const SUMOSAXAttributes &attrs)
Processing of a stop.
#define POSITION_EPS
Definition: config.h:169
std::string fromTaz
The vehicle&#39;s origin zone (district)
void closeTrip()
Ends the processing of a trip.
Boundary & grow(double by)
extends the boundary by the given amount
Definition: Boundary.cpp:301
double endPos
The stopping position end.
void closeVType()
Ends the processing of a vehicle type.
int Search(const float a_min[2], const float a_max[2], const Named::StoringVisitor &c) const
Find all within search rectangle.
Definition: NamedRTree.h:115
double getFloat(const std::string &name) const
Returns the double-value of the named option (only for Option_Float)
vehicle is a passenger car (a "normal" car)
A basic edge for routing applications.
Definition: ROEdge.h:73
const int VEHPARS_FROM_TAZ_SET
Base class for objects which have an id.
Definition: Named.h:57
void addPerson(const SUMOSAXAttributes &attrs)
Processing of a person.
void addTrip(const ROEdge *const from, const ROEdge *const to, const SVCPermissions modeSet, const std::string &vTypes, const double departPos, const double arrivalPos, const std::string &busStop, double walkFactor)
Definition: ROPerson.cpp:62
Definition of vehicle stop (position and duration)
Parser for routes during their loading.
std::vector< std::string > via
List of the via-edges the vehicle must visit.
bool isInternal() const
return whether this edge is an internal edge
Definition: ROEdge.h:148
#define WRITE_ERROR(msg)
Definition: MsgHandler.h:245
void closeContainer()
Ends the processing of a container.
void addFlowPerson(SUMOTime depart, const std::string &baseID, int i)
Processing of a person from a personFlow.
vehicle is a bus
Allows to store the object; used as context while traveling the rtree in TraCI.
Definition: Named.h:93
stop for vehicles
double departPos
(optional) The position the vehicle shall depart from
double startPos
The stopping position start.
static bool checkStopPos(double &startPos, double &endPos, const double laneLength, const double minLength, const bool friendlyPos)
check start and end position of a stop
std::vector< SUMOVehicleParameter::Stop > myActiveRouteStops
List of the stops on the parsed route.
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 router&#39;s network representation.
Definition: RONet.h:64
void addRide(const SUMOSAXAttributes &attrs)
Processing of a ride.
Structure representing possible vehicle parameter.
const SUMOVTypeParameter * getType() const
Returns the type of the routable.
Definition: RORoutable.h:85
void openRoute(const SUMOSAXAttributes &attrs)
opens a route for reading
virtual void myStartElement(int element, const SUMOSAXAttributes &attrs)
Called on the opening of a tag;.
#define SUMOTime_MAX
Definition: SUMOTime.h:36
const NamedObjectCont< ROEdge * > & getEdgeMap() const
Definition: RONet.h:393
bool allowsVehicleClass(SUMOVehicleClass vclass) const
Definition: ROLane.h:113
void openTrip(const SUMOSAXAttributes &attrs)
opens a trip for reading
const std::string DEFAULT_PEDTYPE_ID
void addWalk(const ConstROEdgeVector &edges, const double duration, const double speed, const double departPos, const double arrivalPos, const std::string &busStop)
Definition: ROPerson.cpp:110
bool parseStop(SUMOVehicleParameter::Stop &stop, const SUMOSAXAttributes &attrs, std::string errorSuffix, MsgHandler *const errorOutput)
parses attributes common to all stops
const bool myKeepVTypeDist
whether to keep the the vtype distribution in output
const bool myTryRepair
Information whether routes shall be repaired.
const ConstROEdgeVector & getEdgeVector() const
Returns the list of edges this route consists of.
Definition: RORoute.h:155
virtual void inform(std::string msg, bool addType=true)
adds a new error to the list
Definition: MsgHandler.cpp:118
A storage for options typed value containers)
Definition: OptionsCont.h:90
OutputDevice_String * myActiveContainerPlan
The plan of the current container.
void addTranship(const SUMOSAXAttributes &attrs)
Processing of a tranship.
Base class for a vehicle&#39;s route definition.
Definition: RORouteDef.h:56
std::string id
The vehicle type&#39;s id.
static const GeoConvHelper & getFinal()
the coordinate transformation for writing the location element and for tracking the original coordina...
const ROEdgeVector & getSuccessors(SUMOVehicleClass vClass=SVC_IGNORING) const
Returns the following edges, restricted by vClass.
Definition: ROEdge.cpp:350
double getOverallProb() const
Return the sum of the probabilites assigned to the members.
void addLoadedAlternative(RORoute *alternative)
Adds a single alternative loaded from the file An alternative may also be generated during DUA...
Definition: RORouteDef.cpp:69
void closeRoute(const bool mayBeDisconnected=false)
closes (ends) the building of a route.
bool wasSet(int what) const
Returns whether the given parameter was set.
void addRide(const ROEdge *const from, const ROEdge *const to, const std::string &lines, double arrivalPos, const std::string &destStop)
Definition: ROPerson.cpp:101
const RGBColor * myActiveRouteColor
The currently parsed route&#39;s color.
double myCurrentCosts
The currently parsed route costs.
virtual ~RORouteHandler()
standard destructor
void addPersonTrip(const SUMOSAXAttributes &attrs)
add a routing request for a walking or intermodal person
bool x2cartesian_const(Position &from) const
Converts the given coordinate into a cartesian using the previous initialisation. ...
bool closeTag(const std::string &comment="")
Closes the most recently opened tag and optionally adds a comment.
SUMOVTypeParameter * getVehicleTypeSecure(const std::string &id)
Retrieves the named vehicle type.
Definition: RONet.cpp:279
NamedRTree * myLaneTree
RTree for finding lanes.
const bool myHardFail
flag to enable or disable hard fails
#define NUMERICAL_EPS
Definition: config.h:145
a single trip definition (used by router)
void closeFlow()
Ends the processing of a flow.
std::string containerstop
(Optional) container stop if one is assigned to the stop
const ROEdge * getNormalBefore() const
if this edge is an internal edge, return its first normal predecessor, otherwise the edge itself ...
Definition: ROEdge.cpp:263
ROEdge * getEdge(const std::string &name) const
Retrieves an edge from the network.
Definition: RONet.h:153
void add(double x, double y, double z=0)
Makes the boundary include the given coordinate.
Definition: Boundary.cpp:79
bool addFlow(SUMOVehicleParameter *flow, const bool randomize)
Definition: RONet.cpp:377
double ymax() const
Returns maximum y-coordinate.
Definition: Boundary.cpp:137
static std::string getEdgeIDFromLane(const std::string laneID)
return edge id when given the lane ID
bool add(T val, double prob, bool checkDuplicates=true)
Adds a value with an assigned probability to the distribution.
std::string myActiveRouteRefID
The id of the route the current route references to.
A color information.
bool addPerson(ROPerson *person)
Definition: RONet.cpp:391
void parseFromViaTo(std::string element, const SUMOSAXAttributes &attrs)
Called for parsing from and to and the corresponding taz attributes.
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
A complete router&#39;s route.
Definition: RORoute.h:55
An output device that encapsulates an ofstream.
void closeRouteDistribution()
closes (ends) the building of a distribution
std::string myCurrentVTypeDistributionID
The id of the currently parsed vehicle type distribution.
std::string id
The vehicle&#39;s id.
RORouteHandler(RONet &net, const std::string &file, const bool tryRepair, const bool emptyDestinationsAllowed, const bool ignoreErrors, const bool checkSchema)
standard constructor