本文整理汇总了C++中NBEdgeCont::getAllNames方法的典型用法代码示例。如果您正苦于以下问题:C++ NBEdgeCont::getAllNames方法的具体用法?C++ NBEdgeCont::getAllNames怎么用?C++ NBEdgeCont::getAllNames使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NBEdgeCont
的用法示例。
在下文中一共展示了NBEdgeCont::getAllNames方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
void
NBJoinedEdgesMap::init(NBEdgeCont& ec) {
const std::vector<std::string> edgeNames = ec.getAllNames();
myMap.clear();
for (std::vector<std::string>::const_iterator i = edgeNames.begin(); i != edgeNames.end(); i++) {
MappedEdgesVector e;
e.push_back(*i);
myMap[*i] = e;
myLengths[*i] = ec.retrieve(*i)->getLength();
}
}
示例2: idSupplier
void
NWWriter_DlrNavteq::writeProhibitedManoeuvres(const OptionsCont& oc, const NBNodeCont& nc, const NBEdgeCont& ec) {
OutputDevice& device = OutputDevice::getDevice(oc.getString("dlr-navteq-output") + "_prohibited_manoeuvres.txt");
writeHeader(device, oc);
// need to invent id for relation
std::set<std::string> reservedRelIDs;
if (oc.isSet("reserved-ids")) {
NBHelpers::loadPrefixedIDsFomFile(oc.getString("reserved-ids"), "rel:", reservedRelIDs);
}
std::vector<std::string> avoid = ec.getAllNames(); // already used for tls RELATREC_ID
avoid.insert(avoid.end(), reservedRelIDs.begin(), reservedRelIDs.end());
IDSupplier idSupplier("", avoid); // @note: use a global relRecIDsupplier if this is used more often
// write format specifier
device << "#No driving allowed from ID1 to ID2 or the complete chain from ID1 to IDn\n";
device << "#RELATREC_ID\tPERMANENT_ID_INFO\tVALIDITY_PERIOD\tTHROUGH_TRAFFIC\tVEHICLE_TYPE\tNAVTEQ_LINK_ID1\t[NAVTEQ_LINK_ID2 ...]\n";
// write record for every pair of incoming/outgoing edge that are not connected despite having common permissions
for (std::map<std::string, NBNode*>::const_iterator i = nc.begin(); i != nc.end(); ++i) {
NBNode* n = (*i).second;
const EdgeVector& incoming = n->getIncomingEdges();
const EdgeVector& outgoing = n->getOutgoingEdges();
for (EdgeVector::const_iterator j = incoming.begin(); j != incoming.end(); ++j) {
NBEdge* inEdge = *j;
const SVCPermissions inPerm = inEdge->getPermissions();
for (EdgeVector::const_iterator k = outgoing.begin(); k != outgoing.end(); ++k) {
NBEdge* outEdge = *k;
const SVCPermissions outPerm = outEdge->getPermissions();
const SVCPermissions commonPerm = inPerm & outPerm;
if (commonPerm != 0 && commonPerm != SVC_PEDESTRIAN && !inEdge->isConnectedTo(outEdge)) {
device
<< idSupplier.getNext() << "\t"
<< 1 << "\t" // permanent id
<< UNDEFINED << "\t"
<< 1 << "\t"
<< getAllowedTypes(SVCAll) << "\t"
<< inEdge->getID() << "\t" << outEdge->getID() << "\n";
}
}
}
}
device.close();
}
示例3: if
void
NBNodeCont::removeIsolatedRoads(NBDistrictCont& dc, NBEdgeCont& ec, NBTrafficLightLogicCont& tc) {
UNUSED_PARAMETER(tc);
// Warn of isolated edges, i.e. a single edge with no connection to another edge
int edgeCounter = 0;
const std::vector<std::string>& edgeNames = ec.getAllNames();
for (std::vector<std::string>::const_iterator it = edgeNames.begin(); it != edgeNames.end(); ++it) {
// Test whether this node starts at a dead end, i.e. it has only one adjacent node
// to which an edge exists and from which an edge may come.
NBEdge* e = ec.retrieve(*it);
if (e == 0) {
continue;
}
NBNode* from = e->getFromNode();
const EdgeVector& outgoingEdges = from->getOutgoingEdges();
if (outgoingEdges.size() != 1) {
// At this node, several edges or no edge start; so, this node is no dead end.
continue;
}
const EdgeVector& incomingEdges = from->getIncomingEdges();
if (incomingEdges.size() > 1) {
// At this node, several edges end; so, this node is no dead end.
continue;
} else if (incomingEdges.size() == 1) {
NBNode* fromNodeOfIncomingEdge = incomingEdges[0]->getFromNode();
NBNode* toNodeOfOutgoingEdge = outgoingEdges[0]->getToNode();
if (fromNodeOfIncomingEdge != toNodeOfOutgoingEdge) {
// At this node, an edge ends which is not the inverse direction of
// the starting node.
continue;
}
}
// Now we know that the edge e starts a dead end.
// Next we test if the dead end is isolated, i.e. does not lead to a junction
bool hasJunction = false;
EdgeVector road;
NBEdge* eOld = 0;
NBNode* to;
std::set<NBNode*> adjacentNodes;
do {
road.push_back(e);
eOld = e;
from = e->getFromNode();
to = e->getToNode();
const EdgeVector& outgoingEdgesOfToNode = to->getOutgoingEdges();
const EdgeVector& incomingEdgesOfToNode = to->getIncomingEdges();
adjacentNodes.clear();
for (EdgeVector::const_iterator itOfOutgoings = outgoingEdgesOfToNode.begin(); itOfOutgoings != outgoingEdgesOfToNode.end(); ++itOfOutgoings) {
if ((*itOfOutgoings)->getToNode() != from // The back path
&& (*itOfOutgoings)->getToNode() != to // A loop / dummy edge
) {
e = *itOfOutgoings; // Probably the next edge
}
adjacentNodes.insert((*itOfOutgoings)->getToNode());
}
for (EdgeVector::const_iterator itOfIncomings = incomingEdgesOfToNode.begin(); itOfIncomings != incomingEdgesOfToNode.end(); ++itOfIncomings) {
adjacentNodes.insert((*itOfIncomings)->getFromNode());
}
adjacentNodes.erase(to); // Omit loops
if (adjacentNodes.size() > 2) {
hasJunction = true;
}
} while (!hasJunction && eOld != e);
if (!hasJunction) {
edgeCounter += int(road.size());
std::string warningString = "Removed a road without junctions: ";
for (EdgeVector::iterator roadIt = road.begin(); roadIt != road.end(); ++roadIt) {
if (roadIt == road.begin()) {
warningString += (*roadIt)->getID();
} else {
warningString += ", " + (*roadIt)->getID();
}
NBNode* fromNode = (*roadIt)->getFromNode();
NBNode* toNode = (*roadIt)->getToNode();
ec.erase(dc, *roadIt);
if (fromNode->getIncomingEdges().size() == 0 && fromNode->getOutgoingEdges().size() == 0) {
// Node is empty; can be removed
erase(fromNode);
}
if (toNode->getIncomingEdges().size() == 0 && toNode->getOutgoingEdges().size() == 0) {
// Node is empty; can be removed
erase(toNode);
}
}
WRITE_WARNING(warningString);
}
}
if (edgeCounter > 0 && !OptionsCont::getOptions().getBool("remove-edges.isolated")) {
WRITE_WARNING("Detected isolated roads. Use the option --remove-edges.isolated to get a list of all affected edges.");
}
}
示例4: min
void
NWWriter_DlrNavteq::writeNodesUnsplitted(const OptionsCont& oc, NBNodeCont& nc, NBEdgeCont& ec, std::map<NBEdge*, std::string>& internalNodes) {
// For "real" nodes we simply use the node id.
// For internal nodes (geometry vectors describing edge geometry in the parlance of this format)
// we use the id of the edge and do not bother with
// compression (each direction gets its own internal node).
OutputDevice& device = OutputDevice::getDevice(oc.getString("dlr-navteq-output") + "_nodes_unsplitted.txt");
writeHeader(device, oc);
const GeoConvHelper& gch = GeoConvHelper::getFinal();
const bool haveGeo = gch.usingGeoProjection();
const double geoScale = pow(10.0f, haveGeo ? 5 : 2); // see NIImporter_DlrNavteq::GEO_SCALE
device.setPrecision(oc.getInt("dlr-navteq.precision"));
if (!haveGeo) {
WRITE_WARNING("DlrNavteq node data will be written in (floating point) cartesian coordinates");
}
// write format specifier
device << "# NODE_ID\tIS_BETWEEN_NODE\tamount_of_geocoordinates\tx1\ty1\t[x2 y2 ... xn yn]\n";
// write header
Boundary boundary = gch.getConvBoundary();
Position min(boundary.xmin(), boundary.ymin());
Position max(boundary.xmax(), boundary.ymax());
gch.cartesian2geo(min);
min.mul(geoScale);
gch.cartesian2geo(max);
max.mul(geoScale);
int multinodes = 0;
for (std::map<std::string, NBEdge*>::const_iterator i = ec.begin(); i != ec.end(); ++i) {
if ((*i).second->getGeometry().size() > 2) {
multinodes++;
}
}
device << "# [xmin_region] " << min.x() << "\n";
device << "# [xmax_region] " << max.x() << "\n";
device << "# [ymin_region] " << min.y() << "\n";
device << "# [ymax_region] " << max.y() << "\n";
device << "# [elements_multinode] " << multinodes << "\n";
device << "# [elements_normalnode] " << nc.size() << "\n";
device << "# [xmin] " << min.x() << "\n";
device << "# [xmax] " << max.x() << "\n";
device << "# [ymin] " << min.y() << "\n";
device << "# [ymax] " << max.y() << "\n";
// write normal nodes
for (std::map<std::string, NBNode*>::const_iterator i = nc.begin(); i != nc.end(); ++i) {
NBNode* n = (*i).second;
Position pos = n->getPosition();
gch.cartesian2geo(pos);
pos.mul(geoScale);
device << n->getID() << "\t0\t1\t" << pos.x() << "\t" << pos.y() << "\n";
}
// write "internal" nodes
std::vector<std::string> avoid;
std::set<std::string> reservedNodeIDs;
const bool numericalIDs = oc.getBool("numerical-ids");
if (oc.isSet("reserved-ids")) {
NBHelpers::loadPrefixedIDsFomFile(oc.getString("reserved-ids"), "node:", reservedNodeIDs); // backward compatibility
NBHelpers::loadPrefixedIDsFomFile(oc.getString("reserved-ids"), "junction:", reservedNodeIDs); // selection format
}
if (numericalIDs) {
avoid = nc.getAllNames();
std::vector<std::string> avoid2 = ec.getAllNames();
avoid.insert(avoid.end(), avoid2.begin(), avoid2.end());
avoid.insert(avoid.end(), reservedNodeIDs.begin(), reservedNodeIDs.end());
}
IDSupplier idSupplier("", avoid);
for (std::map<std::string, NBEdge*>::const_iterator i = ec.begin(); i != ec.end(); ++i) {
NBEdge* e = (*i).second;
PositionVector geom = e->getGeometry();
if (geom.size() > 2) {
// the import NIImporter_DlrNavteq checks for the presence of a
// negated edge id to determine spread type. We may need to do some
// shifting to make this consistent
const bool hasOppositeID = ec.getOppositeByID(e->getID()) != nullptr;
if (e->getLaneSpreadFunction() == LANESPREAD_RIGHT && !hasOppositeID) {
// need to write center-line geometry instead
try {
geom.move2side(e->getTotalWidth() / 2);
} catch (InvalidArgument& exception) {
WRITE_WARNING("Could not reconstruct shape for edge:'" + e->getID() + "' (" + exception.what() + ").");
}
} else if (e->getLaneSpreadFunction() == LANESPREAD_CENTER && hasOppositeID) {
// need to write left-border geometry instead
try {
geom.move2side(-e->getTotalWidth() / 2);
} catch (InvalidArgument& exception) {
WRITE_WARNING("Could not reconstruct shape for edge:'" + e->getID() + "' (" + exception.what() + ").");
}
}
std::string internalNodeID = e->getID();
if (internalNodeID == UNDEFINED
|| (nc.retrieve(internalNodeID) != nullptr)
|| reservedNodeIDs.count(internalNodeID) > 0
) {
// need to invent a new name to avoid clashing with the id of a 'real' node or a reserved name
if (numericalIDs) {
internalNodeID = idSupplier.getNext();
} else {
internalNodeID += "_geometry";
}
}
//.........这里部分代码省略.........