本文整理汇总了C++中NBEdge::addEdge2EdgeConnection方法的典型用法代码示例。如果您正苦于以下问题:C++ NBEdge::addEdge2EdgeConnection方法的具体用法?C++ NBEdge::addEdge2EdgeConnection怎么用?C++ NBEdge::addEdge2EdgeConnection使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NBEdge
的用法示例。
在下文中一共展示了NBEdge::addEdge2EdgeConnection方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getNamedNode
void
NIImporter_VISUM::parse_Turns() {
if (myLineParser.know("VSYSSET") && myLineParser.get("VSYSSET") == "") {
// no vehicle allowed; don't add
return;
}
// retrieve the nodes
NBNode* from = getNamedNode("VonKnot", "VonKnotNr");
NBNode* via = getNamedNode("UeberKnot", "UeberKnotNr");
NBNode* to = getNamedNode("NachKnot", "NachKnotNr");
if (from == 0 || via == 0 || to == 0) {
return;
}
// all nodes are known
std::string type = myLineParser.know("VSysCode")
? myLineParser.get("VSysCode")
: myLineParser.get("VSYSSET");
if (myVSysTypes.find(type) != myVSysTypes.end() && myVSysTypes.find(type)->second == "IV") {
// try to set the turning definition
NBEdge* src = from->getConnectionTo(via);
NBEdge* dest = via->getConnectionTo(to);
// check both
if (src == 0) {
// maybe it was removed due to something
if (OptionsCont::getOptions().isSet("keep-edges.min-speed")
||
OptionsCont::getOptions().isSet("keep-edges.explicit")) {
WRITE_WARNING("Could not set connection from node '" + from->getID() + "' to node '" + via->getID() + "'.");
} else {
if (OptionsCont::getOptions().getBool("visum.verbose-warnings")) {
WRITE_WARNING("There is no edge from node '" + from->getID() + "' to node '" + via->getID() + "'.");
}
}
return;
}
if (dest == 0) {
if (OptionsCont::getOptions().isSet("keep-edges.min-speed")
||
OptionsCont::getOptions().isSet("keep-edges.explicit")) {
WRITE_WARNING("Could not set connection from node '" + via->getID() + "' to node '" + to->getID() + "'.");
} else {
if (OptionsCont::getOptions().getBool("visum.verbose-warnings")) {
WRITE_WARNING("There is no edge from node '" + via->getID() + "' to node '" + to->getID() + "'.");
}
}
return;
}
// both edges found
// set them into the edge
src->addEdge2EdgeConnection(dest);
}
}
示例2: sort
void
NBEdgeCont::joinSameNodeConnectingEdges(NBDistrictCont& dc,
NBTrafficLightLogicCont& tlc,
EdgeVector edges) {
// !!! Attention!
// No merging of the geometry to come is being done
// The connections are moved from one edge to another within
// the replacement where the edge is a node's incoming edge.
// count the number of lanes, the speed and the id
unsigned int nolanes = 0;
SUMOReal speed = 0;
int priority = 0;
std::string id;
sort(edges.begin(), edges.end(), NBContHelper::same_connection_edge_sorter());
// retrieve the connected nodes
NBEdge* tpledge = *(edges.begin());
NBNode* from = tpledge->getFromNode();
NBNode* to = tpledge->getToNode();
EdgeVector::const_iterator i;
for (i = edges.begin(); i != edges.end(); i++) {
// some assertions
assert((*i)->getFromNode() == from);
assert((*i)->getToNode() == to);
// ad the number of lanes the current edge has
nolanes += (*i)->getNumLanes();
// build the id
if (i != edges.begin()) {
id += "+";
}
id += (*i)->getID();
// compute the speed
speed += (*i)->getSpeed();
// build the priority
priority = MAX2(priority, (*i)->getPriority());
}
speed /= edges.size();
// build the new edge
// @bug new edge does not know about allowed vclass of old edges
// @bug both the width and the offset are not regarded
NBEdge* newEdge = new NBEdge(id, from, to, "", speed, nolanes, priority,
NBEdge::UNSPECIFIED_WIDTH, NBEdge::UNSPECIFIED_OFFSET,
tpledge->getStreetName(), tpledge->myLaneSpreadFunction);
insert(newEdge, true);
// replace old edge by current within the nodes
// and delete the old
from->replaceOutgoing(edges, newEdge);
to->replaceIncoming(edges, newEdge);
// patch connections
// add edge2edge-information
for (i = edges.begin(); i != edges.end(); i++) {
EdgeVector ev = (*i)->getConnectedEdges();
for (EdgeVector::iterator j = ev.begin(); j != ev.end(); j++) {
newEdge->addEdge2EdgeConnection(*j);
}
}
// move lane2lane-connections
unsigned int currLane = 0;
for (i = edges.begin(); i != edges.end(); i++) {
newEdge->moveOutgoingConnectionsFrom(*i, currLane);
currLane += (*i)->getNumLanes();
}
// patch tl-information
currLane = 0;
for (i = edges.begin(); i != edges.end(); i++) {
unsigned int noLanes = (*i)->getNumLanes();
for (unsigned int j = 0; j < noLanes; j++, currLane++) {
// replace in traffic lights
tlc.replaceRemoved(*i, j, newEdge, currLane);
}
}
// delete joined edges
for (i = edges.begin(); i != edges.end(); i++) {
erase(dc, *i);
}
}
示例3: toString
void
NIXMLConnectionsHandler::myStartElement(int element,
const SUMOSAXAttributes& attrs) {
if (element == SUMO_TAG_DELETE) {
bool ok = true;
std::string from = attrs.get<std::string>(SUMO_ATTR_FROM, 0, ok);
std::string to = attrs.get<std::string>(SUMO_ATTR_TO, 0, ok);
if (!ok) {
return;
}
// these connections were removed when the edge was deleted
if (myEdgeCont.wasRemoved(from) || myEdgeCont.wasRemoved(to)) {
return;
}
NBEdge* fromEdge = myEdgeCont.retrieve(from);
NBEdge* toEdge = myEdgeCont.retrieve(to);
if (fromEdge == 0) {
myErrorMsgHandler->inform("The connection-source edge '" + from + "' to reset is not known.");
return;
}
if (toEdge == 0) {
myErrorMsgHandler->inform("The connection-destination edge '" + to + "' to reset is not known.");
return;
}
if (!fromEdge->isConnectedTo(toEdge) && fromEdge->getStep() >= NBEdge::EDGE2EDGES) {
WRITE_WARNING("Target edge '" + toEdge->getID() + "' is not connected with '" + fromEdge->getID() + "'; the connection cannot be reset.");
return;
}
int fromLane = -1; // Assume all lanes are to be reset.
int toLane = -1;
if (attrs.hasAttribute(SUMO_ATTR_LANE)
|| attrs.hasAttribute(SUMO_ATTR_FROM_LANE)
|| attrs.hasAttribute(SUMO_ATTR_TO_LANE)) {
if (!parseLaneInfo(attrs, fromEdge, toEdge, &fromLane, &toLane)) {
return;
}
// we could be trying to reset a connection loaded from a sumo net and which has become obsolete.
// In this case it's ok to encounter invalid lance indices
if (!fromEdge->hasConnectionTo(toEdge, toLane) && fromEdge->getStep() >= NBEdge::LANES2EDGES) {
WRITE_WARNING("Edge '" + fromEdge->getID() + "' has no connection to lane " + toString(toLane) + " of edge '" + toEdge->getID() + "'; the connection cannot be reset.");
}
}
fromEdge->removeFromConnections(toEdge, fromLane, toLane, true);
}
if (element == SUMO_TAG_CONNECTION) {
bool ok = true;
std::string from = attrs.get<std::string>(SUMO_ATTR_FROM, "connection", ok);
std::string to = attrs.getOpt<std::string>(SUMO_ATTR_TO, "connection", ok, "");
if (!ok || myEdgeCont.wasIgnored(from) || myEdgeCont.wasIgnored(to)) {
return;
}
// extract edges
NBEdge* fromEdge = myEdgeCont.retrieve(from);
NBEdge* toEdge = to.length() != 0 ? myEdgeCont.retrieve(to) : 0;
// check whether they are valid
if (fromEdge == 0) {
myErrorMsgHandler->inform("The connection-source edge '" + from + "' is not known.");
return;
}
if (toEdge == 0 && to.length() != 0) {
myErrorMsgHandler->inform("The connection-destination edge '" + to + "' is not known.");
return;
}
fromEdge->getToNode()->invalidateTLS(myTLLogicCont, true, false);
// parse optional lane information
if (attrs.hasAttribute(SUMO_ATTR_LANE) || attrs.hasAttribute(SUMO_ATTR_FROM_LANE) || attrs.hasAttribute(SUMO_ATTR_TO_LANE)) {
parseLaneBound(attrs, fromEdge, toEdge);
} else {
fromEdge->addEdge2EdgeConnection(toEdge);
}
}
if (element == SUMO_TAG_PROHIBITION) {
bool ok = true;
std::string prohibitor = attrs.getOpt<std::string>(SUMO_ATTR_PROHIBITOR, 0, ok, "");
std::string prohibited = attrs.getOpt<std::string>(SUMO_ATTR_PROHIBITED, 0, ok, "");
if (!ok) {
return;
}
NBConnection prohibitorC = parseConnection("prohibitor", prohibitor);
NBConnection prohibitedC = parseConnection("prohibited", prohibited);
if (prohibitorC == NBConnection::InvalidConnection || prohibitedC == NBConnection::InvalidConnection) {
// something failed
return;
}
NBNode* n = prohibitorC.getFrom()->getToNode();
n->addSortedLinkFoes(prohibitorC, prohibitedC);
}
if (element == SUMO_TAG_CROSSING) {
addCrossing(attrs);
}
if (element == SUMO_TAG_WALKINGAREA) {
addWalkingArea(attrs);
}
}