Eclipse SUMO - Simulation of Urban MObility
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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-2025 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 myCurrentVTypeDistribution(nullptr),
74 myCurrentAlternatives(nullptr),
75 myUseTaz(OptionsCont::getOptions().getBool("with-taz")),
76 myWriteJunctions(OptionsCont::getOptions().exists("write-trips")
77 && OptionsCont::getOptions().getBool("write-trips")
78 && OptionsCont::getOptions().getBool("write-trips.junctions"))
79{
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:
268 parseFromViaTo((SumoXMLTag)element, attrs, ok);
269 break;
270 case SUMO_TAG_TRIP:
272 parseFromViaTo((SumoXMLTag)element, attrs, ok);
273 break;
274 default:
275 break;
276 }
277 } catch (ProcessError&) {
279 throw;
280 }
281}
282
283
284void
286 bool ok = true;
287 myCurrentVTypeDistributionID = attrs.get<std::string>(SUMO_ATTR_ID, nullptr, ok);
288 if (ok) {
290 if (attrs.hasAttribute(SUMO_ATTR_VTYPES)) {
291 std::vector<double> probs;
292 if (attrs.hasAttribute(SUMO_ATTR_PROBS)) {
293 StringTokenizer st(attrs.get<std::string>(SUMO_ATTR_PROBS, myCurrentVTypeDistributionID.c_str(), ok));
294 while (st.hasNext()) {
295 probs.push_back(StringUtils::toDoubleSecure(st.next(), 1.0));
296 }
297 }
298 const std::string vTypes = attrs.get<std::string>(SUMO_ATTR_VTYPES, myCurrentVTypeDistributionID.c_str(), ok);
299 StringTokenizer st(vTypes);
300 int probIndex = 0;
301 while (st.hasNext()) {
302 const std::string typeID = st.next();
304 if (dist != nullptr) {
305 const double distProb = ((int)probs.size() > probIndex ? probs[probIndex] : 1.) / dist->getOverallProb();
306 std::vector<double>::const_iterator probIt = dist->getProbs().begin();
307 for (SUMOVTypeParameter* const type : dist->getVals()) {
308 myCurrentVTypeDistribution->add(type, distProb * *probIt);
309 probIt++;
310 }
311 } else {
312 SUMOVTypeParameter* const type = myNet.getVehicleTypeSecure(typeID);
313 if (type == nullptr) {
314 myErrorOutput->inform("Unknown vehicle type '" + typeID + "' in distribution '" + myCurrentVTypeDistributionID + "'.");
315 } else {
316 const double prob = ((int)probs.size() > probIndex ? probs[probIndex] : type->defaultProbability);
317 myCurrentVTypeDistribution->add(type, prob);
318 }
319 }
320 probIndex++;
321 }
322 if (probs.size() > 0 && probIndex != (int)probs.size()) {
323 WRITE_WARNING("Got " + toString(probs.size()) + " probabilities for " + toString(probIndex) +
324 " types in vTypeDistribution '" + myCurrentVTypeDistributionID + "'");
325 }
326 }
327 }
328}
329
330
331void
333 if (myCurrentVTypeDistribution != nullptr) {
336 myErrorOutput->inform("Vehicle type distribution '" + myCurrentVTypeDistributionID + "' is empty.");
339 myErrorOutput->inform("Another vehicle type (or distribution) with the id '" + myCurrentVTypeDistributionID + "' exists.");
340 }
342 }
343}
344
345
346void
350 // check whether the id is really necessary
351 std::string rid;
352 if (myCurrentAlternatives != nullptr) {
354 rid = "distribution '" + myCurrentAlternatives->getID() + "'";
355 } else if (myVehicleParameter != nullptr) {
356 // ok, a vehicle is wrapping the route,
357 // we may use this vehicle's id as default
358 myVehicleParameter->routeid = myActiveRouteID = "!" + myVehicleParameter->id; // !!! document this
359 if (attrs.hasAttribute(SUMO_ATTR_ID)) {
360 WRITE_WARNINGF(TL("Ids of internal routes are ignored (vehicle '%')."), myVehicleParameter->id);
361 }
362 } else {
363 bool ok = true;
364 myActiveRouteID = attrs.get<std::string>(SUMO_ATTR_ID, nullptr, ok);
365 if (!ok) {
366 return;
367 }
368 rid = "'" + myActiveRouteID + "'";
369 }
370 if (myVehicleParameter != nullptr) { // have to do this here for nested route distributions
371 rid = "for vehicle '" + myVehicleParameter->id + "'";
372 }
373 bool ok = true;
374 if (attrs.hasAttribute(SUMO_ATTR_EDGES)) {
375 parseEdges(attrs.get<std::string>(SUMO_ATTR_EDGES, myActiveRouteID.c_str(), ok), myActiveRoute, rid, ok);
376 }
377 myActiveRouteRefID = attrs.getOpt<std::string>(SUMO_ATTR_REFID, myActiveRouteID.c_str(), ok, "");
378 if (myActiveRouteRefID != "" && myNet.getRouteDef(myActiveRouteRefID) == nullptr) {
379 myErrorOutput->inform("Invalid reference to route '" + myActiveRouteRefID + "' in route " + rid + ".");
380 }
381 if (myCurrentAlternatives != nullptr && !attrs.hasAttribute(SUMO_ATTR_PROB)) {
382 WRITE_WARNINGF(TL("No probability for route %, using default."), rid);
383 }
385 if (ok && myActiveRouteProbability < 0) {
386 myErrorOutput->inform("Invalid probability for route '" + myActiveRouteID + "'.");
387 }
389 ok = true;
390 myActiveRouteRepeat = attrs.getOpt<int>(SUMO_ATTR_REPEAT, myActiveRouteID.c_str(), ok, 0);
392 if (myActiveRouteRepeat > 0) {
394 if (myVehicleParameter != nullptr) {
396 if (type != nullptr) {
397 vClass = type->vehicleClass;
398 }
399 }
400 if (myActiveRoute.size() > 0 && !myActiveRoute.back()->isConnectedTo(*myActiveRoute.front(), vClass)) {
401 myErrorOutput->inform("Disconnected route " + rid + " when repeating.");
402 }
403 }
404 myCurrentCosts = attrs.getOpt<double>(SUMO_ATTR_COST, myActiveRouteID.c_str(), ok, -1);
405 if (ok && myCurrentCosts != -1 && myCurrentCosts < 0) {
406 myErrorOutput->inform("Invalid cost for route '" + myActiveRouteID + "'.");
407 }
408}
409
410
411void
413 // currently unused
414}
415
416
417void
419 // currently unused
420}
421
422
423void
425 // currently unused
426}
427
428
429void
430RORouteHandler::closeRoute(const bool mayBeDisconnected) {
431 const bool mustReroute = myActiveRoute.size() == 0 && myActiveRouteStops.size() != 0;
432 if (mustReroute) {
433 // implicit route from stops
435 ROEdge* edge = myNet.getEdge(stop.edge);
436 myActiveRoute.push_back(edge);
437 }
438 }
439 if (myActiveRoute.size() == 0) {
440 if (myActiveRouteRefID != "" && myCurrentAlternatives != nullptr) {
442 myActiveRouteID = "";
444 return;
445 }
446 if (myVehicleParameter != nullptr) {
447 myErrorOutput->inform("The route for vehicle '" + myVehicleParameter->id + "' has no edges.");
448 } else {
449 myErrorOutput->inform("Route '" + myActiveRouteID + "' has no edges.");
450 }
451 myActiveRouteID = "";
452 myActiveRouteStops.clear();
453 return;
454 }
455 if (myActiveRoute.size() == 1 && myActiveRoute.front()->isTazConnector()) {
456 myErrorOutput->inform("The routing information for vehicle '" + myVehicleParameter->id + "' is insufficient.");
457 myActiveRouteID = "";
458 myActiveRouteStops.clear();
459 return;
460 }
461 if (!mayBeDisconnected && OptionsCont::getOptions().exists("no-internal-links") && !OptionsCont::getOptions().getBool("no-internal-links")) {
462 // fix internal edges which did not get parsed
463 const ROEdge* last = nullptr;
464 ConstROEdgeVector fullRoute;
465 for (const ROEdge* roe : myActiveRoute) {
466 if (last != nullptr) {
467 for (const ROEdge* intern : last->getSuccessors()) {
468 if (intern->isInternal() && intern->getSuccessors().size() == 1 && intern->getSuccessors().front() == roe) {
469 fullRoute.push_back(intern);
470 }
471 }
472 }
473 fullRoute.push_back(roe);
474 last = roe;
475 }
476 myActiveRoute = fullRoute;
477 }
478 if (myActiveRouteRepeat > 0) {
479 // duplicate route
481 auto tmpStops = myActiveRouteStops;
482 for (int i = 0; i < myActiveRouteRepeat; i++) {
483 myActiveRoute.insert(myActiveRoute.begin(), tmpEdges.begin(), tmpEdges.end());
484 for (SUMOVehicleParameter::Stop stop : tmpStops) {
485 if (stop.until > 0) {
486 if (myActiveRoutePeriod <= 0) {
487 const std::string description = myVehicleParameter != nullptr
488 ? "for vehicle '" + myVehicleParameter->id + "'"
489 : "'" + myActiveRouteID + "'";
490 throw ProcessError(TLF("Cannot repeat stops with 'until' in route % because no cycleTime is defined.", description));
491 }
492 stop.until += myActiveRoutePeriod * (i + 1);
493 stop.arrival += myActiveRoutePeriod * (i + 1);
494 }
495 myActiveRouteStops.push_back(stop);
496 }
497 }
498 }
501 myActiveRoute.clear();
502 if (myCurrentAlternatives == nullptr) {
503 if (myNet.getRouteDef(myActiveRouteID) != nullptr) {
504 delete route;
505 if (myVehicleParameter != nullptr) {
506 myErrorOutput->inform("Another route for vehicle '" + myVehicleParameter->id + "' exists.");
507 } else {
508 myErrorOutput->inform("Another route (or distribution) with the id '" + myActiveRouteID + "' exists.");
509 }
510 myActiveRouteID = "";
511 myActiveRouteStops.clear();
512 return;
513 } else {
514 myCurrentAlternatives = new RORouteDef(myActiveRouteID, 0, mayBeDisconnected || myTryRepair, mayBeDisconnected);
517 myCurrentAlternatives = nullptr;
518 }
519 } else {
521 }
522 myActiveRouteID = "";
523 myActiveRouteStops.clear();
524}
525
526
527void
529 // check whether the id is really necessary
530 bool ok = true;
531 std::string id;
532 if (myVehicleParameter != nullptr) {
533 // ok, a vehicle is wrapping the route,
534 // we may use this vehicle's id as default
535 myVehicleParameter->routeid = id = "!" + myVehicleParameter->id; // !!! document this
536 if (attrs.hasAttribute(SUMO_ATTR_ID)) {
537 WRITE_WARNINGF(TL("Ids of internal route distributions are ignored (vehicle '%')."), myVehicleParameter->id);
538 }
539 } else {
540 id = attrs.get<std::string>(SUMO_ATTR_ID, nullptr, ok);
541 if (!ok) {
542 return;
543 }
544 }
545 // try to get the index of the last element
546 int index = attrs.getOpt<int>(SUMO_ATTR_LAST, id.c_str(), ok, 0);
547 if (ok && index < 0) {
548 myErrorOutput->inform("Negative index of a route alternative (id='" + id + "').");
549 return;
550 }
551 // build the alternative cont
552 myCurrentAlternatives = new RORouteDef(id, index, myTryRepair, false);
553 if (attrs.hasAttribute(SUMO_ATTR_ROUTES)) {
554 ok = true;
555 StringTokenizer st(attrs.get<std::string>(SUMO_ATTR_ROUTES, id.c_str(), ok));
556 while (st.hasNext()) {
557 const std::string routeID = st.next();
558 const RORouteDef* route = myNet.getRouteDef(routeID);
559 if (route == nullptr) {
560 myErrorOutput->inform("Unknown route '" + routeID + "' in distribution '" + id + "'.");
561 } else {
563 }
564 }
565 }
566}
567
568
569void
571 if (myCurrentAlternatives != nullptr) {
573 myErrorOutput->inform("Route distribution '" + myCurrentAlternatives->getID() + "' is empty.");
576 myErrorOutput->inform("Another route (or distribution) with the id '" + myCurrentAlternatives->getID() + "' exists.");
578 } else {
579 if (myVehicleParameter != nullptr
580 && (myUseTaz || OptionsCont::getOptions().getBool("junction-taz"))
583 // we are loading a rou.alt.xml, permit rerouting between taz
584 bool ok = true;
585 ConstROEdgeVector edges;
586 if (myVehicleParameter->fromTaz != "") {
587 const std::string tazID = myVehicleParameter->fromTaz;
588 const ROEdge* fromTaz = myNet.getEdge(tazID + "-source");
589 if (fromTaz == nullptr) {
590 myErrorOutput->inform("Source taz '" + tazID + "' not known for vehicle '" + myVehicleParameter->id + "'!");
591 ok = false;
592 } else if (fromTaz->getNumSuccessors() == 0) {
593 myErrorOutput->inform("Source taz '" + tazID + "' has no outgoing edges for vehicle '" + myVehicleParameter->id + "'!");
594 ok = false;
595 } else {
596 edges.push_back(fromTaz);
597 }
598 } else {
599 edges.push_back(myCurrentAlternatives->getOrigin());
600 }
601 if (myVehicleParameter->toTaz != "") {
602 const std::string tazID = myVehicleParameter->toTaz;
603 const ROEdge* toTaz = myNet.getEdge(tazID + "-sink");
604 if (toTaz == nullptr) {
605 myErrorOutput->inform("Sink taz '" + tazID + "' not known for vehicle '" + myVehicleParameter->id + "'!");
606 ok = false;
607 } else if (toTaz->getNumPredecessors() == 0) {
608 myErrorOutput->inform("Sink taz '" + tazID + "' has no incoming edges for vehicle '" + myVehicleParameter->id + "'!");
609 ok = false;
610 } else {
611 edges.push_back(toTaz);
612 }
613 } else {
614 edges.push_back(myCurrentAlternatives->getDestination());
615 }
616 if (ok) {
617 // negative probability indicates that this route should not be written
618 RORoute* route = new RORoute(myCurrentAlternatives->getID(), 0, -1, edges, nullptr, myActiveRouteStops);
620 }
621 }
622 }
623 myCurrentAlternatives = nullptr;
624 }
625}
626
627
628void
631 // get the vehicle id
633 return;
634 }
635 // get vehicle type
637 if (type == nullptr) {
638 myErrorOutput->inform("The vehicle type '" + myVehicleParameter->vtypeid + "' for vehicle '" + myVehicleParameter->id + "' is not known.");
640 } else {
641 if (!myKeepVTypeDist) {
642 // fix the type id in case we used a distribution
644 }
645 }
646 if (type->vehicleClass == SVC_PEDESTRIAN) {
647 WRITE_WARNINGF(TL("Vehicle type '%' with vClass=pedestrian should only be used for persons and not for vehicle '%'."), type->id, myVehicleParameter->id);
648 }
649 // get the route
651 if (route == nullptr) {
652 myErrorOutput->inform("The route of the vehicle '" + myVehicleParameter->id + "' is not known.");
653 return;
654 }
655 if (MsgHandler::getErrorInstance()->wasInformed()) {
656 return;
657 }
658 const bool needCopy = route->getID()[0] != '!';
659 if (needCopy) {
660 route = route->copy("!" + myVehicleParameter->id, myVehicleParameter->depart);
661 }
662 // build the vehicle
663 ROVehicle* veh = new ROVehicle(*myVehicleParameter, route, type, &myNet, myErrorOutput);
666 } else if (needCopy) {
667 delete route;
668 }
669 delete myVehicleParameter;
670 myVehicleParameter = nullptr;
671}
672
673
674void
677 if (myCurrentVTypeDistribution != nullptr) {
679 }
680 }
681 if (OptionsCont::getOptions().isSet("restriction-params")) {
682 const std::vector<std::string> paramKeys = OptionsCont::getOptions().getStringVector("restriction-params");
684 }
685 myCurrentVType = nullptr;
686}
687
688
689void
692 if (type == nullptr) {
693 myErrorOutput->inform("The vehicle type '" + myVehicleParameter->vtypeid + "' for person '" + myVehicleParameter->id + "' is not known.");
695 }
696 if (myActivePlan == nullptr || myActivePlan->empty()) {
697 WRITE_WARNINGF(TL("Discarding person '%' because her plan is empty"), myVehicleParameter->id);
698 } else {
699 ROPerson* person = new ROPerson(*myVehicleParameter, type);
700 for (ROPerson::PlanItem* item : *myActivePlan) {
701 person->getPlan().push_back(item);
702 }
703 if (myNet.addPerson(person)) {
706 }
707 }
708 delete myVehicleParameter;
709 myVehicleParameter = nullptr;
710 delete myActivePlan;
711 myActivePlan = nullptr;
712}
713
714
715void
717 std::string typeID = DEFAULT_PEDTYPE_ID;
719 myErrorOutput->inform("The vehicle type '" + myVehicleParameter->vtypeid + "' for personFlow '" + myVehicleParameter->id + "' is not known.");
720 } else {
721 typeID = myVehicleParameter->vtypeid;
722 }
723 if (myActivePlan == nullptr || myActivePlan->empty()) {
724 WRITE_WARNINGF(TL("Discarding personFlow '%' because their plan is empty"), myVehicleParameter->id);
725 } else {
727 // instantiate all persons of this flow
728 int i = 0;
729 std::string baseID = myVehicleParameter->id;
732 throw ProcessError(TLF("probabilistic personFlow '%' must specify end time", myVehicleParameter->id));
733 } else {
736 addFlowPerson(typeID, t, baseID, i++);
737 }
738 }
739 }
740 } else {
742 // uniform sampling of departures from range is equivalent to poisson flow (encoded by negative offset)
743 if (OptionsCont::getOptions().getBool("randomize-flows") && myVehicleParameter->repetitionOffset >= 0) {
744 std::vector<SUMOTime> departures;
746 for (int j = 0; j < myVehicleParameter->repetitionNumber; ++j) {
747 departures.push_back(depart + RandHelper::rand(range));
748 }
749 std::sort(departures.begin(), departures.end());
750 std::reverse(departures.begin(), departures.end());
751 for (; i < myVehicleParameter->repetitionNumber; i++) {
752 addFlowPerson(typeID, departures[i], baseID, i);
754 }
755 } else {
758 // poisson: randomize first depart
760 }
762 addFlowPerson(typeID, depart + myVehicleParameter->repetitionTotalOffset, baseID, i);
765 }
766 }
767 }
768 }
769 }
770 delete myVehicleParameter;
771 myVehicleParameter = nullptr;
772 for (ROPerson::PlanItem* const it : *myActivePlan) {
773 delete it;
774 }
775 delete myActivePlan;
776 myActivePlan = nullptr;
777}
778
779
780void
781RORouteHandler::addFlowPerson(const std::string& typeID, SUMOTime depart, const std::string& baseID, int i) {
783 pars.id = baseID + "." + toString(i);
784 pars.depart = depart;
785 const SUMOVTypeParameter* const type = myNet.getVehicleTypeSecure(typeID);
786 if (!myKeepVTypeDist) {
787 pars.vtypeid = type->id;
788 }
789 ROPerson* person = new ROPerson(pars, type);
790 for (ROPerson::PlanItem* item : *myActivePlan) {
791 person->getPlan().push_back(item->clone());
792 }
793 if (myNet.addPerson(person)) {
794 if (i == 0) {
796 }
797 }
798}
799
800
801void
808 } else {
809 WRITE_WARNINGF(TL("Discarding container '%' because its plan is empty"), myVehicleParameter->id);
810 }
811 delete myVehicleParameter;
812 myVehicleParameter = nullptr;
814 myActiveContainerPlan = nullptr;
816}
817
818
825 } else {
826 WRITE_WARNINGF(TL("Discarding containerFlow '%' because its plan is empty"), myVehicleParameter->id);
827 }
828 delete myVehicleParameter;
829 myVehicleParameter = nullptr;
831 myActiveContainerPlan = nullptr;
833}
834
835
836void
839 // @todo: consider myScale?
841 delete myVehicleParameter;
842 myVehicleParameter = nullptr;
843 return;
844 }
845 // let's check whether vehicles had to depart before the simulation starts
847 const SUMOTime offsetToBegin = myBegin - myVehicleParameter->depart;
848 while (myVehicleParameter->repetitionTotalOffset < offsetToBegin) {
851 delete myVehicleParameter;
852 myVehicleParameter = nullptr;
853 return;
854 }
855 }
857 myErrorOutput->inform("The vehicle type '" + myVehicleParameter->vtypeid + "' for flow '" + myVehicleParameter->id + "' is not known.");
858 }
859 if (myVehicleParameter->routeid[0] == '!' && myNet.getRouteDef(myVehicleParameter->routeid) == nullptr) {
860 closeRoute(true);
861 }
862 if (myNet.getRouteDef(myVehicleParameter->routeid) == nullptr) {
863 myErrorOutput->inform("The route '" + myVehicleParameter->routeid + "' for flow '" + myVehicleParameter->id + "' is not known.");
864 delete myVehicleParameter;
865 myVehicleParameter = nullptr;
866 return;
867 }
868 myActiveRouteID = "";
869 if (!MsgHandler::getErrorInstance()->wasInformed()) {
872 } else {
873 myErrorOutput->inform("Another flow with the id '" + myVehicleParameter->id + "' exists.");
874 delete myVehicleParameter;
875 }
876 } else {
877 delete myVehicleParameter;
878 }
879 myVehicleParameter = nullptr;
881}
882
883
884void
889
890
892RORouteHandler::retrieveStoppingPlace(const SUMOSAXAttributes& attrs, const std::string& errorSuffix, std::string& id, const SUMOVehicleParameter::Stop* stopParam) {
893 // dummy stop parameter to hold the attributes
895 if (stopParam != nullptr) {
896 stop = *stopParam;
897 } else {
898 bool ok = true;
899 stop.busstop = attrs.getOpt<std::string>(SUMO_ATTR_BUS_STOP, nullptr, ok, "");
900 stop.busstop = attrs.getOpt<std::string>(SUMO_ATTR_TRAIN_STOP, nullptr, ok, stop.busstop); // alias
901 stop.chargingStation = attrs.getOpt<std::string>(SUMO_ATTR_CHARGING_STATION, nullptr, ok, "");
902 stop.overheadWireSegment = attrs.getOpt<std::string>(SUMO_ATTR_OVERHEAD_WIRE_SEGMENT, nullptr, ok, "");
903 stop.containerstop = attrs.getOpt<std::string>(SUMO_ATTR_CONTAINER_STOP, nullptr, ok, "");
904 stop.parkingarea = attrs.getOpt<std::string>(SUMO_ATTR_PARKING_AREA, nullptr, ok, "");
905 }
906 const SUMOVehicleParameter::Stop* toStop = nullptr;
907 if (stop.busstop != "") {
909 id = stop.busstop;
910 if (toStop == nullptr) {
911 WRITE_ERROR("The busStop '" + stop.busstop + "' is not known" + errorSuffix);
912 }
913 } else if (stop.containerstop != "") {
915 id = stop.containerstop;
916 if (toStop == nullptr) {
917 WRITE_ERROR("The containerStop '" + stop.containerstop + "' is not known" + errorSuffix);
918 }
919 } else if (stop.parkingarea != "") {
921 id = stop.parkingarea;
922 if (toStop == nullptr) {
923 WRITE_ERROR("The parkingArea '" + stop.parkingarea + "' is not known" + errorSuffix);
924 }
925 } else if (stop.chargingStation != "") {
926 // ok, we have a charging station
928 id = stop.chargingStation;
929 if (toStop == nullptr) {
930 WRITE_ERROR("The chargingStation '" + stop.chargingStation + "' is not known" + errorSuffix);
931 }
932 } else if (stop.overheadWireSegment != "") {
933 // ok, we have an overhead wire segment
935 id = stop.overheadWireSegment;
936 if (toStop == nullptr) {
937 WRITE_ERROR("The overhead wire segment '" + stop.overheadWireSegment + "' is not known" + errorSuffix);
938 }
939 }
940 return toStop;
941}
942
945 Parameterised* result = nullptr;
946 if (myActiveContainerPlan != nullptr) {
948 (*myActiveContainerPlan) << attrs;
951 return result;
952 }
953 std::string errorSuffix;
954 if (myActivePlan != nullptr) {
955 errorSuffix = " in person '" + myVehicleParameter->id + "'.";
956 } else if (myActiveContainerPlan != nullptr) {
957 errorSuffix = " in container '" + myVehicleParameter->id + "'.";
958 } else if (myVehicleParameter != nullptr) {
959 errorSuffix = " in vehicle '" + myVehicleParameter->id + "'.";
960 } else {
961 errorSuffix = " in route '" + myActiveRouteID + "'.";
962 }
964 bool ok = parseStop(stop, attrs, errorSuffix, myErrorOutput);
965 if (!ok) {
966 return result;
967 }
968 // try to parse the assigned bus stop
969 const ROEdge* edge = nullptr;
970 std::string stoppingPlaceID;
971 const SUMOVehicleParameter::Stop* stoppingPlace = retrieveStoppingPlace(attrs, errorSuffix, stoppingPlaceID, &stop);
972 bool hasPos = false;
973 if (stoppingPlace != nullptr) {
974 stop.lane = stoppingPlace->lane;
975 stop.endPos = stoppingPlace->endPos;
976 stop.startPos = stoppingPlace->startPos;
978 } else {
979 // no, the lane and the position should be given
980 stop.lane = attrs.getOpt<std::string>(SUMO_ATTR_LANE, nullptr, ok, "");
981 stop.edge = attrs.getOpt<std::string>(SUMO_ATTR_EDGE, nullptr, ok, "");
982 if (ok && stop.edge != "") {
983 edge = myNet.getEdge(stop.edge);
984 if (edge == nullptr) {
985 myErrorOutput->inform("The edge '" + stop.edge + "' for a stop is not known" + errorSuffix);
986 return result;
987 }
988 } else if (ok && stop.lane != "") {
990 if (edge == nullptr) {
991 myErrorOutput->inform("The lane '" + stop.lane + "' for a stop is not known" + errorSuffix);
992 return result;
993 }
994 } else if (ok && ((attrs.hasAttribute(SUMO_ATTR_X) && attrs.hasAttribute(SUMO_ATTR_Y))
995 || (attrs.hasAttribute(SUMO_ATTR_LON) && attrs.hasAttribute(SUMO_ATTR_LAT)))) {
996 Position pos;
997 bool geo = false;
998 if (attrs.hasAttribute(SUMO_ATTR_X) && attrs.hasAttribute(SUMO_ATTR_Y)) {
999 pos = Position(attrs.get<double>(SUMO_ATTR_X, myVehicleParameter->id.c_str(), ok), attrs.get<double>(SUMO_ATTR_Y, myVehicleParameter->id.c_str(), ok));
1000 } else {
1001 pos = Position(attrs.get<double>(SUMO_ATTR_LON, myVehicleParameter->id.c_str(), ok), attrs.get<double>(SUMO_ATTR_LAT, myVehicleParameter->id.c_str(), ok));
1002 geo = true;
1003 }
1004 PositionVector positions;
1005 positions.push_back(pos);
1006 ConstROEdgeVector geoEdges;
1010 if (type != nullptr) {
1011 vClass = type->vehicleClass;
1012 }
1013 }
1014 parseGeoEdges(positions, geo, vClass, geoEdges, myVehicleParameter->id, true, ok, true);
1015 if (ok) {
1016 edge = geoEdges.front();
1017 hasPos = true;
1018 if (geo) {
1020 }
1022 stop.endPos = edge->getLanes()[0]->getShape().nearest_offset_to_point2D(pos, false);
1023 } else {
1024 return result;
1025 }
1026 } else if (!ok || (stop.lane == "" && stop.edge == "")) {
1027 myErrorOutput->inform("A stop must be placed on a bus stop, a container stop, a parking area, an edge or a lane" + errorSuffix);
1028 return result;
1029 }
1030 if (!hasPos) {
1031 stop.endPos = attrs.getOpt<double>(SUMO_ATTR_ENDPOS, nullptr, ok, edge->getLength());
1032 }
1033 stop.startPos = attrs.getOpt<double>(SUMO_ATTR_STARTPOS, nullptr, ok, stop.endPos - 2 * POSITION_EPS);
1034 const bool friendlyPos = attrs.getOpt<bool>(SUMO_ATTR_FRIENDLY_POS, nullptr, ok, !attrs.hasAttribute(SUMO_ATTR_STARTPOS) && !attrs.hasAttribute(SUMO_ATTR_ENDPOS));
1035 const double endPosOffset = edge->isInternal() ? edge->getNormalBefore()->getLength() : 0;
1036 if (!ok || (checkStopPos(stop.startPos, stop.endPos, edge->getLength() + endPosOffset, POSITION_EPS, friendlyPos) != SUMORouteHandler::StopPos::STOPPOS_VALID)) {
1037 myErrorOutput->inform("Invalid start or end position for stop" + errorSuffix);
1038 return result;
1039 }
1040 }
1041 stop.edge = edge->getID();
1042 if (myActivePlan != nullptr) {
1043 ROPerson::addStop(*myActivePlan, stop, edge);
1044 result = myActivePlan->back()->getStopParameters();
1045 } else if (myVehicleParameter != nullptr) {
1046 myVehicleParameter->stops.push_back(stop);
1047 result = &myVehicleParameter->stops.back();
1048 } else {
1049 myActiveRouteStops.push_back(stop);
1050 result = &myActiveRouteStops.back();
1051 }
1052 if (myInsertStopEdgesAt >= 0) {
1053 myActiveRoute.insert(myActiveRoute.begin() + myInsertStopEdgesAt, edge);
1055 }
1056 return result;
1057}
1058
1059
1060void
1062 bool ok = true;
1063 std::vector<ROPerson::PlanItem*>& plan = *myActivePlan;
1064 const std::string pid = myVehicleParameter->id;
1065
1066 const ROEdge* from = nullptr;
1067 const ROEdge* to = nullptr;
1068 parseFromViaTo(SUMO_TAG_PERSON, attrs, ok);
1071 if (ok) {
1072 from = myActiveRoute.front();
1073 }
1074 } else if (plan.empty()) {
1075 myErrorOutput->inform("The start edge for person '" + pid + "' is not known.");
1076 return;
1077 }
1078 std::string stoppingPlaceID;
1079 const SUMOVehicleParameter::Stop* stop = retrieveStoppingPlace(attrs, " for ride of person '" + myVehicleParameter->id + "'", stoppingPlaceID);
1080 if (stop != nullptr) {
1082 } else {
1085 to = myActiveRoute.back();
1086 } else {
1087 myErrorOutput->inform("The to edge is missing within a ride of '" + myVehicleParameter->id + "'.");
1088 return;
1089 }
1090 }
1091 double arrivalPos = attrs.getOpt<double>(SUMO_ATTR_ARRIVALPOS, myVehicleParameter->id.c_str(), ok,
1092 stop == nullptr ? std::numeric_limits<double>::infinity() : stop->endPos);
1093 const std::string lines = attrs.getOpt<std::string>(SUMO_ATTR_LINES, pid.c_str(), ok, LINE_ANY);
1094 const std::string group = attrs.getOpt<std::string>(SUMO_ATTR_GROUP, pid.c_str(), ok, "");
1095
1097 StringTokenizer st(lines);
1098 if (st.size() != 1 || st.get(0) == LINE_ANY) {
1099 myErrorOutput->inform("Triggered departure for person '" + pid + "' requires a unique lines value.");
1100 return;
1101 }
1102 const std::string vehID = st.front();
1103 if (!myNet.knowsVehicle(vehID)) {
1104 myErrorOutput->inform("Unknown vehicle '" + vehID + "' in triggered departure for person '" + pid + "'.");
1105 return;
1106 }
1107 SUMOTime vehDepart = myNet.getDeparture(vehID);
1108 if (vehDepart == -1) {
1109 myErrorOutput->inform("Cannot use triggered vehicle '" + vehID + "' in triggered departure for person '" + pid + "'.");
1110 return;
1111 }
1112 myVehicleParameter->depart = vehDepart + 1; // write person after vehicle
1113 }
1114 ROPerson::addRide(plan, from, to, lines, arrivalPos, stoppingPlaceID, group);
1115}
1116
1117
1118void
1121 bool ok = true;
1122 const std::string pid = myVehicleParameter->id;
1123 const std::string desc = attrs.get<std::string>(SUMO_ATTR_LINES, pid.c_str(), ok);
1124 StringTokenizer st(desc);
1125 if (st.size() != 1) {
1126 throw ProcessError(TLF("Triggered departure for container '%' requires a unique lines value.", pid));
1127 }
1128 const std::string vehID = st.front();
1129 if (!myNet.knowsVehicle(vehID)) {
1130 throw ProcessError("Unknown vehicle '" + vehID + "' in triggered departure for container '" + pid + "'.");
1131 }
1132 SUMOTime vehDepart = myNet.getDeparture(vehID);
1133 if (vehDepart == -1) {
1134 throw ProcessError("Cannot use triggered vehicle '" + vehID + "' in triggered departure for container '" + pid + "'.");
1135 }
1136 myVehicleParameter->depart = vehDepart + 1; // write container after vehicle
1137 }
1138}
1139
1140
1141void
1144
1145
1146void
1147RORouteHandler::parseEdges(const std::string& desc, ConstROEdgeVector& into,
1148 const std::string& rid, bool& ok) {
1149 for (StringTokenizer st(desc); st.hasNext();) {
1150 const std::string id = st.next();
1151 const ROEdge* edge = myNet.getEdge(id);
1152 if (edge == nullptr) {
1153 myErrorOutput->inform("The edge '" + id + "' within the route " + rid + " is not known.");
1154 ok = false;
1155 } else {
1156 into.push_back(edge);
1157 }
1158 }
1159}
1160
1161
1162void
1163RORouteHandler::parseWalkPositions(const SUMOSAXAttributes& attrs, const std::string& personID,
1164 const ROEdge* /*fromEdge*/, const ROEdge*& toEdge,
1165 double& departPos, double& arrivalPos, std::string& busStopID,
1166 const ROPerson::PlanItem* const lastStage, bool& ok) {
1167 const std::string description = "walk or personTrip of '" + personID + "'.";
1168 if (attrs.hasAttribute(SUMO_ATTR_DEPARTPOS)) {
1169 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."));
1170 }
1171 departPos = myVehicleParameter->departPos;
1172 if (lastStage != nullptr) {
1173 departPos = lastStage->getDestinationPos();
1174 }
1175
1176 busStopID = attrs.getOpt<std::string>(SUMO_ATTR_BUS_STOP, nullptr, ok, "");
1177
1178 const SUMOVehicleParameter::Stop* bs = retrieveStoppingPlace(attrs, description, busStopID);
1179 if (bs != nullptr) {
1181 arrivalPos = (bs->startPos + bs->endPos) / 2;
1182 }
1183 if (toEdge != nullptr) {
1186 myHardFail, description, toEdge->getLength(),
1187 attrs.get<std::string>(SUMO_ATTR_ARRIVALPOS, description.c_str(), ok));
1188 }
1189 } else {
1190 throw ProcessError(TLF("No destination edge for %.", description));
1191 }
1192}
1193
1194
1195void
1197 bool ok = true;
1198 const char* const id = myVehicleParameter->id.c_str();
1199 assert(!attrs.hasAttribute(SUMO_ATTR_EDGES));
1200 const ROEdge* from = nullptr;
1201 const ROEdge* to = nullptr;
1202 parseFromViaTo(SUMO_TAG_PERSON, attrs, ok);
1206 if (ok) {
1207 from = myActiveRoute.front();
1208 }
1209 } else if (myActivePlan->empty()) {
1210 throw ProcessError(TLF("Start edge not defined for person '%'.", myVehicleParameter->id));
1211 } else {
1212 from = myActivePlan->back()->getDestination();
1213 }
1216 to = myActiveRoute.back();
1217 } // else, to may also be derived from stopping place
1218
1219 const SUMOTime duration = attrs.getOptSUMOTimeReporting(SUMO_ATTR_DURATION, id, ok, -1);
1220 if (attrs.hasAttribute(SUMO_ATTR_DURATION) && duration <= 0) {
1221 throw ProcessError(TLF("Non-positive walking duration for '%'.", myVehicleParameter->id));
1222 }
1223
1224 double departPos = 0;
1225 double arrivalPos = std::numeric_limits<double>::infinity();
1226 std::string busStopID;
1227 const ROPerson::PlanItem* const lastStage = myActivePlan->empty() ? nullptr : myActivePlan->back();
1228 parseWalkPositions(attrs, myVehicleParameter->id, from, to, departPos, arrivalPos, busStopID, lastStage, ok);
1229
1230 const std::string modes = attrs.getOpt<std::string>(SUMO_ATTR_MODES, id, ok, "");
1231 const std::string group = attrs.getOpt<std::string>(SUMO_ATTR_GROUP, id, ok, "");
1232 SVCPermissions modeSet = 0;
1233 for (StringTokenizer st(modes); st.hasNext();) {
1234 const std::string mode = st.next();
1235 if (mode == "car") {
1236 modeSet |= SVC_PASSENGER;
1237 } else if (mode == "taxi") {
1238 modeSet |= SVC_TAXI;
1239 } else if (mode == "bicycle") {
1240 modeSet |= SVC_BICYCLE;
1241 } else if (mode == "public") {
1242 modeSet |= SVC_BUS;
1243 } else {
1244 throw InvalidArgument("Unknown person mode '" + mode + "'.");
1245 }
1246 }
1247 const std::string types = attrs.getOpt<std::string>(SUMO_ATTR_VTYPES, id, ok, "");
1248 double walkFactor = attrs.getOpt<double>(SUMO_ATTR_WALKFACTOR, id, ok, OptionsCont::getOptions().getFloat("persontrip.walkfactor"));
1249 if (ok) {
1250 const std::string originStopID = myActivePlan->empty() ? "" : myActivePlan->back()->getStopDest();
1251 ROPerson::addTrip(*myActivePlan, myVehicleParameter->id, from, to, modeSet, types,
1252 departPos, originStopID, arrivalPos, busStopID, walkFactor, group);
1253 myParamStack.push_back(myActivePlan->back());
1254 }
1255}
1256
1257
1258void
1260 // parse walks from->to as person trips
1262 // XXX allow --repair?
1263 bool ok = true;
1264 if (attrs.hasAttribute(SUMO_ATTR_ROUTE)) {
1265 const std::string routeID = attrs.get<std::string>(SUMO_ATTR_ROUTE, myVehicleParameter->id.c_str(), ok);
1266 RORouteDef* routeDef = myNet.getRouteDef(routeID);
1267 const RORoute* route = routeDef != nullptr ? routeDef->getFirstRoute() : nullptr;
1268 if (route == nullptr) {
1269 throw ProcessError("The route '" + routeID + "' for walk of person '" + myVehicleParameter->id + "' is not known.");
1270 }
1271 myActiveRoute = route->getEdgeVector();
1272 } else {
1273 myActiveRoute.clear();
1274 parseEdges(attrs.get<std::string>(SUMO_ATTR_EDGES, myVehicleParameter->id.c_str(), ok), myActiveRoute, " walk for person '" + myVehicleParameter->id + "'", ok);
1275 }
1276 const char* const objId = myVehicleParameter->id.c_str();
1277 const double duration = attrs.getOpt<double>(SUMO_ATTR_DURATION, objId, ok, -1);
1278 if (attrs.hasAttribute(SUMO_ATTR_DURATION) && duration <= 0) {
1279 throw ProcessError(TLF("Non-positive walking duration for '%'.", myVehicleParameter->id));
1280 }
1281 const double speed = attrs.getOpt<double>(SUMO_ATTR_SPEED, objId, ok, -1.);
1282 if (attrs.hasAttribute(SUMO_ATTR_SPEED) && speed <= 0) {
1283 throw ProcessError(TLF("Non-positive walking speed for '%'.", myVehicleParameter->id));
1284 }
1285 double departPos = 0.;
1286 double arrivalPos = std::numeric_limits<double>::infinity();
1287 if (attrs.hasAttribute(SUMO_ATTR_DEPARTPOS)) {
1288 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."));
1289 }
1291 arrivalPos = SUMOVehicleParserHelper::parseWalkPos(SUMO_ATTR_ARRIVALPOS, myHardFail, objId, myActiveRoute.back()->getLength(), attrs.get<std::string>(SUMO_ATTR_ARRIVALPOS, objId, ok));
1292 }
1293 std::string stoppingPlaceID;
1294 const std::string errorSuffix = " for walk of person '" + myVehicleParameter->id + "'";
1295 retrieveStoppingPlace(attrs, errorSuffix, stoppingPlaceID);
1296 if (ok) {
1297 ROPerson::addWalk(*myActivePlan, myActiveRoute, duration, speed, departPos, arrivalPos, stoppingPlaceID);
1298 myParamStack.push_back(myActivePlan->back());
1299 }
1300 } else {
1301 addPersonTrip(attrs);
1302 }
1303}
1304
1305
1306void
1308 for (const auto& edgeItem : myNet.getEdgeMap()) {
1309 for (ROLane* lane : edgeItem.second->getLanes()) {
1310 Boundary b = lane->getShape().getBoxBoundary();
1311 const float cmin[2] = {(float) b.xmin(), (float) b.ymin()};
1312 const float cmax[2] = {(float) b.xmax(), (float) b.ymax()};
1313 tree->Insert(cmin, cmax, lane);
1314 }
1315 }
1316}
1317
1318
1319ROEdge*
1320RORouteHandler::retrieveEdge(const std::string& id) {
1321 return myNet.getEdge(id);
1322}
1323
1324bool
1326 if (!myUnsortedInput) {
1328 }
1329 return true;
1330}
1331
1332/****************************************************************************/
long long int SUMOTime
Definition GUI.h:36
#define JUNCTION_TAZ_MISSING_HELP
Definition MapMatcher.h:30
#define WRITE_WARNINGF(...)
Definition MsgHandler.h:288
#define WRITE_ERROR(msg)
Definition MsgHandler.h:296
#define WRITE_WARNING(msg)
Definition MsgHandler.h:287
#define TL(string)
Definition MsgHandler.h:305
#define TLF(string,...)
Definition MsgHandler.h:307
std::vector< const ROEdge * > ConstROEdgeVector
Definition ROEdge.h:56
SUMOTime string2time(const std::string &r)
convert string to SUMOTime
Definition SUMOTime.cpp:46
#define SUMOTime_MAX
Definition SUMOTime.h:34
#define TIME2STEPS(x)
Definition SUMOTime.h:57
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_CHARGING_STATION
A Charging Station.
@ SUMO_TAG_TRANSHIP
@ SUMO_TAG_CONTAINER_STOP
A container stop.
@ SUMO_TAG_CONTAINERFLOW
@ SUMO_TAG_BUS_STOP
A bus stop.
@ SUMO_TAG_STOP
stop for vehicles
@ SUMO_TAG_FLOW
a flow definition using from and to edges or a route
@ SUMO_TAG_PARKING_AREA
A parking area.
@ SUMO_TAG_TRANSPORT
@ SUMO_TAG_CONTAINER
@ SUMO_TAG_RIDE
@ SUMO_TAG_OVERHEAD_WIRE_SEGMENT
An overhead wire segment.
@ 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_CONTAINER_STOP
@ SUMO_ATTR_PARKING_AREA
@ SUMO_ATTR_VIAXY
@ SUMO_ATTR_Y
@ SUMO_ATTR_EDGE
@ SUMO_ATTR_BUS_STOP
@ SUMO_ATTR_TRAIN_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_CHARGING_STATION
@ SUMO_ATTR_ROUTES
@ SUMO_ATTR_MODES
@ SUMO_ATTR_VTYPES
@ SUMO_ATTR_OVERHEAD_WIRE_SEGMENT
@ 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:46
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:74
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:89
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:72
const ROEdge * getNormalBefore() const
if this edge is an internal edge, return its first normal predecessor, otherwise the edge itself
Definition ROEdge.cpp:292
bool isInternal() const
return whether this edge is an internal edge
Definition ROEdge.h:159
int getNumSuccessors() const
Returns the number of edges this edge is connected to.
Definition ROEdge.cpp:274
const ROEdgeVector & getSuccessors(SUMOVehicleClass vClass=SVC_IGNORING) const
Returns the following edges, restricted by vClass.
Definition ROEdge.cpp:389
int getNumPredecessors() const
Returns the number of edges connected to this edge.
Definition ROEdge.cpp:283
const std::vector< ROLane * > & getLanes() const
Returns this edge's lanes.
Definition ROEdge.h:534
double getLength() const
Returns the length of the edge.
Definition ROEdge.h:224
A single lane the router may use.
Definition ROLane.h:48
The router's network representation.
Definition RONet.h:63
SUMOVTypeParameter * getVehicleTypeSecure(const std::string &id)
Retrieves the named vehicle type.
Definition RONet.cpp:364
const RandomDistributor< SUMOVTypeParameter * > * getVTypeDistribution(const std::string &id)
Retrieves the named vehicle type distribution.
Definition RONet.h:284
bool addRouteDef(RORouteDef *def)
Definition RONet.cpp:286
bool knowsVehicle(const std::string &id) const
returns whether a vehicle with the given id was already loaded
Definition RONet.cpp:488
virtual bool addVehicle(const std::string &id, ROVehicle *veh)
Definition RONet.cpp:466
SUMOTime getDeparture(const std::string &vehID) const
returns departure time for the given vehicle id
Definition RONet.cpp:493
const SUMOVehicleParameter::Stop * getStoppingPlace(const std::string &id, const SumoXMLTag category) const
Retrieves a stopping place from the network.
Definition RONet.h:220
void addContainer(const SUMOTime depart, const std::string desc)
Definition RONet.cpp:534
ROEdge * getEdge(const std::string &name) const
Retrieves an edge from the network.
Definition RONet.h:161
bool addPerson(ROPerson *person)
Definition RONet.cpp:522
RORouteDef * getRouteDef(const std::string &name) const
Returns the named route definition.
Definition RONet.h:322
virtual bool addVehicleType(SUMOVTypeParameter *type)
Adds a read vehicle type definition to the network.
Definition RONet.cpp:442
bool addVTypeDistribution(const std::string &id, RandomDistributor< SUMOVTypeParameter * > *vehTypeDistribution)
Adds a vehicle type distribution.
Definition RONet.cpp:455
const NamedObjectCont< ROEdge * > & getEdgeMap() const
Definition RONet.h:426
bool addFlow(SUMOVehicleParameter *flow, const bool randomize)
Definition RONet.cpp:504
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:61
static void addStop(std::vector< PlanItem * > &plan, const SUMOVehicleParameter::Stop &stopPar, const ROEdge *const stopEdge)
Definition ROPerson.cpp:133
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:116
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:124
std::vector< PlanItem * > & getPlan()
Definition ROPerson.h:440
Base class for a vehicle's route definition.
Definition RORouteDef.h:53
const ROEdge * getOrigin() const
void addLoadedAlternative(RORoute *alternative)
Adds a single alternative loaded from the file An alternative may also be generated during DUA.
double getOverallProb() const
Returns the sum of the probablities of the contained routes.
void addAlternativeDef(const RORouteDef *alternative)
Adds an alternative loaded from the file.
const ROEdge * getDestination() const
RORouteDef * copy(const std::string &id, const SUMOTime stopOffset) const
Returns a deep copy of the route definition.
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 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 complete router's route.
Definition RORoute.h:52
const ConstROEdgeVector & getEdgeVector() const
Returns the list of edges this route consists of.
Definition RORoute.h:152
A vehicle as used by router.
Definition ROVehicle.h:50
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::vector< SUMOVehicleParameter::Stop > myActiveRouteStops
List of the stops on the parsed route.
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
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.
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.
std::string parkingarea
(Optional) parking area if one is assigned to the stop
double startPos
The stopping position start.
std::string chargingStation
(Optional) charging station if one is assigned to the stop
std::string overheadWireSegment
(Optional) overhead line segment if one is assigned to the stop
int parametersSet
Information for the output which parameter were set.
double endPos
The stopping position end.
std::string busstop
(Optional) bus stop if one is assigned to the stop
std::string containerstop
(Optional) container stop if one is assigned to the stop
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.
std::vector< std::string > via
List of the via-edges the vehicle must visit.
int repetitionsDone
The number of times the vehicle was already inserted.
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 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