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 /****************************************************************************/
RORouteHandler::myLaneTree
NamedRTree * myLaneTree
RTree for finding lanes.
Definition: RORouteHandler.h:225
RandomDistributor::add
bool add(T val, double prob, bool checkDuplicates=true)
Adds a value with an assigned probability to the distribution.
Definition: RandomDistributor.h:71
ROEdge::isInternal
bool isInternal() const
return whether this edge is an internal edge
Definition: ROEdge.h:148
SVC_PEDESTRIAN
pedestrian
Definition: SUMOVehicleClass.h:157
SUMOVehicleClass
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types.
Definition: SUMOVehicleClass.h:134
SUMOVehicleParameter::wasSet
bool wasSet(int what) const
Returns whether the given parameter was set.
Definition: SUMOVehicleParameter.h:306
SUMOSAXAttributes::hasAttribute
virtual bool hasAttribute(int id) const =0
Returns the information whether the named (by its enum-value) attribute is within the current list.
RORouteHandler::openRoute
void openRoute(const SUMOSAXAttributes &attrs)
opens a route for reading
Definition: RORouteHandler.cpp:281
RORouteHandler::addContainer
void addContainer(const SUMOSAXAttributes &attrs)
Processing of a container.
Definition: RORouteHandler.cpp:751
SUMORouteHandler::myStartElement
virtual void myStartElement(int element, const SUMOSAXAttributes &attrs)
Called on the opening of a tag;.
Definition: SUMORouteHandler.cpp:92
WRITE_WARNING
#define WRITE_WARNING(msg)
Definition: MsgHandler.h:239
Named
Base class for objects which have an id.
Definition: Named.h:57
DEFAULT_PEDTYPE_ID
const std::string DEFAULT_PEDTYPE_ID
OutputDevice_String
An output device that encapsulates an ofstream.
Definition: OutputDevice_String.h:40
RORouteHandler::parseFromViaTo
void parseFromViaTo(std::string element, const SUMOSAXAttributes &attrs)
Called for parsing from and to and the corresponding taz attributes.
Definition: RORouteHandler.cpp:81
SUMOVehicleParameter::Stop::lane
std::string lane
The lane to stop at.
Definition: SUMOVehicleParameter.h:580
GeoConvHelper::x2cartesian_const
bool x2cartesian_const(Position &from) const
Converts the given coordinate into a cartesian using the previous initialisation.
Definition: GeoConvHelper.cpp:418
Boundary::ymin
double ymin() const
Returns minimum y-coordinate.
Definition: Boundary.cpp:131
SUMO_ATTR_TOLONLAT
Definition: SUMOXMLDefinitions.h:640
SUMO_ATTR_TOXY
Definition: SUMOXMLDefinitions.h:642
SUMORouteHandler::parseStop
bool parseStop(SUMOVehicleParameter::Stop &stop, const SUMOSAXAttributes &attrs, std::string errorSuffix, MsgHandler *const errorOutput)
parses attributes common to all stops
Definition: SUMORouteHandler.cpp:357
NUMERICAL_EPS
#define NUMERICAL_EPS
Definition: config.h:145
RORouteHandler.h
SUMO_ATTR_LAST
Definition: SUMOXMLDefinitions.h:624
SUMOVehicleParserHelper.h
SUMO_ATTR_VIAXY
Definition: SUMOXMLDefinitions.h:722
OptionsCont.h
RONet::getEdge
ROEdge * getEdge(const std::string &name) const
Retrieves an edge from the network.
Definition: RONet.h:153
StringTokenizer::hasNext
bool hasNext()
returns the information whether further substrings exist
Definition: StringTokenizer.cpp:95
SUMOSAXAttributes::get
T get(int attr, const char *objectid, bool &ok, bool report=true) const
Tries to read given attribute assuming it is an int.
Definition: SUMOSAXAttributes.h:493
Named::StoringVisitor
Allows to store the object; used as context while traveling the rtree in TraCI.
Definition: Named.h:93
SUMOVehicleParameter::vtypeid
std::string vtypeid
The vehicle's type id.
Definition: SUMOVehicleParameter.h:468
ROEdge::getSuccessors
const ROEdgeVector & getSuccessors(SUMOVehicleClass vClass=SVC_IGNORING) const
Returns the following edges, restricted by vClass.
Definition: ROEdge.cpp:350
MsgHandler.h
RORouteHandler::myActiveContainerPlanSize
int myActiveContainerPlanSize
The number of stages in myActiveContainerPlan.
Definition: RORouteHandler.h:198
SUMOVehicleParameter::repetitionOffset
SUMOTime repetitionOffset
The time offset between vehicle reinsertions.
Definition: SUMOVehicleParameter.h:544
SUMO_TAG_CONTAINER_STOP
A container stop.
Definition: SUMOXMLDefinitions.h:106
SUMOVehicleParameter::Stop::busstop
std::string busstop
(Optional) bus stop if one is assigned to the stop
Definition: SUMOVehicleParameter.h:583
RORouteDef::addAlternativeDef
void addAlternativeDef(const RORouteDef *alternative)
Adds an alternative loaded from the file.
Definition: RORouteDef.cpp:75
SUMOSAXHandler.h
SUMO_TAG_PERSON
Definition: SUMOXMLDefinitions.h:296
MsgHandler::inform
virtual void inform(std::string msg, bool addType=true)
adds a new error to the list
Definition: MsgHandler.cpp:118
SUMOTime
long long int SUMOTime
Definition: SUMOTime.h:35
RORoute::getEdgeVector
const ConstROEdgeVector & getEdgeVector() const
Returns the list of edges this route consists of.
Definition: RORoute.h:155
SUMO_ATTR_VIALONLAT
Definition: SUMOXMLDefinitions.h:721
SUMO_ATTR_LINES
Definition: SUMOXMLDefinitions.h:773
GeoConvHelper.h
RONet::getRouteDef
RORouteDef * getRouteDef(const std::string &name) const
Returns the named route definition.
Definition: RONet.h:294
Boundary::xmax
double xmax() const
Returns maximum x-coordinate.
Definition: Boundary.cpp:125
RORouteHandler::addPersonTrip
void addPersonTrip(const SUMOSAXAttributes &attrs)
add a routing request for a walking or intermodal person
Definition: RORouteHandler.cpp:846
OptionsCont::getBool
bool getBool(const std::string &name) const
Returns the boolean-value of the named option (only for Option_Bool)
Definition: OptionsCont.cpp:223
ROLane
A single lane the router may use.
Definition: ROLane.h:51
SUMO_ATTR_COLOR
A color information.
Definition: SUMOXMLDefinitions.h:701
SVC_BICYCLE
vehicle is a bicycle
Definition: SUMOVehicleClass.h:180
OptionsCont::getOptions
static OptionsCont & getOptions()
Retrieves the options.
Definition: OptionsCont.cpp:58
RORouteDef
Base class for a vehicle's route definition.
Definition: RORouteDef.h:56
SUMOVehicleParameter::departProcedure
DepartDefinition departProcedure
Information how the vehicle shall choose the depart time.
Definition: SUMOVehicleParameter.h:479
StringTokenizer::next
std::string next()
returns the next substring when it exists. Otherwise the behaviour is undefined
Definition: StringTokenizer.cpp:100
RONet
The router's network representation.
Definition: RONet.h:64
ROPerson
A person as used by router.
Definition: ROPerson.h:51
SUMO_ATTR_SPEED
Definition: SUMOXMLDefinitions.h:385
RORoutable::getType
const SUMOVTypeParameter * getType() const
Returns the type of the routable.
Definition: RORoutable.h:85
SUMO_ATTR_ARRIVALPOS
Definition: SUMOXMLDefinitions.h:438
SUMO_ATTR_ID
Definition: SUMOXMLDefinitions.h:379
ROVehicle
A vehicle as used by router.
Definition: ROVehicle.h:53
SUMOVehicleParameter::Stop::parkingarea
std::string parkingarea
(Optional) parking area if one is assigned to the stop
Definition: SUMOVehicleParameter.h:589
SUMOVehicleParameter
Structure representing possible vehicle parameter.
Definition: SUMOVehicleParameter.h:291
SUMO_ATTR_LANE
Definition: SUMOXMLDefinitions.h:635
RORouteHandler::closePersonFlow
void closePersonFlow()
Ends the processing of a personFlow.
Definition: RORouteHandler.cpp:535
SUMO_ATTR_ENDPOS
Definition: SUMOXMLDefinitions.h:795
RORouteDef.h
SUMO_TAG_CONTAINER
Definition: SUMOXMLDefinitions.h:317
SUMO_ATTR_COST
Definition: SUMOXMLDefinitions.h:625
PositionVector
A list of positions.
Definition: PositionVector.h:46
RONet::addPerson
bool addPerson(ROPerson *person)
Definition: RONet.cpp:391
RORouteDef::getOverallProb
double getOverallProb() const
Returns the sum of the probablities of the contained routes.
Definition: RORouteDef.cpp:400
SUMORouteHandler::myHardFail
const bool myHardFail
flag to enable or disable hard fails
Definition: SUMORouteHandler.h:193
RONet::addRouteDef
bool addRouteDef(RORouteDef *def)
Definition: RONet.cpp:209
ROLane::allowsVehicleClass
bool allowsVehicleClass(SUMOVehicleClass vclass) const
Definition: ROLane.h:113
SUMOVehicleParameter::depart
SUMOTime depart
Definition: SUMOVehicleParameter.h:476
ROLane::getShape
const PositionVector & getShape() const
Definition: ROLane.h:117
gPrecisionGeo
int gPrecisionGeo
Definition: StdDefs.cpp:28
OutputDevice_String::getString
std::string getString() const
Returns the current content as a string.
Definition: OutputDevice_String.cpp:44
RORouteHandler::myCurrentVTypeDistribution
RandomDistributor< SUMOVTypeParameter * > * myCurrentVTypeDistribution
The currently parsed distribution of vehicle types (probability->vehicle type)
Definition: RORouteHandler.h:216
OutputDevice::closeTag
bool closeTag(const std::string &comment="")
Closes the most recently opened tag and optionally adds a comment.
Definition: OutputDevice.cpp:254
SUMORouteHandler::myActiveRouteStops
std::vector< SUMOVehicleParameter::Stop > myActiveRouteStops
List of the stops on the parsed route.
Definition: SUMORouteHandler.h:217
SUMORouteHandler::checkStopPos
static bool checkStopPos(double &startPos, double &endPos, const double laneLength, const double minLength, const bool friendlyPos)
check start and end position of a stop
Definition: SUMORouteHandler.cpp:290
SUMO_ATTR_TO
Definition: SUMOXMLDefinitions.h:638
RORouteHandler::addRide
void addRide(const SUMOSAXAttributes &attrs)
Processing of a ride.
Definition: RORouteHandler.cpp:756
RORouteHandler::openTrip
void openTrip(const SUMOSAXAttributes &attrs)
opens a trip for reading
Definition: RORouteHandler.cpp:338
SUMORouteHandler::myActiveRouteRefID
std::string myActiveRouteRefID
The id of the route the current route references to.
Definition: SUMORouteHandler.h:205
RGBColor
Definition: RGBColor.h:40
RORouteHandler::addWalk
void addWalk(const SUMOSAXAttributes &attrs)
add a fully specified walk
Definition: RORouteHandler.cpp:919
SUMO_ATTR_FROMLONLAT
Definition: SUMOXMLDefinitions.h:639
RandHelper::rand
static double rand(std::mt19937 *rng=0)
Returns a random real number in [0, 1)
Definition: RandHelper.h:60
RORouteHandler::getLaneTree
NamedRTree * getLaneTree()
initialize lane-RTree
Definition: RORouteHandler.cpp:959
RORouteHandler::parseGeoEdges
void parseGeoEdges(const PositionVector &positions, bool geo, ConstROEdgeVector &into, const std::string &rid)
Parse edges from coordinates.
Definition: RORouteHandler.cpp:792
SUMO_TAG_TRANSPORT
Definition: SUMOXMLDefinitions.h:318
RORouteHandler::addTransport
void addTransport(const SUMOSAXAttributes &attrs)
Processing of a transport.
Definition: RORouteHandler.cpp:761
SUMO_TAG_FLOW
a flow definitio nusing a from-to edges instead of a route (used by router)
Definition: SUMOXMLDefinitions.h:150
SUMO_ATTR_PROB
Definition: SUMOXMLDefinitions.h:627
MsgHandler
Definition: MsgHandler.h:44
SUMO_ATTR_STARTPOS
Definition: SUMOXMLDefinitions.h:794
Boundary::xmin
double xmin() const
Returns minimum x-coordinate.
Definition: Boundary.cpp:119
NamedRTree::Insert
void Insert(const float a_min[2], const float a_max[2], Named *const &a_data)
Insert entry.
Definition: NamedRTree.h:82
GeoConvHelper::getFinal
static const GeoConvHelper & getFinal()
the coordinate transformation for writing the location element and for tracking the original coordina...
Definition: GeoConvHelper.h:106
SVCPermissions
int SVCPermissions
bitset where each bit declares whether a certain SVC may use this edge/lane
Definition: SUMOVehicleClass.h:219
ROPerson::PlanItem
Every person has a plan comprising of multiple planItems.
Definition: ROPerson.h:80
TIME2STEPS
#define TIME2STEPS(x)
Definition: SUMOTime.h:59
SUMO_TAG_RIDE
Definition: SUMOXMLDefinitions.h:298
RONet.h
SUMOVTypeParameter
Structure representing possible vehicle parameter.
Definition: SUMOVTypeParameter.h:86
StringTokenizer
Definition: StringTokenizer.h:62
SUMO_TAG_STOP
stop for vehicles
Definition: SUMOXMLDefinitions.h:179
SUMOVTypeParameter::defaultProbability
double defaultProbability
The probability when being added to a distribution without an explicit probability.
Definition: SUMOVTypeParameter.h:226
DEFAULT_VTYPE_ID
const std::string DEFAULT_VTYPE_ID
SUMORouteHandler::myActiveRouteColor
const RGBColor * myActiveRouteColor
The currently parsed route's color.
Definition: SUMORouteHandler.h:211
ROPerson::addStop
void addStop(const SUMOVehicleParameter::Stop &stopPar, const ROEdge *const stopEdge)
Definition: ROPerson.cpp:119
RONet::addContainer
void addContainer(const SUMOTime depart, const std::string desc)
Definition: RONet.cpp:403
SUMO_ATTR_REFID
Definition: SUMOXMLDefinitions.h:380
SUMORouteHandler::myCurrentCosts
double myCurrentCosts
The currently parsed route costs.
Definition: SUMORouteHandler.h:214
RORoutable::getParameter
const SUMOVehicleParameter & getParameter() const
Returns the definition of the vehicle / person parameter.
Definition: RORoutable.h:74
SVC_PASSENGER
vehicle is a passenger car (a "normal" car)
Definition: SUMOVehicleClass.h:160
SUMOVehicleParameter::id
std::string id
The vehicle's id.
Definition: SUMOVehicleParameter.h:462
SUMO_ATTR_ROUTE
Definition: SUMOXMLDefinitions.h:441
SUMO_ATTR_EDGES
the edges of a route
Definition: SUMOXMLDefinitions.h:428
Boundary
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:42
ROPerson::addTrip
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
SUMO_TAG_PARKING_AREA
A parking area.
Definition: SUMOXMLDefinitions.h:108
SUMOVehicleParameter::repetitionProbability
double repetitionProbability
The probability for emitting a vehicle per second.
Definition: SUMOVehicleParameter.h:547
OutputDevice.h
RONet::getStoppingPlace
const SUMOVehicleParameter::Stop * getStoppingPlace(const std::string &id, const SumoXMLTag category) const
Retrieves a stopping place from the network.
Definition: RONet.h:208
RORouteHandler::closeContainer
void closeContainer()
Ends the processing of a container.
Definition: RORouteHandler.cpp:587
SUMOVehicleParameter::fromTaz
std::string fromTaz
The vehicle's origin zone (district)
Definition: SUMOVehicleParameter.h:558
ProcessError
Definition: UtilExceptions.h:40
ROLane::getEdge
ROEdge & getEdge() const
Returns the lane's edge.
Definition: ROLane.h:95
Position
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:39
FileHelpers::readEdgeVector
static void readEdgeVector(std::istream &in, std::vector< const E * > &edges, const std::string &rid)
Reads an edge vector binary.
Definition: FileHelpers.h:256
Boundary::add
void add(double x, double y, double z=0)
Makes the boundary include the given coordinate.
Definition: Boundary.cpp:79
RORoute
A complete router's route.
Definition: RORoute.h:55
ROPerson::getPlan
std::vector< PlanItem * > & getPlan()
Definition: ROPerson.h:377
UtilExceptions.h
SUMOVehicleParameter::repetitionsDone
int repetitionsDone
The number of times the vehicle was already inserted.
Definition: SUMOVehicleParameter.h:541
OptionsCont
A storage for options typed value containers)
Definition: OptionsCont.h:90
BinaryFormatter::BF_ROUTE
Definition: BinaryFormatter.h:92
SUMOVehicleParameter::Stop::endPos
double endPos
The stopping position end.
Definition: SUMOVehicleParameter.h:598
ROEdge::getNormalBefore
const ROEdge * getNormalBefore() const
if this edge is an internal edge, return its first normal predecessor, otherwise the edge itself
Definition: ROEdge.cpp:263
SUMOSAXAttributes::getOpt
T getOpt(int attr, const char *objectid, bool &ok, T defaultValue, bool report=true) const
Tries to read given attribute assuming it is an int.
Definition: SUMOSAXAttributes.h:519
SUMORouteHandler::myActiveRouteProbability
double myActiveRouteProbability
The probability of the current route.
Definition: SUMORouteHandler.h:208
SUMOVehicleParameter::routeid
std::string routeid
The vehicle's route id.
Definition: SUMOVehicleParameter.h:465
SUMORouteHandler::myVehicleParameter
SUMOVehicleParameter * myVehicleParameter
Parameter of the current vehicle, trip, person, container or flow.
Definition: SUMORouteHandler.h:196
RORouteHandler::myStartElement
virtual void myStartElement(int element, const SUMOSAXAttributes &attrs)
Called on the opening of a tag;.
Definition: RORouteHandler.cpp:147
ROPerson::addWalk
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
RONet::addVehicle
virtual bool addVehicle(const std::string &id, ROVehicle *veh)
Definition: RONet.cpp:357
ROPerson.h
RORouteDef::addLoadedAlternative
void addLoadedAlternative(RORoute *alternative)
Adds a single alternative loaded from the file An alternative may also be generated during DUA.
Definition: RORouteDef.cpp:69
SUMO_ATTR_FRIENDLY_POS
Definition: SUMOXMLDefinitions.h:762
string2time
SUMOTime string2time(const std::string &r)
Definition: SUMOTime.cpp:42
ROEdge::getNumSuccessors
int getNumSuccessors() const
Returns the number of edges this edge is connected to.
Definition: ROEdge.cpp:245
RORouteHandler::myTryRepair
const bool myTryRepair
Information whether routes shall be repaired.
Definition: RORouteHandler.h:201
SUMO_ATTR_FROMXY
Definition: SUMOXMLDefinitions.h:641
RORouteHandler::myBegin
const SUMOTime myBegin
The begin time.
Definition: RORouteHandler.h:210
RONet::addVTypeDistribution
bool addVTypeDistribution(const std::string &id, RandomDistributor< SUMOVTypeParameter * > *vehTypeDistribution)
Adds a vehicle type distribution.
Definition: RONet.cpp:347
RandomDistributor< SUMOVTypeParameter * >
RORouteHandler::myCurrentVTypeDistributionID
std::string myCurrentVTypeDistributionID
The id of the currently parsed vehicle type distribution.
Definition: RORouteHandler.h:219
RORouteHandler::closeFlow
void closeFlow()
Ends the processing of a flow.
Definition: RORouteHandler.cpp:604
SUMO_ATTR_FROM
Definition: SUMOXMLDefinitions.h:637
SUMOVehicleParameter::Stop::startPos
double startPos
The stopping position start.
Definition: SUMOVehicleParameter.h:595
PositionVector::distance2D
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)
Definition: PositionVector.cpp:1242
SUMORouteHandler::registerLastDepart
void registerLastDepart()
save last depart (only to be used if vehicle is not discarded)
Definition: SUMORouteHandler.cpp:79
SUMOVehicleParameter::repetitionEnd
SUMOTime repetitionEnd
The time at which the flow ends (only needed when using repetitionProbability)
Definition: SUMOVehicleParameter.h:550
RORouteHandler::parseEdges
void parseEdges(const std::string &desc, ConstROEdgeVector &into, const std::string &rid)
Parse edges from strings.
Definition: RORouteHandler.cpp:771
RONet::getEdgeMap
const NamedObjectCont< ROEdge * > & getEdgeMap() const
Definition: RONet.h:393
OptionsCont::getFloat
double getFloat(const std::string &name) const
Returns the double-value of the named option (only for Option_Float)
Definition: OptionsCont.cpp:209
RORouteHandler::myErrorOutput
MsgHandler *const myErrorOutput
Depending on the "ignore-errors" option different outputs are used.
Definition: RORouteHandler.h:207
OutputDevice::openTag
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
Definition: OutputDevice.cpp:240
toString
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:48
RORouteHandler::~RORouteHandler
virtual ~RORouteHandler()
standard destructor
Definition: RORouteHandler.cpp:76
SUMO_TAG_BUS_STOP
A bus stop.
Definition: SUMOXMLDefinitions.h:98
SUMO_ATTR_DURATION
Definition: SUMOXMLDefinitions.h:665
SUMO_TAG_TRANSHIP
Definition: SUMOXMLDefinitions.h:319
SUMO_ATTR_VIA
Definition: SUMOXMLDefinitions.h:720
SUMOVehicleParameter::via
std::vector< std::string > via
List of the via-edges the vehicle must visit.
Definition: SUMOVehicleParameter.h:641
SUMOVTypeParameter::id
std::string id
The vehicle type's id.
Definition: SUMOVTypeParameter.h:210
SUMO_ATTR_VTYPES
Definition: SUMOXMLDefinitions.h:630
RORouteHandler::closePerson
void closePerson()
Ends the processing of a person.
Definition: RORouteHandler.cpp:520
RORouteHandler::closeTrip
void closeTrip()
Ends the processing of a trip.
Definition: RORouteHandler.cpp:650
InvalidArgument
Definition: UtilExceptions.h:57
ROEdge::getLength
double getLength() const
Returns the length of the edge.
Definition: ROEdge.h:203
ROEdge::getNumPredecessors
int getNumPredecessors() const
Returns the number of edges connected to this edge.
Definition: ROEdge.cpp:254
RORouteHandler::myActiveRoute
ConstROEdgeVector myActiveRoute
The current route.
Definition: RORouteHandler.h:189
SUMOXMLDefinitions::getEdgeIDFromLane
static std::string getEdgeIDFromLane(const std::string laneID)
return edge id when given the lane ID
Definition: SUMOXMLDefinitions.cpp:958
RORouteHandler::RORouteHandler
RORouteHandler(RONet &net, const std::string &file, const bool tryRepair, const bool emptyDestinationsAllowed, const bool ignoreErrors, const bool checkSchema)
standard constructor
Definition: RORouteHandler.cpp:54
VEHPARS_FROM_TAZ_SET
const int VEHPARS_FROM_TAZ_SET
Definition: SUMOVehicleParameter.h:61
OutputDevice_String.h
RORouteHandler::openVehicleTypeDistribution
void openVehicleTypeDistribution(const SUMOSAXAttributes &attrs)
opens a type distribution for reading
Definition: RORouteHandler.cpp:243
DEPART_GIVEN
The time is given.
Definition: SUMOVehicleParameter.h:96
RORouteHandler::addStop
void addStop(const SUMOSAXAttributes &attrs)
Processing of a stop.
Definition: RORouteHandler.cpp:657
SUMO_ATTR_ROUTES
Definition: SUMOXMLDefinitions.h:629
ROPerson::addRide
void addRide(const ROEdge *const from, const ROEdge *const to, const std::string &lines, double arrivalPos, const std::string &destStop)
Definition: ROPerson.cpp:101
RORouteHandler::closeVehicleTypeDistribution
void closeVehicleTypeDistribution()
closes (ends) the building of a distribution
Definition: RORouteHandler.cpp:266
RORouteHandler::openFlow
void openFlow(const SUMOSAXAttributes &attrs)
opens a flow for reading
Definition: RORouteHandler.cpp:332
ROEdge
A basic edge for routing applications.
Definition: ROEdge.h:73
SUMO_ATTR_MODES
Definition: SUMOXMLDefinitions.h:651
SUMOVehicleParserHelper::parseWalkPos
static double parseWalkPos(SumoXMLAttr attr, const bool hardFail, const std::string &id, double maxPos, const std::string &val, std::mt19937 *rng=0)
parse departPos or arrivalPos for a walk
Definition: SUMOVehicleParserHelper.cpp:1366
NamedRTree
A RT-tree for efficient storing of SUMO's Named objects.
Definition: NamedRTree.h:64
VEHPARS_TO_TAZ_SET
const int VEHPARS_TO_TAZ_SET
Definition: SUMOVehicleParameter.h:62
RORouteHandler::myNet
RONet & myNet
The current route.
Definition: RORouteHandler.h:186
SUMORouteHandler
Parser for routes during their loading.
Definition: SUMORouteHandler.h:51
RORouteHandler::myCurrentAlternatives
RORouteDef * myCurrentAlternatives
The currently parsed route alternatives.
Definition: RORouteHandler.h:222
config.h
ROLane.h
SUMO_TAG_PERSONFLOW
Definition: SUMOXMLDefinitions.h:300
RORouteHandler::closeVType
void closeVType()
Ends the processing of a vehicle type.
Definition: RORouteHandler.cpp:509
SVC_BUS
vehicle is a bus
Definition: SUMOVehicleClass.h:166
StringTokenizer.h
RONet::addFlow
bool addFlow(SUMOVehicleParameter *flow, const bool randomize)
Definition: RONet.cpp:377
SUMORouteHandler::myCurrentVType
SUMOVTypeParameter * myCurrentVType
The currently parsed vehicle type.
Definition: SUMORouteHandler.h:220
gPrecision
int gPrecision
the precision for floating point outputs
Definition: StdDefs.cpp:27
Boundary::grow
Boundary & grow(double by)
extends the boundary by the given amount
Definition: Boundary.cpp:301
NamedRTree::Search
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
SUMOSAXReader.h
SUMO_ATTR_DEPARTPOS
Definition: SUMOXMLDefinitions.h:434
SUMOVehicleParameter::toTaz
std::string toTaz
The vehicle's destination zone (district)
Definition: SUMOVehicleParameter.h:561
SUMOTime_MAX
#define SUMOTime_MAX
Definition: SUMOTime.h:36
MsgHandler::getErrorInstance
static MsgHandler * getErrorInstance()
Returns the instance to add errors to.
Definition: MsgHandler.cpp:81
RORouteDef::copy
RORouteDef * copy(const std::string &id, const SUMOTime stopOffset) const
Returns a deep copy of the route definition.
Definition: RORouteDef.cpp:386
RORouteHandler::closeRoute
void closeRoute(const bool mayBeDisconnected=false)
closes (ends) the building of a route.
Definition: RORouteHandler.cpp:344
SUMOVehicleParameter::repetitionNumber
int repetitionNumber
Definition: SUMOVehicleParameter.h:538
RORouteHandler::closeVehicle
void closeVehicle()
Ends the processing of a vehicle.
Definition: RORouteHandler.cpp:470
RORouteHandler::addTranship
void addTranship(const SUMOSAXAttributes &attrs)
Processing of a tranship.
Definition: RORouteHandler.cpp:766
SUMO_ATTR_BUS_STOP
Definition: SUMOXMLDefinitions.h:766
SUMOVehicleParameter::stops
std::vector< Stop > stops
List of the stops the vehicle will make, TraCI may add entries here.
Definition: SUMOVehicleParameter.h:638
RONet::getVehicleTypeSecure
SUMOVTypeParameter * getVehicleTypeSecure(const std::string &id)
Retrieves the named vehicle type.
Definition: RONet.cpp:279
RandomDistributor::getOverallProb
double getOverallProb() const
Return the sum of the probabilites assigned to the members.
Definition: RandomDistributor.h:131
SUMOSAXAttributes
Encapsulated SAX-Attributes.
Definition: SUMOSAXAttributes.h:57
RORouteHandler::addFlowPerson
void addFlowPerson(SUMOTime depart, const std::string &baseID, int i)
Processing of a person from a personFlow.
Definition: RORouteHandler.cpp:567
SUMO_ATTR_WALKFACTOR
Definition: SUMOXMLDefinitions.h:652
SUMOVTypeParameter::vehicleClass
SUMOVehicleClass vehicleClass
The vehicle's class.
Definition: SUMOVTypeParameter.h:238
Named::getID
const std::string & getID() const
Returns the id.
Definition: Named.h:77
DEFAULT_VEH_PROB
const double DEFAULT_VEH_PROB
POSITION_EPS
#define POSITION_EPS
Definition: config.h:169
SUMOVehicleParameter::Stop::containerstop
std::string containerstop
(Optional) container stop if one is assigned to the stop
Definition: SUMOVehicleParameter.h:586
WRITE_ERROR
#define WRITE_ERROR(msg)
Definition: MsgHandler.h:245
ROEdge.h
SUMORouteHandler::myActiveRouteID
std::string myActiveRouteID
The id of the current route.
Definition: SUMORouteHandler.h:202
RORouteHandler::myActiveContainerPlan
OutputDevice_String * myActiveContainerPlan
The plan of the current container.
Definition: RORouteHandler.h:195
SUMOXMLDefinitions.h
RORouteHandler::openRouteDistribution
void openRouteDistribution(const SUMOSAXAttributes &attrs)
opens a route distribution for reading
Definition: RORouteHandler.cpp:413
SUMORouteHandler::myInsertStopEdgesAt
int myInsertStopEdgesAt
where stop edges can be inserted into the current route (-1 means no insertion)
Definition: SUMORouteHandler.h:238
RORouteHandler::myKeepVTypeDist
const bool myKeepVTypeDist
whether to keep the the vtype distribution in output
Definition: RORouteHandler.h:213
SUMOVehicleParameter::departPos
double departPos
(optional) The position the vehicle shall depart from
Definition: SUMOVehicleParameter.h:488
SUMO_TAG_TRIP
a single trip definition (used by router)
Definition: SUMOXMLDefinitions.h:146
RORouteHandler::myActivePerson
ROPerson * myActivePerson
The plan of the current person.
Definition: RORouteHandler.h:192
ConstROEdgeVector
std::vector< const ROEdge * > ConstROEdgeVector
Definition: ROEdge.h:57
SUMOVehicleParameter::Stop
Definition of vehicle stop (position and duration)
Definition: SUMOVehicleParameter.h:566
XMLSubSys.h
Boundary::ymax
double ymax() const
Returns maximum y-coordinate.
Definition: Boundary.cpp:137
RORouteHandler::closeRouteDistribution
void closeRouteDistribution()
closes (ends) the building of a distribution
Definition: RORouteHandler.cpp:455
RORouteHandler::addPerson
void addPerson(const SUMOSAXAttributes &attrs)
Processing of a person.
Definition: RORouteHandler.cpp:746
RONet::addVehicleType
virtual bool addVehicleType(SUMOVTypeParameter *type)
Adds a read vehicle type definition to the network.
Definition: RONet.cpp:334