39 myAttributeName(attributeName),
40 myAmEdgeBased(edgeBased),
41 myDestination(destination),
45 myHadNonNumeric(false)
123 if (definition->myAmEdgeBased) {
126 definition->myAggValue = attrs.
getFloat(definition->myAttributeName);
127 definition->myNoLanes = 1;
128 definition->myHadAttribute =
true;
132 if (!definition->myHadNonNumeric) {
134 definition->myHadNonNumeric =
true;
135 WRITE_ERRORF(
TL(
"The value '%' of attribute '%' should be numeric in edge '%' at time step %."),
136 attrs.
getStringSecure(definition->myAttributeName,
""), definition->myAttributeName,
141 definition->myHadAttribute =
false;
144 definition->myAggValue = 0;
145 definition->myNoLanes = 0;
151 if (!definition->myAmEdgeBased) {
153 definition->myAggValue += attrs.
getFloat(definition->myAttributeName);
154 definition->myNoLanes++;
155 definition->myHadAttribute =
true;
159 if (!definition->myHadNonNumeric) {
161 definition->myHadNonNumeric =
true;
162 WRITE_ERRORF(
TL(
"The value '%' of attribute '%' should be numeric in edge '%' at time step %."),
163 attrs.
getStringSecure(definition->myAttributeName,
""), definition->myAttributeName,
178 const std::string to = attrs.
get<std::string>(
SUMO_ATTR_TO,
nullptr, ok);
181 ret->myDestination.addEdgeRelWeight(from, to,
182 attrs.
getFloat(ret->myAttributeName),
194 const std::string to = attrs.
get<std::string>(
SUMO_ATTR_TO,
nullptr, ok);
197 ret->myDestination.addTazRelWeight(
myCurrentID, from, to,
198 attrs.
getFloat(ret->myAttributeName),
210 if (definition->myHadAttribute) {
212 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.