本文整理汇总了C++中NBNodeCont类的典型用法代码示例。如果您正苦于以下问题:C++ NBNodeCont类的具体用法?C++ NBNodeCont怎么用?C++ NBNodeCont使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了NBNodeCont类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: assert
std::pair<NIVissimConnectionCluster*, NBNode*>
NIVissimEdge::getFromNode(NBNodeCont& nc, ConnectionClusters& clusters) {
const SUMOReal MAX_DISTANCE = 10.;
assert(clusters.size() >= 1);
const Position& beg = myGeom.front();
NIVissimConnectionCluster* c = *(clusters.begin());
// check whether the edge starts within a already build node
if (c->around(beg, MAX_DISTANCE)) {
clusters.erase(clusters.begin());
return std::pair<NIVissimConnectionCluster*, NBNode*>
(c, c->getNBNode());
}
// check for a parking place at the begin
if (myDistrictConnections.size() > 0) {
SUMOReal pos = *(myDistrictConnections.begin());
if (pos < 10) {
NBNode* node = new NBNode(toString<int>(myID) + "-begin", beg, NODETYPE_NOJUNCTION);
if (!nc.insert(node)) {
throw 1;
}
while (myDistrictConnections.size() > 0 && *(myDistrictConnections.begin()) < 10) {
myDistrictConnections.erase(myDistrictConnections.begin());
}
return std::pair<NIVissimConnectionCluster*, NBNode*>(static_cast<NIVissimConnectionCluster*>(0), node);
}
}
// build a new node for the edge's begin otherwise
NBNode* node = new NBNode(toString<int>(myID) + "-begin", beg, NODETYPE_NOJUNCTION);
if (!nc.insert(node)) {
throw 1;
}
return std::pair<NIVissimConnectionCluster*, NBNode*>(static_cast<NIVissimConnectionCluster*>(0), node);
}
示例2: writeHeader
void
NWWriter_DlrNavteq::writeTrafficSignals(const OptionsCont& oc, NBNodeCont& nc) {
OutputDevice& device = OutputDevice::getDevice(oc.getString("dlr-navteq-output") + "_traffic_signals.txt");
writeHeader(device, oc);
const GeoConvHelper& gch = GeoConvHelper::getFinal();
const bool haveGeo = gch.usingGeoProjection();
const SUMOReal geoScale = pow(10.0f, haveGeo ? 5 : 2); // see NIImporter_DlrNavteq::GEO_SCALE
device.setPrecision(0);
// write format specifier
device << "#Traffic signal related to LINK_ID and NODE_ID with location relative to driving direction.\n#column format like pointcollection.\n#DESCRIPTION->LOCATION: 1-rechts von LINK; 2-links von LINK; 3-oberhalb LINK -1-keineAngabe\n#RELATREC_ID\tPOICOL_TYPE\tDESCRIPTION\tLONGITUDE\tLATITUDE\tLINK_ID\n";
// write record for every edge incoming to a tls controlled node
for (std::map<std::string, NBNode*>::const_iterator i = nc.begin(); i != nc.end(); ++i) {
NBNode* n = (*i).second;
if (n->isTLControlled()) {
Position pos = n->getPosition();
gch.cartesian2geo(pos);
pos.mul(geoScale);
const EdgeVector& incoming = n->getIncomingEdges();
for (EdgeVector::const_iterator it = incoming.begin(); it != incoming.end(); ++it) {
NBEdge* e = *it;
device << e->getID() << "\t"
<< "12\t" // POICOL_TYPE
<< "LSA;NODEIDS#" << n->getID() << "#;LOCATION#-1#;\t"
<< pos.x() << "\t"
<< pos.y() << "\t"
<< e->getID() << "\n";
}
}
}
}
示例3: writeHeader
void
NWWriter_DlrNavteq::writeConnectedLanes(const OptionsCont& oc, NBNodeCont& nc) {
OutputDevice& device = OutputDevice::getDevice(oc.getString("dlr-navteq-output") + "_connected_lanes.txt");
writeHeader(device, oc);
// write format specifier
device << "#Lane connections related to LINK-IDs and NODE-ID.\n";
device << "#column format like pointcollection.\n";
device << "#NODE-ID\tVEHICLE-TYPE\tFROM_LANE\tTO_LANE\tTHROUGH_TRAFFIC\tLINK_IDs[2..*]\n";
// write record for every connection
for (std::map<std::string, NBNode*>::const_iterator i = nc.begin(); i != nc.end(); ++i) {
NBNode* n = (*i).second;
const EdgeVector& incoming = n->getIncomingEdges();
for (EdgeVector::const_iterator j = incoming.begin(); j != incoming.end(); ++j) {
NBEdge* from = *j;
const SVCPermissions fromPerm = from->getPermissions();
const std::vector<NBEdge::Connection>& connections = from->getConnections();
for (std::vector<NBEdge::Connection>::const_iterator it_c = connections.begin(); it_c != connections.end(); it_c++) {
const NBEdge::Connection& c = *it_c;
device
<< n->getID() << "\t"
<< getAllowedTypes(fromPerm & c.toEdge->getPermissions()) << "\t"
<< c.fromLane + 1 << "\t" // one-based
<< c.toLane + 1 << "\t" // one-based
<< 1 << "\t" // no information regarding permissibility of through traffic
<< from->getID() << "\t"
<< c.toEdge->getID() << "\t"
<< "\n";
}
}
}
device.close();
}
示例4: 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();
}
示例5: NBNode
void
NIVissimDistrictConnection::dict_BuildDistrictNodes(NBDistrictCont& dc,
NBNodeCont& nc) {
for (std::map<int, std::vector<int> >::iterator k = myDistrictsConnections.begin(); k != myDistrictsConnections.end(); k++) {
// get the connections
const std::vector<int>& connections = (*k).second;
// retrieve the current district
std::string dsid = toString<int>((*k).first);
NBDistrict* district = new NBDistrict(dsid);
dc.insert(district);
// compute the middle of the district
PositionVector pos;
for (std::vector<int>::const_iterator j = connections.begin(); j != connections.end(); j++) {
NIVissimDistrictConnection* c = dictionary(*j);
pos.push_back(c->geomPosition());
}
Position distCenter = pos.getPolygonCenter();
if (connections.size() == 1) { // !!! ok, ok, maybe not the best way just to add an offset
distCenter.add(10, 10);
}
district->setCenter(distCenter);
// build the node
std::string id = "District" + district->getID();
NBNode* districtNode =
new NBNode(id, district->getPosition(), district);
if (!nc.insert(districtNode)) {
throw 1;
}
}
}
示例6: NBNode
void
NIVissimNodeCluster::buildNBNode(NBNodeCont& nc) {
if (myConnectors.size() == 0) {
return; // !!! Check, whether this can happen
}
// compute the position
PositionVector crossings;
IntVector::iterator i, j;
// check whether this is a split of an edge only
if (myAmEdgeSplit) {
// !!! should be assert(myTLID==-1);
for (i = myConnectors.begin(); i != myConnectors.end(); i++) {
NIVissimConnection* c1 = NIVissimConnection::dictionary(*i);
crossings.push_back_noDoublePos(c1->getFromGeomPosition());
}
} else {
// compute the places the connections cross
for (i = myConnectors.begin(); i != myConnectors.end(); i++) {
NIVissimAbstractEdge* c1 = NIVissimAbstractEdge::dictionary(*i);
c1->buildGeom();
for (j = i + 1; j != myConnectors.end(); j++) {
NIVissimAbstractEdge* c2 = NIVissimAbstractEdge::dictionary(*j);
c2->buildGeom();
if (c1->crossesEdge(c2)) {
crossings.push_back_noDoublePos(c1->crossesEdgeAtPoint(c2));
}
}
}
// alternative way: compute via positions of crossings
if (crossings.size() == 0) {
for (i = myConnectors.begin(); i != myConnectors.end(); i++) {
NIVissimConnection* c1 = NIVissimConnection::dictionary(*i);
crossings.push_back_noDoublePos(c1->getFromGeomPosition());
crossings.push_back_noDoublePos(c1->getToGeomPosition());
}
}
}
// get the position (center)
Position pos = crossings.getPolygonCenter();
// build the node
/* if(myTLID!=-1) {
!!! NIVissimTL *tl = NIVissimTL::dictionary(myTLID);
if(tl->getType()=="festzeit") {
node = new NBNode(getNodeName(), pos.x(), pos.y(),
"traffic_light");
} else {
node = new NBNode(getNodeName(), pos.x(), pos.y(),
"actuated_traffic_light");
}
}*/
NBNode* node = new NBNode(getNodeName(), pos, NODETYPE_PRIORITY_JUNCTION);
if (!nc.insert(node)) {
delete node;
throw 1;
}
myNBNode = node;
}
示例7: setPriorityJunctionPriorities
// ---------------------------------------------------------------------------
// NBEdgePriorityComputer
// ---------------------------------------------------------------------------
void
NBEdgePriorityComputer::computeEdgePriorities(NBNodeCont& nc) {
for (std::map<std::string, NBNode*>::const_iterator i = nc.begin(); i != nc.end(); ++i) {
NBNode* n = (*i).second;
// preset all junction's edge priorities to zero
for (EdgeVector::iterator j = n->myAllEdges.begin(); j != n->myAllEdges.end(); ++j) {
(*j)->setJunctionPriority(n, 0);
}
// check if the junction is not a real junction
if (n->myIncomingEdges.size() == 1 && n->myOutgoingEdges.size() == 1) {
continue;
}
// compute the priorities on junction when needed
if (n->myType != NODETYPE_RIGHT_BEFORE_LEFT) {
setPriorityJunctionPriorities(*n);
}
}
}
示例8:
// ---------------------------------------------------------------------------
// NBNodeTypeComputer
// ---------------------------------------------------------------------------
void
NBNodeTypeComputer::computeNodeTypes(NBNodeCont& nc) {
for (std::map<std::string, NBNode*>::const_iterator i = nc.begin(); i != nc.end(); ++i) {
NBNode* n = (*i).second;
// the type may already be set from the data
if (n->myType != NODETYPE_UNKNOWN) {
continue;
}
// check whether the junction is not a real junction
if (n->myIncomingEdges.size() == 1) {
n->myType = NODETYPE_PRIORITY;
continue;
}
// @todo "isSimpleContinuation" should be revalidated
if (n->isSimpleContinuation()) {
n->myType = NODETYPE_PRIORITY;
continue;
}
// determine the type
SumoXMLNodeType type = NODETYPE_RIGHT_BEFORE_LEFT;
for (EdgeVector::const_iterator i = n->myIncomingEdges.begin(); i != n->myIncomingEdges.end(); i++) {
for (EdgeVector::const_iterator j = i + 1; j != n->myIncomingEdges.end(); j++) {
// @todo "getOppositeIncoming" should probably be refactored into something the edge knows
if (n->getOppositeIncoming(*j) == *i && n->myIncomingEdges.size() > 2) {
continue;
}
// @todo check against a legal document
// @todo figure out when NODETYPE_PRIORITY_STOP is appropriate
const SUMOReal s1 = (*i)->getSpeed() * (SUMOReal) 3.6;
const SUMOReal s2 = (*j)->getSpeed() * (SUMOReal) 3.6;
const int p1 = (*i)->getPriority();
const int p2 = (*j)->getPriority();
if (fabs(s1 - s2) > (SUMOReal) 9.5 || MAX2(s1, s2) >= (SUMOReal) 49. || p1 != p2) {
type = NODETYPE_PRIORITY;
break;
}
}
}
// save type
n->myType = type;
}
}
示例9: idSupplier
void
NWWriter_DlrNavteq::writeProhibitedManoeuvres(const OptionsCont& oc, const NBNodeCont& nc, const NBEdgeCont& ec) {
OutputDevice& device = OutputDevice::getDevice(oc.getString("dlr-navteq-output") + "_prohibited_manoeuvres.txt");
writeHeader(device, oc);
// need to invent id for relation
std::set<std::string> reservedRelIDs;
if (oc.isSet("reserved-ids")) {
NBHelpers::loadPrefixedIDsFomFile(oc.getString("reserved-ids"), "rel:", reservedRelIDs);
}
std::vector<std::string> avoid = ec.getAllNames(); // already used for tls RELATREC_ID
avoid.insert(avoid.end(), reservedRelIDs.begin(), reservedRelIDs.end());
IDSupplier idSupplier("", avoid); // @note: use a global relRecIDsupplier if this is used more often
// write format specifier
device << "#No driving allowed from ID1 to ID2 or the complete chain from ID1 to IDn\n";
device << "#RELATREC_ID\tPERMANENT_ID_INFO\tVALIDITY_PERIOD\tTHROUGH_TRAFFIC\tVEHICLE_TYPE\tNAVTEQ_LINK_ID1\t[NAVTEQ_LINK_ID2 ...]\n";
// write record for every pair of incoming/outgoing edge that are not connected despite having common permissions
for (std::map<std::string, NBNode*>::const_iterator i = nc.begin(); i != nc.end(); ++i) {
NBNode* n = (*i).second;
const EdgeVector& incoming = n->getIncomingEdges();
const EdgeVector& outgoing = n->getOutgoingEdges();
for (EdgeVector::const_iterator j = incoming.begin(); j != incoming.end(); ++j) {
NBEdge* inEdge = *j;
const SVCPermissions inPerm = inEdge->getPermissions();
for (EdgeVector::const_iterator k = outgoing.begin(); k != outgoing.end(); ++k) {
NBEdge* outEdge = *k;
const SVCPermissions outPerm = outEdge->getPermissions();
const SVCPermissions commonPerm = inPerm & outPerm;
if (commonPerm != 0 && commonPerm != SVC_PEDESTRIAN && !inEdge->isConnectedTo(outEdge)) {
device
<< idSupplier.getNext() << "\t"
<< 1 << "\t" // permanent id
<< UNDEFINED << "\t"
<< 1 << "\t"
<< getAllowedTypes(SVCAll) << "\t"
<< inEdge->getID() << "\t" << outEdge->getID() << "\n";
}
}
}
}
device.close();
}
示例10:
void
NIVissimNodeCluster::dict_addDisturbances(NBDistrictCont& dc,
NBNodeCont& nc, NBEdgeCont& ec) {
for (DictType::iterator i = myDict.begin(); i != myDict.end(); i++) {
const IntVector& disturbances = (*i).second->myDisturbances;
NBNode* node = nc.retrieve((*i).second->getNodeName());
for (IntVector::const_iterator j = disturbances.begin(); j != disturbances.end(); j++) {
NIVissimDisturbance* disturbance = NIVissimDisturbance::dictionary(*j);
disturbance->addToNode(node, dc, nc, ec);
}
}
NIVissimDisturbance::reportRefused();
}
示例11: swapWhenReversed
// ---------------------------------------------------------------------------
// NBNodesEdgesSorter
// ---------------------------------------------------------------------------
void
NBNodesEdgesSorter::sortNodesEdges(NBNodeCont& nc, bool leftHand) {
for (std::map<std::string, NBNode*>::const_iterator i = nc.begin(); i != nc.end(); ++i) {
NBNode* n = (*i).second;
if (n->myAllEdges.size() == 0) {
continue;
}
std::vector<NBEdge*>& allEdges = (*i).second->myAllEdges;
std::vector<NBEdge*>& incoming = (*i).second->myIncomingEdges;
std::vector<NBEdge*>& outgoing = (*i).second->myOutgoingEdges;
// sort the edges
std::sort(allEdges.begin(), allEdges.end(), edge_by_junction_angle_sorter(n));
std::sort(incoming.begin(), incoming.end(), edge_by_junction_angle_sorter(n));
std::sort(outgoing.begin(), outgoing.end(), edge_by_junction_angle_sorter(n));
std::vector<NBEdge*>::iterator j;
for (j = allEdges.begin(); j != allEdges.end() - 1 && j != allEdges.end(); ++j) {
swapWhenReversed(n, leftHand, j, j + 1);
}
if (allEdges.size() > 1 && j != allEdges.end()) {
swapWhenReversed(n, leftHand, allEdges.end() - 1, allEdges.begin());
}
}
}
示例12: NBNode
std::pair<NBNode*, NBNode*>
NIVissimEdge::remapOneOfNodes(NBNodeCont& nc,
NIVissimDistrictConnection* d,
NBNode* fromNode, NBNode* toNode) {
std::string nid = "ParkingPlace" + toString<int>(d->getID());
if (d->geomPosition().distanceTo(fromNode->getPosition())
<
d->geomPosition().distanceTo(toNode->getPosition())) {
NBNode* newNode = new NBNode(nid,
fromNode->getPosition(),
NODETYPE_NOJUNCTION);
nc.erase(fromNode);
nc.insert(newNode);
return std::pair<NBNode*, NBNode*>(newNode, toNode);
} else {
NBNode* newNode = new NBNode(nid,
toNode->getPosition(),
NODETYPE_NOJUNCTION);
nc.erase(toNode);
nc.insert(newNode);
return std::pair<NBNode*, NBNode*>(fromNode, newNode);
}
}
示例13: 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);
}
}
}
示例14: ProcessError
void
NIImporter_OpenDrive::setNodeSecure(NBNodeCont &nc, OpenDriveEdge &e,
const std::string &nodeID, NIImporter_OpenDrive::LinkType lt) throw(ProcessError) {
NBNode *n = nc.retrieve(nodeID);
if (n==0) {
throw ProcessError("Could not find node '" + nodeID + "'.");
}
if (lt==OPENDRIVE_LT_SUCCESSOR) {
if (e.to!=0&&e.to!=n) {
throw ProcessError("Edge '" + e.id + "' has two end nodes.");
}
e.to = n;
} else {
if (e.from!=0&&e.from!=n) {
throw ProcessError("Edge '" + e.id + "' has two start nodes.");
}
e.from = n;
}
}
示例15: assert
void
NWWriter_XML::writeJoinedJunctions(const OptionsCont& oc, NBNodeCont& nc) {
OutputDevice& device = OutputDevice::getDevice(oc.getString("junctions.join-output"));
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\"");
const std::vector<std::set<std::string> >& clusters = nc.getJoinedClusters();
for (std::vector<std::set<std::string> >::const_iterator it = clusters.begin(); it != clusters.end(); it++) {
assert((*it).size() > 0);
device.openTag(SUMO_TAG_JOIN);
// prepare string
std::ostringstream oss;
for (std::set<std::string>::const_iterator it_id = it->begin(); it_id != it->end(); it_id++) {
oss << *it_id << " ";
}
// remove final space
std::string ids = oss.str();
device.writeAttr(SUMO_ATTR_NODES, ids.substr(0, ids.size() - 1));
device.closeTag();
}
device.close();
}