SUMO - Simulation of Urban MObility
SUMOVehicleParserHelper Class Reference

Helper methods for parsing vehicle attributes. More...

#include <SUMOVehicleParserHelper.h>

Collaboration diagram for SUMOVehicleParserHelper:
Collaboration graph

Static Public Member Functions

static SUMOVTypeParameterbeginVTypeParsing (const SUMOSAXAttributes &attrs, const std::string &file, const SumoXMLTag defaultCFModel)
 Starts to parse a vehicle type. More...
 
static SUMOVehicleParameterparseFlowAttributes (const SUMOSAXAttributes &attrs, const SUMOTime beginDefault, const SUMOTime endDefault)
 Parses a flow's attributes. More...
 
static SUMOVehicleShape parseGuiShape (const SUMOSAXAttributes &attrs, const std::string &id)
 Parses the vehicle class. More...
 
static void parseJMParams (SUMOVTypeParameter &into, const SUMOSAXAttributes &attrs)
 Parses junction model attributes. More...
 
static void parseLCParams (SUMOVTypeParameter &into, LaneChangeModel model, const SUMOSAXAttributes &attrs)
 Parses lane change model attributes. More...
 
static SUMOVehicleParameterparseVehicleAttributes (const SUMOSAXAttributes &attrs, const bool optionalID=false, const bool skipDepart=false, const bool isPerson=false)
 Parses a vehicle's attributes. More...
 
static SUMOVehicleClass parseVehicleClass (const SUMOSAXAttributes &attrs, const std::string &id)
 Parses the vehicle class. More...
 
static void parseVTypeEmbedded (SUMOVTypeParameter &into, const SumoXMLTag element, const SUMOSAXAttributes &attrs, const bool fromVType=false)
 Parses an element embedded in vtype definition. More...
 
static double parseWalkPos (SumoXMLAttr attr, const std::string &id, double maxPos, const std::string &val, std::mt19937 *rng=0)
 parse departPos or arrivalPos for a walk More...
 
static SUMOTime processActionStepLength (double given)
 Checks and converts given value for the action step length from seconds to miliseconds assuring it being a positive multiple of the simulation step width. More...
 

Private Types

typedef std::map< SumoXMLTag, std::set< SumoXMLAttr > > CFAttrMap
 
typedef std::map< LaneChangeModel, std::set< SumoXMLAttr > > LCAttrMap
 

Static Private Member Functions

static const CFAttrMapgetAllowedCFModelAttrs ()
 
static void parseCommonAttributes (const SUMOSAXAttributes &attrs, SUMOVehicleParameter *ret, std::string element)
 Parses attributes common to vehicles and flows. More...
 

Static Private Attributes

static CFAttrMap allowedCFModelAttrs
 
static std::set< SumoXMLAttrallowedJMAttrs
 
static LCAttrMap allowedLCModelAttrs
 

Detailed Description

Helper methods for parsing vehicle attributes.

This class supports helper methods for parsing a vehicle's attributes.

Definition at line 58 of file SUMOVehicleParserHelper.h.

Member Typedef Documentation

◆ CFAttrMap

typedef std::map<SumoXMLTag, std::set<SumoXMLAttr> > SUMOVehicleParserHelper::CFAttrMap
private

Definition at line 183 of file SUMOVehicleParserHelper.h.

◆ LCAttrMap

typedef std::map<LaneChangeModel, std::set<SumoXMLAttr> > SUMOVehicleParserHelper::LCAttrMap
private

Definition at line 184 of file SUMOVehicleParserHelper.h.

Member Function Documentation

◆ beginVTypeParsing()

SUMOVTypeParameter * SUMOVehicleParserHelper::beginVTypeParsing ( const SUMOSAXAttributes attrs,
const std::string &  file,
const SumoXMLTag  defaultCFModel 
)
static

Starts to parse a vehicle type.

