SUMO - Simulation of Urban MObility
NBNodeCont Class Reference

Container for nodes during the netbuilding process. More...

#include <NBNodeCont.h>

Collaboration diagram for NBNodeCont:
Collaboration graph

Public Member Functions

void analyzeCluster (std::set< NBNode *> cluster, std::string &id, Position &pos, bool &hasTLS, TrafficLightType &type)
 
void clear ()
 deletes all nodes More...
 
void computeLanes2Lanes ()
 divides the incoming lanes on outgoing lanes More...
 
void computeLogics (const NBEdgeCont &ec, OptionsCont &oc)
 build the list of outgoing edges and lanes More...
 
void computeNodeShapes (double mismatchThreshold=-1)
 Compute the junction shape for this node. More...
 
void discardTrafficLights (NBTrafficLightLogicCont &tlc, bool geometryLike, bool guessSignals)
 
std::vector< std::string > getAllNames () const
 get all node names More...
 
std::string getFreeID ()
 generates a new node ID More...
 
const std::vector< std::set< std::string > > & getJoinedClusters () const
 gets all joined clusters (see doc for myClusters2Join) More...
 
void markAsSplit (const NBNode *node)
 mark a node as being created form a split More...
 
 NBNodeCont ()
 Constructor. More...
 
void printBuiltNodesStatistics () const
 Prints statistics about built nodes. More...
 
void registerJoinedCluster (const std::set< NBNode *> &cluster)
 gets all joined clusters (see doc for myClusters2Join) More...
 
int remapIDs (bool numericaIDs, bool reservedIDs)
 remap node IDs accoring to options –numerical-ids and –reserved-ids More...
 
void rename (NBNode *node, const std::string &newID)
 Renames the node. Throws exception if newID already exists. More...
 
int size () const
 Returns the number of nodes stored in this container. More...
 
 ~NBNodeCont ()
 Destructor. More...
 
Insertion/removal/retrieval of nodes
bool insert (const std::string &id, const Position &position, NBDistrict *district=0)
 Inserts a node into the map. More...
 
bool insert (NBNode *node)
 Inserts a node into the map. More...
 
bool erase (NBNode *node)
 Removes the given node, deleting it. More...
 
bool extract (NBNode *node, bool remember=false)
 Removes the given node but does not delete it. More...
 
NBNoderetrieve (const std::string &id) const
 Returns the node with the given name. More...
 
NBNoderetrieve (const Position &position, const double offset=0.) const
 Returns the node with the given coordinates. More...
 
std::map< std::string, NBNode * >::const_iterator begin () const
 Returns the pointer to the begin of the stored nodes. More...
 
std::map< std::string, NBNode * >::const_iterator end () const
 Returns the pointer to the end of the stored nodes. More...
 
Methods for for joining nodes
void addJoinExclusion (const std::vector< std::string > &ids, bool check=false)
 
void addCluster2Join (std::set< std::string > cluster)
 add ids of nodes which shall be joined into a single node More...
 
int joinLoadedClusters (NBDistrictCont &dc, NBEdgeCont &ec, NBTrafficLightLogicCont &tlc)
 Joins loaded junction clusters (see NIXMLNodesHandler) More...
 
int joinJunctions (double maxDist, NBDistrictCont &dc, NBEdgeCont &ec, NBTrafficLightLogicCont &tlc)
 Joins junctions that are very close together. More...
 
Adapting the input
void removeSelfLoops (NBDistrictCont &dc, NBEdgeCont &ec, NBTrafficLightLogicCont &tc)
 Removes self-loop edges (edges where the source and the destination node are the same) More...
 
void joinSimilarEdges (NBDistrictCont &dc, NBEdgeCont &ec, NBTrafficLightLogicCont &tlc)
 Joins edges connecting the same nodes. More...
 
void avoidOverlap ()
 fix overlap More...
 
