本文整理汇总了C++中NBEdge::getLaneID方法的典型用法代码示例。如果您正苦于以下问题:C++ NBEdge::getLaneID方法的具体用法?C++ NBEdge::getLaneID怎么用?C++ NBEdge::getLaneID使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NBEdge
的用法示例。
在下文中一共展示了NBEdge::getLaneID方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: st
bool
NIImporter_DlrNavteq::ConnectedLanesHandler::report(const std::string& result) {
if (result[0] == '#') {
return true;
}
StringTokenizer st(result, StringTokenizer::TAB);
if (st.size() == 1) {
return true; // one line with the number of data containing lines in it (also starts with a comment # since ersion 6.5)
}
assert(st.size() >= 7);
const std::string nodeID = st.next();
const std::string vehicleType = st.next();
const std::string fromLaneS = st.next();
const std::string toLaneS = st.next();
const std::string throughTraffic = st.next();
const std::string startEdge = st.next();
const std::string endEdge = st.get(st.size() - 1);
NBEdge* from = myEdgeCont.retrieve(startEdge);
if (from == nullptr) {
WRITE_WARNING("Ignoring prohibition from unknown start edge '" + startEdge + "'");
return true;
}
NBEdge* to = myEdgeCont.retrieve(endEdge);
if (to == nullptr) {
WRITE_WARNING("Ignoring prohibition from unknown end edge '" + endEdge + "'");
return true;
}
int fromLane = StringUtils::toInt(fromLaneS) - 1; // one based
if (fromLane < 0 || fromLane >= from->getNumLanes()) {
WRITE_WARNING("Ignoring invalid lane index '" + fromLaneS + "' in connection from edge '" + startEdge + "' with " + toString(from->getNumLanes()) + " lanes");
return true;
}
int toLane = StringUtils::toInt(toLaneS) - 1; // one based
if (toLane < 0 || toLane >= to->getNumLanes()) {
WRITE_WARNING("Ignoring invalid lane index '" + toLaneS + "' in connection to edge '" + endEdge + "' with " + toString(to->getNumLanes()) + " lanes");
return true;
}
if (!from->addLane2LaneConnection(fromLane, to, toLane, NBEdge::L2L_USER, true)) {
if (OptionsCont::getOptions().getBool("show-errors.connections-first-try")) {
WRITE_WARNING("Could not set loaded connection from '" + from->getLaneID(fromLane) + "' to '" + to->getLaneID(toLane) + "'.");
}
// set as to be re-applied after network processing
// if this connection runs across a node cluster it may not be possible to set this
const bool warnOnly = st.size() > 7;
myEdgeCont.addPostProcessConnection(from->getID(), fromLane, to->getID(), toLane, false, true,
NBEdge::UNSPECIFIED_CONTPOS, NBEdge::UNSPECIFIED_VISIBILITY_DISTANCE,
NBEdge::UNSPECIFIED_SPEED, PositionVector::EMPTY, false, warnOnly);
}
// ensure that connections for other lanes are guessed if not specified
from->declareConnectionsAsLoaded(NBEdge::INIT);
from->getLaneStruct(fromLane).connectionsDone = true;
return true;
}
示例2: writeLane
void
NWWriter_SUMO::writeEdge(OutputDevice& into, const NBEdge& e, bool noNames, bool origNames) {
// write the edge's begin
into.openTag(SUMO_TAG_EDGE).writeAttr(SUMO_ATTR_ID, e.getID());
into.writeAttr(SUMO_ATTR_FROM, e.getFromNode()->getID());
into.writeAttr(SUMO_ATTR_TO, e.getToNode()->getID());
if (!noNames && e.getStreetName() != "") {
into.writeAttr(SUMO_ATTR_NAME, StringUtils::escapeXML(e.getStreetName()));
}
into.writeAttr(SUMO_ATTR_PRIORITY, e.getPriority());
if (e.getTypeID() != "") {
into.writeAttr(SUMO_ATTR_TYPE, e.getTypeID());
}
if (e.isMacroscopicConnector()) {
into.writeAttr(SUMO_ATTR_FUNCTION, EDGEFUNC_CONNECTOR);
}
// write the spread type if not default ("right")
if (e.getLaneSpreadFunction() != LANESPREAD_RIGHT) {
into.writeAttr(SUMO_ATTR_SPREADTYPE, e.getLaneSpreadFunction());
}
if (e.hasLoadedLength()) {
into.writeAttr(SUMO_ATTR_LENGTH, e.getLoadedLength());
}
if (!e.hasDefaultGeometry()) {
into.writeAttr(SUMO_ATTR_SHAPE, e.getGeometry());
}
// write the lanes
const std::vector<NBEdge::Lane>& lanes = e.getLanes();
SUMOReal length = e.getLoadedLength();
if (OptionsCont::getOptions().getBool("no-internal-links") && !e.hasLoadedLength()) {
// use length to junction center even if a modified geometry was given
PositionVector geom = e.cutAtIntersection(e.getGeometry());
geom.push_back_noDoublePos(e.getToNode()->getCenter());
geom.push_front_noDoublePos(e.getFromNode()->getCenter());
length = geom.length();
}
if (length <= 0) {
length = POSITION_EPS;
}
for (unsigned int i = 0; i < (unsigned int) lanes.size(); i++) {
const NBEdge::Lane& l = lanes[i];
writeLane(into, e.getID(), e.getLaneID(i), l.speed,
l.permissions, l.preferred, l.endOffset, l.width, l.shape, l.origID,
length, i, origNames);
}
// close the edge
into.closeTag();
}
示例3: writeLane
void
NWWriter_SUMO::writeEdge(OutputDevice& into, const NBEdge& e, bool noNames, bool origNames) {
// write the edge's begin
into.openTag(SUMO_TAG_EDGE).writeAttr(SUMO_ATTR_ID, e.getID());
into.writeAttr(SUMO_ATTR_FROM, e.getFromNode()->getID());
into.writeAttr(SUMO_ATTR_TO, e.getToNode()->getID());
if (!noNames && e.getStreetName() != "") {
into.writeAttr(SUMO_ATTR_NAME, StringUtils::escapeXML(e.getStreetName()));
}
into.writeAttr(SUMO_ATTR_PRIORITY, e.getPriority());
if (e.getTypeName() != "") {
into.writeAttr(SUMO_ATTR_TYPE, e.getTypeName());
}
if (e.isMacroscopicConnector()) {
into.writeAttr(SUMO_ATTR_FUNCTION, EDGEFUNC_CONNECTOR);
}
// write the spread type if not default ("right")
if (e.getLaneSpreadFunction() != LANESPREAD_RIGHT) {
into.writeAttr(SUMO_ATTR_SPREADTYPE, e.getLaneSpreadFunction());
}
if (e.hasLoadedLength()) {
into.writeAttr(SUMO_ATTR_LENGTH, e.getLoadedLength());
}
if (!e.hasDefaultGeometry()) {
into.writeAttr(SUMO_ATTR_SHAPE, e.getGeometry());
}
// write the lanes
const std::vector<NBEdge::Lane>& lanes = e.getLanes();
SUMOReal length = e.getLoadedLength();
if (length <= 0) {
length = (SUMOReal) .1;
}
for (unsigned int i = 0; i < (unsigned int) lanes.size(); i++) {
writeLane(into, e.getID(), e.getLaneID(i), lanes[i], length, i, origNames);
}
// close the edge
into.closeTag();
}
示例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 + "')");
}
}
//.........这里部分代码省略.........