本文整理汇总了C++中SUMOSAXAttributes::getOptIntReporting方法的典型用法代码示例。如果您正苦于以下问题:C++ SUMOSAXAttributes::getOptIntReporting方法的具体用法?C++ SUMOSAXAttributes::getOptIntReporting怎么用?C++ SUMOSAXAttributes::getOptIntReporting使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SUMOSAXAttributes
的用法示例。
在下文中一共展示了SUMOSAXAttributes::getOptIntReporting方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: throw
void
NIXMLTypesHandler::myStartElement(SumoXMLTag element,
const SUMOSAXAttributes &attrs) throw(ProcessError) {
if (element!=SUMO_TAG_TYPE) {
return;
}
// get the id, report a warning if not given or empty...
std::string id;
if (!attrs.setIDFromAttributes("type", id), false) {
WRITE_WARNING("No type id given... Skipping.");
return;
}
// check deprecated (unused) attributes
if (!myHaveReportedAboutFunctionDeprecation&&attrs.hasAttribute(SUMO_ATTR_FUNCTION)) {
MsgHandler::getWarningInstance()->inform("While parsing type '" + id + "': 'function' is deprecated.\n All occurences are ignored.");
myHaveReportedAboutFunctionDeprecation = true;
}
bool ok = true;
int priority = attrs.getOptIntReporting(SUMO_ATTR_PRIORITY, "type", id.c_str(), ok, myTypeCont.getDefaultPriority());
int noLanes = attrs.getOptIntReporting(SUMO_ATTR_NOLANES, "type", id.c_str(), ok, myTypeCont.getDefaultNoLanes());
SUMOReal speed = attrs.getOptSUMORealReporting(SUMO_ATTR_SPEED, "type", id.c_str(), ok, (SUMOReal) myTypeCont.getDefaultSpeed());
bool discard = attrs.getOptBoolReporting(SUMO_ATTR_DISCARD, 0, 0, ok, false);
if (!ok) {
return;
}
// build the type
if (!myTypeCont.insert(id, noLanes, speed, priority)) {
MsgHandler::getErrorInstance()->inform("Duplicate type occured. ID='" + id + "'");
} else {
if (discard) {
myTypeCont.markAsToDiscard(id);
}
}
}
示例2: ProcessError
void
NIXMLTrafficLightsHandler::addTlConnection(const SUMOSAXAttributes& attrs) {
bool ok = true;
// parse identifying attributes
NBEdge* from = retrieveEdge(attrs, SUMO_ATTR_FROM, ok);
NBEdge* to = retrieveEdge(attrs, SUMO_ATTR_TO, ok);
if (!ok) {
return;
}
int fromLane = retrieveLaneIndex(attrs, SUMO_ATTR_FROM_LANE, from, ok);
int toLane = retrieveLaneIndex(attrs, SUMO_ATTR_TO_LANE, to, ok);
if (!ok) {
return;
}
// retrieve connection
const std::vector<NBEdge::Connection>& connections = from->getConnections();
std::vector<NBEdge::Connection>::const_iterator con_it;
con_it = find_if(connections.begin(), connections.end(),
NBEdge::connections_finder(fromLane, to, toLane));
if (con_it == connections.end()) {
WRITE_ERROR("Connection from=" + from->getID() + " to=" + to->getID() +
" fromLane=" + toString(fromLane) + " toLane=" + toString(toLane) + " not found");
return;
}
NBEdge::Connection c = *con_it;
// read other attributes
std::string tlID = attrs.getOptStringReporting(SUMO_ATTR_TLID, 0, ok, "");
if (tlID == "") {
// we are updating an existing tl-controlled connection
tlID = c.tlID;
assert(tlID != "");
}
int tlIndex = attrs.getOptIntReporting(SUMO_ATTR_TLLINKINDEX, 0, ok, -1);
if (tlIndex == -1) {
// we are updating an existing tl-controlled connection
tlIndex = c.tlLinkNo;
}
// register the connection with all definitions
const std::map<std::string, NBTrafficLightDefinition*>& programs = myTLLCont.getPrograms(tlID);
if (programs.size() > 0) {
std::map<std::string, NBTrafficLightDefinition*>::const_iterator it;
for (it = programs.begin(); it != programs.end(); it++) {
NBLoadedSUMOTLDef* tlDef = dynamic_cast<NBLoadedSUMOTLDef*>(it->second);
if (tlDef) {
tlDef->addConnection(from, c.toEdge, c.fromLane, c.toLane, tlIndex);
} else {
throw ProcessError("Corrupt traffic light definition '"
+ tlID + "' (program '" + it->first + "')");
}
}
} else {
WRITE_ERROR("The traffic light '" + tlID + "' is not known.");
}
}
示例3: EdgeAttrs
void
NIImporter_SUMO::addEdge(const SUMOSAXAttributes& attrs) {
// get the id, report an error if not given or empty...
bool ok = true;
std::string id = attrs.getStringReporting(SUMO_ATTR_ID, 0, ok);
if (!ok) {
return;
}
myCurrentEdge = new EdgeAttrs();
myCurrentEdge->builtEdge = 0;
myCurrentEdge->id = id;
// get the function
myCurrentEdge->func = attrs.getOptStringReporting(SUMO_ATTR_FUNCTION, id.c_str(), ok, "normal");
if (myCurrentEdge->func == toString(EDGEFUNC_INTERNAL)) {
return; // skip internal edges
}
// get the type
myCurrentEdge->type = attrs.getOptStringReporting(SUMO_ATTR_TYPE, id.c_str(), ok, "");
// get the origin and the destination node
myCurrentEdge->fromNode = attrs.getOptStringReporting(SUMO_ATTR_FROM, id.c_str(), ok, "");
myCurrentEdge->toNode = attrs.getOptStringReporting(SUMO_ATTR_TO, id.c_str(), ok, "");
myCurrentEdge->priority = attrs.getOptIntReporting(SUMO_ATTR_PRIORITY, id.c_str(), ok, -1);
myCurrentEdge->type = attrs.getOptStringReporting(SUMO_ATTR_TYPE, id.c_str(), ok, "");
myCurrentEdge->shape = GeomConvHelper::parseShapeReporting(
attrs.getOptStringReporting(SUMO_ATTR_SHAPE, id.c_str(), ok, ""),
attrs.getObjectType(), id.c_str(), ok, true);
NILoader::transformCoordinates(myCurrentEdge->shape, true, myLocation);
myCurrentEdge->length = attrs.getOptSUMORealReporting(SUMO_ATTR_LENGTH, id.c_str(), ok, NBEdge::UNSPECIFIED_LOADED_LENGTH);
myCurrentEdge->maxSpeed = 0;
myCurrentEdge->streetName = attrs.getOptStringReporting(SUMO_ATTR_NAME, id.c_str(), ok, "");
std::string lsfS = toString(LANESPREAD_RIGHT);
if (attrs.hasAttribute(SUMO_ATTR_SPREADFUNC__DEPRECATED)) {
lsfS = attrs.getStringReporting(SUMO_ATTR_SPREADFUNC__DEPRECATED, id.c_str(), ok);
if (!myHaveWarnedAboutDeprecatedSpreadType) {
WRITE_WARNING("'" + toString(SUMO_ATTR_SPREADFUNC__DEPRECATED) + "' is deprecated; please use '" + toString(SUMO_ATTR_SPREADTYPE) + "'.");
myHaveWarnedAboutDeprecatedSpreadType = true;
}
} else {
lsfS = attrs.getOptStringReporting(SUMO_ATTR_SPREADTYPE, id.c_str(), ok, lsfS);
}
if (SUMOXMLDefinitions::LaneSpreadFunctions.hasString(lsfS)) {
myCurrentEdge->lsf = SUMOXMLDefinitions::LaneSpreadFunctions.get(lsfS);
} else {
WRITE_ERROR("Unknown spreadType '" + lsfS + "' for edge '" + id + "'.");
}
}
示例4:
void
NIImporter_SUMO::addEdge(const SUMOSAXAttributes &attrs) {
// get the id, report an error if not given or empty...
std::string id;
if (!attrs.setIDFromAttributes("edge", id)) {
return;
}
bool ok = true;
myCurrentEdge = new EdgeAttrs;
myCurrentEdge->id = id;
// get the type
myCurrentEdge->type = attrs.getOptStringReporting(SUMO_ATTR_TYPE, "edge", id.c_str(), ok, "");
// get the origin and the destination node
myCurrentEdge->fromNode = attrs.getOptStringReporting(SUMO_ATTR_FROM, "edge", id.c_str(), ok, "");
myCurrentEdge->toNode = attrs.getOptStringReporting(SUMO_ATTR_TO, "edge", id.c_str(), ok, "");
myCurrentEdge->priority = attrs.getOptIntReporting(SUMO_ATTR_PRIORITY, "edge", id.c_str(), ok, -1);
myCurrentEdge->maxSpeed = 0;
myCurrentEdge->builtEdge = 0;
}