void removeIsolatedRoads (NBDistrictCont &dc, NBEdgeCont &ec, NBTrafficLightLogicCont &tc)
 Removes sequences of edges that are not connected with a junction. Simple roads without junctions sometimes remain when converting from OpenStreetMake, but they make no sense. Remaining empty nodes are also deleted. More...
 
int removeUnwishedNodes (NBDistrictCont &dc, NBEdgeCont &ec, NBTrafficLightLogicCont &tlc, bool removeGeometryNodes)
 Removes "unwished" nodes. More...
 
Methods for guessing/computing traffic lights
void guessTLs (OptionsCont &oc, NBTrafficLightLogicCont &tlc)
 Guesses which junctions or junction clusters shall be controlled by tls. More...
 
void joinTLS (NBTrafficLightLogicCont &tlc, double maxdist)
 Builds clusters of tls-controlled junctions and joins the control if possible. More...
 
void setAsTLControlled (NBNode *node, NBTrafficLightLogicCont &tlc, TrafficLightType type, std::string id="")
 Sets the given node as being controlled by a tls. More...
 

Private Types

typedef std::pair< NBNode *, double > NodeAndDist
 
typedef std::vector< std::set< NBNode * > > NodeClusters
 Definition of a node cluster container. More...
 
typedef std::map< std::string, NBNode * > NodeCont
 Definition of the map of names to nodes. More...
 

Private Member Functions

 NBNodeCont (const NBNodeCont &s)
 invalidated copy constructor More...
 
NBNodeContoperator= (const NBNodeCont &s)
 invalidated assignment operator More...
 
Helper methods for for joining nodes
void generateNodeClusters (double maxDist, NodeClusters &into) const
 Builds node clusters. More...
 
void joinNodeClusters (NodeClusters clusters, NBDistrictCont &dc, NBEdgeCont &ec, NBTrafficLightLogicCont &tlc)
 joins the given node clusters More...
 
Helper methods for guessing/computing traffic lights
bool shouldBeTLSControlled (const std::set< NBNode *> &c) const
 Returns whethe the given node cluster should be controlled by a tls. More...
 

Private Attributes

std::vector< std::set< std::string > > myClusters2Join
 loaded sets of node ids to join (cleared after use) More...
 
std::set< NBNode * > myExtractedNodes
 The extracted nodes which are kept for reference. More...
 
int myInternalID
 The running internal id. More...
 
std::set< std::string > myJoined
 ids found in loaded join clusters used for error checking More...
 
std::vector< std::set< std::string > > myJoinedClusters
 sets of node ids which were joined More...
 
std::set< std::string > myJoinExclusions
 set of node ids which should not be joined More...
 
NodeCont myNodes
 The map of names to nodes. More...
 
NamedRTree myRTree
 node positions for faster lookup More...
 
std::set< const NBNode * > mySplit
 nodes that were created when splitting an edge More...
 

Detailed Description

Container for nodes during the netbuilding process.

Definition at line 63 of file NBNodeCont.h.

Member Typedef Documentation

◆ NodeAndDist

typedef std::pair<NBNode*, double> NBNodeCont::NodeAndDist
private

Definition at line 287 of file NBNodeCont.h.

◆ NodeClusters

typedef std::vector<std::set<NBNode*> > NBNodeCont::NodeClusters
private

Definition of a node cluster container.

Definition at line 286 of file NBNodeCont.h.

◆ NodeCont

typedef std::map<std::string, NBNode*> NBNodeCont::NodeCont
private

Definition of the map of names to nodes.

Definition at line 320 of file NBNodeCont.h.

Constructor & Destructor Documentation

◆ NBNodeCont() [1/2]

NBNodeCont::NBNodeCont ( )

Constructor.

Definition at line 65 of file NBNodeCont.cpp.

◆ ~NBNodeCont()

NBNodeCont::~NBNodeCont ( )

Destructor.

Definition at line 70 of file NBNodeCont.cpp.

