Skip to content

Commit

Permalink
parsing mass attribute #13056
Browse files Browse the repository at this point in the history
  • Loading branch information
behrisch committed Jan 29, 2024
1 parent d68d591 commit 83dc638
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions data/xsd/routeTypes.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
<xsd:attribute name="guiShape" type="xsd:string"/>
<xsd:attribute name="width" type="positiveFloatType"/>
<xsd:attribute name="height" type="positiveFloatType"/>
<xsd:attribute name="mass" type="positiveFloatType"/>
<xsd:attribute name="color" type="colorType"/>
<xsd:attribute name="accel" type="positiveFloatType"/>
<xsd:attribute name="decel" type="positiveFloatType"/>
Expand Down
12 changes: 12 additions & 0 deletions src/utils/vehicle/SUMOVehicleParserHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -841,6 +841,18 @@ SUMOVehicleParserHelper::beginVTypeParsing(const SUMOSAXAttributes& attrs, const
return handleVehicleTypeError(hardFail, vType, toString(SUMO_ATTR_EMISSIONCLASS) + " with name '" + parsedEmissionClass + "' doesn't exist.");
}
}
if (attrs.hasAttribute(SUMO_ATTR_MASS)) {
bool ok = true;
const double mass = attrs.get<double>(SUMO_ATTR_MASS, vType->id.c_str(), ok);
if (!ok) {
return handleVehicleTypeError(hardFail, vType);
} else if (mass < 0) {
return handleVehicleTypeError(hardFail, vType, toString(SUMO_ATTR_MASS) + " must be equal or greater than 0");
} else {
vType->mass = mass;
vType->parametersSet |= VTYPEPARS_MASS_SET;
}
}
if (attrs.hasAttribute(SUMO_ATTR_IMPATIENCE)) {
bool ok = true;
const std::string impatienceStr = attrs.get<std::string>(SUMO_ATTR_IMPATIENCE, vType->id.c_str(), ok);
Expand Down

0 comments on commit 83dc638

Please sign in to comment.