本文整理汇总了C++中OptionsCont::isUsableFileList方法的典型用法代码示例。如果您正苦于以下问题:C++ OptionsCont::isUsableFileList方法的具体用法?C++ OptionsCont::isUsableFileList怎么用?C++ OptionsCont::isUsableFileList使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OptionsCont
的用法示例。
在下文中一共展示了OptionsCont::isUsableFileList方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ProcessError
void
NIImporter_SUMO::_loadNetwork(const OptionsCont& oc) {
// check whether the option is set (properly)
if (!oc.isUsableFileList("sumo-net-file")) {
return;
}
// parse file(s)
std::vector<std::string> files = oc.getStringVector("sumo-net-file");
for (std::vector<std::string>::const_iterator file = files.begin(); file != files.end(); ++file) {
if (!FileHelpers::exists(*file)) {
WRITE_ERROR("Could not open sumo-net-file '" + *file + "'.");
return;
}
setFileName(*file);
PROGRESS_BEGIN_MESSAGE("Parsing sumo-net from '" + *file + "'");
XMLSubSys::runParser(*this, *file);
PROGRESS_DONE_MESSAGE();
}
// build edges
for (std::map<std::string, EdgeAttrs*>::const_iterator i = myEdges.begin(); i != myEdges.end(); ++i) {
EdgeAttrs* ed = (*i).second;
// skip internal edges
if (ed->func == toString(EDGEFUNC_INTERNAL)) {
continue;
}
// get and check the nodes
NBNode* from = myNodeCont.retrieve(ed->fromNode);
NBNode* to = myNodeCont.retrieve(ed->toNode);
if (from == 0) {
WRITE_ERROR("Edge's '" + ed->id + "' from-node '" + ed->fromNode + "' is not known.");
continue;
}
if (to == 0) {
WRITE_ERROR("Edge's '" + ed->id + "' to-node '" + ed->toNode + "' is not known.");
continue;
}
// edge shape
PositionVector geom;
if (ed->shape.size() > 0) {
geom = ed->shape;
mySuspectKeepShape = false; // no problem with reconstruction if edge shape is given explicit
} else {
// either the edge has default shape consisting only of the two node
// positions or we have a legacy network
geom = reconstructEdgeShape(ed, from->getPosition(), to->getPosition());
}
// build and insert the edge
NBEdge* e = new NBEdge(ed->id, from, to,
ed->type, ed->maxSpeed,
(unsigned int) ed->lanes.size(),
ed->priority, NBEdge::UNSPECIFIED_WIDTH, NBEdge::UNSPECIFIED_OFFSET,
geom, ed->streetName, ed->lsf, true); // always use tryIgnoreNodePositions to keep original shape
e->setLoadedLength(ed->length);
if (!myNetBuilder.getEdgeCont().insert(e)) {
WRITE_ERROR("Could not insert edge '" + ed->id + "'.");
delete e;
continue;
}
ed->builtEdge = myNetBuilder.getEdgeCont().retrieve(ed->id);
}
// assign further lane attributes (edges are built)
for (std::map<std::string, EdgeAttrs*>::const_iterator i = myEdges.begin(); i != myEdges.end(); ++i) {
EdgeAttrs* ed = (*i).second;
NBEdge* nbe = ed->builtEdge;
if (nbe == 0) { // inner edge or removed by explicit list, vclass, ...
continue;
}
for (unsigned int fromLaneIndex = 0; fromLaneIndex < (unsigned int) ed->lanes.size(); ++fromLaneIndex) {
LaneAttrs* lane = ed->lanes[fromLaneIndex];
// connections
const std::vector<Connection> &connections = lane->connections;
for (std::vector<Connection>::const_iterator c_it = connections.begin(); c_it != connections.end(); c_it++) {
const Connection& c = *c_it;
if (myEdges.count(c.toEdgeID) == 0) {
WRITE_ERROR("Unknown edge '" + c.toEdgeID + "' given in connection.");
continue;
}
NBEdge* toEdge = myEdges[c.toEdgeID]->builtEdge;
if (toEdge == 0) { // removed by explicit list, vclass, ...
continue;
}
nbe->addLane2LaneConnection(
fromLaneIndex, toEdge, c.toLaneIdx, NBEdge::L2L_VALIDATED,
false, c.mayDefinitelyPass);
// maybe we have a tls-controlled connection
if (c.tlID != "") {
const std::map<std::string, NBTrafficLightDefinition*>& programs = myTLLCont.getPrograms(c.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(nbe, toEdge, fromLaneIndex, c.toLaneIdx, c.tlLinkNo);
} else {
throw ProcessError("Corrupt traffic light definition '"
+ c.tlID + "' (program '" + it->first + "')");
}
}
} else {
//.........这里部分代码省略.........
示例2: handler
// ===========================================================================
// method definitions
// ===========================================================================
// ---------------------------------------------------------------------------
// static methods (interface in this case)
// ---------------------------------------------------------------------------
void
NIImporter_OpenDrive::loadNetwork(const OptionsCont &oc, NBNetBuilder &nb) {
// check whether the option is set (properly)
if (!oc.isUsableFileList("opendrive")) {
return;
}
// build the handler
std::vector<OpenDriveEdge> innerEdges, outerEdges;
NIImporter_OpenDrive handler(nb.getNodeCont(), innerEdges, outerEdges);
// parse file(s)
std::vector<std::string> files = oc.getStringVector("opendrive");
for (std::vector<std::string>::const_iterator file=files.begin(); file!=files.end(); ++file) {
if (!FileHelpers::exists(*file)) {
MsgHandler::getErrorInstance()->inform("Could not open opendrive file '" + *file + "'.");
return;
}
handler.setFileName(*file);
MsgHandler::getMessageInstance()->beginProcessMsg("Parsing opendrive from '" + *file + "'...");
XMLSubSys::runParser(handler, *file);
MsgHandler::getMessageInstance()->endProcessMsg("done.");
}
// convert geometries into a discretised representation
computeShapes(innerEdges);
computeShapes(outerEdges);
// -------------------------
// node building
// -------------------------
// build nodes#1
// look at all links which belong to a node, collect their bounding boxes
// and place the node in the middle of this bounding box
std::map<std::string, Boundary> posMap;
std::map<std::string, std::string> edge2junction;
// compute node positions
for (std::vector<OpenDriveEdge>::iterator i=innerEdges.begin(); i!=innerEdges.end(); ++i) {
OpenDriveEdge &e = *i;
assert(e.junction!="-1" && e.junction!="");
edge2junction[e.id] = e.junction;
if (posMap.find(e.junction)==posMap.end()) {
posMap[e.junction] = Boundary();
}
posMap[e.junction].add(e.geom.getBoxBoundary());
}
// build nodes
for (std::map<std::string, Boundary>::iterator i=posMap.begin(); i!=posMap.end(); ++i) {
if (!nb.getNodeCont().insert((*i).first, (*i).second.getCenter())) {
throw ProcessError("Could not add node '" + (*i).first + "'.");
}
}
// assign built nodes
for (std::vector<OpenDriveEdge>::iterator i=outerEdges.begin(); i!=outerEdges.end(); ++i) {
OpenDriveEdge &e = *i;
for (std::vector<OpenDriveLink>::iterator j=e.links.begin(); j!=e.links.end(); ++j) {
OpenDriveLink &l = *j;
if (l.elementType!=OPENDRIVE_ET_ROAD) {
// set node information
setNodeSecure(nb.getNodeCont(), e, l.elementID, l.linkType);
continue;
}
if (edge2junction.find(l.elementID)!=edge2junction.end()) {
// set node information of an internal road
setNodeSecure(nb.getNodeCont(), e, edge2junction[l.elementID], l.linkType);
continue;
}
}
}
// we should now have all nodes set for links which are not outer edge-to-outer edge links
// build nodes#2
// build nodes for all outer edge-to-outer edge connections
for (std::vector<OpenDriveEdge>::iterator i=outerEdges.begin(); i!=outerEdges.end(); ++i) {
OpenDriveEdge &e = *i;
for (std::vector<OpenDriveLink>::iterator j=e.links.begin(); j!=e.links.end(); ++j) {
OpenDriveLink &l = *j;
if (l.elementType!=OPENDRIVE_ET_ROAD || edge2junction.find(l.elementID)!=edge2junction.end()) {
// is a connection to an internal edge, or a node, skip
continue;
}
// we have a direct connection between to external edges
std::string id1 = e.id;
std::string id2 = l.elementID;
if (id1<id2) {
std::swap(id1, id2);
}
std::string nid = id1+"."+id2;
if (nb.getNodeCont().retrieve(nid)==0) {
// not yet seen, build
Position2D pos = l.linkType==OPENDRIVE_LT_SUCCESSOR ? e.geom[(int)e.geom.size()-1] : e.geom[0];
if (!nb.getNodeCont().insert(nid, pos)) {
throw ProcessError("Could not build node '" + nid + "'.");
}
}
/* debug-stuff
//.........这里部分代码省略.........
示例3: handler
// ===========================================================================
// method definitions
// ===========================================================================
// ---------------------------------------------------------------------------
// static methods (interface in this case)
// ---------------------------------------------------------------------------
void
NIImporter_SUMO::loadNetwork(const OptionsCont &oc, NBNetBuilder &nb) {
// check whether the option is set (properly)
if (!oc.isUsableFileList("sumo-net")) {
return;
}
// build the handler
NIImporter_SUMO handler(nb.getNodeCont());
// parse file(s)
std::vector<std::string> files = oc.getStringVector("sumo-net");
for (std::vector<std::string>::const_iterator file=files.begin(); file!=files.end(); ++file) {
if (!FileHelpers::exists(*file)) {
MsgHandler::getErrorInstance()->inform("Could not open sumo-net-file '" + *file + "'.");
return;
}
handler.setFileName(*file);
MsgHandler::getMessageInstance()->beginProcessMsg("Parsing sumo-net from '" + *file + "'...");
XMLSubSys::runParser(handler, *file);
MsgHandler::getMessageInstance()->endProcessMsg("done.");
}
// build edges
std::map<std::string, EdgeAttrs*> &loadedEdges = handler.myEdges;
NBNodeCont &nodesCont = nb.getNodeCont();
NBEdgeCont &edgesCont = nb.getEdgeCont();
for (std::map<std::string, EdgeAttrs*>::const_iterator i=loadedEdges.begin(); i!=loadedEdges.end(); ++i) {
EdgeAttrs *ed = (*i).second;
// get and check the nodes
NBNode *from = nodesCont.retrieve(ed->fromNode);
NBNode *to = nodesCont.retrieve(ed->toNode);
if (from==0) {
MsgHandler::getErrorInstance()->inform("Edge's '" + ed->id + "' from-node '" + ed->fromNode + "' is not known.");
continue;
}
if (to==0) {
MsgHandler::getErrorInstance()->inform("Edge's '" + ed->id + "' to-node '" + ed->toNode + "' is not known.");
continue;
}
// build and insert the edge
NBEdge *e = new NBEdge(ed->id, from, to, ed->type, ed->maxSpeed, (unsigned int) ed->lanes.size(), ed->priority);
if (!edgesCont.insert(e)) {
MsgHandler::getErrorInstance()->inform("Could not insert edge '" + ed->id + "'.");
delete e;
continue;
}
ed->builtEdge = edgesCont.retrieve(ed->id);
}
// assign lane attributes (edges are built)
for (std::map<std::string, EdgeAttrs*>::const_iterator i=loadedEdges.begin(); i!=loadedEdges.end(); ++i) {
EdgeAttrs *ed = (*i).second;
if (ed->builtEdge==0) {
// earlier errors
continue;
}
for (unsigned int j=0; j<(unsigned int) ed->lanes.size(); ++j) {
const std::vector<EdgeLane> &connections = ed->lanes[j]->connections;
for (std::vector<EdgeLane>::const_iterator k=connections.begin(); k!=connections.end(); ++k) {
if ((*k).lane!="SUMO_NO_DESTINATION") {
std::string lane = (*k).lane;
std::string edge = lane.substr(0, lane.find('_'));
int index = TplConvert<char>::_2int(lane.substr(lane.find('_')+1).c_str());
if (loadedEdges.find(edge)==loadedEdges.end()) {
MsgHandler::getErrorInstance()->inform("Unknown edge given in succlane (for lane '" + lane + "').");
continue;
}
NBEdge *ce = loadedEdges.find(edge)->second->builtEdge;
if (ce==0) {
// earlier error or edge removal
continue;
}
ed->builtEdge->addLane2LaneConnection(j, ce, index, NBEdge::L2L_VALIDATED);
}
}
}
}
// clean up
for (std::map<std::string, EdgeAttrs*>::const_iterator i=loadedEdges.begin(); i!=loadedEdges.end(); ++i) {
EdgeAttrs *ed = (*i).second;
for (std::vector<LaneAttrs*>::const_iterator j=ed->lanes.begin(); j!=ed->lanes.end(); ++j) {
delete *j;
}
delete ed;
}
}
示例4: ProcessError
void
NIImporter_SUMO::_loadNetwork(OptionsCont& oc) {
// check whether the option is set (properly)
if (!oc.isUsableFileList("sumo-net-file")) {
return;
}
// parse file(s)
std::vector<std::string> files = oc.getStringVector("sumo-net-file");
for (std::vector<std::string>::const_iterator file = files.begin(); file != files.end(); ++file) {
if (!FileHelpers::isReadable(*file)) {
WRITE_ERROR("Could not open sumo-net-file '" + *file + "'.");
return;
}
setFileName(*file);
PROGRESS_BEGIN_MESSAGE("Parsing sumo-net from '" + *file + "'");
XMLSubSys::runParser(*this, *file, true);
PROGRESS_DONE_MESSAGE();
}
// build edges
for (std::map<std::string, EdgeAttrs*>::const_iterator i = myEdges.begin(); i != myEdges.end(); ++i) {
EdgeAttrs* ed = (*i).second;
// skip internal edges
if (ed->func == EDGEFUNC_INTERNAL || ed->func == EDGEFUNC_CROSSING || ed->func == EDGEFUNC_WALKINGAREA) {
continue;
}
// get and check the nodes
NBNode* from = myNodeCont.retrieve(ed->fromNode);
NBNode* to = myNodeCont.retrieve(ed->toNode);
if (from == 0) {
WRITE_ERROR("Edge's '" + ed->id + "' from-node '" + ed->fromNode + "' is not known.");
continue;
}
if (to == 0) {
WRITE_ERROR("Edge's '" + ed->id + "' to-node '" + ed->toNode + "' is not known.");
continue;
}
// edge shape
PositionVector geom;
if (ed->shape.size() > 0) {
geom = ed->shape;
} else {
// either the edge has default shape consisting only of the two node
// positions or we have a legacy network
geom = reconstructEdgeShape(ed, from->getPosition(), to->getPosition());
}
// build and insert the edge
NBEdge* e = new NBEdge(ed->id, from, to,
ed->type, ed->maxSpeed,
(unsigned int) ed->lanes.size(),
ed->priority, NBEdge::UNSPECIFIED_WIDTH, NBEdge::UNSPECIFIED_OFFSET,
geom, ed->streetName, "", ed->lsf, true); // always use tryIgnoreNodePositions to keep original shape
e->setLoadedLength(ed->length);
if (!myNetBuilder.getEdgeCont().insert(e)) {
WRITE_ERROR("Could not insert edge '" + ed->id + "'.");
delete e;
continue;
}
ed->builtEdge = myNetBuilder.getEdgeCont().retrieve(ed->id);
}
// assign further lane attributes (edges are built)
for (std::map<std::string, EdgeAttrs*>::const_iterator i = myEdges.begin(); i != myEdges.end(); ++i) {
EdgeAttrs* ed = (*i).second;
NBEdge* nbe = ed->builtEdge;
if (nbe == 0) { // inner edge or removed by explicit list, vclass, ...
continue;
}
for (unsigned int fromLaneIndex = 0; fromLaneIndex < (unsigned int) ed->lanes.size(); ++fromLaneIndex) {
LaneAttrs* lane = ed->lanes[fromLaneIndex];
// connections
const std::vector<Connection>& connections = lane->connections;
for (std::vector<Connection>::const_iterator c_it = connections.begin(); c_it != connections.end(); c_it++) {
const Connection& c = *c_it;
if (myEdges.count(c.toEdgeID) == 0) {
WRITE_ERROR("Unknown edge '" + c.toEdgeID + "' given in connection.");
continue;
}
NBEdge* toEdge = myEdges[c.toEdgeID]->builtEdge;
if (toEdge == 0) { // removed by explicit list, vclass, ...
continue;
}
if (nbe->hasConnectionTo(toEdge, c.toLaneIdx)) {
WRITE_WARNING("Target lane '" + toEdge->getLaneID(c.toLaneIdx) + "' has multiple connections from '" + nbe->getID() + "'.");
}
nbe->addLane2LaneConnection(
fromLaneIndex, toEdge, c.toLaneIdx, NBEdge::L2L_VALIDATED,
true, c.mayDefinitelyPass, c.keepClear, c.contPos);
// maybe we have a tls-controlled connection
if (c.tlID != "" && myRailSignals.count(c.tlID) == 0) {
const std::map<std::string, NBTrafficLightDefinition*>& programs = myTLLCont.getPrograms(c.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(nbe, toEdge, fromLaneIndex, c.toLaneIdx, c.tlLinkNo);
} else {
throw ProcessError("Corrupt traffic light definition '" + c.tlID + "' (program '" + it->first + "')");
}
}
//.........这里部分代码省略.........