References clear().

◆ NBNodeCont() [2/2]

NBNodeCont::NBNodeCont ( const NBNodeCont s)
private

invalidated copy constructor

Member Function Documentation

◆ addCluster2Join()

void NBNodeCont::addCluster2Join ( std::set< std::string >  cluster)

add ids of nodes which shall be joined into a single node

Parameters
[in]clusterThe cluster to add

Definition at line 462 of file NBNodeCont.cpp.

References myClusters2Join, myJoined, myJoinExclusions, and WRITE_WARNING.

Referenced by NIXMLNodesHandler::addJoinCluster(), and end().

◆ addJoinExclusion()

void NBNodeCont::addJoinExclusion ( const std::vector< std::string > &  ids,
bool  check = false 
)

◆ analyzeCluster()

void NBNodeCont::analyzeCluster ( std::set< NBNode *>  cluster,
std::string &  id,
Position pos,
bool &  hasTLS,
TrafficLightType type 
)

◆ avoidOverlap()

void NBNodeCont::avoidOverlap ( )

fix overlap

Definition at line 386 of file NBNodeCont.cpp.

References myNodes.

Referenced by NBNetBuilder::compute(), and end().

◆ begin()

◆ clear()

void NBNodeCont::clear ( )

deletes all nodes

Definition at line 1084 of file NBNodeCont.cpp.

References myExtractedNodes, and myNodes.

Referenced by size(), and ~NBNodeCont().

◆ computeLanes2Lanes()

void NBNodeCont::computeLanes2Lanes ( )

divides the incoming lanes on outgoing lanes

Definition at line 1067 of file NBNodeCont.cpp.

References myNodes.

Referenced by NBNetBuilder::compute(), and end().

◆ computeLogics()

void NBNodeCont::computeLogics ( const NBEdgeCont ec,
OptionsCont oc 
)

build the list of outgoing edges and lanes

Definition at line 1076 of file NBNodeCont.cpp.

References myNodes.

Referenced by NBNetBuilder::compute(), and end().

◆ computeNodeShapes()

void NBNodeCont::computeNodeShapes ( double  mismatchThreshold = -1)

Compute the junction shape for this node.

Parameters
[in]mismatchThresholdThe threshold for warning about shapes which are away from myPosition

Definition at line 1111 of file NBNodeCont.cpp.

References myNodes.

Referenced by NBNetBuilder::compute(), and size().

◆ discardTrafficLights()

◆ end()

◆ erase()

bool NBNodeCont::erase ( NBNode node)

Removes the given node, deleting it.

Parameters
[in]nodeThe node to delete and remove
Returns
Whether the node could be removed (existed)

Definition at line 136 of file NBNodeCont.cpp.

References extract().

Referenced by joinNodeClusters(), NIVissimEdge::remapOneOfNodes(), and removeIsolatedRoads().

◆ extract()

bool NBNodeCont::extract ( NBNode node,
bool  remember = false 
)

Removes the given node but does not delete it.

Parameters
[in]nodeThe node to delete and remove
[in]rememberWhether to keep the node for future reference
Returns
Whether the node could be removed (existed)

Definition at line 147 of file NBNodeCont.cpp.

References Named::getID(), NBNode::getPosition(), myExtractedNodes, myNodes, myRTree, NamedRTree::Remove(), NBNode::removeTrafficLights(), Position::x(), and Position::y().

Referenced by NIXMLNodesHandler::deleteNode(), GNENet::deleteSingleJunction(), erase(), and removeUnwishedNodes().

◆ generateNodeClusters()

void NBNodeCont::generateNodeClusters ( double  maxDist,
NodeClusters into 
) const
private

Builds node clusters.

A node cluster is made up from nodes which are near by (distance<maxDist) and connected.

Parameters
[in]maxDistThe maximum distance between two nodes for clustering

Definition at line 394 of file NBNodeCont.cpp.

