本文整理汇总了C++中SUMOSAXAttributes::getOptStringReporting方法的典型用法代码示例。如果您正苦于以下问题:C++ SUMOSAXAttributes::getOptStringReporting方法的具体用法?C++ SUMOSAXAttributes::getOptStringReporting怎么用?C++ SUMOSAXAttributes::getOptStringReporting使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SUMOSAXAttributes
的用法示例。
在下文中一共展示了SUMOSAXAttributes::getOptStringReporting方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: pos
void
PCLoaderXML::myStartElement(int element,
const SUMOSAXAttributes& attrs) {
if (element != SUMO_TAG_POI && element != SUMO_TAG_POLY) {
return;
}
if (element == SUMO_TAG_POI) {
bool ok = true;
// get the id, report an error if not given or empty...
std::string id = attrs.getStringReporting(SUMO_ATTR_ID, 0, ok);
SUMOReal x = attrs.getSUMORealReporting(SUMO_ATTR_X, id.c_str(), ok);
SUMOReal y = attrs.getSUMORealReporting(SUMO_ATTR_Y, id.c_str(), ok);
std::string type = attrs.getOptStringReporting(SUMO_ATTR_TYPE, id.c_str(), ok, "");
if (!ok) {
return;
}
Position pos(x, y);
if (!GeoConvHelper::getProcessing().x2cartesian(pos)) {
WRITE_WARNING("Unable to project coordinates for POI '" + id + "'.");
}
// patch the values
bool discard = myOptions.getBool("discard");
int layer = myOptions.getInt("layer");
RGBColor color;
if (myTypeMap.has(type)) {
const PCTypeMap::TypeDef& def = myTypeMap.get(type);
id = def.prefix + id;
type = def.id;
color = RGBColor::parseColor(def.color);
discard = def.discard;
layer = def.layer;
} else {
id = myOptions.getString("prefix") + id;
type = myOptions.getString("type");
color = RGBColor::parseColor(myOptions.getString("color"));
}
if (!discard) {
bool ignorePrunning = false;
if (OptionsCont::getOptions().isInStringVector("prune.keep-list", id)) {
ignorePrunning = true;
}
PointOfInterest* poi = new PointOfInterest(id, type, pos, color);
if (!myCont.insert(id, poi, layer, ignorePrunning)) {
WRITE_ERROR("POI '" + id + "' could not been added.");
delete poi;
}
}
}
if (element == SUMO_TAG_POLY) {
bool discard = myOptions.getBool("discard");
int layer = myOptions.getInt("layer");
bool ok = true;
std::string id = attrs.getOptStringReporting(SUMO_ATTR_ID, myCurrentID.c_str(), ok, "");
std::string type = attrs.getOptStringReporting(SUMO_ATTR_TYPE, myCurrentID.c_str(), ok, "");
if (!ok) {
return;
}
RGBColor color;
if (myTypeMap.has(type)) {
const PCTypeMap::TypeDef& def = myTypeMap.get(type);
id = def.prefix + id;
type = def.id;
color = RGBColor::parseColor(def.color);
discard = def.discard;
layer = def.layer;
} else {
id = myOptions.getString("prefix") + id;
type = myOptions.getString("type");
color = RGBColor::parseColor(myOptions.getString("color"));
}
if (!discard) {
bool ignorePrunning = false;
if (OptionsCont::getOptions().isInStringVector("prune.keep-list", id)) {
ignorePrunning = true;
}
myCurrentID = id;
myCurrentType = type;
myCurrentColor = color;
myCurrentIgnorePrunning = ignorePrunning;
myCurrentLayer = layer;
if (attrs.hasAttribute(SUMO_ATTR_SHAPE)) {
// @deprecated At some time, no shape definition using characters will be allowed
myCharacters(element, attrs.getStringReporting(SUMO_ATTR_SHAPE, myCurrentID.c_str(), ok));
}
}
}
}
示例2: ProcessError
void
MSRouteHandler::addStop(const SUMOSAXAttributes& attrs) {
bool ok = true;
std::string errorSuffix;
if (myActiveRouteID != "") {
errorSuffix = " in route '" + myActiveRouteID + "'.";
} else if (myActivePlan) {
errorSuffix = " in person '" + myVehicleParameter->id + "'.";
} else {
errorSuffix = " in vehicle '" + myVehicleParameter->id + "'.";
}
SUMOVehicleParameter::Stop stop;
// try to parse the assigned bus stop
if (attrs.hasAttribute(SUMO_ATTR_BUS_STOP__DEPRECATED)) {
stop.busstop = attrs.getStringReporting(SUMO_ATTR_BUS_STOP__DEPRECATED, 0, ok);
if (!myHaveWarnedAboutDeprecatedBusStop) {
myHaveWarnedAboutDeprecatedBusStop = true;
WRITE_WARNING("'bus_stop' is deprecated, please use 'busStop' instead.");
}
} else {
stop.busstop = attrs.getOptStringReporting(SUMO_ATTR_BUS_STOP, 0, ok, "");
}
if (stop.busstop != "") {
// ok, we have obviously a bus stop
MSBusStop* bs = MSNet::getInstance()->getBusStop(stop.busstop);
if (bs != 0) {
const MSLane& l = bs->getLane();
stop.lane = l.getID();
stop.endPos = bs->getEndLanePosition();
stop.startPos = bs->getBeginLanePosition();
} else {
WRITE_ERROR("The bus stop '" + stop.busstop + "' is not known" + errorSuffix);
return;
}
} else {
// no, the lane and the position should be given
// get the lane
stop.lane = attrs.getOptStringReporting(SUMO_ATTR_LANE, 0, ok, "");
if (ok && stop.lane != "") {
if (MSLane::dictionary(stop.lane) == 0) {
WRITE_ERROR("The lane '" + stop.lane + "' for a stop is not known" + errorSuffix);
return;
}
} else {
WRITE_ERROR("A stop must be placed on a bus stop or a lane" + errorSuffix);
return;
}
if (myActivePlan &&
!myActivePlan->empty() &&
&myActivePlan->back()->getDestination() != &MSLane::dictionary(stop.lane)->getEdge()) {
throw ProcessError("Disconnected plan for person '" + myVehicleParameter->id + "' (" + MSLane::dictionary(stop.lane)->getEdge().getID() + "!=" + myActivePlan->back()->getDestination().getID() + ").");
}
stop.endPos = attrs.getOptSUMORealReporting(SUMO_ATTR_ENDPOS, 0, ok, MSLane::dictionary(stop.lane)->getLength());
if (attrs.hasAttribute(SUMO_ATTR_POSITION)) {
WRITE_WARNING("Deprecated attribute 'pos' in description of stop" + errorSuffix);
stop.endPos = attrs.getOptSUMORealReporting(SUMO_ATTR_POSITION, 0, ok, stop.endPos);
}
stop.startPos = attrs.getOptSUMORealReporting(SUMO_ATTR_STARTPOS, 0, ok, stop.endPos - 2 * POSITION_EPS);
if (attrs.hasAttribute(SUMO_ATTR_FRIENDLY_POS__DEPRECATED) && !myHaveWarnedAboutDeprecatedFriendlyPos) {
myHaveWarnedAboutDeprecatedFriendlyPos = true;
WRITE_WARNING("'" + toString(SUMO_ATTR_FRIENDLY_POS__DEPRECATED) + "' is deprecated, use '" + toString(SUMO_ATTR_FRIENDLY_POS) + "' instead.");
}
bool friendlyPos = attrs.hasAttribute(SUMO_ATTR_FRIENDLY_POS__DEPRECATED)
? attrs.getOptBoolReporting(SUMO_ATTR_FRIENDLY_POS__DEPRECATED, 0, ok, false)
: attrs.getOptBoolReporting(SUMO_ATTR_FRIENDLY_POS, 0, ok, false);
if (!ok || !checkStopPos(stop.startPos, stop.endPos, MSLane::dictionary(stop.lane)->getLength(), POSITION_EPS, friendlyPos)) {
WRITE_ERROR("Invalid start or end position for stop" + errorSuffix);
return;
}
}
// get the standing duration
if (!attrs.hasAttribute(SUMO_ATTR_DURATION) && !attrs.hasAttribute(SUMO_ATTR_UNTIL)) {
stop.triggered = attrs.getOptBoolReporting(SUMO_ATTR_TRIGGERED, 0, ok, true);
stop.duration = -1;
stop.until = -1;
} else {
stop.duration = attrs.getOptSUMOTimeReporting(SUMO_ATTR_DURATION, 0, ok, -1);
stop.until = attrs.getOptSUMOTimeReporting(SUMO_ATTR_UNTIL, 0, ok, -1);
if (!ok || (stop.duration < 0 && stop.until < 0)) {
WRITE_ERROR("Invalid duration or end time is given for a stop" + errorSuffix);
return;
}
stop.triggered = attrs.getOptBoolReporting(SUMO_ATTR_TRIGGERED, 0, ok, false);
}
stop.parking = attrs.getOptBoolReporting(SUMO_ATTR_PARKING, 0, ok, stop.triggered);
if (!ok) {
WRITE_ERROR("Invalid bool for 'triggered' or 'parking' for stop" + errorSuffix);
return;
}
const std::string idx = attrs.getOptStringReporting(SUMO_ATTR_INDEX, 0, ok, "end");
if (idx == "end") {
stop.index = STOP_INDEX_END;
} else if (idx == "fit") {
stop.index = STOP_INDEX_FIT;
} else {
stop.index = attrs.getIntReporting(SUMO_ATTR_INDEX, 0, ok);
if (!ok || stop.index < 0) {
WRITE_ERROR("Invalid 'index' for stop" + errorSuffix);
return;
//.........这里部分代码省略.........
示例3: pos
void
PCLoaderXML::myStartElement(int element,
const SUMOSAXAttributes& attrs) {
if (element != SUMO_TAG_POI && element != SUMO_TAG_POLY) {
return;
}
if (element == SUMO_TAG_POI) {
bool ok = true;
// get the id, report an error if not given or empty...
std::string id = attrs.getStringReporting(SUMO_ATTR_ID, 0, ok);
SUMOReal x = attrs.getSUMORealReporting(SUMO_ATTR_X, id.c_str(), ok);
SUMOReal y = attrs.getSUMORealReporting(SUMO_ATTR_Y, id.c_str(), ok);
std::string type = attrs.getOptStringReporting(SUMO_ATTR_TYPE, id.c_str(), ok, myOptions.getString("type"));
if (!ok) {
return;
}
Position pos(x, y);
if (!GeoConvHelper::getProcessing().x2cartesian(pos)) {
WRITE_WARNING("Unable to project coordinates for POI '" + id + "'.");
}
// patch the values
bool discard = myOptions.getBool("discard");
SUMOReal layer = (SUMOReal)myOptions.getInt("layer");
RGBColor color;
if (myTypeMap.has(type)) {
const PCTypeMap::TypeDef& def = myTypeMap.get(type);
id = def.prefix + id;
type = def.id;
color = RGBColor::parseColor(def.color);
discard = def.discard;
layer = (SUMOReal)def.layer;
} else {
id = myOptions.getString("prefix") + id;
color = RGBColor::parseColor(myOptions.getString("color"));
}
layer = attrs.getOptSUMORealReporting(SUMO_ATTR_LAYER, id.c_str(), ok, layer);
if (attrs.hasAttribute(SUMO_ATTR_COLOR)) {
color = attrs.getColorReporting(id.c_str(), ok);
}
SUMOReal angle = attrs.getOptSUMORealReporting(SUMO_ATTR_ANGLE, id.c_str(), ok, Shape::DEFAULT_ANGLE);
std::string imgFile = attrs.getOptStringReporting(SUMO_ATTR_IMGFILE, id.c_str(), ok, Shape::DEFAULT_IMG_FILE);
if (imgFile != "" && !FileHelpers::isAbsolute(imgFile)) {
imgFile = FileHelpers::getConfigurationRelative(getFileName(), imgFile);
}
SUMOReal imgWidth = attrs.getOptSUMORealReporting(SUMO_ATTR_WIDTH, id.c_str(), ok, Shape::DEFAULT_IMG_WIDTH);
SUMOReal imgHeight = attrs.getOptSUMORealReporting(SUMO_ATTR_HEIGHT, id.c_str(), ok, Shape::DEFAULT_IMG_HEIGHT);
if (!ok) {
return;
}
if (!discard) {
bool ignorePrunning = false;
if (OptionsCont::getOptions().isInStringVector("prune.keep-list", id)) {
ignorePrunning = true;
}
PointOfInterest* poi = new PointOfInterest(id, type, color, pos, layer, angle, imgFile, imgWidth, imgHeight);
if (!myCont.insert(id, poi, (int)layer, ignorePrunning)) {
WRITE_ERROR("POI '" + id + "' could not be added.");
delete poi;
}
}
}
if (element == SUMO_TAG_POLY) {
bool discard = myOptions.getBool("discard");
SUMOReal layer = (SUMOReal)myOptions.getInt("layer");
bool ok = true;
std::string id = attrs.getOptStringReporting(SUMO_ATTR_ID, myCurrentID.c_str(), ok, "");
std::string type = attrs.getOptStringReporting(SUMO_ATTR_TYPE, myCurrentID.c_str(), ok, myOptions.getString("type"));
if (!ok) {
return;
}
RGBColor color;
if (myTypeMap.has(type)) {
const PCTypeMap::TypeDef& def = myTypeMap.get(type);
id = def.prefix + id;
type = def.id;
color = RGBColor::parseColor(def.color);
discard = def.discard;
layer = (SUMOReal)def.layer;
} else {
id = myOptions.getString("prefix") + id;
color = RGBColor::parseColor(myOptions.getString("color"));
}
layer = attrs.getOptSUMORealReporting(SUMO_ATTR_LAYER, id.c_str(), ok, layer);
if (attrs.hasAttribute(SUMO_ATTR_COLOR)) {
color = attrs.getColorReporting(id.c_str(), ok);
}
SUMOReal angle = attrs.getOptSUMORealReporting(SUMO_ATTR_ANGLE, id.c_str(), ok, Shape::DEFAULT_ANGLE);
std::string imgFile = attrs.getOptStringReporting(SUMO_ATTR_IMGFILE, id.c_str(), ok, Shape::DEFAULT_IMG_FILE);
if (imgFile != "" && !FileHelpers::isAbsolute(imgFile)) {
imgFile = FileHelpers::getConfigurationRelative(getFileName(), imgFile);
}
bool fill = attrs.getOptBoolReporting(SUMO_ATTR_FILL, id.c_str(), ok, false);
if (!ok) {
return;
}
if (!discard) {
bool ignorePrunning = false;
if (OptionsCont::getOptions().isInStringVector("prune.keep-list", id)) {
ignorePrunning = true;
}
//.........这里部分代码省略.........
示例4: PositionVector
void
NIXMLEdgesHandler::addEdge(const SUMOSAXAttributes& attrs) {
myIsUpdate = false;
bool ok = true;
// initialise the edge
myCurrentEdge = 0;
mySplits.clear();
// get the id, report an error if not given or empty...
myCurrentID = attrs.getStringReporting(SUMO_ATTR_ID, 0, ok);
if (!ok) {
return;
}
myCurrentEdge = myEdgeCont.retrieve(myCurrentID);
// check deprecated (unused) attributes
// use default values, first
myCurrentSpeed = myTypeCont.getSpeed("");
myCurrentPriority = myTypeCont.getPriority("");
myCurrentLaneNo = myTypeCont.getNumLanes("");
myPermissions = myTypeCont.getPermissions("");
myCurrentWidth = myTypeCont.getWidth("");
myCurrentOffset = NBEdge::UNSPECIFIED_OFFSET;
myCurrentType = "";
myShape = PositionVector();
myLanesSpread = LANESPREAD_RIGHT;
myLength = NBEdge::UNSPECIFIED_LOADED_LENGTH;
myCurrentStreetName = "";
myReinitKeepEdgeShape = false;
// check whether a type's values shall be used
if (attrs.hasAttribute(SUMO_ATTR_TYPE)) {
myCurrentType = attrs.getStringReporting(SUMO_ATTR_TYPE, myCurrentID.c_str(), ok);
if (!ok) {
return;
}
if (!myTypeCont.knows(myCurrentType)) {
WRITE_ERROR("Type '" + myCurrentType + "' used by edge '" + myCurrentID + "' was not defined.");
return;
}
myCurrentSpeed = myTypeCont.getSpeed(myCurrentType);
myCurrentPriority = myTypeCont.getPriority(myCurrentType);
myCurrentLaneNo = myTypeCont.getNumLanes(myCurrentType);
myPermissions = myTypeCont.getPermissions(myCurrentType);
myCurrentWidth = myTypeCont.getWidth(myCurrentType);
}
// use values from the edge to overwrite if existing, then
if (myCurrentEdge != 0) {
myIsUpdate = true;
if (!myHaveReportedAboutOverwriting) {
WRITE_MESSAGE("Duplicate edge id occured ('" + myCurrentID + "'); assuming overwriting is wished.");
myHaveReportedAboutOverwriting = true;
}
if (attrs.getOptBoolReporting(SUMO_ATTR_REMOVE, myCurrentID.c_str(), ok, false)) {
myEdgeCont.erase(myDistrictCont, myCurrentEdge);
myCurrentEdge = 0;
return;
}
myCurrentSpeed = myCurrentEdge->getSpeed();
myCurrentPriority = myCurrentEdge->getPriority();
myCurrentLaneNo = myCurrentEdge->getNumLanes();
myCurrentType = myCurrentEdge->getTypeID();
myPermissions = myCurrentEdge->getPermissions();
if (!myCurrentEdge->hasDefaultGeometry()) {
myShape = myCurrentEdge->getGeometry();
myReinitKeepEdgeShape = true;
}
myCurrentWidth = myCurrentEdge->getWidth();
myCurrentOffset = myCurrentEdge->getOffset();
myLanesSpread = myCurrentEdge->getLaneSpreadFunction();
if (myCurrentEdge->hasLoadedLength()) {
myLength = myCurrentEdge->getLoadedLength();
}
myCurrentStreetName = myCurrentEdge->getStreetName();
}
// speed, priority and the number of lanes have now default values;
// try to read the real values from the file
if (attrs.hasAttribute(SUMO_ATTR_SPEED)) {
myCurrentSpeed = attrs.getSUMORealReporting(SUMO_ATTR_SPEED, myCurrentID.c_str(), ok);
}
if (myOptions.getBool("speed-in-kmh")) {
myCurrentSpeed = myCurrentSpeed / (SUMOReal) 3.6;
}
// try to get the number of lanes
if (attrs.hasAttribute(SUMO_ATTR_NUMLANES)) {
myCurrentLaneNo = attrs.getIntReporting(SUMO_ATTR_NUMLANES, myCurrentID.c_str(), ok);
}
// try to get the priority
if (attrs.hasAttribute(SUMO_ATTR_PRIORITY)) {
myCurrentPriority = attrs.getIntReporting(SUMO_ATTR_PRIORITY, myCurrentID.c_str(), ok);
}
// try to get the width
if (attrs.hasAttribute(SUMO_ATTR_WIDTH)) {
myCurrentWidth = attrs.getSUMORealReporting(SUMO_ATTR_WIDTH, myCurrentID.c_str(), ok);
}
// try to get the width
if (attrs.hasAttribute(SUMO_ATTR_ENDOFFSET)) {
myCurrentOffset = attrs.getSUMORealReporting(SUMO_ATTR_ENDOFFSET, myCurrentID.c_str(), ok);
}
// try to get the street name
myCurrentStreetName = attrs.getOptStringReporting(SUMO_ATTR_NAME, myCurrentID.c_str(), ok, myCurrentStreetName);
// try to get the allowed/disallowed classes
//.........这里部分代码省略.........
示例5: throw
void
NIXMLEdgesHandler::myStartElement(SumoXMLTag element,
const SUMOSAXAttributes &attrs) throw(ProcessError) {
if (element==SUMO_TAG_EDGE) {
myIsUpdate = false;
bool ok = true;
// initialise the edge
myCurrentEdge = 0;
mySplits.clear();
// get the id, report an error if not given or empty...
if (!attrs.setIDFromAttributes("edge", myCurrentID)) {
return;
}
myCurrentEdge = myEdgeCont.retrieve(myCurrentID);
// check deprecated (unused) attributes
if (!myHaveReportedAboutFunctionDeprecation&&attrs.hasAttribute(SUMO_ATTR_FUNCTION)) {
MsgHandler::getWarningInstance()->inform("While parsing edge '" + myCurrentID + "': 'function' is deprecated.\n All occurences are ignored.");
myHaveReportedAboutFunctionDeprecation = true;
}
// use default values, first
myCurrentSpeed = myTypeCont.getDefaultSpeed();
myCurrentPriority = myTypeCont.getDefaultPriority();
myCurrentLaneNo = myTypeCont.getDefaultNoLanes();
// use values from the edge to overwrite if existing, then
if (myCurrentEdge!=0) {
myIsUpdate = true;
if (!myHaveReportedAboutOverwriting) {
MsgHandler::getMessageInstance()->inform("Duplicate edge id occured ('" + myCurrentID + "'); assuming overwriting is wished.");
myHaveReportedAboutOverwriting = true;
}
myCurrentSpeed = myCurrentEdge->getSpeed();
myCurrentPriority = myCurrentEdge->getPriority();
myCurrentLaneNo = myCurrentEdge->getNoLanes();
myCurrentType = myCurrentEdge->getTypeID();
}
// check whether a type's values shall be used
myCurrentType = "";
if (attrs.hasAttribute(SUMO_ATTR_TYPE)) {
myCurrentType = attrs.getStringReporting(SUMO_ATTR_TYPE, "edge", myCurrentID.c_str(), ok);
if (!ok) {
return;
}
if (!myTypeCont.knows(myCurrentType)) {
MsgHandler::getErrorInstance()->inform("Type '" + myCurrentType + "' used by edge '" + myCurrentID + "' was not defined.");
return;
}
myCurrentSpeed = myTypeCont.getSpeed(myCurrentType);
myCurrentPriority = myTypeCont.getPriority(myCurrentType);
myCurrentLaneNo = myTypeCont.getNoLanes(myCurrentType);
}
// speed, priority and the number of lanes have now default values;
// try to read the real values from the file
if (attrs.hasAttribute(SUMO_ATTR_SPEED)) {
myCurrentSpeed = attrs.getSUMORealReporting(SUMO_ATTR_SPEED, "edge", myCurrentID.c_str(), ok);
}
if (myOptions.getBool("speed-in-kmh")) {
myCurrentSpeed = myCurrentSpeed / (SUMOReal) 3.6;
}
// try to get the number of lanes
if (attrs.hasAttribute(SUMO_ATTR_NOLANES)) {
myCurrentLaneNo = attrs.getIntReporting(SUMO_ATTR_NOLANES, "edge", myCurrentID.c_str(), ok);
}
// try to get the priority
if (attrs.hasAttribute(SUMO_ATTR_PRIORITY)) {
myCurrentPriority = attrs.getIntReporting(SUMO_ATTR_PRIORITY, "edge", myCurrentID.c_str(), ok);
}
// try to get the shape
myShape = tryGetShape(attrs);
// and how to spread the lanes
if (attrs.getOptStringReporting(SUMO_ATTR_SPREADFUNC, "edge", myCurrentID.c_str(), ok, "")=="center") {
myLanesSpread = NBEdge::LANESPREAD_CENTER;
} else {
myLanesSpread = NBEdge::LANESPREAD_RIGHT;
}
// try to set the nodes
if (!setNodes(attrs)) {
// return if this failed
return;
}
// get the length or compute it
if (attrs.hasAttribute(SUMO_ATTR_LENGTH)) {
myLength = attrs.getSUMORealReporting(SUMO_ATTR_LENGTH, "edge", myCurrentID.c_str(), ok);
} else {
myLength = 0;
}
/// insert the parsed edge into the edges map
if (!ok) {
return;
}
// check whether a previously defined edge shall be overwritten
if (myCurrentEdge!=0) {
myCurrentEdge->reinit(myFromNode, myToNode, myCurrentType, myCurrentSpeed,
myCurrentLaneNo, myCurrentPriority, myShape,
myLanesSpread);
} else {
// the edge must be allocated in dependence to whether a shape is given
if (myShape.size()==0) {
myCurrentEdge = new NBEdge(myCurrentID, myFromNode, myToNode, myCurrentType, myCurrentSpeed,
myCurrentLaneNo, myCurrentPriority, myLanesSpread);
//.........这里部分代码省略.........
示例6: ProcessError
//.........这里部分代码省略.........
break;
case SUMO_TAG_VTYPE_DISTRIBUTION:
openVehicleTypeDistribution(attrs);
break;
case SUMO_TAG_ROUTE:
openRoute(attrs);
break;
case SUMO_TAG_ROUTE_DISTRIBUTION:
openRouteDistribution(attrs);
break;
case SUMO_TAG_TRIPDEF: {
bool ok = true;
myVehicleParameter = SUMOVehicleParserHelper::parseVehicleAttributes(attrs);
myActiveRouteID = "!" + myVehicleParameter->id;
if (attrs.hasAttribute(SUMO_ATTR_FROM) || !myVehicleParameter->wasSet(VEHPARS_TAZ_SET)) {
MSEdge::parseEdgesList(attrs.getStringReporting(SUMO_ATTR_FROM, "tripdef", myVehicleParameter->id.c_str(), ok), myActiveRoute, myActiveRouteID);
MSEdge::parseEdgesList(attrs.getStringReporting(SUMO_ATTR_TO, "tripdef", myVehicleParameter->id.c_str(), ok), myActiveRoute, myActiveRouteID);
} else {
const MSEdge* fromTaz = MSEdge::dictionary(myVehicleParameter->fromTaz+"-source");
if (fromTaz == 0) {
WRITE_ERROR("Source district '" + myVehicleParameter->fromTaz + "' not known for '" + myVehicleParameter->id + "'!");
} else if (fromTaz->getNoFollowing() == 0) {
WRITE_ERROR("Source district '" + myVehicleParameter->fromTaz + "' has no outgoing edges for '" + myVehicleParameter->id + "'!");
} else {
myActiveRoute.push_back(fromTaz->getFollower(0));
}
}
closeRoute();
closeVehicle();
}
break;
default:
break;
}
// parse embedded vtype information
if (myCurrentVType!=0&&element!=SUMO_TAG_VTYPE) {
SUMOVehicleParserHelper::parseVTypeEmbedded(*myCurrentVType, element, attrs);
return;
}
if (element==SUMO_TAG_STOP) {
bool ok = true;
SUMOVehicleParameter::Stop stop;
// try to parse the assigne bus stop
stop.busstop = attrs.getOptStringReporting(SUMO_ATTR_BUS_STOP, "stop", 0, ok, "");
if (stop.busstop!="") {
// ok, we have obviously a bus stop
MSBusStop *bs = MSNet::getInstance()->getBusStop(stop.busstop);
if (bs!=0) {
const MSLane &l = bs->getLane();
stop.lane = l.getID();
stop.pos = bs->getEndLanePosition();
} else {
MsgHandler::getErrorInstance()->inform("The bus stop '" + stop.busstop + "' is not known.");
return;
}
} else {
// no, the lane and the position should be given
// get the lane
stop.lane = attrs.getOptStringReporting(SUMO_ATTR_LANE, "stop", 0, ok, "");
if (stop.lane!="") {
if (MSLane::dictionary(stop.lane)==0) {
MsgHandler::getErrorInstance()->inform("The lane '" + stop.lane + "' for a stop is not known.");
return;
}
} else {
MsgHandler::getErrorInstance()->inform("A stop must be placed on a bus stop or a lane.");
return;
}
// get the position
bool ok = true;
stop.pos = attrs.getSUMORealReporting(SUMO_ATTR_POSITION, "stop", 0, ok);
if (!ok) {
return;
}
}
// get the standing duration
if (!attrs.hasAttribute(SUMO_ATTR_DURATION) && !attrs.hasAttribute(SUMO_ATTR_UNTIL)) {
MsgHandler::getErrorInstance()->inform("The duration of a stop is not defined.");
return;
} else {
bool ok = true;
stop.duration = attrs.getOptSUMOTimeReporting(SUMO_ATTR_DURATION, "stop", 0, ok, -1);
stop.until = attrs.getOptSUMOTimeReporting(SUMO_ATTR_UNTIL, "stop", 0, ok, -1);
if (!ok) {
return;
}
if (stop.duration<0&&stop.until<0) {
MsgHandler::getErrorInstance()->inform("Neither the duration nor the end time is given for a stop.");
return;
}
}
if (myActiveRouteID != "") {
myActiveRouteStops.push_back(stop);
} else {
myVehicleParameter->stops.push_back(stop);
}
}
}