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-2023 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
29#include <utils/xml/XMLSubSys.h>
30
31#include "SUMORouteHandler.h"
32
33
34// ===========================================================================
35// method definitions
36// ===========================================================================
37
38SUMORouteHandler::SUMORouteHandler(const std::string& file, const std::string& expectedRoot, const bool hardFail) :
39 SUMOSAXHandler(file, expectedRoot),
40 myHardFail(hardFail),
41 myVehicleParameter(nullptr),
42 myCurrentStop(nullptr),
43 myLastDepart(-1),
44 myActiveRouteColor(nullptr),
45 myCurrentCosts(0.),
46 myCurrentVType(nullptr),
47 myBeginDefault(string2time(OptionsCont::getOptions().getString("begin"))),
48 myEndDefault(string2time(OptionsCont::getOptions().getString("end"))),
49 myFirstDepart(-1),
50 myInsertStopEdgesAt(-1) {
51}
52
53
58
59
60bool
64 WRITE_WARNINGF(TL("Route file should be sorted by departure time, ignoring '%'!"), myVehicleParameter->id);
65 return false;
66 }
67 }
68 return true;
69}
70
71
72void
74 // register only non public transport to parse all public transport lines in advance
77 if (myFirstDepart == -1) {
79 }
80 }
81 // else: we don't know when this vehicle will depart. keep the previous known depart time
82}
83
84
85void
87 myElementStack.push_back(element);
88 switch (element) {
90 // delete if myVehicleParameter isn't null
92 delete myVehicleParameter;
93 myVehicleParameter = nullptr;
94 }
95 // create a new vehicle
97 break;
98 case SUMO_TAG_PERSON:
99 // delete if myVehicleParameter isn't null
100 if (myVehicleParameter) {
101 delete myVehicleParameter;
102 myVehicleParameter = nullptr;
103 }
104 // create a new person
106 addPerson(attrs);
107 break;
109 // delete if myVehicleParameter isn't null
110 if (myVehicleParameter) {
111 delete myVehicleParameter;
112 myVehicleParameter = nullptr;
113 }
114 // create a new container
116 addContainer(attrs);
117 break;
118 case SUMO_TAG_FLOW:
119 // delete if myVehicleParameter isn't null
120 if (myVehicleParameter) {
121 delete myVehicleParameter;
122 myVehicleParameter = nullptr;
123 }
124 // parse vehicle parameters
125 // might be called to parse vehicles from additional file in the
126 // context of quickReload. In this case, rerouter flows must be ignored
127 if (myElementStack.size() == 1 || myElementStack[myElementStack.size() - 2] != SUMO_TAG_CALIBRATOR) {
129 }
130 // check if myVehicleParameter was successfully created
131 if (myVehicleParameter) {
132 // check tag
133 if (myVehicleParameter->routeid.empty()) {
134 // open a route flow (It could be a flow with embedded route)
135 openFlow(attrs);
136 } else {
137 // open a route flow
138 openRouteFlow(attrs);
139 }
140 }
141 break;
143 // delete if myVehicleParameter isn't null
144 if (myVehicleParameter) {
145 delete myVehicleParameter;
146 myVehicleParameter = nullptr;
147 }
148 // create a new flow
150 break;
152 // delete if myVehicleParameter isn't null
153 if (myVehicleParameter) {
154 delete myVehicleParameter;
155 myVehicleParameter = nullptr;
156 }
157 // create a new flow
159 break;
160 case SUMO_TAG_VTYPE:
161 // delete if myCurrentVType isn't null
162 if (myCurrentVType != nullptr) {
163 delete myCurrentVType;
164 myCurrentVType = nullptr;
165 }
166 // create a new vType
168 break;
171 break;
172 case SUMO_TAG_ROUTE:
173 openRoute(attrs);
174 break;
177 break;
178 case SUMO_TAG_STOP:
179 myCurrentStop = addStop(attrs);
180 break;
181 case SUMO_TAG_TRIP: {
182 // delete if myVehicleParameter isn't null
183 if (myVehicleParameter) {
184 delete myVehicleParameter;
185 myVehicleParameter = nullptr;
186 }
187 // parse vehicle parameters
189 // check if myVehicleParameter was successfully created
190 if (myVehicleParameter) {
193 // open trip
194 openTrip(attrs);
195 }
196 break;
197 }
199 addPersonTrip(attrs);
200 break;
201 case SUMO_TAG_WALK:
202 addWalk(attrs);
203 break;
204 case SUMO_TAG_INTERVAL: {
205 bool ok;
207 myEndDefault = attrs.getSUMOTimeReporting(SUMO_ATTR_END, nullptr, ok);
208 break;
209 }
210 case SUMO_TAG_RIDE:
211 addRide(attrs);
212 break;
214 addTransport(attrs);
215 break;
217 addTranship(attrs);
218 break;
219 case SUMO_TAG_PARAM:
220 addParam(attrs);
221 break;
222 default:
223 // parse embedded car following model information
224 if (myCurrentVType != nullptr) {
225 WRITE_WARNINGF(TL("Defining car-following parameters in a nested element is deprecated in vType '%', use attributes instead!"), myCurrentVType->id);
227 if (myHardFail) {
228 throw ProcessError(TL("Invalid parsing embedded VType"));
229 } else {
230 WRITE_ERROR(TL("Invalid parsing embedded VType"));
231 }
232 }
233 }
234 break;
235 }
236}
237
238
239void
241 switch (element) {
242 case SUMO_TAG_STOP:
243 myCurrentStop = nullptr;
244 break;
245 case SUMO_TAG_ROUTE:
246 closeRoute();
247 break;
248 case SUMO_TAG_VTYPE:
249 closeVType();
250 delete myCurrentVType;
251 myCurrentVType = nullptr;
252 break;
253 case SUMO_TAG_PERSON:
254 closePerson();
255 delete myVehicleParameter;
256 myVehicleParameter = nullptr;
257 break;
260 delete myVehicleParameter;
261 myVehicleParameter = nullptr;
262 break;
265 delete myVehicleParameter;
266 myVehicleParameter = nullptr;
267 break;
270 delete myVehicleParameter;
271 myVehicleParameter = nullptr;
272 break;
273 case SUMO_TAG_VEHICLE:
274 if (myVehicleParameter == nullptr) {
275 break;
276 }
278 myVehicleParameter->repetitionNumber++; // for backwards compatibility
279 // it is a flow, thus no break here
281 } else {
282 closeVehicle();
283 delete myVehicleParameter;
284 myVehicleParameter = nullptr;
285 break;
286 }
287 case SUMO_TAG_FLOW:
288 if (myVehicleParameter) {
289 closeFlow();
290 delete myVehicleParameter;
291 }
292 myVehicleParameter = nullptr;
294 break;
295 case SUMO_TAG_TRIP:
296 closeTrip();
297 delete myVehicleParameter;
298 myVehicleParameter = nullptr;
300 break;
303 break;
306 break;
308 myBeginDefault = string2time(OptionsCont::getOptions().getString("begin"));
310 break;
311 default:
312 break;
313 }
314 myElementStack.pop_back();
315}
316
317
319SUMORouteHandler::checkStopPos(double& startPos, double& endPos, const double laneLength, const double minLength, const bool friendlyPos) {
320 if (minLength > laneLength) {
322 }
323 if (startPos < 0) {
324 startPos += laneLength;
325 }
326 if (endPos < 0) {
327 endPos += laneLength;
328 }
329 if ((endPos < minLength) || (endPos > laneLength)) {
330 if (!friendlyPos) {
332 }
333 if (endPos < minLength) {
334 endPos = minLength;
335 }
336 if (endPos > laneLength) {
337 endPos = laneLength;
338 }
339 }
340 if ((startPos < 0) || (startPos > (endPos - minLength))) {
341 if (!friendlyPos) {
343 }
344 if (startPos < 0) {
345 startPos = 0;
346 }
347 if (startPos > (endPos - minLength)) {
348 startPos = endPos - minLength;
349 }
350 }
351 return STOPPOS_VALID;
352}
353
354
355bool
356SUMORouteHandler::isStopPosValid(const double startPos, const double endPos, const double laneLength, const double minLength, const bool friendlyPos) {
357 // declare dummy start and end positions
358 double dummyStartPos = startPos;
359 double dummyEndPos = endPos;
360 // return checkStopPos
361 return (checkStopPos(dummyStartPos, dummyEndPos, laneLength, minLength, friendlyPos) == STOPPOS_VALID);
362}
363
364
369
370
375
376
377void
379 bool ok = true;
380 const std::string key = attrs.get<std::string>(SUMO_ATTR_KEY, nullptr, ok);
381 // only continue if key isn't empty
382 if (ok && (key.size() > 0)) {
383 // circumventing empty string test
384 const std::string val = attrs.hasAttribute(SUMO_ATTR_VALUE) ? attrs.getString(SUMO_ATTR_VALUE) : "";
385 // add parameter in current created element, or in myLoadedParameterised
386 if (myCurrentStop != nullptr) {
387 myCurrentStop->setParameter(key, val);
388 } else if (myVehicleParameter != nullptr) {
390 } else if (myCurrentVType != nullptr) {
391 myCurrentVType->setParameter(key, val);
392 } else {
394 }
395 }
396}
397
398
399bool
400SUMORouteHandler::parseStop(SUMOVehicleParameter::Stop& stop, const SUMOSAXAttributes& attrs, std::string errorSuffix, MsgHandler* const errorOutput) {
401 stop.parametersSet = 0;
402 if (attrs.hasAttribute(SUMO_ATTR_ARRIVAL)) {
404 }
405 if (attrs.hasAttribute(SUMO_ATTR_DURATION)) {
407 }
408 if (attrs.hasAttribute(SUMO_ATTR_UNTIL)) {
410 }
411 if (attrs.hasAttribute(SUMO_ATTR_STARTED)) {
413 }
414 if (attrs.hasAttribute(SUMO_ATTR_ENDED)) {
416 }
419 }
420 if (attrs.hasAttribute(SUMO_ATTR_ENDPOS)) {
422 }
423 if (attrs.hasAttribute(SUMO_ATTR_STARTPOS)) {
425 }
428 }
431 }
432 // legacy attribute
435 }
436 if (attrs.hasAttribute(SUMO_ATTR_PARKING)) {
438 }
439 if (attrs.hasAttribute(SUMO_ATTR_EXPECTED)) {
441 }
444 }
447 }
448 if (attrs.hasAttribute(SUMO_ATTR_TRIP_ID)) {
450 }
451 if (attrs.hasAttribute(SUMO_ATTR_SPLIT)) {
453 }
454 if (attrs.hasAttribute(SUMO_ATTR_JOIN)) {
456 }
457 if (attrs.hasAttribute(SUMO_ATTR_LINE)) {
459 }
460 if (attrs.hasAttribute(SUMO_ATTR_SPEED)) {
462 }
463 if (attrs.hasAttribute(SUMO_ATTR_ONDEMAND)) {
465 }
466 if (attrs.hasAttribute(SUMO_ATTR_JUMP)) {
468 }
469 bool ok = true;
470 stop.busstop = attrs.getOpt<std::string>(SUMO_ATTR_BUS_STOP, nullptr, ok, "");
471 stop.busstop = attrs.getOpt<std::string>(SUMO_ATTR_TRAIN_STOP, nullptr, ok, stop.busstop);
472 stop.chargingStation = attrs.getOpt<std::string>(SUMO_ATTR_CHARGING_STATION, nullptr, ok, "");
473 stop.overheadWireSegment = attrs.getOpt<std::string>(SUMO_ATTR_OVERHEAD_WIRE_SEGMENT, nullptr, ok, "");
474 stop.containerstop = attrs.getOpt<std::string>(SUMO_ATTR_CONTAINER_STOP, nullptr, ok, "");
475 stop.parkingarea = attrs.getOpt<std::string>(SUMO_ATTR_PARKING_AREA, nullptr, ok, "");
476 if (stop.busstop != "") {
477 errorSuffix = " at '" + stop.busstop + "'" + errorSuffix;
478 } else if (stop.chargingStation != "") {
479 errorSuffix = " at '" + stop.chargingStation + "'" + errorSuffix;
480 } else if (stop.overheadWireSegment != "") {
481 errorSuffix = " at '" + stop.overheadWireSegment + "'" + errorSuffix;
482 } else if (stop.containerstop != "") {
483 errorSuffix = " at '" + stop.containerstop + "'" + errorSuffix;
484 } else if (stop.parkingarea != "") {
485 errorSuffix = " at '" + stop.parkingarea + "'" + errorSuffix;
486 } else if (attrs.hasAttribute(SUMO_ATTR_LANE)) {
487 errorSuffix = " on lane '" + attrs.get<std::string>(SUMO_ATTR_LANE, nullptr, ok) + "'" + errorSuffix;
488 } else if (attrs.hasAttribute(SUMO_ATTR_EDGE)) {
489 errorSuffix = " on edge '" + attrs.get<std::string>(SUMO_ATTR_EDGE, nullptr, ok) + "'" + errorSuffix;
490 } else {
491 errorSuffix = " at undefined location" + errorSuffix;
492 }
493 // speed for counting as stopped
494 stop.speed = attrs.getOpt<double>(SUMO_ATTR_SPEED, nullptr, ok, 0);
495 if (stop.speed < 0) {
496 errorOutput->inform("Speed cannot be negative for stop" + errorSuffix);
497 return false;
498 }
499
500 // get the standing duration
501 bool expectTrigger = !attrs.hasAttribute(SUMO_ATTR_DURATION) && !attrs.hasAttribute(SUMO_ATTR_UNTIL) && !attrs.hasAttribute(SUMO_ATTR_SPEED);
502 std::vector<std::string> triggers = attrs.getOpt<std::vector<std::string> >(SUMO_ATTR_TRIGGERED, nullptr, ok);
503 // legacy
504 if (attrs.getOpt<bool>(SUMO_ATTR_CONTAINER_TRIGGERED, nullptr, ok, false)) {
505 triggers.push_back(toString(SUMO_TAG_CONTAINER));
506 }
507 SUMOVehicleParameter::parseStopTriggers(triggers, expectTrigger, stop);
508 stop.arrival = attrs.getOptSUMOTimeReporting(SUMO_ATTR_ARRIVAL, nullptr, ok, -1);
509 stop.duration = attrs.getOptSUMOTimeReporting(SUMO_ATTR_DURATION, nullptr, ok, -1);
510 stop.until = attrs.getOptSUMOTimeReporting(SUMO_ATTR_UNTIL, nullptr, ok, -1);
511 if (!expectTrigger && (!ok || (stop.duration < 0 && stop.until < 0 && stop.speed == 0))) {
512 errorOutput->inform("Invalid duration or end time is given for a stop" + errorSuffix);
513 return false;
514 }
515 if (triggers.size() > 0 && stop.speed > 0) {
516 errorOutput->inform("Triggers and waypoints cannot be combined" + errorSuffix);
517 return false;
518 }
519 stop.extension = attrs.getOptSUMOTimeReporting(SUMO_ATTR_EXTENSION, nullptr, ok, -1);
520 const bool defaultParking = (stop.triggered || stop.containerTriggered || stop.parkingarea != "");
521 stop.parking = attrs.getOpt<ParkingType>(SUMO_ATTR_PARKING, nullptr, ok, defaultParking ? ParkingType::OFFROAD : ParkingType::ONROAD);
522 if ((stop.parkingarea != "") && (stop.parking == ParkingType::ONROAD)) {
523 WRITE_WARNING("Stop at parkingarea overrides attribute 'parking' for stop" + errorSuffix);
525 }
526
527 // expected persons
528 const std::vector<std::string>& expected = attrs.getOpt<std::vector<std::string> >(SUMO_ATTR_EXPECTED, nullptr, ok);
529 stop.awaitedPersons.insert(expected.begin(), expected.end());
530 if (stop.awaitedPersons.size() > 0) {
531 stop.triggered = true;
532 if ((stop.parametersSet & STOP_PARKING_SET) == 0) {
534 }
535 }
536
537 // permitted transportables
538 const std::vector<std::string>& permitted = attrs.getOpt<std::vector<std::string> >(SUMO_ATTR_PERMITTED, nullptr, ok);
539 stop.permitted.insert(permitted.begin(), permitted.end());
540
541 // expected containers
542 const std::vector<std::string>& expectedContainers = attrs.getOpt<std::vector<std::string> >(SUMO_ATTR_EXPECTED_CONTAINERS, nullptr, ok);
543 stop.awaitedContainers.insert(expectedContainers.begin(), expectedContainers.end());
544 if (stop.awaitedContainers.size() > 0) {
545 stop.containerTriggered = true;
546 if ((stop.parametersSet & STOP_PARKING_SET) == 0) {
548 }
549 }
550 // public transport trip id
551 stop.tripId = attrs.getOpt<std::string>(SUMO_ATTR_TRIP_ID, nullptr, ok, "");
552 stop.split = attrs.getOpt<std::string>(SUMO_ATTR_SPLIT, nullptr, ok, "");
553 stop.join = attrs.getOpt<std::string>(SUMO_ATTR_JOIN, nullptr, ok, "");
554 stop.line = attrs.getOpt<std::string>(SUMO_ATTR_LINE, nullptr, ok, "");
555
556 const std::string idx = attrs.getOpt<std::string>(SUMO_ATTR_INDEX, nullptr, ok, "end");
557 if (idx == "end") {
558 stop.index = STOP_INDEX_END;
559 } else if (idx == "fit") {
560 stop.index = STOP_INDEX_FIT;
561 } else {
562 stop.index = attrs.get<int>(SUMO_ATTR_INDEX, nullptr, ok);
563 if (!ok || stop.index < 0) {
564 errorOutput->inform("Invalid 'index' for stop" + errorSuffix);
565 return false;
566 }
567 }
568 stop.started = attrs.getOptSUMOTimeReporting(SUMO_ATTR_STARTED, nullptr, ok, -1);
569 stop.ended = attrs.getOptSUMOTimeReporting(SUMO_ATTR_ENDED, nullptr, ok, -1);
570 stop.posLat = attrs.getOpt<double>(SUMO_ATTR_POSITION_LAT, nullptr, ok, INVALID_DOUBLE);
571 stop.actType = attrs.getOpt<std::string>(SUMO_ATTR_ACTTYPE, nullptr, ok, "");
572 stop.onDemand = attrs.getOpt<bool>(SUMO_ATTR_ONDEMAND, nullptr, ok, false);
573 stop.jump = attrs.getOptSUMOTimeReporting(SUMO_ATTR_JUMP, nullptr, ok, -1);
574 stop.collision = attrs.getOpt<bool>(SUMO_ATTR_COLLISION, nullptr, ok, false);
575 return true;
576}
577
578
579/****************************************************************************/
long long int SUMOTime
Definition GUI.h:36
#define WRITE_WARNINGF(...)
Definition MsgHandler.h:271
#define WRITE_ERROR(msg)
Definition MsgHandler.h:279
#define WRITE_WARNING(msg)
Definition MsgHandler.h:270
#define TL(string)
Definition MsgHandler.h:287
SUMOTime string2time(const std::string &r)
convert string to SUMOTime
Definition SUMOTime.cpp:46
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 int STOP_SPEED_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 VEHPARS_FORCE_REROUTE
const int STOP_INDEX_FIT
const int STOP_ENDED_SET
const int STOP_TRIGGER_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
begin/end of the 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_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_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_EXPECTED_CONTAINERS
@ SUMO_ATTR_UNTIL
@ SUMO_ATTR_TRIGGERED
@ SUMO_ATTR_DURATION
@ SUMO_ATTR_KEY
#define FALLTHROUGH
Definition StdDefs.h:35
const double INVALID_DOUBLE
invalid double
Definition StdDefs.h:64
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition ToString.h:46
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.
virtual void setParameter(const std::string &key, const std::string &value)
Sets a parameter.
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
static bool isStopPosValid(const double startPos, const double endPos, const double laneLength, const double minLength, const bool friendlyPos)
check if start and end position of a stop is valid
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
std::string myActiveRouteID
The id of the current route.
virtual void addPerson(const SUMOSAXAttributes &attrs)=0
Processing of a person.
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.
Parameterised * myCurrentStop
The currently parsed vehicle stop.
Parameterised myLoadedParameterised
Parameterised used for saving loaded generic parameters that aren't saved in Vehicles or Vehicle Type...
virtual void closePersonFlow()=0
Ends the processing of a person flow.
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
virtual void addContainer(const SUMOSAXAttributes &attrs)=0
Processing of a container.
std::vector< int > myElementStack
hierachy of elements being parsed
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 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
int myInsertStopEdgesAt
where stop edges can be inserted into the current route (-1 means no insertion)
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.
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
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.
int parametersSet
Information for the output which parameter were set.
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.
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)
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 * parseFlowAttributes(SumoXMLTag tag, const SUMOSAXAttributes &attrs, const bool hardFail, const bool needID, const SUMOTime beginDefault, const SUMOTime endDefault)
Parses a flow's attributes.
static SUMOVehicleParameter * parseVehicleAttributes(int element, const SUMOSAXAttributes &attrs, const bool hardFail, const bool optionalID=false, const bool skipDepart=false)
Parses a vehicle's attributes.