Parameters
[in]attrThe SAX-attributes to get vehicle parameter from
[in]fileThe name of the file being parsed (for resolving paths)
[in]defaultCFModelThe XML tag of the default car following model (SUMO_TAG_NOTHING means no default)
Exceptions
ProcessErrorIf an attribute's value is invalid
See also
SUMOVTypeParameter
Note
: the caller is responsible for deleting the returned pointer

Definition at line 350 of file SUMOVehicleParserHelper.cpp.

References SUMOVTypeParameter::actionStepLength, SUMOVTypeParameter::boardingDuration, SUMOXMLDefinitions::CarFollowModels, SUMOVTypeParameter::cfModel, SUMOVTypeParameter::color, SUMOVTypeParameter::containerCapacity, SUMOVTypeParameter::defaultProbability, SUMOVTypeParameter::emissionClass, SUMOSAXAttributes::get(), StringBijection< T >::get(), PollutantsInterface::getClassByName(), FileHelpers::getConfigurationRelative(), SUMOSAXAttributes::getOpt(), Distribution_Parameterized::getParameter(), SUMOSAXAttributes::getSUMOTimeReporting(), SUMOSAXAttributes::hasAttribute(), SUMOVTypeParameter::height, SUMOVTypeParameter::id, SUMOVTypeParameter::imgFile, SUMOVTypeParameter::impatience, FileHelpers::isAbsolute(), SUMOXMLDefinitions::LaneChangeModels, SUMOVTypeParameter::latAlignment, SUMOXMLDefinitions::LateralAlignments, SUMOVTypeParameter::lcModel, SUMOVTypeParameter::length, SUMOVTypeParameter::loadingDuration, SUMOVTypeParameter::maxSpeed, SUMOVTypeParameter::maxSpeedLat, SUMOVTypeParameter::minGap, SUMOVTypeParameter::minGapLat, SUMOVTypeParameter::osgFile, SUMOVTypeParameter::parametersSet, Distribution_Parameterized::parse(), parseGuiShape(), parseJMParams(), parseLCParams(), parseVehicleClass(), parseVTypeEmbedded(), SUMOVTypeParameter::personCapacity, processActionStepLength(), SUMOVTypeParameter::shape, SUMOVTypeParameter::speedFactor, SUMO_ATTR_ACTIONSTEPLENGTH, SUMO_ATTR_BOARDING_DURATION, SUMO_ATTR_CAR_FOLLOW_MODEL, SUMO_ATTR_COLOR, SUMO_ATTR_CONTAINER_CAPACITY, SUMO_ATTR_EMISSIONCLASS, SUMO_ATTR_GUISHAPE, SUMO_ATTR_HEIGHT, SUMO_ATTR_ID, SUMO_ATTR_IMGFILE, SUMO_ATTR_IMPATIENCE, SUMO_ATTR_LANE_CHANGE_MODEL, SUMO_ATTR_LATALIGNMENT, SUMO_ATTR_LENGTH, SUMO_ATTR_LOADING_DURATION, SUMO_ATTR_MAXSPEED, SUMO_ATTR_MAXSPEED_LAT, SUMO_ATTR_MINGAP, SUMO_ATTR_MINGAP_LAT, SUMO_ATTR_OSGFILE, SUMO_ATTR_PERSON_CAPACITY, SUMO_ATTR_PROB, SUMO_ATTR_SPEEDDEV, SUMO_ATTR_SPEEDFACTOR, SUMO_ATTR_VCLASS, SUMO_ATTR_WIDTH, SVC_PASSENGER, VTYPEPARS_ACTIONSTEPLENGTH_SET, VTYPEPARS_BOARDING_DURATION, VTYPEPARS_CAR_FOLLOW_MODEL, VTYPEPARS_COLOR_SET, VTYPEPARS_CONTAINER_CAPACITY, VTYPEPARS_EMISSIONCLASS_SET, VTYPEPARS_HEIGHT_SET, VTYPEPARS_IMGFILE_SET, VTYPEPARS_IMPATIENCE_SET, VTYPEPARS_LANE_CHANGE_MODEL_SET, VTYPEPARS_LATALIGNMENT_SET, VTYPEPARS_LENGTH_SET, VTYPEPARS_LOADING_DURATION, VTYPEPARS_MAXSPEED_LAT_SET, VTYPEPARS_MAXSPEED_SET, VTYPEPARS_MINGAP_LAT_SET, VTYPEPARS_MINGAP_SET, VTYPEPARS_OSGFILE_SET, VTYPEPARS_PERSON_CAPACITY, VTYPEPARS_PROBABILITY_SET, VTYPEPARS_SHAPE_SET, VTYPEPARS_SPEEDFACTOR_SET, VTYPEPARS_VEHICLECLASS_SET, VTYPEPARS_WIDTH_SET, SUMOVTypeParameter::wasSet(), SUMOVTypeParameter::width, WRITE_ERROR, WRITE_WARNING, and RGBColor::YELLOW.