References NBNode::geometryLike(), NBNode::getEdges(), NBEdge::getFromNode(), NBEdge::getLoadedLength(), NBEdge::getPermissions(), NBEdge::getToNode(), NBNode::hasIncoming(), myNodes, and SVC_PEDESTRIAN.

Referenced by guessTLs(), joinJunctions(), and joinTLS().

◆ getAllNames()

std::vector< std::string > NBNodeCont::getAllNames ( ) const

get all node names

Definition at line 1184 of file NBNodeCont.cpp.

References myNodes.

Referenced by GNENet::GNENet(), remapIDs(), size(), and NWWriter_DlrNavteq::writeNodesUnsplitted().

◆ getFreeID()

std::string NBNodeCont::getFreeID ( )

generates a new node ID

Definition at line 1097 of file NBNodeCont.cpp.

References retrieve().

Referenced by size().

◆ getJoinedClusters()

const std::vector<std::set<std::string> >& NBNodeCont::getJoinedClusters ( ) const
inline

gets all joined clusters (see doc for myClusters2Join)

Definition at line 267 of file NBNodeCont.h.

References discardTrafficLights(), and myJoinedClusters.

Referenced by NWWriter_XML::writeJoinedJunctions().

◆ guessTLs()

◆ insert() [1/2]

◆ insert() [2/2]

bool NBNodeCont::insert ( NBNode node)

Inserts a node into the map.

Parameters
[in]nodeThe node to insert
Returns
Whether the node could be added (no other with the same id or position is stored)

Definition at line 92 of file NBNodeCont.cpp.

References Named::getID(), NBNode::getPosition(), NamedRTree::Insert(), myNodes, myRTree, Position::x(), and Position::y().

◆ joinJunctions()

◆ joinLoadedClusters()

int NBNodeCont::joinLoadedClusters ( NBDistrictCont dc,
NBEdgeCont ec,
NBTrafficLightLogicCont tlc 
)

Joins loaded junction clusters (see NIXMLNodesHandler)

Definition at line 480 of file NBNodeCont.cpp.

References joinNodeClusters(), myClusters2Join, retrieve(), and WRITE_WARNING.

Referenced by NBNetBuilder::compute(), NBNetBuilder::computeSingleNode(), and end().

◆ joinNodeClusters()

◆ joinSimilarEdges()

void NBNodeCont::joinSimilarEdges ( NBDistrictCont dc,
NBEdgeCont ec,
NBTrafficLightLogicCont tlc 
)

◆ joinTLS()

void NBNodeCont::joinTLS ( NBTrafficLightLogicCont tlc,
double  maxdist 
)

Builds clusters of tls-controlled junctions and joins the control if possible.

Parameters

Definition at line 1004 of file NBNodeCont.cpp.

References analyzeCluster(), generateNodeClusters(), NBTrafficLightLogicCont::insert(), NBTrafficLightLogicCont::removeFully(), toString(), and WRITE_WARNING.

Referenced by NBNetBuilder::compute(), NBNetBuilder::computeSingleNode(), and end().

◆ markAsSplit()

void NBNodeCont::markAsSplit ( const NBNode node)
inline

mark a node as being created form a split

Definition at line 277 of file NBNodeCont.h.

References mySplit, and remapIDs().

Referenced by NIXMLEdgesHandler::myEndElement().

◆ operator=()

NBNodeCont& NBNodeCont::operator= ( const NBNodeCont s)
private

invalidated assignment operator

◆ printBuiltNodesStatistics()

void NBNodeCont::printBuiltNodesStatistics ( ) const

Prints statistics about built nodes.

Goes through stored nodes, computes the numbers of unregulated, priority and right-before-left junctions and prints them.

Definition at line 1119 of file NBNodeCont.cpp.

