本文整理汇总了C++中NBEdge::hasConnectionTo方法的典型用法代码示例。如果您正苦于以下问题:C++ NBEdge::hasConnectionTo方法的具体用法?C++ NBEdge::hasConnectionTo怎么用?C++ NBEdge::hasConnectionTo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NBEdge
的用法示例。
在下文中一共展示了NBEdge::hasConnectionTo方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
GNEConnectorFrame::LaneStatus
GNEConnectorFrame::getLaneStatus(const std::vector<NBEdge::Connection>& connections, GNELane* targetLane) {
NBEdge* srcEdge = myCurrentLane->getParentEdge().getNBEdge();
const int fromIndex = myCurrentLane->getIndex();
NBEdge* destEdge = targetLane->getParentEdge().getNBEdge();
const int toIndex = targetLane->getIndex();
std::vector<NBEdge::Connection>::const_iterator con_it = find_if(
connections.begin(), connections.end(),
NBEdge::connections_finder(fromIndex, destEdge, toIndex));
const bool isConnected = con_it != connections.end();
if (isConnected) {
if (con_it->mayDefinitelyPass) {
return CONNECTED_PASS;
} else {
return CONNECTED;
}
} else if (srcEdge->hasConnectionTo(destEdge, toIndex)) {
return CONFLICTED;
} else {
return UNCONNECTED;
}
}
示例2: toString
void
NIXMLConnectionsHandler::myStartElement(int element,
const SUMOSAXAttributes& attrs) {
if (element == SUMO_TAG_DELETE) {
bool ok = true;
std::string from = attrs.get<std::string>(SUMO_ATTR_FROM, 0, ok);
std::string to = attrs.get<std::string>(SUMO_ATTR_TO, 0, ok);
if (!ok) {
return;
}
// these connections were removed when the edge was deleted
if (myEdgeCont.wasRemoved(from) || myEdgeCont.wasRemoved(to)) {
return;
}
NBEdge* fromEdge = myEdgeCont.retrieve(from);
NBEdge* toEdge = myEdgeCont.retrieve(to);
if (fromEdge == 0) {
myErrorMsgHandler->inform("The connection-source edge '" + from + "' to reset is not known.");
return;
}
if (toEdge == 0) {
myErrorMsgHandler->inform("The connection-destination edge '" + to + "' to reset is not known.");
return;
}
if (!fromEdge->isConnectedTo(toEdge) && fromEdge->getStep() >= NBEdge::EDGE2EDGES) {
WRITE_WARNING("Target edge '" + toEdge->getID() + "' is not connected with '" + fromEdge->getID() + "'; the connection cannot be reset.");
return;
}
int fromLane = -1; // Assume all lanes are to be reset.
int toLane = -1;
if (attrs.hasAttribute(SUMO_ATTR_LANE)
|| attrs.hasAttribute(SUMO_ATTR_FROM_LANE)
|| attrs.hasAttribute(SUMO_ATTR_TO_LANE)) {
if (!parseLaneInfo(attrs, fromEdge, toEdge, &fromLane, &toLane)) {
return;
}
// we could be trying to reset a connection loaded from a sumo net and which has become obsolete.
// In this case it's ok to encounter invalid lance indices
if (!fromEdge->hasConnectionTo(toEdge, toLane) && fromEdge->getStep() >= NBEdge::LANES2EDGES) {
WRITE_WARNING("Edge '" + fromEdge->getID() + "' has no connection to lane " + toString(toLane) + " of edge '" + toEdge->getID() + "'; the connection cannot be reset.");
}
}
fromEdge->removeFromConnections(toEdge, fromLane, toLane, true);
}
if (element == SUMO_TAG_CONNECTION) {
bool ok = true;
std::string from = attrs.get<std::string>(SUMO_ATTR_FROM, "connection", ok);
std::string to = attrs.getOpt<std::string>(SUMO_ATTR_TO, "connection", ok, "");
if (!ok || myEdgeCont.wasIgnored(from) || myEdgeCont.wasIgnored(to)) {
return;
}
// extract edges
NBEdge* fromEdge = myEdgeCont.retrieve(from);
NBEdge* toEdge = to.length() != 0 ? myEdgeCont.retrieve(to) : 0;
// check whether they are valid
if (fromEdge == 0) {
myErrorMsgHandler->inform("The connection-source edge '" + from + "' is not known.");
return;
}
if (toEdge == 0 && to.length() != 0) {
myErrorMsgHandler->inform("The connection-destination edge '" + to + "' is not known.");
return;
}
fromEdge->getToNode()->invalidateTLS(myTLLogicCont, true, false);
// parse optional lane information
if (attrs.hasAttribute(SUMO_ATTR_LANE) || attrs.hasAttribute(SUMO_ATTR_FROM_LANE) || attrs.hasAttribute(SUMO_ATTR_TO_LANE)) {
parseLaneBound(attrs, fromEdge, toEdge);
} else {
fromEdge->addEdge2EdgeConnection(toEdge);
}
}
if (element == SUMO_TAG_PROHIBITION) {
bool ok = true;
std::string prohibitor = attrs.getOpt<std::string>(SUMO_ATTR_PROHIBITOR, 0, ok, "");
std::string prohibited = attrs.getOpt<std::string>(SUMO_ATTR_PROHIBITED, 0, ok, "");
if (!ok) {
return;
}
NBConnection prohibitorC = parseConnection("prohibitor", prohibitor);
NBConnection prohibitedC = parseConnection("prohibited", prohibited);
if (prohibitorC == NBConnection::InvalidConnection || prohibitedC == NBConnection::InvalidConnection) {
// something failed
return;
}
NBNode* n = prohibitorC.getFrom()->getToNode();
n->addSortedLinkFoes(prohibitorC, prohibitedC);
}
if (element == SUMO_TAG_CROSSING) {
addCrossing(attrs);
}
if (element == SUMO_TAG_WALKINGAREA) {
addWalkingArea(attrs);
}
}
示例3: 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 + "')");
}
}
//.........这里部分代码省略.........