Referenced by SUMORouteHandler::myStartElement().

◆ getAllowedCFModelAttrs()

◆ parseCommonAttributes()

void SUMOVehicleParserHelper::parseCommonAttributes ( const SUMOSAXAttributes attrs,
SUMOVehicleParameter ret,
std::string  element 
)
staticprivate

Parses attributes common to vehicles and flows.

Parses all attributes stored in "SUMOVehicleParameter".

See also
SUMOVehicleParameter
Parameters
[in]attrThe SAX-attributes to get vehicle parameter from
[out]retThe parameter to parse into
[in]elementThe name of the element (vehicle or flow)
Exceptions
ProcessErrorIf an attribute's value is invalid

Definition at line 223 of file SUMOVehicleParserHelper.cpp.

References SUMOVehicleParameter::arrivalLane, SUMOVehicleParameter::arrivalLaneProcedure, SUMOVehicleParameter::arrivalPos, SUMOVehicleParameter::arrivalPosLat, SUMOVehicleParameter::arrivalPosLatProcedure, SUMOVehicleParameter::arrivalPosProcedure, SUMOVehicleParameter::arrivalSpeed, SUMOVehicleParameter::arrivalSpeedProcedure, SUMOVehicleParameter::color, SUMOVehicleParameter::containerNumber, RGBColor::DEFAULT_COLOR, SUMOVehicleParameter::departLane, SUMOVehicleParameter::departLaneProcedure, SUMOVehicleParameter::departPos, SUMOVehicleParameter::departPosLat, SUMOVehicleParameter::departPosLatProcedure, SUMOVehicleParameter::departPosProcedure, SUMOVehicleParameter::departSpeed, SUMOVehicleParameter::departSpeedProcedure, SUMOVehicleParameter::fromTaz, SUMOSAXAttributes::get(), SUMOSAXAttributes::getOpt(), SUMOSAXAttributes::hasAttribute(), SUMOVehicleParameter::id, SUMOVehicleParameter::line, SUMOVehicleParameter::parametersSet, SUMOVehicleParameter::parseArrivalLane(), SUMOVehicleParameter::parseArrivalPos(), SUMOVehicleParameter::parseArrivalPosLat(), SUMOVehicleParameter::parseArrivalSpeed(), SUMOVehicleParameter::parseDepartLane(), SUMOVehicleParameter::parseDepartPos(), SUMOVehicleParameter::parseDepartPosLat(), SUMOVehicleParameter::parseDepartSpeed(), SUMOVehicleParameter::personNumber, SUMOVehicleParameter::routeid, SUMO_ATTR_ARRIVALLANE, SUMO_ATTR_ARRIVALPOS, SUMO_ATTR_ARRIVALPOS_LAT, SUMO_ATTR_ARRIVALSPEED, SUMO_ATTR_COLOR, SUMO_ATTR_CONTAINER_NUMBER, SUMO_ATTR_DEPARTLANE, SUMO_ATTR_DEPARTPOS, SUMO_ATTR_DEPARTPOS_LAT, SUMO_ATTR_DEPARTSPEED, SUMO_ATTR_FROM_TAZ, SUMO_ATTR_LINE, SUMO_ATTR_PERSON_NUMBER, SUMO_ATTR_REROUTE, SUMO_ATTR_ROUTE, SUMO_ATTR_TO_TAZ, SUMO_ATTR_TYPE, SUMOVehicleParameter::toTaz, VEHPARS_ARRIVALLANE_SET, VEHPARS_ARRIVALPOS_SET, VEHPARS_ARRIVALPOSLAT_SET, VEHPARS_ARRIVALSPEED_SET, VEHPARS_COLOR_SET, VEHPARS_CONTAINER_NUMBER_SET, VEHPARS_DEPARTLANE_SET, VEHPARS_DEPARTPOS_SET, VEHPARS_DEPARTPOSLAT_SET, VEHPARS_DEPARTSPEED_SET, VEHPARS_FORCE_REROUTE, VEHPARS_FROM_TAZ_SET, VEHPARS_LINE_SET, VEHPARS_PERSON_NUMBER_SET, VEHPARS_ROUTE_SET, VEHPARS_TO_TAZ_SET, VEHPARS_VTYPE_SET, and SUMOVehicleParameter::vtypeid.

