本文整理汇总了C++中NBNode::getType方法的典型用法代码示例。如果您正苦于以下问题:C++ NBNode::getType方法的具体用法?C++ NBNode::getType怎么用?C++ NBNode::getType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NBNode
的用法示例。
在下文中一共展示了NBNode::getType方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
void
NWWriter_SUMO::writeJunction(OutputDevice& into, const NBNode& n) {
// write the attributes
into.openTag(SUMO_TAG_JUNCTION).writeAttr(SUMO_ATTR_ID, n.getID());
into.writeAttr(SUMO_ATTR_TYPE, n.getType());
NWFrame::writePositionLong(n.getPosition(), into);
// write the incoming lanes
std::string incLanes;
const std::vector<NBEdge*>& incoming = n.getIncomingEdges();
for (std::vector<NBEdge*>::const_iterator i = incoming.begin(); i != incoming.end(); ++i) {
unsigned int noLanes = (*i)->getNumLanes();
for (unsigned int j = 0; j < noLanes; j++) {
incLanes += (*i)->getLaneID(j);
if (i != incoming.end() - 1 || j < noLanes - 1) {
incLanes += ' ';
}
}
}
into.writeAttr(SUMO_ATTR_INCLANES, incLanes);
// write the internal lanes
std::string intLanes;
if (!OptionsCont::getOptions().getBool("no-internal-links")) {
unsigned int l = 0;
for (EdgeVector::const_iterator i = incoming.begin(); i != incoming.end(); i++) {
const std::vector<NBEdge::Connection>& elv = (*i)->getConnections();
for (std::vector<NBEdge::Connection>::const_iterator k = elv.begin(); k != elv.end(); ++k) {
if ((*k).toEdge == 0) {
continue;
}
if (l != 0) {
intLanes += ' ';
}
if (!(*k).haveVia) {
intLanes += (*k).id + "_0";
} else {
intLanes += (*k).viaID + "_0";
}
l++;
}
}
}
into.writeAttr(SUMO_ATTR_INTLANES, intLanes);
// close writing
into.writeAttr(SUMO_ATTR_SHAPE, n.getShape());
if (n.getType() == NODETYPE_DEAD_END) {
into.closeTag();
} else {
// write right-of-way logics
n.writeLogic(into);
into.closeTag();
}
}
示例2: st
bool
NIImporter_DlrNavteq::TrafficlightsHandler::report(const std::string& result) {
// #ID POICOL-TYPE DESCRIPTION LONGITUDE LATITUDE NAVTEQ_LINK_ID NODEID
if (result[0] == '#') {
return true;
}
StringTokenizer st(result, StringTokenizer::WHITECHARS);
const std::string edgeID = st.get(5);
NBEdge* edge = myEdgeCont.retrieve(edgeID);
if (edge == nullptr) {
WRITE_WARNING("The traffic light edge '" + edgeID + "' could not be found");
} else {
NBNode* node = edge->getToNode();
if (node->getType() != NODETYPE_TRAFFIC_LIGHT) {
node->reinit(node->getPosition(), NODETYPE_TRAFFIC_LIGHT);
// @note. There may be additional information somewhere in the GDF files about traffic light type ...
TrafficLightType type = SUMOXMLDefinitions::TrafficLightTypes.get(OptionsCont::getOptions().getString("tls.default-type"));
// @note actually we could use the navteq node ID here
NBTrafficLightDefinition* tlDef = new NBOwnTLDef(node->getID(), node, 0, type);
if (!myTLLogicCont.insert(tlDef)) {
// actually, nothing should fail here
delete tlDef;
throw ProcessError("Could not allocate tls for '" + node->getID() + "'.");
}
}
}
return true;
}
示例3: toString
void
NWWriter_XML::writeNodes(const OptionsCont& oc, NBNodeCont& nc) {
const GeoConvHelper& gch = GeoConvHelper::getFinal();
bool useGeo = oc.exists("proj.plain-geo") && oc.getBool("proj.plain-geo");
if (useGeo && !gch.usingGeoProjection()) {
WRITE_WARNING("Ignoring option \"proj.plain-geo\" because no geo-conversion has been defined");
useGeo = false;
}
const bool geoAccuracy = useGeo || gch.usingInverseGeoProjection();
OutputDevice& device = OutputDevice::getDevice(oc.getString("plain-output-prefix") + ".nod.xml");
device.writeXMLHeader("nodes", NWFrame::MAJOR_VERSION + " xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"http://sumo-sim.org/xsd/nodes_file.xsd\"");
// write network offsets and projection to allow reconstruction of original coordinates
if (!useGeo) {
NWWriter_SUMO::writeLocation(device);
}
// write nodes
for (std::map<std::string, NBNode*>::const_iterator i = nc.begin(); i != nc.end(); ++i) {
NBNode* n = (*i).second;
device.openTag(SUMO_TAG_NODE);
device.writeAttr(SUMO_ATTR_ID, n->getID());
// write position
Position pos = n->getPosition();
if (useGeo) {
gch.cartesian2geo(pos);
}
if (geoAccuracy) {
device.setPrecision(GEO_OUTPUT_ACCURACY);
}
NWFrame::writePositionLong(pos, device);
if (geoAccuracy) {
device.setPrecision();
}
device.writeAttr(SUMO_ATTR_TYPE, toString(n->getType()));
if (n->isTLControlled()) {
const std::set<NBTrafficLightDefinition*>& tlss = n->getControllingTLS();
// set may contain multiple programs for the same id.
// make sure ids are unique and sorted
std::set<std::string> tlsIDs;
for (std::set<NBTrafficLightDefinition*>::const_iterator it_tl = tlss.begin(); it_tl != tlss.end(); it_tl++) {
tlsIDs.insert((*it_tl)->getID());
}
std::vector<std::string> sortedIDs(tlsIDs.begin(), tlsIDs.end());
sort(sortedIDs.begin(), sortedIDs.end());
device.writeAttr(SUMO_ATTR_TLID, sortedIDs);
}
device.closeTag();
}
device.close();
}
示例4: dummy
void
NBTrafficLightLogicCont::setTLControllingInformation(const NBEdgeCont& ec, const NBNodeCont& nc) {
Definitions definitions = getDefinitions();
// set the information about all participants, first
for (Definitions::iterator it = definitions.begin(); it != definitions.end(); it++) {
(*it)->setParticipantsInformation();
}
// clear previous information because tlDefs may have been removed in NETEDIT
ec.clearControllingTLInformation();
// insert the information about the tl-controlling
for (Definitions::iterator it = definitions.begin(); it != definitions.end(); it++) {
(*it)->setTLControllingInformation();
}
// handle rail signals which are not instantiated as normal definitions
for (std::map<std::string, NBNode*>::const_iterator it = nc.begin(); it != nc.end(); it ++) {
NBNode* n = it->second;
if (n->getType() == NODETYPE_RAIL_SIGNAL || n->getType() == NODETYPE_RAIL_CROSSING) {
NBOwnTLDef dummy(n->getID(), n, 0, TLTYPE_STATIC);
dummy.setParticipantsInformation();
dummy.setTLControllingInformation();
n->removeTrafficLight(&dummy);
}
}
}
示例5:
void
NWWriter_SUMO::writeJunction(OutputDevice& into, const NBNode& n, const bool checkLaneFoes) {
// write the attributes
into.openTag(SUMO_TAG_JUNCTION).writeAttr(SUMO_ATTR_ID, n.getID());
into.writeAttr(SUMO_ATTR_TYPE, n.getType());
NWFrame::writePositionLong(n.getPosition(), into);
// write the incoming lanes
std::string incLanes;
const std::vector<NBEdge*>& incoming = n.getIncomingEdges();
for (std::vector<NBEdge*>::const_iterator i = incoming.begin(); i != incoming.end(); ++i) {
unsigned int noLanes = (*i)->getNumLanes();
for (unsigned int j = 0; j < noLanes; j++) {
incLanes += (*i)->getLaneID(j);
if (i != incoming.end() - 1 || j < noLanes - 1) {
incLanes += ' ';
}
}
}
const std::vector<NBNode::Crossing>& crossings = n.getCrossings();
for (std::vector<NBNode::Crossing>::const_iterator it = crossings.begin(); it != crossings.end(); it++) {
incLanes += ' ' + (*it).prevWalkingArea + "_0";
}
into.writeAttr(SUMO_ATTR_INCLANES, incLanes);
// write the internal lanes
std::string intLanes;
if (!OptionsCont::getOptions().getBool("no-internal-links")) {
unsigned int l = 0;
for (EdgeVector::const_iterator i = incoming.begin(); i != incoming.end(); i++) {
const std::vector<NBEdge::Connection>& elv = (*i)->getConnections();
for (std::vector<NBEdge::Connection>::const_iterator k = elv.begin(); k != elv.end(); ++k) {
if ((*k).toEdge == 0) {
continue;
}
if (l != 0) {
intLanes += ' ';
}
if (!(*k).haveVia) {
intLanes += (*k).getInternalLaneID();
} else {
intLanes += (*k).viaID + "_0";
}
l++;
}
}
}
if (n.getType() != NODETYPE_DEAD_END && n.getType() != NODETYPE_NOJUNCTION) {
for (std::vector<NBNode::Crossing>::const_iterator it = crossings.begin(); it != crossings.end(); it++) {
intLanes += ' ' + (*it).id + "_0";
}
}
into.writeAttr(SUMO_ATTR_INTLANES, intLanes);
// close writing
into.writeAttr(SUMO_ATTR_SHAPE, n.getShape());
// write optional radius
if (n.getRadius() != NBNode::UNSPECIFIED_RADIUS) {
into.writeAttr(SUMO_ATTR_RADIUS, n.getRadius());
}
// specify whether a custom shape was used
if (n.hasCustomShape()) {
into.writeAttr(SUMO_ATTR_CUSTOMSHAPE, true);
}
if (n.getType() == NODETYPE_DEAD_END) {
into.closeTag();
} else {
// write right-of-way logics
n.writeLogic(into, checkLaneFoes);
into.closeTag();
}
}