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