Referenced by parseFlowAttributes(), and parseVehicleAttributes().

◆ parseFlowAttributes()

SUMOVehicleParameter * SUMOVehicleParserHelper::parseFlowAttributes ( const SUMOSAXAttributes attrs,
const SUMOTime  beginDefault,
const SUMOTime  endDefault 
)
static

Parses a flow's attributes.

Parses all attributes stored in "SUMOVehicleParameter".

See also
SUMOVehicleParameter
Parameters
[in]attrThe SAX-attributes to get vehicle parameter from
Returns
The parsed attribute structure if no error occured, 0 otherwise
Exceptions
ProcessErrorIf an attribute's value is invalid
Note
: the caller is responsible for deleting the returned pointer

Definition at line 58 of file SUMOVehicleParserHelper.cpp.

References SUMOSAXAttributes::get(), SUMOSAXAttributes::getName(), SUMOSAXAttributes::getSUMOTimeReporting(), SUMOSAXAttributes::hasAttribute(), parseCommonAttributes(), SUMO_ATTR_BEGIN, SUMO_ATTR_END, SUMO_ATTR_ID, SUMO_ATTR_NUMBER, SUMO_ATTR_PERIOD, SUMO_ATTR_PROB, SUMO_ATTR_VEHSPERHOUR, SUMOTime_MAX, TIME2STEPS, VEHPARS_PERIODFREQ_SET, and WRITE_WARNING.

Referenced by SUMORouteHandler::myStartElement().

◆ parseGuiShape()

SUMOVehicleShape SUMOVehicleParserHelper::parseGuiShape ( const SUMOSAXAttributes attrs,
const std::string &  id 
)
static

Parses the vehicle class.

When given, the vehicle class is parsed using getVehicleShapeID. Exceptions occuring within this process are catched and reported.

If no vehicle class is available in the attributes, the default class (SVS_UNKNOWN) is returned.

Parameters
[in]attrsThe attributes to read the class from
[in]idThe id of the parsed element, for error message generation
Returns
The parsed vehicle shape
See also
SUMOVehicleShape
Todo:
Recheck how errors are handled and what happens if they occure

Definition at line 743 of file SUMOVehicleParserHelper.cpp.

References SUMOSAXAttributes::getObjectType(), SUMOSAXAttributes::getOpt(), SUMO_ATTR_GUISHAPE, SumoVehicleShapeStrings, SVS_UNKNOWN, WRITE_ERROR, and WRITE_WARNING.

Referenced by beginVTypeParsing().

◆ parseJMParams()

◆ parseLCParams()

◆ parseVehicleAttributes()

SUMOVehicleParameter * SUMOVehicleParserHelper::parseVehicleAttributes ( const SUMOSAXAttributes attrs,
const bool  optionalID = false,
const bool  skipDepart = false,
const bool  isPerson = false 
)
static

