39 myAttributeName(attributeName),
40 myAmEdgeBased(edgeBased),
41 myDestination(destination),
45 myHadNonNumeric(false)
122 if (definition->myAmEdgeBased) {
125 definition->myAggValue = attrs.
getFloat(definition->myAttributeName);
126 definition->myNoLanes = 1;
127 definition->myHadAttribute =
true;
131 if (!definition->myHadNonNumeric) {
133 definition->myHadNonNumeric =
true;
134 WRITE_ERRORF(
TL(
"The value '%' of attribute '%' should be numeric in edge '%' at time step %."),
135 attrs.
getStringSecure(definition->myAttributeName,
""), definition->myAttributeName,
140 definition->myHadAttribute =
false;
143 definition->myAggValue = 0;
144 definition->myNoLanes = 0;
150 if (!definition->myAmEdgeBased) {
152 definition->myAggValue += attrs.
getFloat(definition->myAttributeName);
153 definition->myNoLanes++;
154 definition->myHadAttribute =
true;
158 if (!definition->myHadNonNumeric) {
160 definition->myHadNonNumeric =
true;
161 WRITE_ERRORF(
TL(
"The value '%' of attribute '%' should be numeric in edge '%' at time step %."),
162 attrs.
getStringSecure(definition->myAttributeName,
""), definition->myAttributeName,
177 const std::string to = attrs.
get<std::string>(
SUMO_ATTR_TO,
nullptr, ok);
180 ret->myDestination.addEdgeRelWeight(from, to,
181 attrs.
getFloat(ret->myAttributeName),
193 const std::string to = attrs.
get<std::string>(
SUMO_ATTR_TO,
nullptr, ok);
196 ret->myDestination.addTazRelWeight(
myCurrentID, from, to,
197 attrs.
getFloat(ret->myAttributeName),
209 if (definition->myHadAttribute) {
211 definition->myAggValue / (
double)definition->myNoLanes,
#define WRITE_ERRORF(...)
std::string time2string(SUMOTime t, bool humanReadable)
convert SUMOTime to string (independently of global format setting)
@ SUMO_TAG_INTERVAL
an aggreagated-output interval
@ SUMO_TAG_EDGEREL
a relation between two edges
@ SUMO_TAG_LANE
begin/end of the description of a single lane
@ SUMO_TAG_TAZREL
a relation between two TAZs
@ SUMO_TAG_EDGE
begin/end of the description of an edge
@ SUMO_ATTR_BEGIN
weights: time range begin
@ SUMO_ATTR_END
weights: time range end
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Interface for a class which obtains read weights for named edges.
Complete definition about what shall be retrieved and where to store it.
ToRetrieveDefinition(const std::string &attributeName, bool edgeBased, EdgeFloatTimeLineRetriever &destination)
Constructor.
~ToRetrieveDefinition()
Destructor.
double myCurrentTimeEnd
the end of the time period that is currently processed
double myCurrentTimeBeg
the begin of the time period that is currently processed
void myEndElement(int elemente)
Called when a closing tag occurs.
void tryParseTazRel(const SUMOSAXAttributes &attrs)
Parses the data of an tazRelation for the previously read times.
~SAXWeightsHandler()
Destructor.
void tryParseEdgeRel(const SUMOSAXAttributes &attrs)
Parses the data of an edgeRelation for the previously read times.
void myStartElement(int element, const SUMOSAXAttributes &attrs)
Called on the opening of a tag;.
void tryParse(const SUMOSAXAttributes &attrs, bool isEdge)
Parses the data of an edge or lane for the previously read times.
SAXWeightsHandler(const std::vector< ToRetrieveDefinition * > &defs, const std::string &file)
Constructor.
std::string myCurrentEdgeID
the edge which is currently being processed
std::string myCurrentID
the id of the interval being parsed
std::vector< ToRetrieveDefinition * > myDefinitions
List of definitions what shall be read and whereto stored while parsing the file.
Encapsulated SAX-Attributes.
T getOpt(int attr, const char *objectid, bool &ok, T defaultValue=T(), bool report=true) const
Tries to read given attribute assuming it is an int.
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.
double getFloat(int id) const
Returns the double-value of the named (by its enum-value) attribute.
SAX-handler base for SUMO-files.