本文整理汇总了C++中SUMOSAXAttributes::getOpt方法的典型用法代码示例。如果您正苦于以下问题:C++ SUMOSAXAttributes::getOpt方法的具体用法?C++ SUMOSAXAttributes::getOpt怎么用?C++ SUMOSAXAttributes::getOpt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SUMOSAXAttributes
的用法示例。
在下文中一共展示了SUMOSAXAttributes::getOpt方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: addSplit
void NIXMLEdgesHandler::addSplit(const SUMOSAXAttributes& attrs) {
if (myCurrentEdge == 0) {
if (!OptionsCont::getOptions().isInStringVector("remove-edges.explicit", myCurrentID)) {
WRITE_WARNING("Ignoring 'split' because it cannot be assigned to an edge");
}
return;
}
bool ok = true;
Split e;
e.pos = attrs.get<SUMOReal>(SUMO_ATTR_POSITION, 0, ok);
if (ok) {
if (fabs(e.pos) > myCurrentEdge->getGeometry().length()) {
WRITE_ERROR("Edge '" + myCurrentID + "' has a split at invalid position " + toString(e.pos) + ".");
return;
}
std::vector<Split>::iterator i = find_if(mySplits.begin(), mySplits.end(), split_by_pos_finder(e.pos));
if (i != mySplits.end()) {
WRITE_ERROR("Edge '" + myCurrentID + "' has already a split at position " + toString(e.pos) + ".");
return;
}
const std::string nameid = toString((int)e.pos);
if (e.pos < 0) {
e.pos += myCurrentEdge->getGeometry().length();
}
std::vector<std::string> lanes;
SUMOSAXAttributes::parseStringVector(attrs.getOpt<std::string>(SUMO_ATTR_LANES, 0, ok, ""), lanes);
for (std::vector<std::string>::iterator i = lanes.begin(); i != lanes.end(); ++i) {
try {
int lane = TplConvert::_2int((*i).c_str());
e.lanes.push_back(lane);
} catch (NumberFormatException&) {
WRITE_ERROR("Error on parsing a split (edge '" + myCurrentID + "').");
} catch (EmptyData&) {
WRITE_ERROR("Error on parsing a split (edge '" + myCurrentID + "').");
}
}
if (e.lanes.empty()) {
for (int l = 0; l < myCurrentEdge->getNumLanes(); ++l) {
e.lanes.push_back(l);
}
}
e.speed = attrs.getOpt(SUMO_ATTR_SPEED, 0, ok, myCurrentEdge->getSpeed());
if (attrs.hasAttribute(SUMO_ATTR_SPEED) && myOptions.getBool("speed-in-kmh")) {
e.speed /= (SUMOReal) 3.6;
}
e.idBefore = attrs.getOpt(SUMO_ATTR_ID_BEFORE, 0, ok, std::string(""));
e.idAfter = attrs.getOpt(SUMO_ATTR_ID_AFTER, 0, ok, std::string(""));
if (!ok) {
return;
}
e.node = new NBNode(myCurrentID + "." + nameid,
myCurrentEdge->getGeometry().positionAtOffset(e.pos));
NIXMLNodesHandler::processNodeType(attrs, e.node, e.node->getID(), e.node->getPosition(), false,
myNodeCont, myTLLogicCont);
mySplits.push_back(e);
}
}