Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
RORouteHandler.cpp
Go to the documentation of this file.
1/****************************************************************************/
2// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3// Copyright (C) 2001-2026 German Aerospace Center (DLR) and others.
4// This program and the accompanying materials are made available under the
5// terms of the Eclipse Public License 2.0 which is available at
6// https://www.eclipse.org/legal/epl-2.0/
7// This Source Code may also be made available under the following Secondary
8// Licenses when the conditions for such availability set forth in the Eclipse
9// Public License 2.0 are satisfied: GNU General Public License, version 2
10// or later which is available at
11// https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13/****************************************************************************/
21// Parser and container for routes during their loading
22/****************************************************************************/
23#include <config.h>
24
25#include <string>
26#include <map>
27#include <vector>
28#include <iostream>
40#include <utils/xml/XMLSubSys.h>
42#include "RONet.h"
43#include "ROEdge.h"
44#include "ROLane.h"
45#include "RORouteDef.h"
46#include "RORouteHandler.h"
47
48// ===========================================================================
49// method definitions
50// ===========================================================================
51RORouteHandler::RORouteHandler(RONet& net, const std::string& file,
52 const bool tryRepair,
53 const bool emptyDestinationsAllowed,
54 const bool ignoreErrors,
55 const bool checkSchema) :
56 SUMORouteHandler(file, checkSchema ? "routes" : "", true),
57 MapMatcher(OptionsCont::getOptions().getBool("mapmatch.junctions"),
58 OptionsCont::getOptions().getBool("mapmatch.taz"),
59 OptionsCont::getOptions().getFloat("mapmatch.distance"),
60 ignoreErrors ? MsgHandler::getWarningInstance() : MsgHandler::getErrorInstance()),
61 myNet(net),
62 myActiveRouteRepeat(0),
63 myActiveRoutePeriod(0),
64 myActivePlan(nullptr),
65 myActiveContainerPlan(nullptr),
66 myActiveContainerPlanSize(0),
67 myTryRepair(tryRepair),
68 myEmptyDestinationsAllowed(emptyDestinationsAllowed),
69 myErrorOutput(ignoreErrors ? MsgHandler::getWarningInstance() : MsgHandler::getErrorInstance()),
70 myBegin(string2time(OptionsCont::getOptions().getString("begin"))),
71 myKeepVTypeDist(OptionsCont::getOptions().getBool("keep-vtype-distributions")),
72 myUnsortedInput(OptionsCont::getOptions().exists("unsorted-input") && OptionsCont::getOptions().getBool("unsorted-input")),
73 myWriteFlows(OptionsCont::getOptions().exists("keep-flows") && OptionsCont::getOptions().getBool("keep-flows")),
74 myCurrentVTypeDistribution(nullptr),
75 myCurrentAlternatives(nullptr),
76 myUseTaz(OptionsCont::getOptions().getBool("with-taz")),
77 myWriteJunctions(OptionsCont::getOptions().exists("write-trips")
78 && OptionsCont::getOptions().getBool("write-trips")
79 && OptionsCont::getOptions().getBool("write-trips.junctions")) {
80 myActiveRoute.reserve(100);
81}
82
83
87
88
89void
91 if (myActivePlan != nullptr) {
92 for (ROPerson::PlanItem* const it : *myActivePlan) {
93 delete it;
94 }
95 delete myActivePlan;
96 myActivePlan = nullptr;
97 }
99 myActiveContainerPlan = nullptr;
100 delete myVehicleParameter;
101 myVehicleParameter = nullptr;
102}
103
104
105void
107 const std::string element = toString(tag);
108 myActiveRoute.clear();
109 bool useTaz = myUseTaz;
111 WRITE_WARNINGF(TL("Taz usage was requested but no taz present in % '%'!"), element, myVehicleParameter->id);
112 useTaz = false;
113 }
117 if (type != nullptr) {
118 vClass = type->vehicleClass;
119 }
120 }
121 // from-attributes
122 const std::string rid = "for " + element + " '" + myVehicleParameter->id + "'";
123 if ((useTaz || (!attrs.hasAttribute(SUMO_ATTR_FROM) && !attrs.hasAttribute(SUMO_ATTR_FROMXY) && !attrs.hasAttribute(SUMO_ATTR_FROMLONLAT))) &&
125 const bool useJunction = attrs.hasAttribute(SUMO_ATTR_FROM_JUNCTION);
126 const std::string tazType = useJunction ? "junction" : "taz";
127 const std::string tazID = attrs.get<std::string>(useJunction ? SUMO_ATTR_FROM_JUNCTION : SUMO_ATTR_FROM_TAZ, myVehicleParameter->id.c_str(), ok, true);
128 const ROEdge* fromTaz = myNet.getEdge(tazID + "-source");
129 if (fromTaz == nullptr) {
130 myErrorOutput->inform("Source " + tazType + " '" + tazID + "' not known for " + element + " '" + myVehicleParameter->id + "'!"
131 + (useJunction ? JUNCTION_TAZ_MISSING_HELP : ""));
132 ok = false;
133 } else if (fromTaz->getNumSuccessors() == 0 && tag != SUMO_TAG_PERSON) {
134 myErrorOutput->inform("Source " + tazType + " '" + tazID + "' has no outgoing edges for " + element + " '" + myVehicleParameter->id + "'!");
135 ok = false;
136 } else {
137 myActiveRoute.push_back(fromTaz);
138 if (useJunction && tag != SUMO_TAG_PERSON && !myWriteJunctions) {
141 }
142 }
143 } else if (attrs.hasAttribute(SUMO_ATTR_FROMXY)) {
144 parseGeoEdges(attrs.get<PositionVector>(SUMO_ATTR_FROMXY, myVehicleParameter->id.c_str(), ok), false, vClass, myActiveRoute, rid, true, ok);
145 if (myMapMatchTAZ && ok) {
146 myVehicleParameter->fromTaz = myActiveRoute.back()->getID();
148 }
149 } else if (attrs.hasAttribute(SUMO_ATTR_FROMLONLAT)) {
150 parseGeoEdges(attrs.get<PositionVector>(SUMO_ATTR_FROMLONLAT, myVehicleParameter->id.c_str(), ok), true, vClass, myActiveRoute, rid, true, ok);
151 if (myMapMatchTAZ && ok) {
152 myVehicleParameter->fromTaz = myActiveRoute.back()->getID();
154 }
155 } else {
156 parseEdges(attrs.getOpt<std::string>(SUMO_ATTR_FROM, myVehicleParameter->id.c_str(), ok), myActiveRoute, rid, ok);
157 }
160 }
161
162 // via-attributes
163 ConstROEdgeVector viaEdges;
164 if (attrs.hasAttribute(SUMO_ATTR_VIAXY)) {
165 parseGeoEdges(attrs.get<PositionVector>(SUMO_ATTR_VIAXY, myVehicleParameter->id.c_str(), ok), false, vClass, viaEdges, rid, false, ok);
166 } else if (attrs.hasAttribute(SUMO_ATTR_VIALONLAT)) {
167 parseGeoEdges(attrs.get<PositionVector>(SUMO_ATTR_VIALONLAT, myVehicleParameter->id.c_str(), ok), true, vClass, viaEdges, rid, false, ok);
168 } else if (attrs.hasAttribute(SUMO_ATTR_VIAJUNCTIONS)) {
169 for (std::string junctionID : attrs.get<std::vector<std::string> >(SUMO_ATTR_VIAJUNCTIONS, myVehicleParameter->id.c_str(), ok)) {
170 const ROEdge* viaSink = myNet.getEdge(junctionID + "-sink");
171 if (viaSink == nullptr) {
172 myErrorOutput->inform("Junction-taz '" + junctionID + "' not found." + JUNCTION_TAZ_MISSING_HELP);
173 ok = false;
174 } else {
175 viaEdges.push_back(viaSink);
176 }
177 }
178 } else {
179 parseEdges(attrs.getOpt<std::string>(SUMO_ATTR_VIA, myVehicleParameter->id.c_str(), ok, "", true), viaEdges, rid, ok);
180 }
181 for (const ROEdge* e : viaEdges) {
182 myActiveRoute.push_back(e);
183 myVehicleParameter->via.push_back(e->getID());
184 }
185
186 // to-attributes
187 if ((useTaz || (!attrs.hasAttribute(SUMO_ATTR_TO) && !attrs.hasAttribute(SUMO_ATTR_TOXY) && !attrs.hasAttribute(SUMO_ATTR_TOLONLAT))) &&
189 const bool useJunction = attrs.hasAttribute(SUMO_ATTR_TO_JUNCTION);
190 const std::string tazType = useJunction ? "junction" : "taz";
191 const std::string tazID = attrs.get<std::string>(useJunction ? SUMO_ATTR_TO_JUNCTION : SUMO_ATTR_TO_TAZ, myVehicleParameter->id.c_str(), ok, true);
192 const ROEdge* toTaz = myNet.getEdge(tazID + "-sink");
193 if (toTaz == nullptr) {
194 myErrorOutput->inform("Sink " + tazType + " '" + tazID + "' not known for " + element + " '" + myVehicleParameter->id + "'!"
195 + (useJunction ? JUNCTION_TAZ_MISSING_HELP : ""));
196 ok = false;
197 } else if (toTaz->getNumPredecessors() == 0 && tag != SUMO_TAG_PERSON) {
198 myErrorOutput->inform("Sink " + tazType + " '" + tazID + "' has no incoming edges for " + element + " '" + myVehicleParameter->id + "'!");
199 ok = false;
200 } else {
201 myActiveRoute.push_back(toTaz);
202 if (useJunction && tag != SUMO_TAG_PERSON && !myWriteJunctions) {
203 myVehicleParameter->toTaz = tazID;
205 }
206 }
207 } else if (attrs.hasAttribute(SUMO_ATTR_TOXY)) {
208 parseGeoEdges(attrs.get<PositionVector>(SUMO_ATTR_TOXY, myVehicleParameter->id.c_str(), ok, true), false, vClass, myActiveRoute, rid, false, ok);
209 if (myMapMatchTAZ && ok) {
210 myVehicleParameter->toTaz = myActiveRoute.back()->getID();
212 }
213 } else if (attrs.hasAttribute(SUMO_ATTR_TOLONLAT)) {
214 parseGeoEdges(attrs.get<PositionVector>(SUMO_ATTR_TOLONLAT, myVehicleParameter->id.c_str(), ok, true), true, vClass, myActiveRoute, rid, false, ok);
215 if (myMapMatchTAZ && ok) {
216 myVehicleParameter->toTaz = myActiveRoute.back()->getID();
218 }
219 } else {
220 parseEdges(attrs.getOpt<std::string>(SUMO_ATTR_TO, myVehicleParameter->id.c_str(), ok, "", true), myActiveRoute, rid, ok);
221 }
223 if (myVehicleParameter->routeid == "") {
225 }
226}
227
228
229void
231 const SUMOSAXAttributes& attrs) {
232 try {
233 if (myActivePlan != nullptr && myActivePlan->empty() && myVehicleParameter->departProcedure == DepartDefinition::TRIGGERED && element != SUMO_TAG_RIDE && element != SUMO_TAG_PARAM) {
234 throw ProcessError(TLF("Triggered departure for person '%' requires starting with a ride.", myVehicleParameter->id));
236 throw ProcessError(TLF("Triggered departure for container '%' requires starting with a transport.", myVehicleParameter->id));
237 }
238 SUMORouteHandler::myStartElement(element, attrs);
239 bool ok = true;
240 switch (element) {
241 case SUMO_TAG_PERSON:
242 case SUMO_TAG_PERSONFLOW: {
243 myActivePlan = new std::vector<ROPerson::PlanItem*>();
244 break;
245 }
246 case SUMO_TAG_RIDE:
247 break; // handled in addRide, called from SUMORouteHandler::myStartElement
253 (*myActiveContainerPlan) << attrs;
254 break;
257 if (myActiveContainerPlan == nullptr) {
258 throw ProcessError(TLF("Found % outside container element", toString((SumoXMLTag)element)));
259 }
260 // copy container elements
262 (*myActiveContainerPlan) << attrs;
265 break;
266 case SUMO_TAG_FLOW:
267 // The base handler skips calibrator flows.
268 if (myVehicleParameter != nullptr) {
270 parseFromViaTo((SumoXMLTag)element, attrs, ok);
271 }
272 break;
273 case SUMO_TAG_TRIP:
275 parseFromViaTo((SumoXMLTag)element, attrs, ok);
276 break;
277 default:
278 break;
279 }
280 } catch (ProcessError&) {
282 throw;
283 }
284}
285
286
287void
289 bool ok = true;
290 myCurrentVTypeDistributionID = attrs.get<std::string>(SUMO_ATTR_ID, nullptr, ok);
291 if (ok) {
293 if (attrs.hasAttribute(SUMO_ATTR_VTYPES)) {
294 std::vector<double> probs;
295 if (attrs.hasAttribute(SUMO_ATTR_PROBS)) {
296 StringTokenizer st(attrs.get<std::string>(SUMO_ATTR_PROBS, myCurrentVTypeDistributionID.c_str(), ok));
297 while (st.hasNext()) {
298 probs.push_back(StringUtils::toDoubleSecure(st.next(), 1.0));
299 }
300 }
301 const std::string vTypes = attrs.get<std::string>(SUMO_ATTR_VTYPES, myCurrentVTypeDistributionID.c_str(), ok);
302 StringTokenizer st(vTypes);
303 int probIndex = 0;
304 while (st.hasNext()) {
305 const std::string typeID = st.next();
307 if (dist != nullptr) {
308 const double distProb = ((int)probs.size() > probIndex ? probs[probIndex] : 1.) / dist->getOverallProb();
309 std::vector<double>::const_iterator probIt = dist->getProbs().begin();
310 for (SUMOVTypeParameter* const type : dist->getVals()) {
311 myCurrentVTypeDistribution->add(type, distProb * *probIt);
312 probIt++;
313 }
314 } else {
315 SUMOVTypeParameter* const type = myNet.getVehicleTypeSecure(typeID);
316 if (type == nullptr) {
317 myErrorOutput->inform("Unknown vehicle type '" + typeID + "' in distribution '" + myCurrentVTypeDistributionID + "'.");
318 } else {
319 const double prob = ((int)probs.size() > probIndex ? probs[probIndex] : type->defaultProbability);
320 myCurrentVTypeDistribution->add(type, prob);
321 }
322 }
323 probIndex++;
324 }
325 if (probs.size() > 0 && probIndex != (int)probs.size()) {
326 WRITE_WARNING("Got " + toString(probs.size()) + " probabilities for " + toString(probIndex) +
327 " types in vTypeDistribution '" + myCurrentVTypeDistributionID + "'");
328 }
329 }
330 }
331}
332
333
334void
336 if (myCurrentVTypeDistribution != nullptr) {
339 myErrorOutput->inform("Vehicle type distribution '" + myCurrentVTypeDistributionID + "' is empty.");
342 myErrorOutput->inform("Another vehicle type (or distribution) with the id '" + myCurrentVTypeDistributionID + "' exists.");
343 }
345 }
346}
347
348
349void
353 // check whether the id is really necessary
354 std::string rid;
355 if (myCurrentAlternatives != nullptr) {
357 rid = "distribution '" + myCurrentAlternatives->getID() + "'";
358 } else if (myVehicleParameter != nullptr) {
359 // ok, a vehicle is wrapping the route,
360 // we may use this vehicle's id as default
361 myVehicleParameter->routeid = myActiveRouteID = "!" + myVehicleParameter->id; // !!! document this
362 if (attrs.hasAttribute(SUMO_ATTR_ID)) {
363 WRITE_WARNINGF(TL("Ids of internal routes are ignored (vehicle '%')."), myVehicleParameter->id);
364 }
365 } else {
366 bool ok = true;
367 myActiveRouteID = attrs.get<std::string>(SUMO_ATTR_ID, nullptr, ok);
368 if (!ok) {
369 return;
370 }
371 rid = "'" + myActiveRouteID + "'";
372 }
373 if (myVehicleParameter != nullptr) { // have to do this here for nested route distributions
374 rid = "for vehicle '" + myVehicleParameter->id + "'";
375 }
376 bool ok = true;
377 if (attrs.hasAttribute(SUMO_ATTR_EDGES)) {
378 parseEdges(attrs.get<std::string>(SUMO_ATTR_EDGES, myActiveRouteID.c_str(), ok), myActiveRoute, rid, ok);
379 }
380 myActiveRouteRefID = attrs.getOpt<std::string>(SUMO_ATTR_REFID, myActiveRouteID.c_str(), ok, "");
381 if (myActiveRouteRefID != "" && myNet.getRouteDef(myActiveRouteRefID) == nullptr) {
382 myErrorOutput->inform("Invalid reference to route '" + myActiveRouteRefID + "' in route " + rid + ".");
383 }
384 if (myCurrentAlternatives != nullptr && !attrs.hasAttribute(SUMO_ATTR_PROB)) {
385 WRITE_WARNINGF(TL("No probability for route %, using default."), rid);
386 }
388 if (ok && myActiveRouteProbability < 0) {
389 myErrorOutput->inform("Invalid probability for route '" + myActiveRouteID + "'.");
390 }
392 ok = true;
393 myActiveRouteRepeat = attrs.getOpt<int>(SUMO_ATTR_REPEAT, myActiveRouteID.c_str(), ok, 0);
395 if (myActiveRouteRepeat > 0) {
397 if (myVehicleParameter != nullptr) {
399 if (type != nullptr) {
400 vClass = type->vehicleClass;
401 }
402 }
403 if (myActiveRoute.size() > 0 && !myActiveRoute.back()->isConnectedTo(*myActiveRoute.front(), vClass)) {
404 myErrorOutput->inform("Disconnected route " + rid + " when repeating.");
405 }
406 }
407 myCurrentCosts = attrs.getOpt<double>(SUMO_ATTR_COST, myActiveRouteID.c_str(), ok, -1);
408 if (ok && myCurrentCosts != -1 && myCurrentCosts < 0) {
409 myErrorOutput->inform("Invalid cost for route '" + myActiveRouteID + "'.");
410 }
411}
412
413
414void
416 // currently unused
417}
418
419
420void
422 // currently unused
423}
424
425
426void
428 // currently unused
429}
430
431
432void
433RORouteHandler::closeRoute(const bool mayBeDisconnected) {
434 const bool mustReroute = myActiveRoute.size() == 0 && myActiveRouteStops.size() != 0;
435 if (mustReroute) {
436 // implicit route from stops
438 ROEdge* edge = myNet.getEdge(stop.edge);
439 myActiveRoute.push_back(edge);
440 }
441 }
442 if (myActiveRoute.size() == 0) {
443 if (myActiveRouteRefID != "" && myCurrentAlternatives != nullptr) {
445 myActiveRouteID = "";
447 return;
448 }
449 if (myVehicleParameter != nullptr) {
450 myErrorOutput->inform("The route for vehicle '" + myVehicleParameter->id + "' has no edges.");
451 } else {
452 myErrorOutput->inform("Route '" + myActiveRouteID + "' has no edges.");
453 }
454 myActiveRouteID = "";
455 myActiveRouteStops.clear();
456 return;
457 }
458 if (myActiveRoute.size() == 1 && myActiveRoute.front()->isTazConnector()) {
459 myErrorOutput->inform("The routing information for vehicle '" + myVehicleParameter->id + "' is insufficient.");
460 myActiveRouteID = "";
461 myActiveRouteStops.clear();
462 return;
463 }
464 if (!mayBeDisconnected && OptionsCont::getOptions().exists("no-internal-links") && !OptionsCont::getOptions().getBool("no-internal-links")) {
465 // fix internal edges which did not get parsed
466 const ROEdge* last = nullptr;
467 ConstROEdgeVector fullRoute;
468 for (const ROEdge* roe : myActiveRoute) {
469 if (last != nullptr) {
470 for (const ROEdge* intern : last->getSuccessors()) {
471 if (intern->isInternal() && intern->getSuccessors().size() == 1 && intern->getSuccessors().front() == roe) {
472 fullRoute.push_back(intern);
473 }
474 }
475 }
476 fullRoute.push_back(roe);
477 last = roe;
478 }
479 myActiveRoute = fullRoute;
480 }
481 if (myActiveRouteRepeat > 0) {
482 // duplicate route
484 auto tmpStops = myActiveRouteStops;
485 for (int i = 0; i < myActiveRouteRepeat; i++) {
486 myActiveRoute.insert(myActiveRoute.begin(), tmpEdges.begin(), tmpEdges.end());
487 for (SUMOVehicleParameter::Stop stop : tmpStops) {
488 if (stop.until > 0) {
489 if (myActiveRoutePeriod <= 0) {
490 const std::string description = myVehicleParameter != nullptr
491 ? "for vehicle '" + myVehicleParameter->id + "'"
492 : "'" + myActiveRouteID + "'";
493 throw ProcessError(TLF("Cannot repeat stops with 'until' in route % because no cycleTime is defined.", description));
494 }
495 stop.until += myActiveRoutePeriod * (i + 1);
496 stop.arrival += myActiveRoutePeriod * (i + 1);
497 }
498 myActiveRouteStops.push_back(stop);
499 }
500 }
501 }
502 std::shared_ptr<RORoute> route = std::make_shared<RORoute>(myActiveRouteID, myCurrentCosts, myActiveRouteProbability, myActiveRoute,
504 myActiveRoute.clear();
505 if (myCurrentAlternatives == nullptr) {
506 if (myNet.getRouteDef(myActiveRouteID) != nullptr) {
507 if (myVehicleParameter != nullptr) {
508 myErrorOutput->inform("Another route for vehicle '" + myVehicleParameter->id + "' exists.");
509 } else {
510 myErrorOutput->inform("Another route (or distribution) with the id '" + myActiveRouteID + "' exists.");
511 }
512 myActiveRouteID = "";
513 myActiveRouteStops.clear();
514 return;
515 } else {
516 myCurrentAlternatives = new RORouteDef(myActiveRouteID, 0, mayBeDisconnected || myTryRepair, mayBeDisconnected);
519 myCurrentAlternatives = nullptr;
520 }
521 } else {
523 }
524 myActiveRouteID = "";
525 myActiveRouteStops.clear();
526}
527
528
529void
531 // check whether the id is really necessary
532 bool ok = true;
533 std::string id;
534 if (myVehicleParameter != nullptr) {
535 // ok, a vehicle is wrapping the route,
536 // we may use this vehicle's id as default
537 myVehicleParameter->routeid = id = "!" + myVehicleParameter->id; // !!! document this
538 if (attrs.hasAttribute(SUMO_ATTR_ID)) {
539 WRITE_WARNINGF(TL("Ids of internal route distributions are ignored (vehicle '%')."), myVehicleParameter->id);
540 }
541 } else {
542 id = attrs.get<std::string>(SUMO_ATTR_ID, nullptr, ok);
543 if (!ok) {
544 return;
545 }
546 }
547 // try to get the index of the last element
548 int index = attrs.getOpt<int>(SUMO_ATTR_LAST, id.c_str(), ok, 0);
549 if (ok && index < 0) {
550 myErrorOutput->inform("Negative index of a route alternative (id='" + id + "').");
551 return;
552 }
553 // build the alternative cont
554 myCurrentAlternatives = new RORouteDef(id, index, myTryRepair, false);
555 if (attrs.hasAttribute(SUMO_ATTR_ROUTES)) {
556 ok = true;
557 StringTokenizer st(attrs.get<std::string>(SUMO_ATTR_ROUTES, id.c_str(), ok));
558 while (st.hasNext()) {
559 const std::string routeID = st.next();
560 const RORouteDef* route = myNet.getRouteDef(routeID);
561 if (route == nullptr) {
562 myErrorOutput->inform("Unknown route '" + routeID + "' in distribution '" + id + "'.");
563 } else {
565 }
566 }
567 }
568}
569
570
571void
573 if (myCurrentAlternatives != nullptr) {
575 myErrorOutput->inform("Route distribution '" + myCurrentAlternatives->getID() + "' is empty.");
578 myErrorOutput->inform("Another route (or distribution) with the id '" + myCurrentAlternatives->getID() + "' exists.");
580 } else {
581 if (myVehicleParameter != nullptr
582 && (myUseTaz || OptionsCont::getOptions().getBool("junction-taz"))
585 // we are loading a rou.alt.xml, permit rerouting between taz
586 bool ok = true;
587 ConstROEdgeVector edges;
588 if (myVehicleParameter->fromTaz != "") {
589 const std::string tazID = myVehicleParameter->fromTaz;
590 const ROEdge* fromTaz = myNet.getEdge(tazID + "-source");
591 if (fromTaz == nullptr) {
592 myErrorOutput->inform("Source taz '" + tazID + "' not known for vehicle '" + myVehicleParameter->id + "'!");
593 ok = false;
594 } else if (fromTaz->getNumSuccessors() == 0) {
595 myErrorOutput->inform("Source taz '" + tazID + "' has no outgoing edges for vehicle '" + myVehicleParameter->id + "'!");
596 ok = false;
597 } else {
598 edges.push_back(fromTaz);
599 }
600 } else {
601 edges.push_back(myCurrentAlternatives->getOrigin());
602 }
603 if (myVehicleParameter->toTaz != "") {
604 const std::string tazID = myVehicleParameter->toTaz;
605 const ROEdge* toTaz = myNet.getEdge(tazID + "-sink");
606 if (toTaz == nullptr) {
607 myErrorOutput->inform("Sink taz '" + tazID + "' not known for vehicle '" + myVehicleParameter->id + "'!");
608 ok = false;
609 } else if (toTaz->getNumPredecessors() == 0) {
610 myErrorOutput->inform("Sink taz '" + tazID + "' has no incoming edges for vehicle '" + myVehicleParameter->id + "'!");
611 ok = false;
612 } else {
613 edges.push_back(toTaz);
614 }
615 } else {
616 edges.push_back(myCurrentAlternatives->getDestination());
617 }
618 if (ok) {
619 // negative probability indicates that this route should not be written
620 myCurrentAlternatives->addLoadedAlternative(std::make_shared<RORoute>(myCurrentAlternatives->getID(), 0, -1, edges, nullptr, myActiveRouteStops));
621 }
622 }
623 }
624 myCurrentAlternatives = nullptr;
625 }
626}
627
628
629void
632 // get the vehicle id
636 return;
637 }
638 // get vehicle type
640 if (type == nullptr) {
641 myErrorOutput->inform("The vehicle type '" + myVehicleParameter->vtypeid + "' for vehicle '" + myVehicleParameter->id + "' is not known.");
643 } else {
644 if (!myKeepVTypeDist) {
645 // fix the type id in case we used a distribution
647 }
648 }
649 if (type->vehicleClass == SVC_PEDESTRIAN) {
650 WRITE_WARNINGF(TL("Vehicle type '%' with vClass=pedestrian should only be used for persons and not for vehicle '%'."), type->id, myVehicleParameter->id);
651 }
652 // get the route
654 if (route == nullptr) {
655 myErrorOutput->inform("The route of the vehicle '" + myVehicleParameter->id + "' is not known.");
656 return;
657 }
658 if (MsgHandler::getErrorInstance()->wasInformed()) {
659 return;
660 }
661 const bool needCopy = route->getID()[0] != '!';
662 if (needCopy) {
663 route = route->copy("!" + myVehicleParameter->id, myVehicleParameter->depart);
664 }
665 // build the vehicle
666 ROVehicle* veh = new ROVehicle(*myVehicleParameter, route, type, &myNet, myErrorOutput);
669 } else if (needCopy) {
670 delete route;
671 }
672 delete myVehicleParameter;
673 myVehicleParameter = nullptr;
674}
675
676
677void
679 if (myCurrentVTypeRef.empty()) {
681 if (OptionsCont::getOptions().isSet("restriction-params")) {
682 const std::vector<std::string> paramKeys = OptionsCont::getOptions().getStringVector("restriction-params");
684 }
685 }
686 if (myCurrentVTypeDistribution != nullptr) {
687 if (myCurrentVTypeRef.empty()) {
689 } else {
691 if (dist != nullptr) {
692 const double distProb = (myCurrentVTypeProbability >= 0 ? myCurrentVTypeProbability : 1) / dist->getOverallProb();
693 std::vector<double>::const_iterator probIt = dist->getProbs().begin();
694 for (SUMOVTypeParameter* const type : dist->getVals()) {
695 myCurrentVTypeDistribution->add(type, distProb * *probIt);
696 probIt++;
697 }
698 } else {
701 myCurrentVTypeDistribution->add(type, probability);
702 }
703 }
704 }
705 myCurrentVType = nullptr;
706}
707
708
709void
712 if (type == nullptr) {
713 myErrorOutput->inform("The vehicle type '" + myVehicleParameter->vtypeid + "' for person '" + myVehicleParameter->id + "' is not known.");
715 }
716 if (myActivePlan == nullptr || myActivePlan->empty()) {
717 WRITE_WARNINGF(TL("Discarding person '%' because her plan is empty"), myVehicleParameter->id);
719 ROPerson* person = new ROPerson(*myVehicleParameter, type);
720 for (ROPerson::PlanItem* item : *myActivePlan) {
721 person->getPlan().push_back(item);
722 }
723 myActivePlan->clear();
724 if (myNet.addPerson(person)) {
727 }
728 } else {
730 }
732}
733
734
735void
737 std::string typeID = DEFAULT_PEDTYPE_ID;
739 myErrorOutput->inform("The vehicle type '" + myVehicleParameter->vtypeid + "' for personFlow '" + myVehicleParameter->id + "' is not known.");
740 } else {
741 typeID = myVehicleParameter->vtypeid;
742 }
743 if (myActivePlan == nullptr || myActivePlan->empty()) {
744 WRITE_WARNINGF(TL("Discarding personFlow '%' because their plan is empty"), myVehicleParameter->id);
745 } else {
747 // instantiate all persons of this flow
748 int i = 0;
749 std::string baseID = myVehicleParameter->id;
750 if (myWriteFlows) {
751 addFlowPerson(typeID, myVehicleParameter->depart, baseID, i);
754 throw ProcessError(TLF("probabilistic personFlow '%' must specify end time", myVehicleParameter->id));
755 } else {
758 addFlowPerson(typeID, t, baseID, i++);
759 }
760 }
761 }
762 } else {
764 // uniform sampling of departures from range is equivalent to poisson flow (encoded by negative offset)
765 if (OptionsCont::getOptions().getBool("randomize-flows") && myVehicleParameter->repetitionOffset >= 0) {
766 std::vector<SUMOTime> departures;
768 for (int j = 0; j < myVehicleParameter->repetitionNumber; ++j) {
769 departures.push_back(depart + RandHelper::rand(range));
770 }
771 std::sort(departures.begin(), departures.end());
772 std::reverse(departures.begin(), departures.end());
773 for (; i < myVehicleParameter->repetitionNumber; i++) {
774 addFlowPerson(typeID, departures[i], baseID, i);
776 }
777 } else {
780 // poisson: randomize first depart
782 }
784 addFlowPerson(typeID, depart + myVehicleParameter->repetitionTotalOffset, baseID, i);
787 }
788 }
789 }
790 }
791 }
793}
794
795
796void
797RORouteHandler::addFlowPerson(const std::string& typeID, SUMOTime depart, const std::string& baseID, int i) {
800 return;
801 }
803 pars.id = baseID + "." + toString(i);
804 pars.depart = depart;
805 const SUMOVTypeParameter* const type = myNet.getVehicleTypeSecure(typeID);
806 if (!myKeepVTypeDist) {
807 pars.vtypeid = type->id;
808 }
809 ROPerson* person = new ROPerson(pars, type);
810 for (ROPerson::PlanItem* item : *myActivePlan) {
811 person->getPlan().push_back(item->clone());
812 }
813 if (myNet.addPerson(person)) {
814 if (i == 0) {
816 }
817 }
818}
819
820
821void
828 } else {
829 WRITE_WARNINGF(TL("Discarding container '%' because its plan is empty"), myVehicleParameter->id);
830 }
831 delete myVehicleParameter;
832 myVehicleParameter = nullptr;
834 myActiveContainerPlan = nullptr;
836}
837
838
845 } else {
846 WRITE_WARNINGF(TL("Discarding containerFlow '%' because its plan is empty"), myVehicleParameter->id);
847 }
848 delete myVehicleParameter;
849 myVehicleParameter = nullptr;
851 myActiveContainerPlan = nullptr;
853}
854
855
856void
859 // @todo: consider myScale?
861 delete myVehicleParameter;
862 myVehicleParameter = nullptr;
863 return;
864 }
865 // let's check whether vehicles had to depart before the simulation starts
867 const SUMOTime offsetToBegin = myBegin - myVehicleParameter->depart;
868 while (myVehicleParameter->repetitionTotalOffset < offsetToBegin) {
872 delete myVehicleParameter;
873 myVehicleParameter = nullptr;
874 return;
875 }
876 }
878 myErrorOutput->inform("The vehicle type '" + myVehicleParameter->vtypeid + "' for flow '" + myVehicleParameter->id + "' is not known.");
879 }
880 if (myVehicleParameter->routeid[0] == '!' && myNet.getRouteDef(myVehicleParameter->routeid) == nullptr) {
881 closeRoute(true);
882 }
883 if (myNet.getRouteDef(myVehicleParameter->routeid) == nullptr) {
884 myErrorOutput->inform("The route '" + myVehicleParameter->routeid + "' for flow '" + myVehicleParameter->id + "' is not known.");
885 delete myVehicleParameter;
886 myVehicleParameter = nullptr;
887 return;
888 }
889 myActiveRouteID = "";
890 if (!MsgHandler::getErrorInstance()->wasInformed()) {
893 } else {
894 myErrorOutput->inform("Another flow with the id '" + myVehicleParameter->id + "' exists.");
895 delete myVehicleParameter;
896 }
897 } else {
898 delete myVehicleParameter;
899 }
900 myVehicleParameter = nullptr;
902}
903
904
905void
910
911
913RORouteHandler::retrieveStoppingPlace(const SUMOSAXAttributes& attrs, const std::string& errorSuffix, std::string& id, const SUMOVehicleParameter::Stop* stopParam) {
914 const SUMOVehicleParameter::Stop* toStop = nullptr;
916 SUMOVehicleParserHelper::parseStopTag(attrs, stopParam, tag, id);
917 if (tag != SUMO_TAG_NOTHING) {
918 toStop = myNet.getStoppingPlace(id, tag);
919 if (toStop == nullptr) {
920 myErrorOutput->inform(TLF("The % '%' is not known%", toString(tag), id, errorSuffix));
921 }
922 }
923 return toStop;
924}
925
928 Parameterised* result = nullptr;
929 if (myActiveContainerPlan != nullptr) {
931 (*myActiveContainerPlan) << attrs;
934 return result;
935 }
936 std::string errorSuffix;
937 if (myActivePlan != nullptr) {
938 errorSuffix = " in person '" + myVehicleParameter->id + "'.";
939 } else if (myActiveContainerPlan != nullptr) {
940 errorSuffix = " in container '" + myVehicleParameter->id + "'.";
941 } else if (myVehicleParameter != nullptr) {
942 errorSuffix = " in vehicle '" + myVehicleParameter->id + "'.";
943 } else {
944 errorSuffix = " in route '" + myActiveRouteID + "'.";
945 }
947 bool ok = parseStop(stop, attrs, errorSuffix, myErrorOutput);
948 if (!ok) {
949 return result;
950 }
951 // try to parse the assigned bus stop
952 const ROEdge* edge = nullptr;
953 std::string stoppingPlaceID;
954 const SUMOVehicleParameter::Stop* stoppingPlace = retrieveStoppingPlace(attrs, errorSuffix, stoppingPlaceID, &stop);
955 bool hasPos = false;
956 if (stoppingPlace != nullptr) {
957 stop.lane = stoppingPlace->lane;
958 stop.endPos = stoppingPlace->endPos;
959 stop.startPos = stoppingPlace->startPos;
961 } else {
962 // no, the lane and the position should be given
963 stop.lane = attrs.getOpt<std::string>(SUMO_ATTR_LANE, nullptr, ok, "");
964 stop.edge = attrs.getOpt<std::string>(SUMO_ATTR_EDGE, nullptr, ok, "");
965 if (ok && stop.edge != "") {
966 edge = myNet.getEdge(stop.edge);
967 if (edge == nullptr) {
968 myErrorOutput->inform("The edge '" + stop.edge + "' for a stop is not known" + errorSuffix);
969 return result;
970 }
971 } else if (ok && stop.lane != "") {
973 if (edge == nullptr) {
974 myErrorOutput->inform("The lane '" + stop.lane + "' for a stop is not known" + errorSuffix);
975 return result;
976 }
977 } else if (ok && ((attrs.hasAttribute(SUMO_ATTR_X) && attrs.hasAttribute(SUMO_ATTR_Y))
978 || (attrs.hasAttribute(SUMO_ATTR_LON) && attrs.hasAttribute(SUMO_ATTR_LAT)))) {
979 Position pos;
980 bool geo = false;
981 if (attrs.hasAttribute(SUMO_ATTR_X) && attrs.hasAttribute(SUMO_ATTR_Y)) {
982 pos = Position(attrs.get<double>(SUMO_ATTR_X, myVehicleParameter->id.c_str(), ok), attrs.get<double>(SUMO_ATTR_Y, myVehicleParameter->id.c_str(), ok));
983 } else {
984 pos = Position(attrs.get<double>(SUMO_ATTR_LON, myVehicleParameter->id.c_str(), ok), attrs.get<double>(SUMO_ATTR_LAT, myVehicleParameter->id.c_str(), ok));
985 geo = true;
986 }
987 PositionVector positions;
988 positions.push_back(pos);
989 ConstROEdgeVector geoEdges;
993 if (type != nullptr) {
994 vClass = type->vehicleClass;
995 }
996 }
997 parseGeoEdges(positions, geo, vClass, geoEdges, myVehicleParameter->id, true, ok, true);
998 if (ok) {
999 edge = geoEdges.front();
1000 hasPos = true;
1001 if (geo) {
1003 }
1005 stop.endPos = edge->getLanes()[0]->getShape().nearest_offset_to_point2D(pos, false);
1006 } else {
1007 return result;
1008 }
1009 } else if (!ok || (stop.lane == "" && stop.edge == "")) {
1010 myErrorOutput->inform("A stop must be placed on a bus stop, a container stop, a parking area, an edge or a lane" + errorSuffix);
1011 return result;
1012 }
1013 if (!hasPos) {
1014 stop.endPos = attrs.getOpt<double>(SUMO_ATTR_ENDPOS, nullptr, ok, edge->getLength());
1015 }
1016 stop.startPos = attrs.getOpt<double>(SUMO_ATTR_STARTPOS, nullptr, ok, stop.endPos - 2 * POSITION_EPS);
1017 const bool friendlyPos = attrs.getOpt<bool>(SUMO_ATTR_FRIENDLY_POS, nullptr, ok, !attrs.hasAttribute(SUMO_ATTR_STARTPOS) && !attrs.hasAttribute(SUMO_ATTR_ENDPOS));
1018 const double endPosOffset = edge->isInternal() ? edge->getNormalBefore()->getLength() : 0;
1019 if (!ok || (checkStopPos(stop.startPos, stop.endPos, edge->getLength() + endPosOffset, POSITION_EPS, friendlyPos) != SUMORouteHandler::StopPos::STOPPOS_VALID)) {
1020 myErrorOutput->inform("Invalid start or end position for stop" + errorSuffix);
1021 return result;
1022 }
1023 }
1024 stop.edge = edge->getID();
1025 if (myActivePlan != nullptr) {
1026 ROPerson::addStop(*myActivePlan, stop, edge);
1027 result = myActivePlan->back()->getStopParameters();
1028 } else if (myVehicleParameter != nullptr) {
1029 myVehicleParameter->stops.push_back(stop);
1030 result = &myVehicleParameter->stops.back();
1031 } else {
1032 myActiveRouteStops.push_back(stop);
1033 result = &myActiveRouteStops.back();
1034 }
1035 if (myInsertStopEdgesAt >= 0) {
1036 myActiveRoute.insert(myActiveRoute.begin() + myInsertStopEdgesAt, edge);
1038 }
1039 return result;
1040}
1041
1042
1043void
1045 bool ok = true;
1046 std::vector<ROPerson::PlanItem*>& plan = *myActivePlan;
1047 const std::string pid = myVehicleParameter->id;
1048
1049 const ROEdge* from = nullptr;
1050 const ROEdge* to = nullptr;
1051 parseFromViaTo(SUMO_TAG_PERSON, attrs, ok);
1054 if (ok) {
1055 from = myActiveRoute.front();
1056 }
1057 } else if (plan.empty()) {
1058 myErrorOutput->inform("The start edge for person '" + pid + "' is not known.");
1059 return;
1060 }
1061 std::string stoppingPlaceID;
1062 const SUMOVehicleParameter::Stop* stop = retrieveStoppingPlace(attrs, " for ride of person '" + myVehicleParameter->id + "'", stoppingPlaceID);
1063 if (stop != nullptr) {
1065 } else {
1068 to = myActiveRoute.back();
1069 } else {
1070 myErrorOutput->inform("The to edge is missing within a ride of '" + myVehicleParameter->id + "'.");
1071 return;
1072 }
1073 }
1074 double arrivalPos = attrs.getOpt<double>(SUMO_ATTR_ARRIVALPOS, myVehicleParameter->id.c_str(), ok,
1075 stop == nullptr ? std::numeric_limits<double>::infinity() : stop->endPos);
1076 const std::string lines = attrs.getOpt<std::string>(SUMO_ATTR_LINES, pid.c_str(), ok, LINE_ANY);
1077 const std::string group = attrs.getOpt<std::string>(SUMO_ATTR_GROUP, pid.c_str(), ok, "");
1078
1080 StringTokenizer st(lines);
1081 if (st.size() != 1 || st.get(0) == LINE_ANY) {
1082 myErrorOutput->inform("Triggered departure for person '" + pid + "' requires a unique lines value.");
1083 return;
1084 }
1085 const std::string vehID = st.front();
1086 if (myNet.knowsVehicle(vehID)) {
1087 const SUMOTime vehDepart = myNet.getDeparture(vehID);
1088 if (vehDepart == -1) {
1089 myErrorOutput->inform("Cannot use triggered vehicle '" + vehID + "' in triggered departure for person '" + pid + "'.");
1090 return;
1091 }
1092 myVehicleParameter->depart = vehDepart + 1; // write person after vehicle
1093 } else {
1094 if (mySkippedVehicles.count(vehID) == 0) {
1095 myErrorOutput->inform("Unknown vehicle '" + vehID + "' in triggered departure for person '" + pid + "'.");
1096 return;
1097 }
1098 myVehicleParameter->departProcedure = DepartDefinition::GIVEN; // make sure the person gets skipped due to depart time
1099 }
1100 }
1101 ROPerson::addRide(plan, from, to, lines, arrivalPos, stoppingPlaceID, group);
1102}
1103
1104
1105void
1108 bool ok = true;
1109 const std::string pid = myVehicleParameter->id;
1110 const std::string desc = attrs.get<std::string>(SUMO_ATTR_LINES, pid.c_str(), ok);
1111 StringTokenizer st(desc);
1112 if (st.size() != 1) {
1113 throw ProcessError(TLF("Triggered departure for container '%' requires a unique lines value.", pid));
1114 }
1115 const std::string vehID = st.front();
1116 if (!myNet.knowsVehicle(vehID)) {
1117 if (mySkippedVehicles.count(vehID) == 0) {
1118 throw ProcessError("Unknown vehicle '" + vehID + "' in triggered departure for container '" + pid + "'.");
1119 }
1120 return;
1121 }
1122 SUMOTime vehDepart = myNet.getDeparture(vehID);
1123 if (vehDepart == -1) {
1124 throw ProcessError("Cannot use triggered vehicle '" + vehID + "' in triggered departure for container '" + pid + "'.");
1125 }
1126 myVehicleParameter->depart = vehDepart + 1; // write container after vehicle
1127 }
1128}
1129
1130
1131void
1134
1135
1136void
1137RORouteHandler::parseEdges(const std::string& desc, ConstROEdgeVector& into,
1138 const std::string& rid, bool& ok) {
1139 for (StringTokenizer st(desc); st.hasNext();) {
1140 const std::string id = st.next();
1141 const ROEdge* edge = myNet.getEdge(id);
1142 if (edge == nullptr) {
1143 myErrorOutput->inform("The edge '" + id + "' within the route " + rid + " is not known.");
1144 ok = false;
1145 } else {
1146 into.push_back(edge);
1147 }
1148 }
1149}
1150
1151
1152void
1153RORouteHandler::parseWalkPositions(const SUMOSAXAttributes& attrs, const std::string& personID,
1154 const ROEdge* /*fromEdge*/, const ROEdge*& toEdge,
1155 double& departPos, double& arrivalPos, std::string& busStopID,
1156 const ROPerson::PlanItem* const lastStage, bool& ok) {
1157 const std::string description = "walk or personTrip of '" + personID + "'.";
1158 if (attrs.hasAttribute(SUMO_ATTR_DEPARTPOS)) {
1159 WRITE_WARNING(TL("The attribute departPos is no longer supported for walks, please use the person attribute, the arrivalPos of the previous step or explicit stops."));
1160 }
1161 departPos = myVehicleParameter->departPos;
1162 if (lastStage != nullptr) {
1163 departPos = lastStage->getDestinationPos();
1164 }
1165
1166 busStopID = attrs.getOpt<std::string>(SUMO_ATTR_BUS_STOP, nullptr, ok, "");
1167
1168 const SUMOVehicleParameter::Stop* bs = retrieveStoppingPlace(attrs, description, busStopID);
1169 if (bs != nullptr) {
1171 arrivalPos = (bs->startPos + bs->endPos) / 2;
1172 }
1173 if (toEdge != nullptr) {
1176 myHardFail, description, toEdge->getLength(),
1177 attrs.get<std::string>(SUMO_ATTR_ARRIVALPOS, description.c_str(), ok));
1178 }
1179 } else {
1180 throw ProcessError(TLF("No destination edge for %.", description));
1181 }
1182}
1183
1184
1185void
1187 bool ok = true;
1188 const char* const id = myVehicleParameter->id.c_str();
1189 assert(!attrs.hasAttribute(SUMO_ATTR_EDGES));
1190 const ROEdge* from = nullptr;
1191 const ROEdge* to = nullptr;
1192 parseFromViaTo(SUMO_TAG_PERSON, attrs, ok);
1196 if (ok) {
1197 from = myActiveRoute.front();
1198 }
1199 } else if (myActivePlan->empty()) {
1200 throw ProcessError(TLF("Start edge not defined for person '%'.", myVehicleParameter->id));
1201 } else {
1202 from = myActivePlan->back()->getDestination();
1203 }
1206 to = myActiveRoute.back();
1207 } // else, to may also be derived from stopping place
1208
1209 const SUMOTime duration = attrs.getOptSUMOTimeReporting(SUMO_ATTR_DURATION, id, ok, -1);
1210 if (attrs.hasAttribute(SUMO_ATTR_DURATION) && duration <= 0) {
1211 throw ProcessError(TLF("Non-positive walking duration for '%'.", myVehicleParameter->id));
1212 }
1213
1214 double departPos = 0;
1215 double arrivalPos = std::numeric_limits<double>::infinity();
1216 std::string busStopID;
1217 const ROPerson::PlanItem* const lastStage = myActivePlan->empty() ? nullptr : myActivePlan->back();
1218 parseWalkPositions(attrs, myVehicleParameter->id, from, to, departPos, arrivalPos, busStopID, lastStage, ok);
1219
1220 const std::string modes = attrs.getOpt<std::string>(SUMO_ATTR_MODES, id, ok, "");
1221 const std::string group = attrs.getOpt<std::string>(SUMO_ATTR_GROUP, id, ok, "");
1222 SVCPermissions modeSet = 0;
1223 for (StringTokenizer st(modes); st.hasNext();) {
1224 const std::string mode = st.next();
1225 if (mode == "car") {
1226 modeSet |= SVC_PASSENGER;
1227 } else if (mode == "taxi") {
1228 modeSet |= SVC_TAXI;
1229 } else if (mode == "bicycle") {
1230 modeSet |= SVC_BICYCLE;
1231 } else if (mode == "public") {
1232 modeSet |= SVC_BUS;
1233 } else {
1234 throw InvalidArgument("Unknown person mode '" + mode + "'.");
1235 }
1236 }
1237 const std::string types = attrs.getOpt<std::string>(SUMO_ATTR_VTYPES, id, ok, "");
1238 double walkFactor = attrs.getOpt<double>(SUMO_ATTR_WALKFACTOR, id, ok, OptionsCont::getOptions().getFloat("persontrip.walkfactor"));
1239 if (ok) {
1240 const std::string originStopID = myActivePlan->empty() ? "" : myActivePlan->back()->getStopDest();
1241 ROPerson::addTrip(*myActivePlan, myVehicleParameter->id, from, to, modeSet, types,
1242 departPos, originStopID, arrivalPos, busStopID, walkFactor, group);
1243 myParamStack.push_back(myActivePlan->back());
1244 }
1245}
1246
1247
1248void
1250 // parse walks from->to as person trips
1252 // XXX allow --repair?
1253 bool ok = true;
1254 if (attrs.hasAttribute(SUMO_ATTR_ROUTE)) {
1255 const std::string routeID = attrs.get<std::string>(SUMO_ATTR_ROUTE, myVehicleParameter->id.c_str(), ok);
1256 RORouteDef* routeDef = myNet.getRouteDef(routeID);
1257 const std::shared_ptr<const RORoute> route = routeDef != nullptr ? routeDef->getFirstRoute() : nullptr;
1258 if (route == nullptr) {
1259 throw ProcessError("The route '" + routeID + "' for walk of person '" + myVehicleParameter->id + "' is not known.");
1260 }
1261 myActiveRoute = route->getEdgeVector();
1262 } else {
1263 myActiveRoute.clear();
1264 parseEdges(attrs.get<std::string>(SUMO_ATTR_EDGES, myVehicleParameter->id.c_str(), ok), myActiveRoute, " walk for person '" + myVehicleParameter->id + "'", ok);
1265 }
1266 const char* const objId = myVehicleParameter->id.c_str();
1267 const double duration = attrs.getOpt<double>(SUMO_ATTR_DURATION, objId, ok, -1);
1268 if (attrs.hasAttribute(SUMO_ATTR_DURATION) && duration <= 0) {
1269 throw ProcessError(TLF("Non-positive walking duration for '%'.", myVehicleParameter->id));
1270 }
1271 const double speed = attrs.getOpt<double>(SUMO_ATTR_SPEED, objId, ok, -1.);
1272 if (attrs.hasAttribute(SUMO_ATTR_SPEED) && speed <= 0) {
1273 throw ProcessError(TLF("Non-positive walking speed for '%'.", myVehicleParameter->id));
1274 }
1275 double departPos = 0.;
1276 double arrivalPos = std::numeric_limits<double>::infinity();
1277 if (attrs.hasAttribute(SUMO_ATTR_DEPARTPOS)) {
1278 WRITE_WARNING(TL("The attribute departPos is no longer supported for walks, please use the person attribute, the arrivalPos of the previous step or explicit stops."));
1279 }
1281 arrivalPos = SUMOVehicleParserHelper::parseWalkPos(SUMO_ATTR_ARRIVALPOS, myHardFail, objId, myActiveRoute.back()->getLength(), attrs.get<std::string>(SUMO_ATTR_ARRIVALPOS, objId, ok));
1282 }
1283 std::string stoppingPlaceID;
1284 const std::string errorSuffix = " for walk of person '" + myVehicleParameter->id + "'";
1285 retrieveStoppingPlace(attrs, errorSuffix, stoppingPlaceID);
1286 if (ok) {
1287 ROPerson::addWalk(*myActivePlan, myActiveRoute, duration, speed, departPos, arrivalPos, stoppingPlaceID);
1288 myParamStack.push_back(myActivePlan->back());
1289 }
1290 } else {
1291 addPersonTrip(attrs);
1292 }
1293}
1294
1295
1296void
1298 for (const auto& edgeItem : myNet.getEdgeMap()) {
1299 for (ROLane* lane : edgeItem.second->getLanes()) {
1300 Boundary b = lane->getShape().getBoxBoundary();
1301 const float cmin[2] = {(float) b.xmin(), (float) b.ymin()};
1302 const float cmax[2] = {(float) b.xmax(), (float) b.ymax()};
1303 tree->Insert(cmin, cmax, lane);
1304 }
1305 }
1306}
1307
1308
1309ROEdge*
1310RORouteHandler::retrieveEdge(const std::string& id) {
1311 return myNet.getEdge(id);
1312}
1313
1314
1315const SUMOVTypeParameter*
1316RORouteHandler::getVTypeParameter(const std::string& refid) {
1317 if (refid == "") {
1318 return nullptr;
1319 }
1320 if (!myNet.knowsVType(refid)) {
1321 myErrorOutput->inform(TLF("Unknown vehicle type '%'.", refid));
1322 return nullptr;
1323 }
1324 return myNet.getVehicleTypeSecure(refid);
1325}
1326
1327
1328bool
1330 if (!myUnsortedInput) {
1332 }
1333 return true;
1334}
1335
1336
1337/****************************************************************************/
long long int SUMOTime
Definition GUI.h:36
#define JUNCTION_TAZ_MISSING_HELP
Definition MapMatcher.h:30
#define WRITE_WARNINGF(...)
Definition MsgHandler.h:299
#define WRITE_WARNING(msg)
Definition MsgHandler.h:298
#define TL(string)
Definition MsgHandler.h:316
#define TLF(string,...)
Definition MsgHandler.h:318
std::vector< const ROEdge * > ConstROEdgeVector
Definition ROEdge.h:57
SUMOTime string2time(const std::string &r)
convert string to SUMOTime
Definition SUMOTime.cpp:47
constexpr SUMOTime TIME2STEPS(double x)
Definition SUMOTime.h:60
#define SUMOTime_MAX
Definition SUMOTime.h:34
long long int SVCPermissions
bitset where each bit declares whether a certain SVC may use this edge/lane
const double DEFAULT_VEH_PROB
const std::string DEFAULT_PEDTYPE_ID
const std::string DEFAULT_VTYPE_ID
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types.
@ SVC_IGNORING
vehicles ignoring classes
@ SVC_PASSENGER
vehicle is a passenger car (a "normal" car)
@ SVC_BICYCLE
vehicle is a bicycle
@ SVC_TAXI
vehicle is a taxi
@ SVC_BUS
vehicle is a bus
@ SVC_PEDESTRIAN
pedestrian
const std::string LINE_ANY
const long long int VEHPARS_TO_TAZ_SET
const long long int VEHPARS_FROM_TAZ_SET
const int STOP_END_SET
@ GIVEN
The time is given.
@ TRIGGERED
The departure is person triggered.
SumoXMLTag
Numbers representing SUMO-XML - element names.
@ SUMO_TAG_NOTHING
invalid tag, must be the last one
@ SUMO_TAG_TRANSHIP
@ SUMO_TAG_CONTAINERFLOW
@ SUMO_TAG_STOP
stop for vehicles
@ SUMO_TAG_FLOW
a flow definition using from and to edges or a route
@ SUMO_TAG_TRANSPORT
@ SUMO_TAG_CONTAINER
@ SUMO_TAG_RIDE
@ SUMO_TAG_PARAM
parameter associated to a certain key
@ SUMO_TAG_PERSON
@ SUMO_TAG_PERSONFLOW
@ SUMO_TAG_TRIP
a single trip definition (used by router)
@ SUMO_ATTR_STARTPOS
@ SUMO_ATTR_LINES
@ SUMO_ATTR_LAST
@ SUMO_ATTR_LANE
@ SUMO_ATTR_LON
@ SUMO_ATTR_REFID
@ SUMO_ATTR_FROM_JUNCTION
@ SUMO_ATTR_VIALONLAT
@ SUMO_ATTR_SPEED
@ SUMO_ATTR_VIA
@ SUMO_ATTR_VIAXY
@ SUMO_ATTR_Y
@ SUMO_ATTR_EDGE
@ SUMO_ATTR_BUS_STOP
@ SUMO_ATTR_ENDPOS
@ SUMO_ATTR_TO_JUNCTION
@ SUMO_ATTR_X
@ SUMO_ATTR_ARRIVALPOS
@ SUMO_ATTR_PROBS
@ SUMO_ATTR_EDGES
the edges of a route
@ SUMO_ATTR_TOLONLAT
@ SUMO_ATTR_ROUTES
@ SUMO_ATTR_MODES
@ SUMO_ATTR_VTYPES
@ SUMO_ATTR_DEPARTPOS
@ SUMO_ATTR_GROUP
@ SUMO_ATTR_COST
@ SUMO_ATTR_TO_TAZ
@ SUMO_ATTR_TO
@ SUMO_ATTR_FROM
@ SUMO_ATTR_FROM_TAZ
@ SUMO_ATTR_VIAJUNCTIONS
@ SUMO_ATTR_FROMXY
@ SUMO_ATTR_PROB
@ SUMO_ATTR_FRIENDLY_POS
@ SUMO_ATTR_LAT
@ SUMO_ATTR_WALKFACTOR
@ SUMO_ATTR_TOXY
@ SUMO_ATTR_ROUTE
@ SUMO_ATTR_COLOR
A color information.
@ SUMO_ATTR_ID
@ SUMO_ATTR_DURATION
@ SUMO_ATTR_FROMLONLAT
@ SUMO_ATTR_REPEAT
@ SUMO_ATTR_CYCLETIME
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition ToString.h:57
A class that stores a 2D geometrical boundary.
Definition Boundary.h:39
double ymin() const
Returns minimum y-coordinate.
Definition Boundary.cpp:127
double xmin() const
Returns minimum x-coordinate.
Definition Boundary.cpp:115
PositionVector getShape(const bool closeShape) const
get position vector (shape) based on this boundary
Definition Boundary.cpp:444
double ymax() const
Returns maximum y-coordinate.
Definition Boundary.cpp:133
double xmax() const
Returns maximum x-coordinate.
Definition Boundary.cpp:121
static const GeoConvHelper & getFinal()
the coordinate transformation for writing the location element and for tracking the original coordina...
bool x2cartesian_const(Position &from) const
Converts the given coordinate into a cartesian using the previous initialisation.
Provides utility functions for matching locations to edges (during route parsing)
Definition MapMatcher.h:45
void parseGeoEdges(const PositionVector &positions, bool geo, SUMOVehicleClass vClass, std::vector< const ROEdge * > &into, const std::string &rid, bool isFrom, bool &ok, bool forceEdge=false)
Definition MapMatcher.h:48
static MsgHandler * getErrorInstance()
Returns the instance to add errors to.
virtual void inform(std::string msg, bool addType=true)
adds a new error to the list
const std::string & getID() const
Returns the id.
Definition Named.h:73
A RT-tree for efficient storing of SUMO's Named objects.
Definition NamedRTree.h:61
void Insert(const float a_min[2], const float a_max[2], Named *const &a_data)
Insert entry.
Definition NamedRTree.h:79
A storage for options typed value containers)
Definition OptionsCont.h:92
double getFloat(const std::string &name) const
Returns the double-value of the named option (only for Option_Float)
bool exists(const std::string &name) const
Returns the information whether the named option is known.
bool getBool(const std::string &name) const
Returns the boolean-value of the named option (only for Option_Bool)
const StringVector & getStringVector(const std::string &name) const
Returns the list of string-value of the named option (only for Option_StringVector)
static OptionsCont & getOptions()
Retrieves the options.
An output device that encapsulates an ofstream.
std::string getString() const
Returns the current content as a string.
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
bool closeTag(const std::string &comment="")
Closes the most recently opened tag and optionally adds a comment.
An upper class for objects with additional parameters.
A point in 2D or 3D with translation and scaling methods.
Definition Position.h:37
A list of positions.
Boundary getBoxBoundary() const
Returns a boundary enclosing this list of lines.
A basic edge for routing applications.
Definition ROEdge.h:73
const ROEdge * getNormalBefore() const
if this edge is an internal edge, return its first normal predecessor, otherwise the edge itself
Definition ROEdge.cpp:294
bool isInternal() const
return whether this edge is an internal edge
Definition ROEdge.h:160
int getNumSuccessors() const
Returns the number of edges this edge is connected to.
Definition ROEdge.cpp:276
const ROEdgeVector & getSuccessors(SUMOVehicleClass vClass=SVC_IGNORING) const
Returns the following edges, restricted by vClass.
Definition ROEdge.cpp:391
int getNumPredecessors() const
Returns the number of edges connected to this edge.
Definition ROEdge.cpp:285
const std::vector< ROLane * > & getLanes() const
Returns this edge's lanes.
Definition ROEdge.h:569
double getLength() const
Returns the length of the edge.
Definition ROEdge.h:225
A single lane the router may use.
Definition ROLane.h:48
The router's network representation.
Definition RONet.h:63
bool knowsVType(const std::string &id) const
returns whether a vehicle type or distribution with the given id was already loaded
Definition RONet.cpp:540
SUMOVTypeParameter * getVehicleTypeSecure(const std::string &id)
Retrieves the named vehicle type.
Definition RONet.cpp:410
const RandomDistributor< SUMOVTypeParameter * > * getVTypeDistribution(const std::string &id)
Retrieves the named vehicle type distribution.
Definition RONet.h:302
bool addRouteDef(RORouteDef *def)
Definition RONet.cpp:335
bool knowsVehicle(const std::string &id) const
returns whether a vehicle with the given id was already loaded
Definition RONet.cpp:534
virtual bool addVehicle(const std::string &id, ROVehicle *veh)
Definition RONet.cpp:512
SUMOTime getDeparture(const std::string &vehID) const
returns departure time for the given vehicle id
Definition RONet.cpp:546
const SUMOVehicleParameter::Stop * getStoppingPlace(const std::string &id, const SumoXMLTag category) const
Retrieves a stopping place from the network.
Definition RONet.h:238
void addContainer(const SUMOTime depart, const std::string desc)
Definition RONet.cpp:591
ROEdge * getEdge(const std::string &name) const
Retrieves an edge from the network.
Definition RONet.h:179
bool addPerson(ROPerson *person)
Definition RONet.cpp:579
RORouteDef * getRouteDef(const std::string &name) const
Returns the named route definition.
Definition RONet.h:340
virtual bool addVehicleType(SUMOVTypeParameter *type)
Adds a read vehicle type definition to the network.
Definition RONet.cpp:488
bool addVTypeDistribution(const std::string &id, RandomDistributor< SUMOVTypeParameter * > *vehTypeDistribution)
Adds a vehicle type distribution.
Definition RONet.cpp:501
void routeSkipped()
Record routes excluded by the begin time.
Definition RONet.h:418
const NamedObjectCont< ROEdge * > & getEdgeMap() const
Definition RONet.h:460
bool addFlow(SUMOVehicleParameter *flow, const bool randomize)
Definition RONet.cpp:557
Every person has a plan comprising of multiple planItems.
Definition ROPerson.h:83
virtual double getDestinationPos() const =0
A person as used by router.
Definition ROPerson.h:50
static void addTrip(std::vector< PlanItem * > &plan, const std::string &id, const ROEdge *const from, const ROEdge *const to, const SVCPermissions modeSet, const std::string &vTypes, const double departPos, const std::string &stopOrigin, const double arrivalPos, const std::string &busStop, double walkFactor, const std::string &group)
Definition ROPerson.cpp:63
static void addStop(std::vector< PlanItem * > &plan, const SUMOVehicleParameter::Stop &stopPar, const ROEdge *const stopEdge)
Definition ROPerson.cpp:135
static void addRide(std::vector< PlanItem * > &plan, const ROEdge *const from, const ROEdge *const to, const std::string &lines, double arrivalPos, const std::string &destStop, const std::string &group)
Definition ROPerson.cpp:118
static void addWalk(std::vector< PlanItem * > &plan, const ConstROEdgeVector &edges, const double duration, const double speed, const double departPos, const double arrivalPos, const std::string &busStop)
Definition ROPerson.cpp:126
std::vector< PlanItem * > & getPlan()
Definition ROPerson.h:449
Base class for a vehicle's route definition.
Definition RORouteDef.h:54
const ROEdge * getOrigin() const
double getOverallProb() const
Returns the sum of the probablities of the contained routes.
std::shared_ptr< const RORoute > getFirstRoute() const
Definition RORouteDef.h:108
void addAlternativeDef(const RORouteDef *alternative)
Adds an alternative loaded from the file.
void addLoadedAlternative(std::shared_ptr< RORoute > alternative)
Adds a single alternative loaded from the file An alternative may also be generated during DUA.
Definition RORouteDef.h:71
const ROEdge * getDestination() const
RORouteDef * copy(const std::string &id, const SUMOTime stopOffset) const
Returns a deep copy of the route definition.
const SUMOVTypeParameter * getVTypeParameter(const std::string &refid) override
void openVehicleTypeDistribution(const SUMOSAXAttributes &attrs) override
opens a type distribution for reading
const SUMOVehicleParameter::Stop * retrieveStoppingPlace(const SUMOSAXAttributes &attrs, const std::string &errorSuffix, std::string &id, const SUMOVehicleParameter::Stop *stopParam=nullptr)
retrieve stopping place element
bool myUseTaz
cached options
void addTransport(const SUMOSAXAttributes &attrs) override
Processing of a transport.
void deleteActivePlanAndVehicleParameter()
void openRoute(const SUMOSAXAttributes &attrs) override
opens a route for reading
std::string myCurrentVTypeDistributionID
The id of the currently parsed vehicle type distribution.
void addFlowPerson(const std::string &typeID, SUMOTime depart, const std::string &baseID, int i)
Processing of a person from a personFlow.
void closeContainerFlow() override
Ends the processing of a containerFlow.
RORouteHandler(RONet &net, const std::string &file, const bool tryRepair, const bool emptyDestinationsAllowed, const bool ignoreErrors, const bool checkSchema)
standard constructor
void parseEdges(const std::string &desc, ConstROEdgeVector &into, const std::string &rid, bool &ok)
Parse edges from strings.
RONet & myNet
The current route.
void addRide(const SUMOSAXAttributes &attrs) override
Processing of a ride.
ConstROEdgeVector myActiveRoute
The current route.
void closeRouteDistribution() override
closes (ends) the building of a distribution
void addTranship(const SUMOSAXAttributes &attrs) override
Processing of a tranship.
void closeContainer() override
Ends the processing of a container.
std::vector< ROPerson::PlanItem * > * myActivePlan
The plan of the current person.
const bool myWriteFlows
whether flows shall not be expanded
const bool myTryRepair
Information whether routes shall be repaired.
bool checkLastDepart() override
Checks whether the route file is sorted by departure time if needed.
OutputDevice_String * myActiveContainerPlan
The plan of the current container.
void closeVehicle() override
Ends the processing of a vehicle.
SUMOTime myActiveRoutePeriod
const SUMOTime myBegin
The begin time.
void closeRoute(const bool mayBeDisconnected=false) override
closes (ends) the building of a route.
Parameterised * addStop(const SUMOSAXAttributes &attrs) override
Processing of a stop.
RandomDistributor< SUMOVTypeParameter * > * myCurrentVTypeDistribution
The currently parsed distribution of vehicle types (probability->vehicle type)
void closePersonFlow() override
Ends the processing of a personFlow.
void openRouteDistribution(const SUMOSAXAttributes &attrs) override
opens a route distribution for reading
int myActiveContainerPlanSize
The number of stages in myActiveContainerPlan.
const bool myKeepVTypeDist
whether to keep the vtype distribution in output
void openTrip(const SUMOSAXAttributes &attrs) override
opens a trip for reading
const bool myUnsortedInput
whether input is read all at once (no sorting check is necessary)
void parseWalkPositions(const SUMOSAXAttributes &attrs, const std::string &personID, const ROEdge *fromEdge, const ROEdge *&toEdge, double &departPos, double &arrivalPos, std::string &busStopID, const ROPerson::PlanItem *const lastStage, bool &ok)
@ brief parse depart- and arrival positions of a walk
MsgHandler *const myErrorOutput
Depending on the "ignore-errors" option different outputs are used.
int myActiveRouteRepeat
number of repetitions of the active route
void closeFlow() override
Ends the processing of a flow.
ROEdge * retrieveEdge(const std::string &id) override
void addPersonTrip(const SUMOSAXAttributes &attrs) override
add a routing request for a walking or intermodal person
void closePerson() override
Ends the processing of a person.
~RORouteHandler() override
standard destructor
RORouteDef * myCurrentAlternatives
The currently parsed route alternatives.
void myStartElement(int element, const SUMOSAXAttributes &attrs) override
Called on the opening of a tag;.
void addWalk(const SUMOSAXAttributes &attrs) override
add a fully specified walk
void initLaneTree(NamedRTree *tree) override
void openRouteFlow(const SUMOSAXAttributes &attrs) override
opens a route flow for reading
void closeTrip() override
Ends the processing of a trip.
void openFlow(const SUMOSAXAttributes &attrs) override
opens a flow for reading
void closeVType() override
Ends the processing of a vehicle type.
void closeVehicleTypeDistribution() override
closes (ends) the building of a distribution
void parseFromViaTo(SumoXMLTag tag, const SUMOSAXAttributes &attrs, bool &ok)
Called for parsing from and to and the corresponding taz attributes.
A vehicle as used by router.
Definition ROVehicle.h:51
static double rand(SumoRNG *rng=nullptr)
Returns a random real number in [0, 1)
Represents a generic random distribution.
double getOverallProb() const
Return the sum of the probabilites assigned to the members.
bool add(T val, double prob, bool checkDuplicates=true)
Adds a value with an assigned probability to the distribution.
const std::vector< T > & getVals() const
Returns the members of the distribution.
void clear()
Clears the distribution.
const std::vector< double > & getProbs() const
Returns the probabilities assigned to the members of the distribution.
Parser for routes during their loading.
bool parseStop(SUMOVehicleParameter::Stop &stop, const SUMOSAXAttributes &attrs, std::string errorSuffix, MsgHandler *const errorOutput)
parses attributes common to all stops
std::set< std::string > mySkippedVehicles
IDs of skipped vehicles to suppress errors for the triggered transportables within.
void registerLastDepart()
save last depart (only to be used if vehicle is not discarded)
double myCurrentCosts
The currently parsed route costs.
std::string myActiveRouteID
The id of the current route.
std::vector< Parameterised * > myParamStack
The stack of currently parsed parameterised objects.
SUMOVehicleParameter * myVehicleParameter
Parameter of the current vehicle, trip, person, container or flow.
const bool myHardFail
flag to enable or disable hard fails
StopParVector myActiveRouteStops
List of the stops on the parsed route.
std::string myCurrentVTypeRef
if the currently parsed vType is only a reference to an existing type, store the refId
SUMOVTypeParameter * myCurrentVType
The currently parsed vehicle type.
static StopPos checkStopPos(double &startPos, double &endPos, const double laneLength, const double minLength, const bool friendlyPos)
check start and end position of a stop
virtual void myStartElement(int element, const SUMOSAXAttributes &attrs)
Called on the opening of a tag;.
double myActiveRouteProbability
The probability of the current route.
double myCurrentVTypeProbability
if the currently parsed vType is only a reference, store the probability here
int myInsertStopEdgesAt
where stop edges can be inserted into the current route (-1 means no insertion)
std::string myActiveRouteRefID
The id of the route the current route references to.
const RGBColor * myActiveRouteColor
The currently parsed route's color.
virtual bool checkLastDepart()
Checks whether the route file is sorted by departure time if needed.
Encapsulated SAX-Attributes.
T getOpt(int attr, const char *objectid, bool &ok, T defaultValue=T(), bool report=true) const
Tries to read given attribute assuming it is an int.
SUMOTime getOptSUMOTimeReporting(int attr, const char *objectid, bool &ok, SUMOTime defaultValue, bool report=true) const
Tries to read given attribute assuming it is a SUMOTime.
T get(int attr, const char *objectid, bool &ok, bool report=true) const
Tries to read given attribute assuming it is an int.
virtual bool hasAttribute(int id) const =0
Returns the information whether the named (by its enum-value) attribute is within the current list.
Structure representing possible vehicle parameter.
double defaultProbability
The probability when being added to a distribution without an explicit probability.
void cacheParamRestrictions(const std::vector< std::string > &restrictionKeys)
SUMOVehicleClass vehicleClass
The vehicle's class.
std::string id
The vehicle type's id.
Definition of vehicle stop (position and duration)
std::string edge
The edge to stop at.
std::string lane
The lane to stop at.
double startPos
The stopping position start.
int parametersSet
Information for the output which parameter were set.
double endPos
The stopping position end.
Structure representing possible vehicle parameter.
double repetitionProbability
The probability for emitting a vehicle per second.
void incrementFlow(double scale, SumoRNG *rng=nullptr)
increment flow
std::string vtypeid
The vehicle's type id.
SUMOTime repetitionOffset
The time offset between vehicle reinsertions.
long long int repetitionsDone
The number of times the vehicle was already inserted.
std::vector< std::string > via
List of the via-edges the vehicle must visit.
SUMOTime repetitionTotalOffset
The offset between depart and the time for the next vehicle insertions.
long long int parametersSet
Information for the router which parameter were set, TraCI may modify this (when changing color)
SUMOTime repetitionEnd
The time at which the flow ends (only needed when using repetitionProbability)
bool wasSet(long long int what) const
Returns whether the given parameter was set.
double departPos
(optional) The position the vehicle shall depart from
std::string routeid
The vehicle's route id.
std::string id
The vehicle's id.
std::vector< Stop > stops
List of the stops the vehicle will make, TraCI may add entries here.
std::string toTaz
The vehicle's destination zone (district)
DepartDefinition departProcedure
Information how the vehicle shall choose the depart time.
std::string fromTaz
The vehicle's origin zone (district)
static bool parseStopTag(const SUMOSAXAttributes &attrs, const SUMOVehicleParameter::Stop *stopParam, SumoXMLTag &tag, std::string &id)
parse named stopping place attrs (or use stopParam attrs) and return it's tag and id
static double parseWalkPos(SumoXMLAttr attr, const bool hardFail, const std::string &id, double maxPos, const std::string &val, SumoRNG *rng=0)
parse departPos or arrivalPos for a walk
static std::string getEdgeIDFromLane(const std::string laneID)
return edge id when given the lane ID
std::string front()
returns the first substring without moving the iterator
int size() const
returns the number of existing substrings
std::string get(int pos) const
returns the item at the given position
bool hasNext()
returns the information whether further substrings exist
std::string next()
returns the next substring when it exists. Otherwise the behaviour is undefined
static double toDoubleSecure(const std::string &sData, const double def)
converts a string into the integer value described by it