本文整理汇总了C++中NBEdge::getLanes方法的典型用法代码示例。如果您正苦于以下问题:C++ NBEdge::getLanes方法的具体用法?C++ NBEdge::getLanes怎么用?C++ NBEdge::getLanes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NBEdge
的用法示例。
在下文中一共展示了NBEdge::getLanes方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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();
}
示例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.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();
}
示例3: ProcessError
//.........这里部分代码省略.........
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 + "')");
}
}
} 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));
示例4: toString
void
NWWriter_XML::writeEdgesAndConnections(const OptionsCont& oc, NBNodeCont& nc, NBEdgeCont& ec) {
const GeoConvHelper& gch = GeoConvHelper::getFinal();
bool useGeo = oc.exists("proj.plain-geo") && oc.getBool("proj.plain-geo");
const bool geoAccuracy = useGeo || gch.usingInverseGeoProjection();
OutputDevice& edevice = OutputDevice::getDevice(oc.getString("plain-output-prefix") + ".edg.xml");
edevice.writeXMLHeader("edges", NWFrame::MAJOR_VERSION + " xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"http://sumo-sim.org/xsd/edges_file.xsd\"");
OutputDevice& cdevice = OutputDevice::getDevice(oc.getString("plain-output-prefix") + ".con.xml");
cdevice.writeXMLHeader("connections", NWFrame::MAJOR_VERSION + " xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"http://sumo-sim.org/xsd/connections_file.xsd\"");
bool noNames = !oc.getBool("output.street-names");
for (std::map<std::string, NBEdge*>::const_iterator i = ec.begin(); i != ec.end(); ++i) {
// write the edge itself to the edges-files
NBEdge* e = (*i).second;
edevice.openTag(SUMO_TAG_EDGE);
edevice.writeAttr(SUMO_ATTR_ID, e->getID());
edevice.writeAttr(SUMO_ATTR_FROM, e->getFromNode()->getID());
edevice.writeAttr(SUMO_ATTR_TO, e->getToNode()->getID());
if (!noNames && e->getStreetName() != "") {
edevice.writeAttr(SUMO_ATTR_NAME, StringUtils::escapeXML(e->getStreetName()));
}
edevice.writeAttr(SUMO_ATTR_PRIORITY, e->getPriority());
// write the type if given
if (e->getTypeID() != "") {
edevice.writeAttr(SUMO_ATTR_TYPE, e->getTypeID());
}
edevice.writeAttr(SUMO_ATTR_NUMLANES, e->getNumLanes());
if (!e->hasLaneSpecificSpeed()) {
edevice.writeAttr(SUMO_ATTR_SPEED, e->getSpeed());
}
// write non-default geometry
if (!e->hasDefaultGeometry()) {
PositionVector geom = e->getGeometry();
if (useGeo) {
for (int i = 0; i < (int) geom.size(); i++) {
gch.cartesian2geo(geom[i]);
}
}
if (geoAccuracy) {
edevice.setPrecision(GEO_OUTPUT_ACCURACY);
}
edevice.writeAttr(SUMO_ATTR_SHAPE, geom);
if (geoAccuracy) {
edevice.setPrecision();
}
}
// write the spread type if not default ("right")
if (e->getLaneSpreadFunction() != LANESPREAD_RIGHT) {
edevice.writeAttr(SUMO_ATTR_SPREADTYPE, toString(e->getLaneSpreadFunction()));
}
// write the length if it was specified
if (e->hasLoadedLength()) {
edevice.writeAttr(SUMO_ATTR_LENGTH, e->getLoadedLength());
}
// some attributes can be set by edge default or per lane. Write as default if possible (efficiency)
if (e->getLaneWidth() != NBEdge::UNSPECIFIED_WIDTH && !e->hasLaneSpecificWidth()) {
edevice.writeAttr(SUMO_ATTR_WIDTH, e->getLaneWidth());
}
if (e->getOffset() != NBEdge::UNSPECIFIED_OFFSET && !e->hasLaneSpecificOffset()) {
edevice.writeAttr(SUMO_ATTR_OFFSET, e->getOffset());
}
if (!e->needsLaneSpecificOutput()) {
edevice.closeTag();
} else {
for (unsigned int i = 0; i < e->getLanes().size(); ++i) {
const NBEdge::Lane& lane = e->getLanes()[i];
edevice.openTag(SUMO_TAG_LANE);
edevice.writeAttr(SUMO_ATTR_INDEX, i);
// write allowed lanes
NWWriter_SUMO::writePermissions(edevice, lane.permissions);
NWWriter_SUMO::writePreferences(edevice, lane.preferred);
// write other attributes
if (lane.width != NBEdge::UNSPECIFIED_WIDTH && e->hasLaneSpecificWidth()) {
edevice.writeAttr(SUMO_ATTR_WIDTH, lane.width);
}
if (lane.offset != NBEdge::UNSPECIFIED_OFFSET && e->hasLaneSpecificOffset()) {
edevice.writeAttr(SUMO_ATTR_OFFSET, lane.offset);
}
if (e->hasLaneSpecificSpeed()) {
edevice.writeAttr(SUMO_ATTR_SPEED, lane.speed);
}
edevice.closeTag();
}
edevice.closeTag();
}
// write this edge's connections to the connections-files
e->sortOutgoingConnectionsByIndex();
const std::vector<NBEdge::Connection> connections = e->getConnections();
for (std::vector<NBEdge::Connection>::const_iterator c = connections.begin(); c != connections.end(); ++c) {
NWWriter_SUMO::writeConnection(cdevice, *e, *c, false, NWWriter_SUMO::PLAIN);
}
if (connections.size() > 0) {
cdevice << "\n";
}
}
// write loaded prohibitions to the connections-file
for (std::map<std::string, NBNode*>::const_iterator i = nc.begin(); i != nc.end(); ++i) {
NWWriter_SUMO::writeProhibitions(cdevice, i->second->getProhibitions());
}
//.........这里部分代码省略.........