本文整理汇总了C++中NBEdge::getNoLanes方法的典型用法代码示例。如果您正苦于以下问题:C++ NBEdge::getNoLanes方法的具体用法?C++ NBEdge::getNoLanes怎么用?C++ NBEdge::getNoLanes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NBEdge
的用法示例。
在下文中一共展示了NBEdge::getNoLanes方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: toString
unsigned int
NIVissimConnection::buildEdgeConnections(NBEdgeCont &ec) {
unsigned int unsetConnections = 0;
// try to determine the connected edges
NBEdge *fromEdge = 0;
NBEdge *toEdge = 0;
NIVissimEdge *vissimFrom = NIVissimEdge::dictionary(getFromEdgeID());
if (vissimFrom->wasWithinAJunction()) {
// this edge was not built, try to get one that approaches it
vissimFrom = vissimFrom->getBestIncoming();
if (vissimFrom!=0) {
fromEdge = ec.retrievePossiblySplitted(toString(vissimFrom->getID()), toString(getFromEdgeID()), true);
}
} else {
// this edge was built, try to get the proper part
fromEdge = ec.retrievePossiblySplitted(toString(getFromEdgeID()), toString(getToEdgeID()), true);
}
NIVissimEdge *vissimTo = NIVissimEdge::dictionary(getToEdgeID());
if (vissimTo->wasWithinAJunction()) {
vissimTo = vissimTo->getBestOutgoing();
if (vissimTo!=0) {
toEdge = ec.retrievePossiblySplitted(toString(vissimTo->getID()), toString(getToEdgeID()), true);
}
} else {
toEdge = ec.retrievePossiblySplitted(toString(getToEdgeID()), toString(getFromEdgeID()), false);
}
// try to get the edges the current connection connects
/*
NBEdge *fromEdge = ec.retrievePossiblySplitted(toString(getFromEdgeID()), toString(getToEdgeID()), true);
NBEdge *toEdge = ec.retrievePossiblySplitted(toString(getToEdgeID()), toString(getFromEdgeID()), false);
*/
if (fromEdge==0||toEdge==0) {
WRITE_WARNING("Could not build connection between '" + toString(getFromEdgeID())+ "' and '" + toString(getToEdgeID())+ "'.");
return 1; // !!! actually not 1
}
recheckLanes(fromEdge, toEdge);
const IntVector &fromLanes = getFromLanes();
const IntVector &toLanes = getToLanes();
if (fromLanes.size()!=toLanes.size()) {
MsgHandler::getWarningInstance()->inform("Lane sizes differ for connection '" + toString(getID()) + "'.");
} else {
for (unsigned int index=0; index<fromLanes.size(); ++index) {
if (fromEdge->getNoLanes()<=static_cast<unsigned int>(fromLanes[index])) {
MsgHandler::getWarningInstance()->inform("Could not set connection between '" + fromEdge->getID() + "_" + toString(fromLanes[index]) + "' and '" + toEdge->getID() + "_" + toString(toLanes[index]) + "'.");
++unsetConnections;
} else if (!fromEdge->addLane2LaneConnection(fromLanes[index], toEdge, toLanes[index], NBEdge::L2L_VALIDATED)) {
MsgHandler::getWarningInstance()->inform("Could not set connection between '" + fromEdge->getID() + "_" + toString(fromLanes[index]) + "' and '" + toEdge->getID() + "_" + toString(toLanes[index]) + "'.");
++unsetConnections;
}
}
}
return unsetConnections;
}
示例2: ProcessError
void
NBOwnTLDef::collectLinks() throw(ProcessError) {
// build the list of links which are controled by the traffic light
for (EdgeVector::iterator i=myIncomingEdges.begin(); i!=myIncomingEdges.end(); i++) {
NBEdge *incoming = *i;
unsigned int noLanes = incoming->getNoLanes();
for (unsigned int j=0; j<noLanes; j++) {
std::vector<NBEdge::Connection> connected = incoming->getConnectionsFromLane(j);
for (std::vector<NBEdge::Connection>::iterator k=connected.begin(); k!=connected.end(); k++) {
const NBEdge::Connection &el = *k;
if (incoming->mayBeTLSControlled(el.fromLane, el.toEdge, el.toLane)) {
if (el.toEdge!=0&&el.toLane>=(int) el.toEdge->getNoLanes()) {
throw ProcessError("Connection '" + incoming->getID() + "_" + toString(j) + "->" + el.toEdge->getID() + "_" + toString(el.toLane) + "' yields in a not existing lane.");
}
myControlledLinks.push_back(NBConnection(incoming, j, el.toEdge, el.toLane));
}
}
}
}
}
示例3: throw
void
NIXMLEdgesHandler::myEndElement(SumoXMLTag element) throw(ProcessError) {
if (element==SUMO_TAG_EDGE && myCurrentEdge!=0) {
if (!myIsUpdate) {
try {
if (!myEdgeCont.insert(myCurrentEdge)) {
MsgHandler::getErrorInstance()->inform("Duplicate edge occured. ID='" + myCurrentID + "'");
delete myCurrentEdge;
}
} catch (InvalidArgument &e) {
MsgHandler::getErrorInstance()->inform(e.what());
throw;
} catch (...) {
MsgHandler::getErrorInstance()->inform("An important information is missing in edge '" + myCurrentID + "'.");
}
}
if (mySplits.size()!=0) {
std::vector<Split>::iterator i, i2;
sort(mySplits.begin(), mySplits.end(), split_sorter());
NBEdge *e = myCurrentEdge;
unsigned int noLanesMax = e->getNoLanes();
// compute the node positions and sort the lanes
for (i=mySplits.begin(); i!=mySplits.end(); ++i) {
(*i).gpos = e->getGeometry().positionAtLengthPosition((*i).pos);
sort((*i).lanes.begin(), (*i).lanes.end());
noLanesMax = MAX2(noLanesMax, (unsigned int)(*i).lanes.size());
}
// split the edge
std::vector<int> currLanes;
for (unsigned int l=0; l<noLanesMax; ++l) {
currLanes.push_back(l);
}
std::string edgeid = e->getID();
SUMOReal seen = 0;
for (i=mySplits.begin(); i!=mySplits.end(); ++i) {
const Split &exp = *i;
assert(exp.lanes.size()!=0);
if (exp.pos>0 && e->getGeometry().length()+seen>exp.pos) {
std::string nid = edgeid + "." + toString(exp.nameid);
NBNode *rn = new NBNode(nid, exp.gpos);
if (myNodeCont.insert(rn)) {
// split the edge
std::string nid = myCurrentID + "." + toString(exp.nameid);
std::string pid = e->getID();
myEdgeCont.splitAt(myDistrictCont, e, exp.pos-seen, rn,
pid, nid, e->getNoLanes(), (unsigned int) exp.lanes.size());
seen = exp.pos;
std::vector<int> newLanes = exp.lanes;
NBEdge *pe = myEdgeCont.retrieve(pid);
NBEdge *ne = myEdgeCont.retrieve(nid);
// reconnect lanes
pe->invalidateConnections(true);
// new on right
unsigned int rightMostP = currLanes[0];
unsigned int rightMostN = newLanes[0];
for (int l=0; l<(int) rightMostP-(int) rightMostN; ++l) {
pe->addLane2LaneConnection(0, ne, l, NBEdge::L2L_VALIDATED, true);
}
// new on left
unsigned int leftMostP = currLanes.back();
unsigned int leftMostN = newLanes.back();
for (int l=0; l<(int) leftMostN-(int) leftMostP; ++l) {
pe->addLane2LaneConnection(pe->getNoLanes()-1, ne, leftMostN-l, NBEdge::L2L_VALIDATED, true);
}
// all other connected
for (unsigned int l=0; l<noLanesMax; ++l) {
if (find(currLanes.begin(), currLanes.end(), l)==currLanes.end()) {
continue;
}
if (find(newLanes.begin(), newLanes.end(), l)==newLanes.end()) {
continue;
}
pe->addLane2LaneConnection(l-rightMostP, ne, l-rightMostN, NBEdge::L2L_VALIDATED, true);
}
// move to next
e = ne;
currLanes = newLanes;
} else {
MsgHandler::getWarningInstance()->inform("Error on parsing a split (edge '" + myCurrentID + "').");
}
} else if (exp.pos==0) {
e->decLaneNo(e->getNoLanes()-exp.lanes.size());
currLanes = exp.lanes;
} else {
MsgHandler::getWarningInstance()->inform("Split at '" + toString(exp.pos) + "' lies beyond the edge's length (edge '" + myCurrentID + "').");
}
}
// patch lane offsets
e = myEdgeCont.retrieve(edgeid);
i = mySplits.begin();
if ((*i).pos!=0) {
e = e->getToNode()->getOutgoingEdges()[0];
}
for (; i!=mySplits.end(); ++i) {
unsigned int maxLeft = (*i).lanes.back();
if (maxLeft<noLanesMax) {
Position2DVector g = e->getGeometry();
g.move2side(SUMO_const_laneWidthAndOffset*(noLanesMax-1-maxLeft));
e->setGeometry(g);
}
//.........这里部分代码省略.........
示例4: state
NBTrafficLightLogic *
NBOwnTLDef::myCompute(const NBEdgeCont &,
unsigned int brakingTime) throw() {
// build complete lists first
const EdgeVector &incoming = getIncomingEdges();
std::vector<NBEdge*> fromEdges, toEdges;
std::vector<bool> isLeftMoverV, isTurnaround;
unsigned int noLanesAll = 0;
unsigned int noLinksAll = 0;
for (unsigned int i1=0; i1<incoming.size(); i1++) {
unsigned int noLanes = incoming[i1]->getNoLanes();
noLanesAll += noLanes;
for (unsigned int i2=0; i2<noLanes; i2++) {
NBEdge *fromEdge = incoming[i1];
std::vector<NBEdge::Connection> approached = fromEdge->getConnectionsFromLane(i2);
noLinksAll += (unsigned int) approached.size();
for (unsigned int i3=0; i3<approached.size(); i3++) {
if (!fromEdge->mayBeTLSControlled(i2, approached[i3].toEdge, approached[i3].toLane)) {
--noLinksAll;
continue;
}
assert(i3<approached.size());
NBEdge *toEdge = approached[i3].toEdge;
fromEdges.push_back(fromEdge);
//myFromLanes.push_back(i2);
toEdges.push_back(toEdge);
if (toEdge!=0) {
isLeftMoverV.push_back(
isLeftMover(fromEdge, toEdge)
||
fromEdge->isTurningDirectionAt(fromEdge->getToNode(), toEdge));
isTurnaround.push_back(
fromEdge->isTurningDirectionAt(
fromEdge->getToNode(), toEdge));
} else {
isLeftMoverV.push_back(true);
isTurnaround.push_back(true);
}
}
}
}
NBTrafficLightLogic *logic = new NBTrafficLightLogic(getID(), "0", noLinksAll);
std::vector<NBEdge*> toProc = incoming;
// build all phases
while (toProc.size()>0) {
std::pair<NBEdge*, NBEdge*> chosen;
if (incoming.size()==2) {
chosen = std::pair<NBEdge*, NBEdge*>(toProc[0], static_cast<NBEdge*>(0));
toProc.erase(toProc.begin());
} else {
chosen = getBestPair(toProc);
}
unsigned int pos = 0;
unsigned int duration = 31;
if (OptionsCont::getOptions().isSet("traffic-light-green")) {
duration = OptionsCont::getOptions().getInt("traffic-light-green");
}
std::string state((size_t) noLinksAll, 'o');
// plain straight movers
for (unsigned int i1=0; i1<(unsigned int) incoming.size(); ++i1) {
NBEdge *fromEdge = incoming[i1];
bool inChosen = fromEdge==chosen.first||fromEdge==chosen.second;//chosen.find(fromEdge)!=chosen.end();
unsigned int noLanes = fromEdge->getNoLanes();
for (unsigned int i2=0; i2<noLanes; i2++) {
std::vector<NBEdge::Connection> approached = fromEdge->getConnectionsFromLane(i2);
for (unsigned int i3=0; i3<approached.size(); ++i3) {
if (!fromEdge->mayBeTLSControlled(i2, approached[i3].toEdge, approached[i3].toLane)) {
continue;
}
if (inChosen) {
state[pos] = 'G';
} else {
state[pos] = 'r';
}
++pos;
}
}
}
// correct behaviour for those that are not in chosen, but may drive, though
for (unsigned int i1=0; i1<pos; ++i1) {
if (state[i1]=='G') {
continue;
}
bool isForbidden = false;
for (unsigned int i2=0; i2<pos&&!isForbidden; ++i2) {
if (state[i2]=='G'&&!isTurnaround[i2]&&
(forbids(fromEdges[i2], toEdges[i2], fromEdges[i1], toEdges[i1], true)||forbids(fromEdges[i1], toEdges[i1], fromEdges[i2], toEdges[i2], true))) {
isForbidden = true;
}
}
if (!isForbidden) {
state[i1] = 'G';
}
}
// correct behaviour for those that have to wait (mainly left-mover)
bool haveForbiddenLeftMover = false;
for (unsigned int i1=0; i1<pos; ++i1) {
if (state[i1]!='G') {
//.........这里部分代码省略.........