Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
SUMORouteHandler.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 for routes during their loading
22/****************************************************************************/
23#include <config.h>
24
31#include <utils/xml/XMLSubSys.h>
32
33#include "SUMORouteHandler.h"
34
35// ===========================================================================
36// static members
37// ===========================================================================
39
40// ===========================================================================
41// method definitions
42// ===========================================================================
43
44SUMORouteHandler::SUMORouteHandler(const std::string& file, const std::string& expectedRoot, const bool hardFail) :
45 SUMOSAXHandler(file, expectedRoot),
46 myHardFail(hardFail),
47 myVehicleParameter(nullptr),
48 myLastDepart(-1),
49 myActiveRouteColor(nullptr),
50 myCurrentCosts(0.),
51 myCurrentVType(nullptr),
52 myCurrentVTypeProbability(-1),
53 myBeginDefault(OptionsCont::getOptions().exists("begin") ? string2time(OptionsCont::getOptions().getString("begin")) : 0),
54 myEndDefault(OptionsCont::getOptions().exists("end") ? string2time(OptionsCont::getOptions().getString("end")) : -1),
55 myFirstDepart(-1),
56 myInsertStopEdgesAt(-1),
57 myAllowInternalRoutes(false) {
58}
59
60
65
66
67bool
71 WRITE_WARNINGF(TL("Route file should be sorted by departure time, ignoring '%'!"), myVehicleParameter->id);
72 return false;
73 }
74 }
75 return true;
76}
77
78
79void
81 // register only non public transport to parse all public transport lines in advance
84 if (myFirstDepart == -1) {
86 }
87 }
88 // else: we don't know when this vehicle will depart. keep the previous known depart time
89}
90
91
92void
94 myElementStack.push_back(element);
95 switch (element) {
97 case SUMO_TAG_PERSON:
99 // if myVehicleParameter is nullptr this will do nothing
100 delete myVehicleParameter;
101 // we set to nullptr to have a consistent state if the parsing fails
102 myVehicleParameter = nullptr;
105 if (element != SUMO_TAG_VEHICLE) {
106 addTransportable(attrs, element == SUMO_TAG_PERSON);
107 }
108 break;
109 case SUMO_TAG_FLOW:
110 // delete if myVehicleParameter isn't null
111 if (myVehicleParameter) {
112 delete myVehicleParameter;
113 myVehicleParameter = nullptr;
114 }
115 // parse vehicle parameters
116 // might be called to parse vehicles from additional file in the
117 // context of quickReload. In this case, rerouter flows must be ignored
118 if (myElementStack.size() == 1 || myElementStack[myElementStack.size() - 2] != SUMO_TAG_CALIBRATOR) {
120 }
121 // check if myVehicleParameter was successfully created
122 if (myVehicleParameter) {
123 // check tag
124 if (myVehicleParameter->routeid.empty()) {
125 // open a route flow (It could be a flow with embedded route)
126 openFlow(attrs);
127 } else {
128 // open a route flow
129 openRouteFlow(attrs);
130 }
132 }
133 break;
136 // delete if myVehicleParameter isn't null
137 if (myVehicleParameter) {
138 delete myVehicleParameter;
139 myVehicleParameter = nullptr;
140 }
141 // create a new flow
144 break;
145 case SUMO_TAG_VTYPE:
146 // delete if myCurrentVType isn't null
147 if (myCurrentVType != nullptr) {
148 delete myCurrentVType;
149 myCurrentVType = nullptr;
150 }
151 // create a new vType
153 bool ok = true;
154 myCurrentVTypeRef = attrs.get<std::string>(SUMO_ATTR_REFID, nullptr, ok);
155 myCurrentVTypeProbability = attrs.getOpt<double>(SUMO_ATTR_PROB, myCurrentVTypeRef.c_str(), ok, -1);
156 } else {
158 }
159 myParamStack.push_back(myCurrentVType);
160 break;
163 break;
164 case SUMO_TAG_ROUTE:
165 openRoute(attrs);
166 break;
169 break;
170 case SUMO_TAG_STOP:
171 myParamStack.push_back(addStop(attrs));
172 break;
173 case SUMO_TAG_TRIP: {
174 // delete if myVehicleParameter isn't null
175 if (myVehicleParameter) {
176 delete myVehicleParameter;
177 myVehicleParameter = nullptr;
178 }
179 // parse vehicle parameters
181 // check if myVehicleParameter was successfully created
182 if (myVehicleParameter) {
185 // open trip
186 openTrip(attrs);
188 }
189 break;
190 }
192 addPersonTrip(attrs);
193 break;
194 case SUMO_TAG_WALK:
195 addWalk(attrs);
196 break;
197 case SUMO_TAG_INTERVAL: {
198 bool ok;
200 myEndDefault = attrs.getSUMOTimeReporting(SUMO_ATTR_END, nullptr, ok);
201 break;
202 }
203 case SUMO_TAG_RIDE:
204 addRide(attrs);
205 break;
207 addTransport(attrs);
208 break;
210 addTranship(attrs);
211 break;
212 case SUMO_TAG_PARAM:
213 addParam(attrs);
214 break;
215 default:
216 // parse embedded car following model information
217 if (myCurrentVType != nullptr) {
218 WRITE_WARNINGF(TL("Defining car-following parameters in a nested element is deprecated in vType '%', use attributes instead!"), myCurrentVType->id);
220 if (myHardFail) {
221 throw ProcessError(TL("Invalid parsing embedded VType"));
222 } else {
223 WRITE_ERROR(TL("Invalid parsing embedded VType"));
224 }
225 }
226 }
227 break;
228 }
229}
230
231
232void
234 switch (element) {
235 case SUMO_TAG_STOP:
236 myParamStack.pop_back();
237 break;
238 case SUMO_TAG_ROUTE:
239 closeRoute();
240 break;
241 case SUMO_TAG_VTYPE:
242 closeVType();
243 if (myCurrentVTypeRef.empty()) {
244 delete myCurrentVType;
245 }
246 myCurrentVType = nullptr;
249 myParamStack.pop_back();
250 break;
251 case SUMO_TAG_PERSON:
252 closePerson();
253 delete myVehicleParameter;
254 myVehicleParameter = nullptr;
255 myParamStack.pop_back();
256 break;
259 delete myVehicleParameter;
260 myVehicleParameter = nullptr;
261 myParamStack.pop_back();
262 break;
265 delete myVehicleParameter;
266 myVehicleParameter = nullptr;
267 myParamStack.pop_back();
268 break;
271 delete myVehicleParameter;
272 myVehicleParameter = nullptr;
273 myParamStack.pop_back();
274 break;
275 case SUMO_TAG_VEHICLE:
276 if (myVehicleParameter == nullptr) {
277 break;
278 }
280 closeVehicle();
281 delete myVehicleParameter;
282 myVehicleParameter = nullptr;
283 myParamStack.pop_back();
284 break;
285 }
286 myVehicleParameter->repetitionNumber++; // for backwards compatibility
287 // it is a flow, thus no break here
289 case SUMO_TAG_FLOW:
290 if (myVehicleParameter) {
291 closeFlow();
292 delete myVehicleParameter;
293 myParamStack.pop_back();
294 }
295 myVehicleParameter = nullptr;
297 break;
298 case SUMO_TAG_TRIP:
299 closeTrip();
300 delete myVehicleParameter;
301 myVehicleParameter = nullptr;
302 myParamStack.pop_back();
304 break;
307 break;
310 break;
312 case SUMO_TAG_RIDE:
315 case SUMO_TAG_WALK:
316 if (myParamStack.size() == 2) {
317 myParamStack.pop_back();
318 }
319 break;
321 myBeginDefault = string2time(OptionsCont::getOptions().getString("begin"));
323 break;
324 default:
325 break;
326 }
327 myElementStack.pop_back();
328}
329
330
332SUMORouteHandler::checkStopPos(double& startPos, double& endPos, const double laneLength, const double minLength, const bool friendlyPos) {
333 if (minLength > laneLength) {
335 }
336 if (startPos < 0) {
337 startPos += laneLength;
338 }
339 if (endPos < 0) {
340 endPos += laneLength;
341 }
342 if ((endPos < minLength) || (endPos > laneLength)) {
343 if (!friendlyPos) {
345 }
346 if (endPos < minLength) {
347 endPos = minLength;
348 }
349 if (endPos > laneLength) {
350 endPos = laneLength;
351 }
352 }
353 if ((startPos < 0) || (startPos > (endPos - minLength))) {
354 if (!friendlyPos) {
356 }
357 if (startPos < 0) {
358 startPos = 0;
359 }
360 if (startPos > (endPos - minLength)) {
361 startPos = endPos - minLength;
362 }
363 }
364 return STOPPOS_VALID;
365}
366
367
372
373
378
379
380void
382 bool ok = true;
383 const std::string key = attrs.get<std::string>(SUMO_ATTR_KEY, nullptr, ok);
384 // only continue if key isn't empty
385 if (ok && (key.size() > 0)) {
386 // circumventing empty string test
387 std::string val = attrs.hasAttribute(SUMO_ATTR_VALUE) ? attrs.getString(SUMO_ATTR_VALUE) : "";
388 // check special params that must be interpreted as relative paths
389 if ((myVehicleParameter != nullptr || myCurrentVType != nullptr)
390 && (key == "device.toc.file" || key == "device.ssm.file")) {
392 }
393 // add parameter in current created element
394 if (!myParamStack.empty()) {
395 if (!myCurrentVTypeRef.empty() && myParamStack.back() == myCurrentVType) {
396 WRITE_WARNINGF(TL("Ignoring param for referenced vType %"), myCurrentVType->id);
397 } else {
398 myParamStack.back()->setParameter(key, val);
399 }
400 }
401 }
402}
403
404
405bool
406SUMORouteHandler::parseStop(SUMOVehicleParameter::Stop& stop, const SUMOSAXAttributes& attrs, std::string errorSuffix, MsgHandler* const errorOutput) {
407 stop.parametersSet = 0;
408 if (attrs.hasAttribute(SUMO_ATTR_ARRIVAL)) {
410 }
411 if (attrs.hasAttribute(SUMO_ATTR_DURATION)) {
413 }
414 if (attrs.hasAttribute(SUMO_ATTR_UNTIL)) {
416 }
417 if (attrs.hasAttribute(SUMO_ATTR_STARTED)) {
419 }
420 if (attrs.hasAttribute(SUMO_ATTR_ENDED)) {
422 }
425 }
426 if (attrs.hasAttribute(SUMO_ATTR_ENDPOS)) {
428 }
429 if (attrs.hasAttribute(SUMO_ATTR_STARTPOS)) {
431 }
434 }
437 }
438 // legacy attribute
441 }
442 if (attrs.hasAttribute(SUMO_ATTR_PARKING)) {
444 }
445 if (attrs.hasAttribute(SUMO_ATTR_EXPECTED)) {
447 }
450 }
453 }
454 if (attrs.hasAttribute(SUMO_ATTR_TRIP_ID)) {
456 }
457 if (attrs.hasAttribute(SUMO_ATTR_SPLIT)) {
459 }
460 if (attrs.hasAttribute(SUMO_ATTR_JOIN)) {
462 }
463 if (attrs.hasAttribute(SUMO_ATTR_LINE)) {
465 }
466 if (attrs.hasAttribute(SUMO_ATTR_SPEED)) {
468 }
469 if (attrs.hasAttribute(SUMO_ATTR_ONDEMAND)) {
471 }
472 if (attrs.hasAttribute(SUMO_ATTR_PRIORITY)) {
474 }
475 if (attrs.hasAttribute(SUMO_ATTR_JUMP)) {
477 }
480 }
481 bool ok = true;
482 stop.busstop = attrs.getOpt<std::string>(SUMO_ATTR_BUS_STOP, nullptr, ok, "");
483 stop.busstop = attrs.getOpt<std::string>(SUMO_ATTR_TRAIN_STOP, nullptr, ok, stop.busstop);
484 stop.chargingStation = attrs.getOpt<std::string>(SUMO_ATTR_CHARGING_STATION, nullptr, ok, "");
485 stop.overheadWireSegment = attrs.getOpt<std::string>(SUMO_ATTR_OVERHEAD_WIRE_SEGMENT, nullptr, ok, "");
486 stop.containerstop = attrs.getOpt<std::string>(SUMO_ATTR_CONTAINER_STOP, nullptr, ok, "");
487 stop.parkingarea = attrs.getOpt<std::string>(SUMO_ATTR_PARKING_AREA, nullptr, ok, "");
488 if (stop.busstop != "") {
489 errorSuffix = " at '" + stop.busstop + "'" + errorSuffix;
490 } else if (stop.chargingStation != "") {
491 errorSuffix = " at '" + stop.chargingStation + "'" + errorSuffix;
492 } else if (stop.overheadWireSegment != "") {
493 errorSuffix = " at '" + stop.overheadWireSegment + "'" + errorSuffix;
494 } else if (stop.containerstop != "") {
495 errorSuffix = " at '" + stop.containerstop + "'" + errorSuffix;
496 } else if (stop.parkingarea != "") {
497 errorSuffix = " at '" + stop.parkingarea + "'" + errorSuffix;
498 } else if (attrs.hasAttribute(SUMO_ATTR_LANE)) {
499 errorSuffix = " on lane '" + attrs.get<std::string>(SUMO_ATTR_LANE, nullptr, ok) + "'" + errorSuffix;
500 } else if (attrs.hasAttribute(SUMO_ATTR_EDGE)) {
501 errorSuffix = " on edge '" + attrs.get<std::string>(SUMO_ATTR_EDGE, nullptr, ok) + "'" + errorSuffix;
502 } else {
503 errorSuffix = " at undefined location" + errorSuffix;
504 }
505 // speed for counting as stopped
506 stop.speed = attrs.getOpt<double>(SUMO_ATTR_SPEED, nullptr, ok, 0);
507 if (stop.speed < 0) {
508 errorOutput->inform(TLF("Speed cannot be negative for stop%.", errorSuffix));
509 return false;
510 }
511
512 // get the standing duration
513 bool expectTrigger = !attrs.hasAttribute(SUMO_ATTR_DURATION) && !attrs.hasAttribute(SUMO_ATTR_UNTIL) && !attrs.hasAttribute(SUMO_ATTR_SPEED);
514 std::vector<std::string> triggers = attrs.getOpt<std::vector<std::string> >(SUMO_ATTR_TRIGGERED, nullptr, ok);
515 // legacy
516 if (attrs.getOpt<bool>(SUMO_ATTR_CONTAINER_TRIGGERED, nullptr, ok, false)) {
517 triggers.push_back(toString(SUMO_TAG_CONTAINER));
518 }
519 SUMOVehicleParameter::parseStopTriggers(triggers, expectTrigger, stop);
520 stop.arrival = attrs.getOptSUMOTimeReporting(SUMO_ATTR_ARRIVAL, nullptr, ok, -1);
521 if (attrs.hasAttribute(SUMO_ATTR_DURATION)) {
522 const std::string durationStr = attrs.get<std::string>(SUMO_ATTR_DURATION, nullptr, ok);
523 std::string error;
525 errorOutput->inform(TLF("Invalid duration for a stop% (%).", errorSuffix, error));
526 return false;
527 }
528 stop.durationDist = Distribution_Parameterized(durationStr);
530 }
531 stop.until = attrs.getOptSUMOTimeReporting(SUMO_ATTR_UNTIL, nullptr, ok, -1);
532 if (!expectTrigger && (!ok || (stop.duration < 0 && stop.until < 0 && stop.speed == 0))) {
533 errorOutput->inform(TLF("Invalid duration or end time is given for a stop%.", errorSuffix));
534 return false;
535 }
536 if (triggers.size() > 0 && stop.speed > 0) {
537 errorOutput->inform(TLF("Triggers and waypoints cannot be combined%.", errorSuffix));
538 return false;
539 }
540 stop.extension = attrs.getOptSUMOTimeReporting(SUMO_ATTR_EXTENSION, nullptr, ok, -1);
541 const bool defaultParking = (stop.triggered || stop.containerTriggered || stop.parkingarea != "");
542 stop.parking = attrs.getOpt<ParkingType>(SUMO_ATTR_PARKING, nullptr, ok, defaultParking ? ParkingType::OFFROAD : ParkingType::ONROAD);
543 if ((stop.parkingarea != "") && (stop.parking == ParkingType::ONROAD)) {
544 WRITE_WARNINGF(TL("Stop at parkingArea overrides attribute 'parking' for stop%."), errorSuffix);
546 }
547
548 // expected persons
549 const std::vector<std::string>& expected = attrs.getOpt<std::vector<std::string> >(SUMO_ATTR_EXPECTED, nullptr, ok);
550 stop.awaitedPersons.insert(expected.begin(), expected.end());
551 if (stop.awaitedPersons.size() > 0) {
552 stop.triggered = true;
553 if ((stop.parametersSet & STOP_PARKING_SET) == 0) {
555 }
556 }
557
558 // permitted transportables
559 const std::vector<std::string>& permitted = attrs.getOpt<std::vector<std::string> >(SUMO_ATTR_PERMITTED, nullptr, ok);
560 stop.permitted.insert(permitted.begin(), permitted.end());
561
562 // expected containers
563 const std::vector<std::string>& expectedContainers = attrs.getOpt<std::vector<std::string> >(SUMO_ATTR_EXPECTED_CONTAINERS, nullptr, ok);
564 stop.awaitedContainers.insert(expectedContainers.begin(), expectedContainers.end());
565 if (stop.awaitedContainers.size() > 0) {
566 stop.containerTriggered = true;
567 if ((stop.parametersSet & STOP_PARKING_SET) == 0) {
569 }
570 }
571 // public transport trip id
572 stop.tripId = attrs.getOpt<std::string>(SUMO_ATTR_TRIP_ID, nullptr, ok, "");
573 stop.split = attrs.getOpt<std::string>(SUMO_ATTR_SPLIT, nullptr, ok, "");
574 stop.join = attrs.getOpt<std::string>(SUMO_ATTR_JOIN, nullptr, ok, "");
575 stop.line = attrs.getOpt<std::string>(SUMO_ATTR_LINE, nullptr, ok, "");
576
577 const std::string idx = attrs.getOpt<std::string>(SUMO_ATTR_INDEX, nullptr, ok, "end");
578 if (idx == "end") {
579 stop.index = STOP_INDEX_END;
580 } else if (idx == "fit") {
581 stop.index = STOP_INDEX_FIT;
582 } else {
583 stop.index = attrs.get<int>(SUMO_ATTR_INDEX, nullptr, ok);
584 if (!ok || stop.index < 0) {
585 errorOutput->inform(TLF("Invalid 'index' for stop%.", errorSuffix));
586 return false;
587 }
588 }
589 stop.started = attrs.getOptSUMOTimeReporting(SUMO_ATTR_STARTED, nullptr, ok, -1);
590 stop.ended = attrs.getOptSUMOTimeReporting(SUMO_ATTR_ENDED, nullptr, ok, -1);
591 stop.posLat = attrs.getOpt<double>(SUMO_ATTR_POSITION_LAT, nullptr, ok, INVALID_DOUBLE);
592 stop.actType = attrs.getOpt<std::string>(SUMO_ATTR_ACTTYPE, nullptr, ok, "");
593 stop.onDemand = attrs.getOpt<bool>(SUMO_ATTR_ONDEMAND, nullptr, ok, false);
594 stop.priority = attrs.getOpt<double>(SUMO_ATTR_PRIORITY, nullptr, ok, -1);
595 stop.jump = attrs.getOptSUMOTimeReporting(SUMO_ATTR_JUMP, nullptr, ok, -1);
596 stop.jumpUntil = attrs.getOptSUMOTimeReporting(SUMO_ATTR_JUMP_UNTIL, nullptr, ok, -1);
597 stop.collision = attrs.getOpt<bool>(SUMO_ATTR_COLLISION, nullptr, ok, false);
598 return true;
599}
600
601
602/****************************************************************************/
long long int SUMOTime
Definition GUI.h:36
#define WRITE_WARNINGF(...)
Definition MsgHandler.h:287
#define WRITE_ERROR(msg)
Definition MsgHandler.h:295
#define TL(string)
Definition MsgHandler.h:304
#define TLF(string,...)
Definition MsgHandler.h:306
SUMOTime string2time(const std::string &r)
convert string to SUMOTime
Definition SUMOTime.cpp:46
constexpr SUMOTime TIME2STEPS(double x)
Definition SUMOTime.h:60
const int STOP_ARRIVAL_SET
const int STOP_DURATION_SET
const int STOP_INDEX_END
const int STOP_POSLAT_SET
const int STOP_EXPECTED_SET
const long long int VEHPARS_FORCE_REROUTE
const int STOP_SPEED_SET
const int STOP_JUMP_UNTIL_SET
const int STOP_UNTIL_SET
const int STOP_LINE_SET
const int STOP_PARKING_SET
const int STOP_TRIP_ID_SET
const int STOP_PERMITTED_SET
const int STOP_SPLIT_SET
const int STOP_START_SET
const int STOP_JOIN_SET
const int STOP_EXTENSION_SET
const int STOP_INDEX_FIT
const int STOP_ENDED_SET
const int STOP_TRIGGER_SET
const int STOP_PRIORITY_SET
const int STOP_JUMP_SET
const int STOP_ONDEMAND_SET
const int STOP_END_SET
const int STOP_STARTED_SET
const int STOP_EXPECTED_CONTAINERS_SET
@ GIVEN
The time is given.
SumoXMLTag
Numbers representing SUMO-XML - element names.
@ SUMO_TAG_INTERVAL
an aggreagated-output interval
@ SUMO_TAG_VTYPE
description of a vehicle/person/container type
@ SUMO_TAG_WALK
@ SUMO_TAG_TRANSHIP
@ SUMO_TAG_CONTAINERFLOW
@ SUMO_TAG_STOP
stop for vehicles
@ SUMO_TAG_VEHICLE
description of a vehicle
@ SUMO_TAG_ROUTE_DISTRIBUTION
distribution of a route
@ SUMO_TAG_FLOW
a flow definition using from and to edges or a route
@ SUMO_TAG_TRANSPORT
@ SUMO_TAG_CONTAINER
@ SUMO_TAG_ROUTE
description of a route
@ SUMO_TAG_RIDE
@ SUMO_TAG_VTYPE_DISTRIBUTION
distribution of a vehicle type
@ SUMO_TAG_PARAM
parameter associated to a certain key
@ SUMO_TAG_PERSON
@ SUMO_TAG_PERSONTRIP
@ SUMO_TAG_CALIBRATOR
A calibrator placed over edge.
@ SUMO_TAG_PERSONFLOW
@ SUMO_TAG_TRIP
a single trip definition (used by router)
ParkingType
Numbers representing special SUMO-XML-attribute values Information on whether a car is parking on the...
@ SUMO_ATTR_CONTAINER_TRIGGERED
@ SUMO_ATTR_STARTPOS
@ SUMO_ATTR_PARKING
@ SUMO_ATTR_EXTENSION
@ SUMO_ATTR_LANE
@ SUMO_ATTR_COLLISION
@ SUMO_ATTR_REFID
@ SUMO_ATTR_SPEED
@ SUMO_ATTR_STARTED
@ SUMO_ATTR_VALUE
@ SUMO_ATTR_CONTAINER_STOP
@ SUMO_ATTR_PARKING_AREA
@ SUMO_ATTR_EDGE
@ SUMO_ATTR_BUS_STOP
@ SUMO_ATTR_TRAIN_STOP
@ SUMO_ATTR_ENDPOS
@ SUMO_ATTR_SPLIT
@ SUMO_ATTR_ACTTYPE
@ SUMO_ATTR_BEGIN
weights: time range begin
@ SUMO_ATTR_POSITION_LAT
@ SUMO_ATTR_EXPECTED
@ SUMO_ATTR_PRIORITY
@ SUMO_ATTR_LINE
@ SUMO_ATTR_CHARGING_STATION
@ SUMO_ATTR_OVERHEAD_WIRE_SEGMENT
@ SUMO_ATTR_ENDED
@ SUMO_ATTR_ONDEMAND
@ SUMO_ATTR_INDEX
@ SUMO_ATTR_ARRIVAL
@ SUMO_ATTR_TRIP_ID
@ SUMO_ATTR_END
weights: time range end
@ SUMO_ATTR_PERMITTED
@ SUMO_ATTR_JOIN
@ SUMO_ATTR_JUMP
@ SUMO_ATTR_PROB
@ SUMO_ATTR_EXPECTED_CONTAINERS
@ SUMO_ATTR_ID
@ SUMO_ATTR_UNTIL
@ SUMO_ATTR_JUMP_UNTIL
@ SUMO_ATTR_TRIGGERED
@ SUMO_ATTR_DURATION
@ SUMO_ATTR_KEY
#define FALLTHROUGH
Definition StdDefs.h:39
const double INVALID_DOUBLE
invalid double
Definition StdDefs.h:68
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition ToString.h:49
static bool isValidDescription(const std::string &description, std::string &error)
validate input description
double sample(SumoRNG *which=nullptr) const
Draw a sample of the distribution using the given RNG.
static std::string checkForRelativity(const std::string &filename, const std::string &basePath)
Returns the path from a configuration so that it is accessible from the current working directory.
void error(const XERCES_CPP_NAMESPACE::SAXParseException &exception)
Handler for XML-errors.
const std::string & getFileName() const
returns the current file name
virtual void inform(std::string msg, bool addType=true)
adds a new error to the list
A storage for options typed value containers)
Definition OptionsCont.h:89
static OptionsCont & getOptions()
Retrieves the options.
bool parseStop(SUMOVehicleParameter::Stop &stop, const SUMOSAXAttributes &attrs, std::string errorSuffix, MsgHandler *const errorOutput)
parses attributes common to all stops
virtual void openTrip(const SUMOSAXAttributes &attrs)=0
opens a trip for reading
StopPos
enum for stops
void registerLastDepart()
save last depart (only to be used if vehicle is not discarded)
virtual void openFlow(const SUMOSAXAttributes &attrs)=0
opens a flow for reading
virtual void closeContainer()=0
Ends the processing of a container.
SUMOTime myFirstDepart
the first read departure time
virtual void addWalk(const SUMOSAXAttributes &attrs)=0
add a fully specified walk
SUMOTime myBeginDefault
The default value for flow begins.
SUMORouteHandler(const std::string &file, const std::string &expectedRoot, const bool hardFail)
standard constructor
virtual void openRouteDistribution(const SUMOSAXAttributes &attrs)=0
opens a route distribution for reading
bool myAllowInternalRoutes
whether references to internal routes are allowed in this context
std::string myActiveRouteID
The id of the current route.
virtual void openRoute(const SUMOSAXAttributes &attrs)=0
opens a route for reading
virtual void openVehicleTypeDistribution(const SUMOSAXAttributes &attrs)=0
opens a type distribution for reading
virtual ~SUMORouteHandler()
standard destructor
virtual void closeVehicle()=0
Ends the processing of a vehicle.
virtual void closeFlow()=0
Ends the processing of a flow.
virtual void closePersonFlow()=0
Ends the processing of a person flow.
std::vector< Parameterised * > myParamStack
The stack of currently parsed parameterised objects.
SUMOVehicleParameter * myVehicleParameter
Parameter of the current vehicle, trip, person, container or flow.
virtual void addRide(const SUMOSAXAttributes &attrs)=0
Processing of a ride.
virtual void addTranship(const SUMOSAXAttributes &attrs)=0
Processing of a tranship.
SUMOTime getLastDepart() const
Returns the last loaded depart time.
const bool myHardFail
flag to enable or disable hard fails
static SumoRNG myParsingRNG
A random number generator used to choose from vtype/route distributions and computing the speed facto...
std::vector< int > myElementStack
hierarchy of elements being parsed
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.
virtual void addTransport(const SUMOSAXAttributes &attrs)=0
Processing of a transport.
virtual void closeRoute(const bool mayBeDisconnected=false)=0
virtual void closePerson()=0
Ends the processing of a person.
SUMOTime myLastDepart
The insertion time of the vehicle read last.
SUMOTime myEndDefault
The default value for flow ends.
virtual void closeVehicleTypeDistribution()=0
closes (ends) the building of a distribution
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;.
void addParam(const SUMOSAXAttributes &attrs)
assign arbitrary vehicle parameters
virtual void closeContainerFlow()=0
Ends the processing of a container flow.
virtual const SUMOVTypeParameter * getVTypeParameter(const std::string &refid)=0
virtual Parameterised * addStop(const SUMOSAXAttributes &attrs)=0
Processing of a stop.
virtual void closeTrip()=0
Ends the processing of a trip.
SUMOTime getFirstDepart() const
returns the first departure time that was ever read
virtual void openRouteFlow(const SUMOSAXAttributes &attrs)=0
opens a route flow for reading
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)
virtual void addTransportable(const SUMOSAXAttributes &attrs, const bool isPerson)
Processing of a person or container.
virtual void addPersonTrip(const SUMOSAXAttributes &attrs)=0
add a routing request for a walking or intermodal person
virtual void myEndElement(int element)
Called when a closing tag occurs.
virtual void closeVType()=0
Ends the processing of a vehicle type.
virtual void closeRouteDistribution()=0
closes (ends) the building of a distribution
virtual bool checkLastDepart()
Checks whether the route file is sorted by departure time if needed.
Encapsulated SAX-Attributes.
virtual std::string getString(int id, bool *isPresent=nullptr) const =0
Returns the string-value of the named (by its enum-value) attribute.
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.
virtual std::string getStringSecure(int id, const std::string &def) const =0
Returns the string-value of the named (by its enum-value) attribute.
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.
SUMOTime getSUMOTimeReporting(int attr, const char *objectid, bool &ok, bool report=true) const
Tries to read given attribute assuming it is a SUMOTime.
SAX-handler base for SUMO-files.
std::string id
The vehicle type's id.
Definition of vehicle stop (position and duration)
SUMOTime started
the time at which this stop was reached
ParkingType parking
whether the vehicle is removed from the net while stopping
SUMOTime extension
The maximum time extension for boarding / loading.
double speed
the speed at which this stop counts as reached (waypoint mode)
std::string parkingarea
(Optional) parking area if one is assigned to the stop
std::string split
the id of the vehicle (train portion) that splits of upon reaching this stop
std::string line
the new line id of the trip within a cyclical public transport route
Distribution_Parameterized durationDist
double posLat
the lateral offset when stopping
bool onDemand
whether the stop may be skipped
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
std::set< std::string > permitted
IDs of persons or containers that may board/load at this stop.
SUMOTime jumpUntil
earlierst jump end if there shall be a jump from this stop to the next route edge
int parametersSet
Information for the output which parameter were set.
double priority
priority for weighting/skipping stops
int index
at which position in the stops list
SUMOTime jump
transfer time if there shall be a jump from this stop to the next route edge
std::string join
the id of the vehicle (train portion) to which this vehicle shall be joined
SUMOTime until
The time at which the vehicle may continue its journey.
std::string actType
act Type (only used by Persons) (used by netedit)
bool triggered
whether an arriving person lets the vehicle continue
SUMOTime ended
the time at which this stop was ended
std::set< std::string > awaitedPersons
IDs of persons the vehicle has to wait for until departing.
std::set< std::string > awaitedContainers
IDs of containers the vehicle has to wait for until departing.
std::string busstop
(Optional) bus stop if one is assigned to the stop
std::string tripId
id of the trip within a cyclical public transport route
std::string containerstop
(Optional) container stop if one is assigned to the stop
bool containerTriggered
whether an arriving container lets the vehicle continue
bool collision
Whether this stop was triggered by a collision.
SUMOTime arrival
The (expected) time at which the vehicle reaches the stop.
SUMOTime duration
The stopping duration.
long long int parametersSet
Information for the router which parameter were set, TraCI may modify this (when changing color)
std::string routeid
The vehicle's route id.
std::string id
The vehicle's id.
DepartDefinition departProcedure
Information how the vehicle shall choose the depart time.
std::string line
The vehicle's line (mainly for public transport)
static void parseStopTriggers(const std::vector< std::string > &triggers, bool expectTrigger, Stop &stop)
parses stop trigger values
static SUMOVTypeParameter * beginVTypeParsing(const SUMOSAXAttributes &attrs, const bool hardFail, const std::string &file, const SUMOVTypeParameter *const base)
Starts to parse a vehicle type.
static bool parseCFMParams(SUMOVTypeParameter *into, const SumoXMLTag element, const SUMOSAXAttributes &attrs, const bool nestedCFM)
Parses Car Following Mode params.
static SUMOVehicleParameter * parseVehicleAttributes(int element, const SUMOSAXAttributes &attrs, const bool hardFail, const bool optionalID=false, const bool skipDepart=false, const bool allowInternalRoutes=false)
Parses a vehicle's attributes.
static SUMOVehicleParameter * parseFlowAttributes(SumoXMLTag tag, const SUMOSAXAttributes &attrs, const bool hardFail, const bool needID, const SUMOTime beginDefault, const SUMOTime endDefault, const bool allowInternalRoutes=false)
Parses a flow's attributes.