本文整理汇总了C++中NBEdge::sortOutgoingConnectionsByIndex方法的典型用法代码示例。如果您正苦于以下问题:C++ NBEdge::sortOutgoingConnectionsByIndex方法的具体用法?C++ NBEdge::sortOutgoingConnectionsByIndex怎么用?C++ NBEdge::sortOutgoingConnectionsByIndex使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NBEdge
的用法示例。
在下文中一共展示了NBEdge::sortOutgoingConnectionsByIndex方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: writeLocation
// ===========================================================================
// method definitions
// ===========================================================================
// ---------------------------------------------------------------------------
// static methods
// ---------------------------------------------------------------------------
void
NWWriter_SUMO::writeNetwork(const OptionsCont& oc, NBNetBuilder& nb) {
// check whether a sumo net-file shall be generated
if (!oc.isSet("output-file")) {
return;
}
OutputDevice& device = OutputDevice::getDevice(oc.getString("output-file"));
device.writeXMLHeader("net", NWFrame::MAJOR_VERSION + " xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"http://sumo.sf.net/xsd/net_file.xsd\""); // street names may contain non-ascii chars
device.lf();
// get involved container
const NBNodeCont& nc = nb.getNodeCont();
const NBEdgeCont& ec = nb.getEdgeCont();
const NBDistrictCont& dc = nb.getDistrictCont();
// write network offsets and projection
writeLocation(device);
// write inner lanes
bool origNames = oc.getBool("output.original-names");
if (!oc.getBool("no-internal-links")) {
bool hadAny = false;
for (std::map<std::string, NBNode*>::const_iterator i = nc.begin(); i != nc.end(); ++i) {
hadAny |= writeInternalEdges(device, *(*i).second, origNames);
}
if (hadAny) {
device.lf();
}
}
// write edges with lanes and connected edges
bool noNames = !oc.getBool("output.street-names");
for (std::map<std::string, NBEdge*>::const_iterator i = ec.begin(); i != ec.end(); ++i) {
writeEdge(device, *(*i).second, noNames, origNames);
}
device.lf();
// write tls logics
writeTrafficLights(device, nb.getTLLogicCont());
// write the nodes (junctions)
for (std::map<std::string, NBNode*>::const_iterator i = nc.begin(); i != nc.end(); ++i) {
writeJunction(device, *(*i).second);
}
device.lf();
const bool includeInternal = !oc.getBool("no-internal-links");
if (includeInternal) {
// ... internal nodes if not unwanted
bool hadAny = false;
for (std::map<std::string, NBNode*>::const_iterator i = nc.begin(); i != nc.end(); ++i) {
hadAny |= writeInternalNodes(device, *(*i).second);
}
if (hadAny) {
device.lf();
}
}
// write the successors of lanes
unsigned int numConnections = 0;
for (std::map<std::string, NBEdge*>::const_iterator it_edge = ec.begin(); it_edge != ec.end(); it_edge++) {
NBEdge* from = it_edge->second;
from->sortOutgoingConnectionsByIndex();
const std::vector<NBEdge::Connection> connections = from->getConnections();
numConnections += (unsigned int)connections.size();
for (std::vector<NBEdge::Connection>::const_iterator it_c = connections.begin(); it_c != connections.end(); it_c++) {
writeConnection(device, *from, *it_c, includeInternal);
}
}
if (numConnections > 0) {
device.lf();
}
if (includeInternal) {
// ... internal successors if not unwanted
bool hadAny = false;
for (std::map<std::string, NBNode*>::const_iterator i = nc.begin(); i != nc.end(); ++i) {
hadAny |= writeInternalConnections(device, *(*i).second);
}
if (hadAny) {
device.lf();
}
}
// write loaded prohibitions
for (std::map<std::string, NBNode*>::const_iterator i = nc.begin(); i != nc.end(); ++i) {
writeProhibitions(device, i->second->getProhibitions());
}
// write roundabout information
const std::vector<EdgeVector>& roundabouts = nb.getRoundabouts();
for (std::vector<EdgeVector>::const_iterator i = roundabouts.begin(); i != roundabouts.end(); ++i) {
writeRoundabout(device, *i);
}
if (roundabouts.size() != 0) {
device.lf();
}
//.........这里部分代码省略.........
示例2: toString
// ===========================================================================
// method definitions
// ===========================================================================
// ---------------------------------------------------------------------------
// static methods
// ---------------------------------------------------------------------------
void
NWWriter_SUMO::writeNetwork(const OptionsCont& oc, NBNetBuilder& nb) {
// check whether a sumo net-file shall be generated
if (!oc.isSet("output-file")) {
return;
}
OutputDevice& device = OutputDevice::getDevice(oc.getString("output-file"));
const std::string lefthand = oc.getBool("lefthand") ? " " + toString(SUMO_ATTR_LEFTHAND) + "=\"true\"" : "";
const int cornerDetail = oc.getInt("junctions.corner-detail");
const int linkDetail = oc.getInt("junctions.internal-link-detail");
const std::string junctionCornerDetail = (cornerDetail > 0
? " " + toString(SUMO_ATTR_CORNERDETAIL) + "=\"" + toString(cornerDetail) + "\"" : "");
const std::string junctionLinkDetail = (oc.isDefault("junctions.internal-link-detail") ? "" :
" " + toString(SUMO_ATTR_LINKDETAIL) + "=\"" + toString(linkDetail) + "\"");
device.writeXMLHeader("net", NWFrame::MAJOR_VERSION + lefthand + junctionCornerDetail + junctionLinkDetail +
" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"http://sumo.dlr.de/xsd/net_file.xsd\""); // street names may contain non-ascii chars
device.lf();
// get involved container
const NBNodeCont& nc = nb.getNodeCont();
const NBEdgeCont& ec = nb.getEdgeCont();
const NBDistrictCont& dc = nb.getDistrictCont();
// write network offsets and projection
GeoConvHelper::writeLocation(device);
// write edge types and restrictions
nb.getTypeCont().writeTypes(device);
// write inner lanes
bool origNames = oc.getBool("output.original-names");
if (!oc.getBool("no-internal-links")) {
bool hadAny = false;
for (std::map<std::string, NBNode*>::const_iterator i = nc.begin(); i != nc.end(); ++i) {
hadAny |= writeInternalEdges(device, *(*i).second, origNames);
}
if (hadAny) {
device.lf();
}
}
// write edges with lanes and connected edges
bool noNames = !oc.getBool("output.street-names");
for (std::map<std::string, NBEdge*>::const_iterator i = ec.begin(); i != ec.end(); ++i) {
writeEdge(device, *(*i).second, noNames, origNames);
}
device.lf();
// write tls logics
writeTrafficLights(device, nb.getTLLogicCont());
// write the nodes (junctions)
std::set<NBNode*> roundaboutNodes;
const bool checkLaneFoesAll = oc.getBool("check-lane-foes.all");
const bool checkLaneFoesRoundabout = !checkLaneFoesAll && oc.getBool("check-lane-foes.roundabout");
if (checkLaneFoesRoundabout) {
const std::set<EdgeSet>& roundabouts = ec.getRoundabouts();
for (std::set<EdgeSet>::const_iterator i = roundabouts.begin(); i != roundabouts.end(); ++i) {
for (EdgeSet::const_iterator j = (*i).begin(); j != (*i).end(); ++j) {
roundaboutNodes.insert((*j)->getToNode());
}
}
}
for (std::map<std::string, NBNode*>::const_iterator i = nc.begin(); i != nc.end(); ++i) {
const bool checkLaneFoes = checkLaneFoesAll || (checkLaneFoesRoundabout && roundaboutNodes.count((*i).second) > 0);
writeJunction(device, *(*i).second, checkLaneFoes);
}
device.lf();
const bool includeInternal = !oc.getBool("no-internal-links");
if (includeInternal) {
// ... internal nodes if not unwanted
bool hadAny = false;
for (std::map<std::string, NBNode*>::const_iterator i = nc.begin(); i != nc.end(); ++i) {
hadAny |= writeInternalNodes(device, *(*i).second);
}
if (hadAny) {
device.lf();
}
}
// write the successors of lanes
unsigned int numConnections = 0;
for (std::map<std::string, NBEdge*>::const_iterator it_edge = ec.begin(); it_edge != ec.end(); it_edge++) {
NBEdge* from = it_edge->second;
from->sortOutgoingConnectionsByIndex();
const std::vector<NBEdge::Connection> connections = from->getConnections();
numConnections += (unsigned int)connections.size();
for (std::vector<NBEdge::Connection>::const_iterator it_c = connections.begin(); it_c != connections.end(); it_c++) {
writeConnection(device, *from, *it_c, includeInternal);
}
}
if (numConnections > 0) {
device.lf();
}
if (includeInternal) {
//.........这里部分代码省略.........
示例3: toString
void
NWWriter_XML::writeEdgesAndConnections(const OptionsCont& oc, NBNodeCont& nc, NBEdgeCont& ec) {
const GeoConvHelper& gch = GeoConvHelper::getFinal();
bool useGeo = oc.exists("proj.plain-geo") && oc.getBool("proj.plain-geo");
const bool geoAccuracy = useGeo || gch.usingInverseGeoProjection();
OutputDevice& edevice = OutputDevice::getDevice(oc.getString("plain-output-prefix") + ".edg.xml");
edevice.writeXMLHeader("edges", NWFrame::MAJOR_VERSION + " xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"http://sumo-sim.org/xsd/edges_file.xsd\"");
OutputDevice& cdevice = OutputDevice::getDevice(oc.getString("plain-output-prefix") + ".con.xml");
cdevice.writeXMLHeader("connections", NWFrame::MAJOR_VERSION + " xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"http://sumo-sim.org/xsd/connections_file.xsd\"");
bool noNames = !oc.getBool("output.street-names");
for (std::map<std::string, NBEdge*>::const_iterator i = ec.begin(); i != ec.end(); ++i) {
// write the edge itself to the edges-files
NBEdge* e = (*i).second;
edevice.openTag(SUMO_TAG_EDGE);
edevice.writeAttr(SUMO_ATTR_ID, e->getID());
edevice.writeAttr(SUMO_ATTR_FROM, e->getFromNode()->getID());
edevice.writeAttr(SUMO_ATTR_TO, e->getToNode()->getID());
if (!noNames && e->getStreetName() != "") {
edevice.writeAttr(SUMO_ATTR_NAME, StringUtils::escapeXML(e->getStreetName()));
}
edevice.writeAttr(SUMO_ATTR_PRIORITY, e->getPriority());
// write the type if given
if (e->getTypeID() != "") {
edevice.writeAttr(SUMO_ATTR_TYPE, e->getTypeID());
}
edevice.writeAttr(SUMO_ATTR_NUMLANES, e->getNumLanes());
if (!e->hasLaneSpecificSpeed()) {
edevice.writeAttr(SUMO_ATTR_SPEED, e->getSpeed());
}
// write non-default geometry
if (!e->hasDefaultGeometry()) {
PositionVector geom = e->getGeometry();
if (useGeo) {
for (int i = 0; i < (int) geom.size(); i++) {
gch.cartesian2geo(geom[i]);
}
}
if (geoAccuracy) {
edevice.setPrecision(GEO_OUTPUT_ACCURACY);
}
edevice.writeAttr(SUMO_ATTR_SHAPE, geom);
if (geoAccuracy) {
edevice.setPrecision();
}
}
// write the spread type if not default ("right")
if (e->getLaneSpreadFunction() != LANESPREAD_RIGHT) {
edevice.writeAttr(SUMO_ATTR_SPREADTYPE, toString(e->getLaneSpreadFunction()));
}
// write the length if it was specified
if (e->hasLoadedLength()) {
edevice.writeAttr(SUMO_ATTR_LENGTH, e->getLoadedLength());
}
// some attributes can be set by edge default or per lane. Write as default if possible (efficiency)
if (e->getLaneWidth() != NBEdge::UNSPECIFIED_WIDTH && !e->hasLaneSpecificWidth()) {
edevice.writeAttr(SUMO_ATTR_WIDTH, e->getLaneWidth());
}
if (e->getOffset() != NBEdge::UNSPECIFIED_OFFSET && !e->hasLaneSpecificOffset()) {
edevice.writeAttr(SUMO_ATTR_OFFSET, e->getOffset());
}
if (!e->needsLaneSpecificOutput()) {
edevice.closeTag();
} else {
for (unsigned int i = 0; i < e->getLanes().size(); ++i) {
const NBEdge::Lane& lane = e->getLanes()[i];
edevice.openTag(SUMO_TAG_LANE);
edevice.writeAttr(SUMO_ATTR_INDEX, i);
// write allowed lanes
NWWriter_SUMO::writePermissions(edevice, lane.permissions);
NWWriter_SUMO::writePreferences(edevice, lane.preferred);
// write other attributes
if (lane.width != NBEdge::UNSPECIFIED_WIDTH && e->hasLaneSpecificWidth()) {
edevice.writeAttr(SUMO_ATTR_WIDTH, lane.width);
}
if (lane.offset != NBEdge::UNSPECIFIED_OFFSET && e->hasLaneSpecificOffset()) {
edevice.writeAttr(SUMO_ATTR_OFFSET, lane.offset);
}
if (e->hasLaneSpecificSpeed()) {
edevice.writeAttr(SUMO_ATTR_SPEED, lane.speed);
}
edevice.closeTag();
}
edevice.closeTag();
}
// write this edge's connections to the connections-files
e->sortOutgoingConnectionsByIndex();
const std::vector<NBEdge::Connection> connections = e->getConnections();
for (std::vector<NBEdge::Connection>::const_iterator c = connections.begin(); c != connections.end(); ++c) {
NWWriter_SUMO::writeConnection(cdevice, *e, *c, false, NWWriter_SUMO::PLAIN);
}
if (connections.size() > 0) {
cdevice << "\n";
}
}
// write loaded prohibitions to the connections-file
for (std::map<std::string, NBNode*>::const_iterator i = nc.begin(); i != nc.end(); ++i) {
NWWriter_SUMO::writeProhibitions(cdevice, i->second->getProhibitions());
}
//.........这里部分代码省略.........