359 if (vehicleTypeParameter) {
365 delete vehicleTypeParameter;
373 bool parsedOk =
true;
375 const std::string ID = attrs.
get<std::string>(
SUMO_ATTR_ID,
"", parsedOk);
394 WRITE_ERROR(
"a route must be defined either within a vehicle/flow or with an ID attribute");
397 bool parsedOk =
true;
401 const std::vector<std::string> edges = attrs.
get<std::vector<std::string> >(
SUMO_ATTR_EDGES,
id.c_str(), parsedOk);
425 bool parsedOk =
true;
427 const std::string ID = attrs.
get<std::string>(
SUMO_ATTR_ID,
"", parsedOk);
440 bool parsedOk =
true;
446 WRITE_ERROR(
"Attributes 'from' and 'fromJunction' cannot be defined together");
448 WRITE_ERROR(
"Attributes 'to' and 'toJunction' cannot be defined together");
451 const std::string from = attrs.
getOpt<std::string>(
SUMO_ATTR_FROM, tripParameter->
id.c_str(), parsedOk,
"");
452 const std::string to = attrs.
getOpt<std::string>(
SUMO_ATTR_TO, tripParameter->
id.c_str(), parsedOk,
"");
479 WRITE_ERROR(
"trip definition needs either 'from/to' or 'fromJunction/toJunction'");
482 delete tripParameter;
491 if (vehicleParameter) {
497 delete vehicleParameter;
505 bool parsedOk =
true;
513 WRITE_ERROR(
"Attributes 'from' and 'fromJunction' cannot be defined together");
515 WRITE_ERROR(
"Attributes 'to' and 'toJunction' cannot be defined together");
518 const std::string from = attrs.
get<std::string>(
SUMO_ATTR_FROM, flowParameter->
id.c_str(), parsedOk);
519 const std::string to = attrs.
get<std::string>(
SUMO_ATTR_TO, flowParameter->
id.c_str(), parsedOk);
543 const std::string route = attrs.
get<std::string>(
SUMO_ATTR_ROUTE, flowParameter->
id.c_str(), parsedOk);
555 delete flowParameter;
563 bool parsedOk =
true;
582 if (personParameter) {
588 delete personParameter;
597 if (personFlowParameter) {
603 delete personFlowParameter;
611 bool parsedOk =
true;
644 bool parsedOk =
true;
681 bool parsedOk =
true;
705 if (containerParameter) {
711 delete containerParameter;
720 if (containerFlowParameter) {
726 delete containerFlowParameter;
734 bool parsedOk =
true;
757 bool parsedOk =
true;
784 bool parsedOk =
true;
794 bool parsedOk =
true;
796 const std::string key = attrs.
get<std::string>(
SUMO_ATTR_KEY,
nullptr, parsedOk);
800 if (SumoBaseObjectParent ==
nullptr) {
801 WRITE_ERROR(
"Parameters must be defined within an object");
803 WRITE_ERROR(
"Parameters cannot be defined in the additional file's root.");
805 WRITE_ERROR(
"Parameters cannot be defined within another parameter.");
806 }
else if (parsedOk) {
808 const std::string parentTagStr =
toString(SumoBaseObjectParent->getTag());
813 WRITE_WARNING(
"Error parsing key from " + parentTagStr +
" generic parameter. Key cannot be empty");
815 WRITE_WARNING(
"Error parsing key from " + parentTagStr +
" generic parameter. Key contains invalid characters");
817 WRITE_DEBUG(
"Inserting generic parameter '" + key +
"|" + value +
"' into " + parentTagStr);
819 SumoBaseObjectParent->addParameter(key, value);
831 WRITE_WARNING(
"Defining car following parameters in a nested element is deprecated in vType '" + vTypeObject->getStringAttribute(
SUMO_ATTR_ID) +
"', use attributes instead!");
833 auto vType = vTypeObject->getVehicleTypeParameter();
836 vTypeObject->setVehicleTypeParameter(&vType);
918 if (!stop.
edge.empty() && !stop.
lane.empty()) {
919 WRITE_ERROR(
"A stop must be defined either with an edge or with an lane, not both");
932 if (numStoppingPlaces > 1) {
933 WRITE_ERROR(
"A stop must be defined only in a StoppingPlace");
935 }
else if ((numStoppingPlaces == 0) && stop.
edge.empty() && stop.
lane.empty()) {
936 WRITE_ERROR(
"A stop must be defined in an edge, a lane, or in a StoppingPlace");
940 std::string errorSuffix;
942 errorSuffix =
" at '" + stop.
busstop +
"'" + errorSuffix;
948 errorSuffix =
" at '" + stop.
containerstop +
"'" + errorSuffix;
950 errorSuffix =
" at '" + stop.
parkingarea +
"'" + errorSuffix;
951 }
else if (stop.
edge !=
"") {
952 errorSuffix =
" at '" + stop.
edge +
"'" + errorSuffix;
954 errorSuffix =
" on lane '" + stop.
lane +
"'" + errorSuffix;
958 if (stop.
speed < 0) {
959 WRITE_ERROR(
"Speed cannot be negative for stop" + errorSuffix);
976 if (!expectTrigger && (!ok || (stop.
duration < 0 && stop.
until < 0 && stop.
speed == 0))) {
977 WRITE_ERROR(
"Invalid duration or end time is given for a stop" + errorSuffix);
983 WRITE_WARNING(
"Stop at parkingarea overrides attribute 'parking' for stop" + errorSuffix);
987 WRITE_ERROR(
"Invalid bool for 'triggered', 'containerTriggered' or 'parking' for stop" + errorSuffix);
1001 stop.
permitted.insert(permitted.begin(), permitted.end());
1004 stop.
awaitedContainers.insert(expectedContainers.begin(), expectedContainers.end());
1020 }
else if (idx ==
"fit") {
1024 if (!ok || stop.
index < 0) {
1025 WRITE_ERROR(
"Invalid 'index' for stop" + errorSuffix);
1060 std::string parentStrings;
1061 for (
const auto& tag : parentTags) {
1062 if (tag == parentTags.back()) {
1063 parentStrings.append(
toString(tag));
1065 parentStrings.append(
toString(tag) +
", ");
1068 if ((parent !=
nullptr) &&
1069 (parentTags.size() > 0) &&
1070 (std::find(parentTags.begin(), parentTags.end(), parent->
getTag()) == parentTags.end())) {
1072 WRITE_ERROR(
"'" +
toString(currentTag) +
"' must be defined within the definition of a '" + parentStrings +
"' (found '" +
toString(parent->
getTag()) +
"'" +
id +
").");
#define WRITE_WARNING(msg)
SUMOTime string2time(const std::string &r)
convert string to SUMOTime
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types.
const int STOP_ARRIVAL_SET
const int STOP_DURATION_SET
const int STOP_POSLAT_SET
const int STOP_EXPECTED_SET
const int STOP_PARKING_SET
const int STOP_TRIP_ID_SET
const int STOP_PERMITTED_SET
const int STOP_CONTAINER_TRIGGER_SET
const int STOP_EXTENSION_SET
const int STOP_TRIGGER_SET
const int STOP_STARTED_SET
const int STOP_EXPECTED_CONTAINERS_SET
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_ROOTFILE
root file
@ 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 definitio nusing a from-to edges instead of a route (used by router)
@ SUMO_TAG_ROUTE
begin/end of the description of a route
@ SUMO_TAG_VTYPE_DISTRIBUTION
distribution of a vehicle type
@ SUMO_TAG_PARAM
parameter associated to a certain key
@ SUMO_TAG_TRIP
a single trip definition (used by router)
@ SUMO_ATTR_CONTAINER_TRIGGERED
@ SUMO_ATTR_CONTAINER_STOP
@ SUMO_ATTR_DEPARTPOS_LAT
@ SUMO_ATTR_BEGIN
weights: time range begin
@ SUMO_ATTR_EDGES
the edges of a route
@ SUMO_ATTR_CHARGING_STATION
@ SUMO_ATTR_OVERHEAD_WIRE_SEGMENT
@ SUMO_ATTR_END
weights: time range end
@ SUMO_ATTR_EXPECTED_CONTAINERS
@ SUMO_ATTR_COLOR
A color information.
const double INVALID_DOUBLE
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
void addIntAttribute(const SumoXMLAttr attr, const int value)
add int attribute into current SumoBaseObject node
void setVehicleTypeParameter(const SUMOVTypeParameter *vehicleTypeParameter)
set vehicle type parameters
const SUMOVehicleParameter::Stop & getStopParameter() const
get stop parameters
const RGBColor & getColorAttribute(const SumoXMLAttr attr) const
get color attribute
SUMOTime getTimeAttribute(const SumoXMLAttr attr) const
get time attribute
bool hasStringAttribute(const SumoXMLAttr attr) const
has function
void setTag(const SumoXMLTag tag)
set SumoBaseObject tag
SumoBaseObject * getParentSumoBaseObject() const
get pointer to mySumoBaseObjectParent SumoBaseObject (if is null, then is the root)
const std::map< std::string, std::string > & getParameters() const
get parameters
SUMOVehicleClass getVClass() const
vehicle class
const SUMOVTypeParameter & getVehicleTypeParameter() const
get current vType
SumoXMLTag getTag() const
void addTimeAttribute(const SumoXMLAttr attr, const SUMOTime value)
add time attribute into current SumoBaseObject node
void addStringListAttribute(const SumoXMLAttr attr, const std::vector< std::string > &value)
add string list attribute into current SumoBaseObject node
int getIntAttribute(const SumoXMLAttr attr) const
get int attribute
void addDoubleAttribute(const SumoXMLAttr attr, const double value)
add double attribute into current SumoBaseObject node
void setVClass(SUMOVehicleClass vClass)
set vehicle class
void setVehicleParameter(const SUMOVehicleParameter *vehicleParameter)
set vehicle parameters
void addStringAttribute(const SumoXMLAttr attr, const std::string &value)
void setStopParameter(const SUMOVehicleParameter::Stop &stopParameter)
add stop parameters
double getDoubleAttribute(const SumoXMLAttr attr) const
get double attribute
const SUMOVehicleParameter & getVehicleParameter() const
get vehicle parameters
const std::vector< std::string > & getStringListAttribute(const SumoXMLAttr attr) const
get string list attribute
void addColorAttribute(const SumoXMLAttr attr, const RGBColor &value)
add color attribute into current SumoBaseObject node
const std::string & getStringAttribute(const SumoXMLAttr attr) const
get string attribute
const std::vector< SumoBaseObject * > & getSumoBaseObjectChildren() const
get SumoBaseObject children
CommonXMLStructure::SumoBaseObject * getCurrentSumoBaseObject() const
get current editedSumoBaseObject
void openSUMOBaseOBject()
open SUMOBaseOBject
void closeSUMOBaseOBject()
close myTag
A storage for options typed value containers)
static const RGBColor INVISIBLE
void parseWalk(const SUMOSAXAttributes &attrs)
parse walk
virtual void buildContainer(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const SUMOVehicleParameter &containerParameters)=0
build container
virtual void buildTransport(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const std::string &fromEdgeID, const std::string &toEdgeID, const std::string &toBusStopID, const std::vector< std::string > &lines, const double arrivalPos)=0
build transport
void parseContainerFlow(const SUMOSAXAttributes &attrs)
parse container flow
void parseFlow(const SUMOSAXAttributes &attrs)
parse flow (including flows, flows over routes and flows with embedded routes)
bool beginParseAttributes(SumoXMLTag tag, const SUMOSAXAttributes &attrs)
begin parse attributes
CommonXMLStructure myCommonXMLStructure
common XML Structure
virtual void buildFlowOverRoute(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const SUMOVehicleParameter &vehicleParameters)=0
build a flow over an existent route
bool isEmbeddedRoute(const SUMOSAXAttributes &attrs) const
check embedded route
void checkParent(const SumoXMLTag currentTag, const std::vector< SumoXMLTag > &parentTags, bool &ok) const
check parents
void parsePerson(const SUMOSAXAttributes &attrs)
parse person
void parseTransport(const SUMOSAXAttributes &attrs)
parse transport
void endParseAttributes()
end parse attributes
void parseVTypeDistribution(const SUMOSAXAttributes &attrs)
parse vType distribution
virtual void buildTranship(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const std::string &fromEdgeID, const std::string &toEdgeID, const std::string &toBusStopID, const std::vector< std::string > &edgeIDs, const double speed, const double departPosition, const double arrivalPosition)=0
build tranship
virtual void buildRouteDistribution(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const std::string &id)=0
build route distribution
const std::string myFilename
filename (needed for parsing vTypes)
virtual void buildRide(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const std::string &fromEdgeID, const std::string &toEdgeID, const std::string &toBusStopID, double arrivalPos, const std::vector< std::string > &lines)=0
build ride
void parseStop(const SUMOSAXAttributes &attrs)
parse stop
void parseContainer(const SUMOSAXAttributes &attrs)
parse container
RouteHandler(const std::string &filename, const bool hardFail)
Constructor.
virtual void buildPersonTrip(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const std::string &fromEdgeID, const std::string &toEdgeID, const std::string &fromJunctionID, const std::string &toJunctionID, const std::string &toBusStopID, double arrivalPos, const std::vector< std::string > &types, const std::vector< std::string > &modes)=0
build person trip
virtual void buildVTypeDistribution(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const std::string &id, const std::vector< std::string > &vTypes)=0
build vType distribution
void parsePersonTrip(const SUMOSAXAttributes &attrs)
parse person trip
bool parseStopParameters(SUMOVehicleParameter::Stop &stop, const SUMOSAXAttributes &attrs) const
parse stop parameters
virtual void buildVType(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const SUMOVTypeParameter &vTypeParameter)=0
build vType
void parseRoute(const SUMOSAXAttributes &attrs)
parse route
virtual void buildTrip(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const SUMOVehicleParameter &vehicleParameters, const std::string &fromEdgeID, const std::string &toEdgeID, const std::vector< std::string > &viaIDs)=0
build trip (from-to edges)
virtual void buildRoute(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const std::string &id, SUMOVehicleClass vClass, const std::vector< std::string > &edgeIDs, const RGBColor &color, const int repeat, const SUMOTime cycleTime, const std::map< std::string, std::string > &routeParameters)=0
build route
void parseTrip(const SUMOSAXAttributes &attrs)
parse trip
SUMOTime myFlowEndDefault
The default value for flow ends.
~RouteHandler()
Destructor.
void parseParameters(const SUMOSAXAttributes &attrs)
parse generic parameters
void parseSumoBaseObject(CommonXMLStructure::SumoBaseObject *obj)
parse SumoBaseObject (it's called recursivelly)
virtual void buildEmbeddedRoute(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const std::vector< std::string > &edgeIDs, const RGBColor &color, const int repeat, const SUMOTime cycleTime, const std::map< std::string, std::string > &routeParameters)=0
build embedded route
virtual void buildPersonFlow(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const SUMOVehicleParameter &personFlowParameters)=0
build person flow
void parsePersonFlow(const SUMOSAXAttributes &attrs)
parse person flow
void parseInterval(const SUMOSAXAttributes &attrs)
parse interval
void parseVType(const SUMOSAXAttributes &attrs)
void parseRide(const SUMOSAXAttributes &attrs)
parse ride
bool parseNestedCFM(const SumoXMLTag tag, const SUMOSAXAttributes &attrs)
parse nested CarFollowingModel
virtual void buildStop(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const SUMOVehicleParameter::Stop &stopParameters)=0
build stop
SUMOTime myFlowBeginDefault
The default value for flow begins.
virtual void buildVehicleOverRoute(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const SUMOVehicleParameter &vehicleParameters)=0
build a vehicle over an existent route
void parseVehicle(const SUMOSAXAttributes &attrs)
parse vehicle (including vehicles over routes and vehicles with embedded routes)
virtual void buildContainerFlow(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const SUMOVehicleParameter &containerFlowParameters)=0
build container flow
virtual void buildPerson(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const SUMOVehicleParameter &personParameters)=0
build person
virtual void buildWalk(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const std::string &fromEdgeID, const std::string &toEdgeID, const std::string &fromJunctionID, const std::string &toJunctionID, const std::string &toBusStopID, const std::vector< std::string > &edgeIDs, const std::string &routeID, double arrivalPos)=0
build walk
const bool myHardFail
enable or disable hardFail (stop parsing if parameter aren't correct)
virtual void buildFlow(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const SUMOVehicleParameter &vehicleParameters, const std::string &fromEdgeID, const std::string &toEdgeID, const std::vector< std::string > &viaIDs)=0
build flow (from-to edges)
void parseRouteDistribution(const SUMOSAXAttributes &attrs)
parse route distribution
void parseTranship(const SUMOSAXAttributes &attrs)
parse tranship
Encapsulated SAX-Attributes.
T getOpt(int attr, const char *objectid, bool &ok, T defaultValue, bool report=true) const
Tries to read given attribute assuming it is an int.
const std::vector< std::string > getOptStringVector(int attr, const char *objectid, bool &ok, bool report=true) const
convenience function to avoid the default argument and the template stuff at getOpt<>
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.
virtual std::string getString(int id) const =0
Returns the string-value of the named (by its enum-value) attribute.
SUMOTime getSUMOTimeReporting(int attr, const char *objectid, bool &ok, bool report=true) const
Tries to read given attribute assuming it is a SUMOTime.
Structure representing possible vehicle parameter.
Definition of vehicle stop (position and duration)
SUMOTime started
the time at which this stop was reached
std::string edge
The edge to stop at (used only in NETEDIT)
std::string lane
The lane to stop at.
SUMOTime extension
The maximum time extension for boarding / loading.
bool friendlyPos
enable or disable friendly position (used by NETEDIT)
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
double startPos
The stopping position start.
std::string line
the new line id of the trip within a cyclical public transport route
double posLat
the lateral offset when stopping
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
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.
bool triggered
whether an arriving person lets the vehicle continue
SUMOTime ended
the time at which this stop was ended
double endPos
The stopping position end.
bool parking
whether the vehicle is removed from the net while stopping
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
SUMOTime arrival
The (expected) time at which the vehicle reaches the stop.
SUMOTime duration
The stopping duration.
Structure representing possible vehicle parameter.
std::string id
The vehicle's id.
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 SUMOVehicleClass parseVehicleClass(const SUMOSAXAttributes &attrs, const std::string &id)
Parses the vehicle class.
static SUMOVehicleParameter * parseVehicleAttributes(int element, const SUMOSAXAttributes &attrs, const bool hardFail, const bool optionalID=false, const bool skipDepart=false)
Parses a vehicle's attributes.
static bool isValidParameterKey(const std::string &value)
whether the given string is a valid key for a parameter