References myNodes, NODETYPE_ALLWAY_STOP, NODETYPE_DEAD_END, NODETYPE_DISTRICT, NODETYPE_NOJUNCTION, NODETYPE_PRIORITY, NODETYPE_PRIORITY_STOP, NODETYPE_RAIL_CROSSING, NODETYPE_RAIL_SIGNAL, NODETYPE_RIGHT_BEFORE_LEFT, NODETYPE_TRAFFIC_LIGHT, NODETYPE_TRAFFIC_LIGHT_NOJUNCTION, NODETYPE_TRAFFIC_LIGHT_RIGHT_ON_RED, NODETYPE_UNKNOWN, NODETYPE_ZIPPER, toString(), and WRITE_MESSAGE.

Referenced by NBNetBuilder::compute(), and size().

◆ registerJoinedCluster()

void NBNodeCont::registerJoinedCluster ( const std::set< NBNode *> &  cluster)

gets all joined clusters (see doc for myClusters2Join)

Definition at line 766 of file NBNodeCont.cpp.

References myJoinedClusters.

Referenced by joinNodeClusters(), GNENet::joinSelectedJunctions(), and size().

◆ remapIDs()

int NBNodeCont::remapIDs ( bool  numericaIDs,
bool  reservedIDs 
)

◆ removeIsolatedRoads()

void NBNodeCont::removeIsolatedRoads ( NBDistrictCont dc,
NBEdgeCont ec,
NBTrafficLightLogicCont tc 
)

Removes sequences of edges that are not connected with a junction. Simple roads without junctions sometimes remain when converting from OpenStreetMake, but they make no sense. Remaining empty nodes are also deleted.

Parameters

Definition at line 222 of file NBNodeCont.cpp.

References erase(), NBEdgeCont::erase(), NBEdgeCont::getAllNames(), NBEdge::getFromNode(), Named::getID(), NBNode::getIncomingEdges(), OptionsCont::getOptions(), NBNode::getOutgoingEdges(), NBEdge::getToNode(), NBEdgeCont::retrieve(), UNUSED_PARAMETER, and WRITE_WARNING.

Referenced by NBNetBuilder::compute(), NBNetBuilder::computeSingleNode(), and end().

◆ removeSelfLoops()

void NBNodeCont::removeSelfLoops ( NBDistrictCont dc,
NBEdgeCont ec,
NBTrafficLightLogicCont tc 
)

Removes self-loop edges (edges where the source and the destination node are the same)

Parameters

Definition at line 165 of file NBNodeCont.cpp.

References myNodes, toString(), and WRITE_WARNING.

Referenced by NBNetBuilder::compute(), and end().

◆ removeUnwishedNodes()

int NBNodeCont::removeUnwishedNodes ( NBDistrictCont dc,
NBEdgeCont ec,
NBTrafficLightLogicCont tlc,
bool  removeGeometryNodes 
)

Removes "unwished" nodes.

Removes nodes if a) no incoming/outgoing edges exist or b) if the node is a "geometry" node. In the second case, edges that participate at the node will be joined. Whether the node is a geometry node or not, is determined by a call to NBNode::checkIsRemovable. The node is removed from the list of tls-controlled nodes.

Parameters

Definition at line 316 of file NBNodeCont.cpp.

References NBEdge::append(), begin(), NBNode::checkIsRemovable(), extract(), NBEdgeCont::extract(), NBNode::getEdges(), NBNode::getEdgesToJoin(), NBNode::getIncomingEdges(), OptionsCont::getOptions(), NBNode::getOutgoingEdges(), OptionsCont::getString(), OptionsCont::getStringVector(), NBEdge::getToNode(), OptionsCont::isSet(), NBHelpers::loadEdgesFromFile(), myNodes, mySplit, NBNode::replaceIncoming(), and NBTrafficLightLogicCont::replaceRemoved().

Referenced by NBNetBuilder::compute(), NBNetBuilder::computeSingleNode(), and end().

◆ rename()

void NBNodeCont::rename ( NBNode node,
const std::string &  newID 
)