Parses a vehicle's attributes.

Parses all attributes stored in "SUMOVehicleParameter".

See also
SUMOVehicleParameter
Parameters
[in]attrThe SAX-attributes to get vehicle parameter from
[in]optionalIDWhether the id shall be skipped
[in]skipDepartWhether parsing the departure time shall be skipped
[in]isPersonWhether a person is parsed
Returns
The parsed attribute structure if no error occured, 0 otherwise
Exceptions
ProcessErrorIf an attribute's value is invalid
Note
: the caller is responsible for deleting the returned pointer

Definition at line 192 of file SUMOVehicleParserHelper.cpp.

References DEFAULT_PEDTYPE_ID, SUMOSAXAttributes::get(), SUMOSAXAttributes::getOpt(), parseCommonAttributes(), SUMOVehicleParameter::parseDepart(), SUMO_ATTR_DEPART, and SUMO_ATTR_ID.

Referenced by ROMARouteHandler::myStartElement(), SUMORouteHandler::myStartElement(), and MSCalibrator::myStartElement().

◆ parseVehicleClass()

SUMOVehicleClass SUMOVehicleParserHelper::parseVehicleClass ( const SUMOSAXAttributes attrs,
const std::string &  id 
)
static

Parses the vehicle class.

When given, the vehicle class is parsed using getVehicleClassID. Exceptions occuring within this process are catched and reported.

If no vehicle class is available in the attributes, the default class (SVC_IGNORING) is returned.

Parameters
[in]attrsThe attributes to read the class from
[in]idThe id of the parsed element, for error message generation
Returns
The parsed vehicle class
See also
SUMOVehicleClass
Todo:
Recheck how errors are handled and what happens if they occure

Definition at line 720 of file SUMOVehicleParserHelper.cpp.

References SUMOSAXAttributes::getObjectType(), SUMOSAXAttributes::getOpt(), getVehicleClassID(), SUMO_ATTR_VCLASS, SumoVehicleClassStrings, SVC_IGNORING, WRITE_ERROR, and WRITE_WARNING.

Referenced by beginVTypeParsing().

◆ parseVTypeEmbedded()

◆ parseWalkPos()

double SUMOVehicleParserHelper::parseWalkPos ( SumoXMLAttr  attr,
const std::string &  id,
double  maxPos,
const std::string &  val,
std::mt19937 *  rng = 0 
)
static

◆ processActionStepLength()

SUMOTime SUMOVehicleParserHelper::processActionStepLength ( double  given)
static

Checks and converts given value for the action step length from seconds to miliseconds assuring it being a positive multiple of the simulation step width.

Parameters
[in]givenThe value parsed from the configuration (seconds).
Returns
The milisecond value rounded to the next positive multiple of the simulation step length.

Definition at line 779 of file SUMOVehicleParserHelper.cpp.

References DELTA_T, MAX2(), NUMERICAL_EPS, STEPS2TIME, TIME2STEPS, and WRITE_WARNING.

Referenced by beginVTypeParsing(), libsumo::VehicleType::setActionStepLength(), libsumo::Vehicle::setActionStepLength(), and MSFrame::setMSGlobals().

Field Documentation

◆ allowedCFModelAttrs

SUMOVehicleParserHelper::CFAttrMap SUMOVehicleParserHelper::allowedCFModelAttrs
staticprivate

Definition at line 190 of file SUMOVehicleParserHelper.h.

Referenced by getAllowedCFModelAttrs().

◆ allowedJMAttrs

std::set< SumoXMLAttr > SUMOVehicleParserHelper::allowedJMAttrs
staticprivate

Definition at line 194 of file SUMOVehicleParserHelper.h.

Referenced by parseJMParams().

◆ allowedLCModelAttrs

SUMOVehicleParserHelper::LCAttrMap SUMOVehicleParserHelper::allowedLCModelAttrs
staticprivate

Definition at line 192 of file SUMOVehicleParserHelper.h.

Referenced by parseLCParams().


The documentation for this class was generated from the following files: