本文整理汇总了C++中NBNetBuilder::getDistrictCont方法的典型用法代码示例。如果您正苦于以下问题:C++ NBNetBuilder::getDistrictCont方法的具体用法?C++ NBNetBuilder::getDistrictCont怎么用?C++ NBNetBuilder::getDistrictCont使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NBNetBuilder
的用法示例。
在下文中一共展示了NBNetBuilder::getDistrictCont方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: buildOnRamp
// ===========================================================================
// method definitions
// ===========================================================================
// ---------------------------------------------------------------------------
// NBRampsComputer
// ---------------------------------------------------------------------------
void
NBRampsComputer::computeRamps(NBNetBuilder& nb, OptionsCont& oc) {
SUMOReal minHighwaySpeed = oc.getFloat("ramps.min-highway-speed");
SUMOReal maxRampSpeed = oc.getFloat("ramps.max-ramp-speed");
SUMOReal rampLength = oc.getFloat("ramps.ramp-length");
bool dontSplit = oc.getBool("ramps.no-split");
std::set<NBEdge*> incremented;
// check whether on-off ramps shall be guessed
if (oc.getBool("ramps.guess")) {
NBNodeCont& nc = nb.getNodeCont();
NBEdgeCont& ec = nb.getEdgeCont();
NBDistrictCont& dc = nb.getDistrictCont();
std::set<NBNode*> potOnRamps;
std::set<NBNode*> potOffRamps;
for (std::map<std::string, NBNode*>::const_iterator i = nc.begin(); i != nc.end(); ++i) {
NBNode* cur = (*i).second;
if (mayNeedOnRamp(cur, minHighwaySpeed, maxRampSpeed)) {
potOnRamps.insert(cur);
}
if (mayNeedOffRamp(cur, minHighwaySpeed, maxRampSpeed)) {
potOffRamps.insert(cur);
}
}
for (std::set<NBNode*>::const_iterator i = potOnRamps.begin(); i != potOnRamps.end(); ++i) {
buildOnRamp(*i, nc, ec, dc, rampLength, dontSplit, incremented);
}
for (std::set<NBNode*>::const_iterator i = potOffRamps.begin(); i != potOffRamps.end(); ++i) {
buildOffRamp(*i, nc, ec, dc, rampLength, dontSplit, incremented);
}
}
// check whether on-off ramps shall be guessed
if (oc.isSet("ramps.set")) {
std::vector<std::string> edges = oc.getStringVector("ramps.set");
NBNodeCont& nc = nb.getNodeCont();
NBEdgeCont& ec = nb.getEdgeCont();
NBDistrictCont& dc = nb.getDistrictCont();
for (std::vector<std::string>::iterator i = edges.begin(); i != edges.end(); ++i) {
NBEdge* e = ec.retrieve(*i);
if (e == 0) {
WRITE_WARNING("Can not build on ramp on edge '" + *i + "' - the edge is not known.");
continue;
}
NBNode* from = e->getFromNode();
if (from->getIncomingEdges().size() == 2 && from->getOutgoingEdges().size() == 1) {
buildOnRamp(from, nc, ec, dc, rampLength, dontSplit, incremented);
}
// load edge again to check offramps
e = ec.retrieve(*i);
if (e == 0) {
WRITE_WARNING("Can not build off ramp on edge '" + *i + "' - the edge is not known.");
continue;
}
NBNode* to = e->getToNode();
if (to->getIncomingEdges().size() == 1 && to->getOutgoingEdges().size() == 2) {
buildOffRamp(to, nc, ec, dc, rampLength, dontSplit, incremented);
}
}
}
}
示例2: ProcessError
// ===========================================================================
// method definitions
// ===========================================================================
// ---------------------------------------------------------------------------
// static methods
// ---------------------------------------------------------------------------
void
NIImporter_DlrNavteq::loadNetwork(const OptionsCont& oc, NBNetBuilder& nb) {
// check whether the option is set (properly)
if (!oc.isSet("dlr-navteq-prefix")) {
return;
}
time_t csTime;
time(&csTime);
// parse file(s)
LineReader lr;
// load nodes
std::map<std::string, PositionVector> myGeoms;
PROGRESS_BEGIN_MESSAGE("Loading nodes");
std::string file = oc.getString("dlr-navteq-prefix") + "_nodes_unsplitted.txt";
NodesHandler handler1(nb.getNodeCont(), file, myGeoms);
if (!lr.setFile(file)) {
throw ProcessError("The file '" + file + "' could not be opened.");
}
lr.readAll(handler1);
PROGRESS_DONE_MESSAGE();
// load street names if given and wished
std::map<std::string, std::string> streetNames; // nameID : name
if (oc.getBool("output.street-names")) {
file = oc.getString("dlr-navteq-prefix") + "_names.txt";
if (lr.setFile(file)) {
PROGRESS_BEGIN_MESSAGE("Loading Street Names");
NamesHandler handler4(file, streetNames);
lr.readAll(handler4);
PROGRESS_DONE_MESSAGE();
} else {
WRITE_WARNING("Output will not contain street names because the file '" + file + "' was not found");
}
}
// load edges
PROGRESS_BEGIN_MESSAGE("Loading edges");
file = oc.getString("dlr-navteq-prefix") + "_links_unsplitted.txt";
// parse the file
EdgesHandler handler2(nb.getNodeCont(), nb.getEdgeCont(), nb.getTypeCont(), file, myGeoms, streetNames);
if (!lr.setFile(file)) {
throw ProcessError("The file '" + file + "' could not be opened.");
}
lr.readAll(handler2);
nb.getEdgeCont().recheckLaneSpread();
PROGRESS_DONE_MESSAGE();
// load traffic lights if given
file = oc.getString("dlr-navteq-prefix") + "_traffic_signals.txt";
if (lr.setFile(file)) {
PROGRESS_BEGIN_MESSAGE("Loading traffic lights");
TrafficlightsHandler handler3(nb.getNodeCont(), nb.getTLLogicCont(), nb.getEdgeCont(), file);
lr.readAll(handler3);
PROGRESS_DONE_MESSAGE();
}
// load prohibited manoeuvres if given
file = oc.getString("dlr-navteq-prefix") + "_prohibited_manoeuvres.txt";
if (lr.setFile(file)) {
PROGRESS_BEGIN_MESSAGE("Loading prohibited manoeuvres");
ProhibitionHandler handler6(nb.getEdgeCont(), file, csTime);
lr.readAll(handler6);
PROGRESS_DONE_MESSAGE();
}
// load connected lanes if given
file = oc.getString("dlr-navteq-prefix") + "_connected_lanes.txt";
if (lr.setFile(file)) {
PROGRESS_BEGIN_MESSAGE("Loading connected lanes");
ConnectedLanesHandler handler7(nb.getEdgeCont());
lr.readAll(handler7);
PROGRESS_DONE_MESSAGE();
}
// load time restrictions if given
file = oc.getString("dlr-navteq-prefix") + "_links_timerestrictions.txt";
if (lr.setFile(file)) {
PROGRESS_BEGIN_MESSAGE("Loading time restrictions");
if (!oc.isDefault("construction-date")) {
csTime = readDate(oc.getString("construction-date"));
}
TimeRestrictionsHandler handler5(nb.getEdgeCont(), nb.getDistrictCont(), csTime);
lr.readAll(handler5);
handler5.printSummary();
PROGRESS_DONE_MESSAGE();
}
}
示例3: 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) {
//.........这里部分代码省略.........
示例4: 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();
}
//.........这里部分代码省略.........