Renames the node. Throws exception if newID already exists.

Definition at line 1194 of file NBNodeCont.cpp.

References Named::getID(), myNodes, and Named::setID().

Referenced by end(), and GNENet::renameJunction().

◆ retrieve() [1/2]

◆ retrieve() [2/2]

NBNode * NBNodeCont::retrieve ( const Position position,
const double  offset = 0. 
) const

Returns the node with the given coordinates.

Parameters
[in]positionThe position at which the node to retrieve lies
[in]offsetAn offset which can be applied in the case positions are blurred
Returns
The node at the given position, or 0 if no such node exists

Definition at line 116 of file NBNodeCont.cpp.

References NBNode::getPosition(), myNodes, myRTree, POSITION_EPS, NamedRTree::Search(), Position::x(), and Position::y().

◆ setAsTLControlled()

void NBNodeCont::setAsTLControlled ( NBNode node,
NBTrafficLightLogicCont tlc,
TrafficLightType  type,
std::string  id = "" 
)

Sets the given node as being controlled by a tls.

Parameters
[in]nodeThe node that shall be controlled by a tls
[in]tlcThe traffic lights control into which the new traffic light definition shall be stored
[in]typeThe type of the new tls
[in]idThe id of the tls to add
Todo:
Recheck exception handling

Definition at line 1050 of file NBNodeCont.cpp.

References Named::getID(), NBTrafficLightLogicCont::insert(), and WRITE_WARNING.

Referenced by NBNetBuilder::compute(), NBNetBuilder::computeSingleNode(), end(), and guessTLs().

◆ shouldBeTLSControlled()

bool NBNodeCont::shouldBeTLSControlled ( const std::set< NBNode *> &  c) const
private

Returns whethe the given node cluster should be controlled by a tls.

Parameters
[in]cThe node cluster
Returns
Whether this node cluster shall be controlled by a tls

Definition at line 811 of file NBNodeCont.cpp.

Referenced by guessTLs().

◆ size()

Field Documentation

◆ myClusters2Join

std::vector<std::set<std::string> > NBNodeCont::myClusters2Join
private

loaded sets of node ids to join (cleared after use)

Definition at line 332 of file NBNodeCont.h.

Referenced by addCluster2Join(), and joinLoadedClusters().

◆ myExtractedNodes

std::set<NBNode*> NBNodeCont::myExtractedNodes
private

The extracted nodes which are kept for reference.

Definition at line 326 of file NBNodeCont.h.

Referenced by clear(), and extract().

◆ myInternalID

int NBNodeCont::myInternalID
private

The running internal id.

Definition at line 317 of file NBNodeCont.h.

◆ myJoined

std::set<std::string> NBNodeCont::myJoined
private

ids found in loaded join clusters used for error checking

Definition at line 338 of file NBNodeCont.h.

Referenced by addCluster2Join(), and addJoinExclusion().

◆ myJoinedClusters

std::vector<std::set<std::string> > NBNodeCont::myJoinedClusters
private

sets of node ids which were joined

Definition at line 335 of file NBNodeCont.h.

Referenced by getJoinedClusters(), and registerJoinedCluster().

◆ myJoinExclusions

std::set<std::string> NBNodeCont::myJoinExclusions
private

set of node ids which should not be joined

Definition at line 329 of file NBNodeCont.h.

Referenced by addCluster2Join(), addJoinExclusion(), and joinJunctions().

◆ myNodes

◆ myRTree

NamedRTree NBNodeCont::myRTree
private

node positions for faster lookup

Definition at line 344 of file NBNodeCont.h.

Referenced by extract(), insert(), and retrieve().

◆ mySplit

std::set<const NBNode*> NBNodeCont::mySplit
private

nodes that were created when splitting an edge

Definition at line 341 of file NBNodeCont.h.

Referenced by markAsSplit(), and removeUnwishedNodes().


The documentation for this class was generated from the following files: