本文整理汇总了C++中NBNode::addCrossing方法的典型用法代码示例。如果您正苦于以下问题:C++ NBNode::addCrossing方法的具体用法?C++ NBNode::addCrossing怎么用?C++ NBNode::addCrossing使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NBNode
的用法示例。
在下文中一共展示了NBNode::addCrossing方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
void
NIXMLConnectionsHandler::addCrossing(const SUMOSAXAttributes& attrs) {
bool ok = true;
NBNode* node = 0;
EdgeVector edges;
const std::string nodeID = attrs.get<std::string>(SUMO_ATTR_NODE, 0, ok);
const double width = attrs.getOpt<double>(SUMO_ATTR_WIDTH, nodeID.c_str(), ok, NBEdge::UNSPECIFIED_WIDTH, true);
const bool discard = attrs.getOpt<bool>(SUMO_ATTR_DISCARD, nodeID.c_str(), ok, false, true);
int tlIndex = attrs.getOpt<int>(SUMO_ATTR_TLLINKINDEX, 0, ok, -1);
int tlIndex2 = attrs.getOpt<int>(SUMO_ATTR_TLLINKINDEX2, 0, ok, -1);
std::vector<std::string> edgeIDs;
if (!attrs.hasAttribute(SUMO_ATTR_EDGES)) {
if (discard) {
node = myNodeCont.retrieve(nodeID);
if (node == 0) {
WRITE_ERROR("Node '" + nodeID + "' in crossing is not known.");
return;
}
node->discardAllCrossings(true);
return;
} else {
WRITE_ERROR("No edges specified for crossing at node '" + nodeID + "'.");
return;
}
}
SUMOSAXAttributes::parseStringVector(attrs.get<std::string>(SUMO_ATTR_EDGES, 0, ok), edgeIDs);
if (!ok) {
return;
}
for (std::vector<std::string>::const_iterator it = edgeIDs.begin(); it != edgeIDs.end(); ++it) {
NBEdge* edge = myEdgeCont.retrieve(*it);
if (edge == 0) {
WRITE_ERROR("Edge '" + (*it) + "' for crossing at node '" + nodeID + "' is not known.");
return;
}
if (node == 0) {
if (edge->getToNode()->getID() == nodeID) {
node = edge->getToNode();
} else if (edge->getFromNode()->getID() == nodeID) {
node = edge->getFromNode();
} else {
WRITE_ERROR("Edge '" + (*it) + "' does not touch node '" + nodeID + "'.");
return;
}
} else {
if (edge->getToNode() != node && edge->getFromNode() != node) {
WRITE_ERROR("Edge '" + (*it) + "' does not touch node '" + nodeID + "'.");
return;
}
}
edges.push_back(edge);
}
bool priority = attrs.getOpt<bool>(SUMO_ATTR_PRIORITY, nodeID.c_str(), ok, node->isTLControlled(), true);
if (node->isTLControlled() && !priority) {
// traffic_light nodes should always have priority crossings
WRITE_WARNING("Crossing at controlled node '" + nodeID + "' must be prioritized");
priority = true;
}
PositionVector customShape = attrs.getOpt<PositionVector>(SUMO_ATTR_SHAPE, 0, ok, PositionVector::EMPTY);
if (!NBNetBuilder::transformCoordinates(customShape)) {
WRITE_ERROR("Unable to project shape for crossing at node '" + node->getID() + "'.");
}
if (discard) {
node->removeCrossing(edges);
} else {
if (node->checkCrossingDuplicated(edges)) {
WRITE_ERROR("Crossing with edges '" + toString(edges) + "' already exists at node '" + node->getID() + "'.");
return;
}
node->addCrossing(edges, width, priority, tlIndex, tlIndex2, customShape);
}
}
示例2: ProcessError
//.........这里部分代码省略.........
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 + "')");
}
}
} else {
WRITE_ERROR("The traffic light '" + c.tlID + "' is not known.");
}
}
}
// allow/disallow XXX preferred
nbe->setPermissions(parseVehicleClasses(lane->allow, lane->disallow), fromLaneIndex);
// width, offset
nbe->setLaneWidth(fromLaneIndex, lane->width);
nbe->setEndOffset(fromLaneIndex, lane->endOffset);
nbe->setSpeed(fromLaneIndex, lane->maxSpeed);
}
nbe->declareConnectionsAsLoaded();
if (!nbe->hasLaneSpecificWidth() && nbe->getLanes()[0].width != NBEdge::UNSPECIFIED_WIDTH) {
nbe->setLaneWidth(-1, nbe->getLaneWidth(0));
}
if (!nbe->hasLaneSpecificEndOffset() && nbe->getEndOffset(0) != NBEdge::UNSPECIFIED_OFFSET) {
nbe->setEndOffset(-1, nbe->getEndOffset(0));
}
}
// insert loaded prohibitions
for (std::vector<Prohibition>::const_iterator it = myProhibitions.begin(); it != myProhibitions.end(); it++) {
NBEdge* prohibitedFrom = myEdges[it->prohibitedFrom]->builtEdge;
NBEdge* prohibitedTo = myEdges[it->prohibitedTo]->builtEdge;
NBEdge* prohibitorFrom = myEdges[it->prohibitorFrom]->builtEdge;
NBEdge* prohibitorTo = myEdges[it->prohibitorTo]->builtEdge;
if (prohibitedFrom == 0) {
WRITE_WARNING("Edge '" + it->prohibitedFrom + "' in prohibition was not built");
} else if (prohibitedTo == 0) {
WRITE_WARNING("Edge '" + it->prohibitedTo + "' in prohibition was not built");
} else if (prohibitorFrom == 0) {
WRITE_WARNING("Edge '" + it->prohibitorFrom + "' in prohibition was not built");
} else if (prohibitorTo == 0) {
WRITE_WARNING("Edge '" + it->prohibitorTo + "' in prohibition was not built");
} else {
NBNode* n = prohibitedFrom->getToNode();
n->addSortedLinkFoes(
NBConnection(prohibitorFrom, prohibitorTo),
NBConnection(prohibitedFrom, prohibitedTo));
}
}
if (!myHaveSeenInternalEdge) {
myNetBuilder.haveLoadedNetworkWithoutInternalEdges();
}
if (oc.isDefault("lefthand")) {
oc.set("lefthand", toString(myAmLefthand));
}
if (oc.isDefault("junctions.corner-detail")) {
oc.set("junctions.corner-detail", toString(myCornerDetail));
}
if (oc.isDefault("junctions.internal-link-detail") && myLinkDetail > 0) {
oc.set("junctions.internal-link-detail", toString(myLinkDetail));
}
if (!deprecatedVehicleClassesSeen.empty()) {
WRITE_WARNING("Deprecated vehicle class(es) '" + toString(deprecatedVehicleClassesSeen) + "' in input network.");
deprecatedVehicleClassesSeen.clear();
}
// add loaded crossings
if (!oc.getBool("no-internal-links")) {
for (std::map<std::string, std::vector<Crossing> >::const_iterator it = myPedestrianCrossings.begin(); it != myPedestrianCrossings.end(); ++it) {
NBNode* node = myNodeCont.retrieve((*it).first);
for (std::vector<Crossing>::const_iterator it_c = (*it).second.begin(); it_c != (*it).second.end(); ++it_c) {
const Crossing& crossing = (*it_c);
EdgeVector edges;
for (std::vector<std::string>::const_iterator it_e = crossing.crossingEdges.begin(); it_e != crossing.crossingEdges.end(); ++it_e) {
NBEdge* edge = myNetBuilder.getEdgeCont().retrieve(*it_e);
// edge might have been removed due to options
if (edge != 0) {
edges.push_back(edge);
}
}
if (edges.size() > 0) {
node->addCrossing(edges, crossing.width, crossing.priority, true);
}
}
}
}
// add roundabouts
for (std::vector<std::vector<std::string> >::const_iterator it = myRoundabouts.begin(); it != myRoundabouts.end(); ++it) {
EdgeSet roundabout;
for (std::vector<std::string>::const_iterator it_r = it->begin(); it_r != it->end(); ++it_r) {
NBEdge* edge = myNetBuilder.getEdgeCont().retrieve(*it_r);
if (edge == 0) {
if (!myNetBuilder.getEdgeCont().wasIgnored(*it_r)) {
WRITE_ERROR("Unknown edge '" + (*it_r) + "' in roundabout");
}
} else {
roundabout.insert(edge);
}
}
myNetBuilder.getEdgeCont().addRoundabout(roundabout);
}
}