SUMO - Simulation of Urban MObility

NBNodeCont Class Reference

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

#include <NBNodeCont.h>

Public Member Functions

void analyzeCluster (std::set< NBNode * > cluster, std::string &id, Position &pos, bool &hasTLS)
void clear ()
void computeLanes2Lanes ()
 divides the incoming lanes on outgoing lanes
void computeLogics (const NBEdgeCont &ec, OptionsCont &oc)
 build the list of outgoing edges and lanes
void computeNodeShapes (bool leftHand)
void computeNodeTypes (const NBTypeCont &tc)
 computes the nodes' types
void computePriorities ()
 computes priorities of edges based on junction types
std::vector< std::string > getAllNames () const throw ()
 get all node names
std::string getFreeID ()
void guessRamps (OptionsCont &oc, NBEdgeCont &ec, NBDistrictCont &dc)
 NBNodeCont () throw ()
 Constructor.
void printBuiltNodesStatistics () const throw ()
 Prints statistics about built nodes.
unsigned int size () const throw ()
 Returns the number of known nodes.
void sortNodesEdges (bool leftHand)
 sorts the nodes' edges
 ~NBNodeCont () throw ()
 Destructor.
Insertion/removal/retrieval of nodes
bool insert (const std::string &id, const Position &position, NBDistrict *district) throw ()
 Inserts a node into the map.
bool insert (const std::string &id, const Position &position) throw ()
 Inserts a node into the map.
Position insert (const std::string &id) throw ()
 Inserts a node into the map.
bool insert (NBNode *node) throw ()
 Inserts a node into the map.
bool erase (NBNode *node) throw ()
 Removes the given node, deleting it.
bool extract (NBNode *node, bool remember=false) throw ()
 Removes the given node but does not delete it.
NBNode * retrieve (const std::string &id) const throw ()
 Returns the node with the given name.
NBNode * retrieve (const Position &position, SUMOReal offset=0.) const throw ()
 Returns the node with the given coordinates.
std::map< std::string, NBNode * >
::const_iterator 
begin () const
 Returns the pointer to the begin of the stored nodes.
std::map< std::string, NBNode * >
::const_iterator 
end () const
 Returns the pointer to the end of the stored nodes.
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
unsigned int joinLoadedClusters (NBDistrictCont &dc, NBEdgeCont &ec, NBTrafficLightLogicCont &tlc)
 Joins loaded junction clusters (see NIXMLNodesHandler)
unsigned int joinJunctions (SUMOReal maxdist, NBDistrictCont &dc, NBEdgeCont &ec, NBTrafficLightLogicCont &tlc)
 Joins junctions that are very close together.
Adapting the input
void removeDummyEdges (NBDistrictCont &dc, NBEdgeCont &ec, NBTrafficLightLogicCont &tc)
 Removes dummy edges (edges lying completely within a node)
void joinDoubleNodeConnections (NBDistrictCont &dc, NBEdgeCont &ec, NBTrafficLightLogicCont &tlc)
 Joins edges connecting the same nodes.
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.
unsigned int removeUnwishedNodes (NBDistrictCont &dc, NBEdgeCont &ec, NBJoinedEdgesMap &je, NBTrafficLightLogicCont &tlc, bool removeGeometryNodes)
 Removes "unwished" nodes.
Methods for guessing/computing traffic lights
void guessTLs (OptionsCont &oc, NBTrafficLightLogicCont &tlc)
 Guesses which junctions or junction clusters shall be controlled by tls.
void joinTLS (NBTrafficLightLogicCont &tlc)
 Builds clusters of tls-controlled junctions and joins the control if possible.
void setAsTLControlled (NBNode *node, NBTrafficLightLogicCont &tlc, std::string id="")
 Sets the given node as being controlled by a tls.

Private Types

typedef std::map< std::string,
NBNode * > 
NodeCont
 Definition of the map of names to nodes.

Private Member Functions

void buildOffRamp (OptionsCont &oc, NBNode *cur, NBEdgeCont &ec, NBDistrictCont &dc, EdgeVector &incremented)
bool buildOnRamp (OptionsCont &oc, NBNode *cur, NBEdgeCont &ec, NBDistrictCont &dc, EdgeVector &incremented)
void checkHighwayRampOrder (NBEdge *&pot_highway, NBEdge *&pot_ramp)
bool mayNeedOffRamp (OptionsCont &oc, NBNode *cur) const
bool mayNeedOnRamp (OptionsCont &oc, NBNode *cur) const
 NBNodeCont (const NBNodeCont &s)
 invalidated copy constructor
NBNodeCont & operator= (const NBNodeCont &s)
 invalidated assignment operator
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.

Private Attributes

std::vector< std::set
< std::string > > 
myClusters2Join
std::set< NBNode * > myExtractedNodes
 The extracted nodes which are kept for reference.
int myInternalID
 The running internal id.
std::set< std::string > myJoined
 ids found in loaded join clusters used for error checking
std::set< std::string > myJoinExclusions
NodeCont myNodes
 The map of names to nodes.

Helper methods for for joining nodes

typedef std::vector< std::set
< NBNode * > > 
NodeClusters
 Definition of a node cluster container.
void generateNodeClusters (SUMOReal maxDist, NodeClusters &into) const
 Builds node clusters.
void merge (NBNode *moved, NBNode *target, NBDistrictCont &dc, NBEdgeCont &ec)
void remapEdge (NBEdge *oldEdge, NBNode *from, NBNode *to, NBDistrictCont &dc, NBEdgeCont &ec)
void joinNodeClusters (NodeClusters clusters, NBDistrictCont &dc, NBEdgeCont &ec, NBTrafficLightLogicCont &tlc)

Detailed Description

Container for nodes during the netbuilding process.

Definition at line 58 of file NBNodeCont.h.


Member Typedef Documentation

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

Definition of a node cluster container.

Definition at line 336 of file NBNodeCont.h.

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

Definition of the map of names to nodes.

Definition at line 378 of file NBNodeCont.h.


Constructor & Destructor Documentation

NBNodeCont::NBNodeCont ( ) throw ()

Constructor.

Definition at line 60 of file NBNodeCont.cpp.

NBNodeCont::~NBNodeCont ( ) throw ()

Destructor.

Definition at line 64 of file NBNodeCont.cpp.

References clear().

NBNodeCont::NBNodeCont ( const NBNodeCont &  s) [private]

invalidated copy constructor


Member Function Documentation

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 442 of file NBNodeCont.cpp.

References myClusters2Join, myJoined, myJoinExclusions, and WRITE_WARNING.

Referenced by NIXMLNodesHandler::addJoinCluster().

void NBNodeCont::addJoinExclusion ( const std::vector< std::string > &  ids,
bool  check = false 
)
void NBNodeCont::analyzeCluster ( std::set< NBNode * >  cluster,
std::string &  id,
Position &  pos,
bool &  hasTLS 
)

Definition at line 546 of file NBNodeCont.cpp.

References Position::add(), and Position::mul().

Referenced by joinNodeClusters().

std::map<std::string, NBNode*>::const_iterator NBNodeCont::begin ( ) const [inline]

Returns the pointer to the begin of the stored nodes.

Returns:
The iterator to the beginning of stored nodes

Definition at line 136 of file NBNodeCont.h.

References myNodes.

Referenced by NBNetBuilder::compute(), removeUnwishedNodes(), NWWriter_XML::writeEdgesAndConnections(), NWWriter_SUMO::writeNetwork(), NWWriter_OpenDrive::writeNetwork(), NWWriter_MATSim::writeNetwork(), and NWWriter_XML::writeNodes().

void NBNodeCont::checkHighwayRampOrder ( NBEdge *&  pot_highway,
NBEdge *&  pot_ramp 
) [private]

Definition at line 1179 of file NBNodeCont.cpp.

References NBEdge::getNumLanes(), and NBEdge::getSpeed().

void NBNodeCont::clear ( )

deletes all nodes

Definition at line 825 of file NBNodeCont.cpp.

References myExtractedNodes, and myNodes.

Referenced by ~NBNodeCont().

void NBNodeCont::computeLanes2Lanes ( )

divides the incoming lanes on outgoing lanes

Definition at line 784 of file NBNodeCont.cpp.

References myNodes.

Referenced by NBNetBuilder::compute().

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

build the list of outgoing edges and lanes

Definition at line 793 of file NBNodeCont.cpp.

References myNodes.

Referenced by NBNetBuilder::compute().

void NBNodeCont::computeNodeShapes ( bool  leftHand)

Definition at line 847 of file NBNodeCont.cpp.

References myNodes.

Referenced by NBNetBuilder::compute().

void NBNodeCont::computeNodeTypes ( const NBTypeCont &  tc)

computes the nodes' types

Definition at line 809 of file NBNodeCont.cpp.

References myNodes.

Referenced by NBNetBuilder::compute().

void NBNodeCont::computePriorities ( )

computes priorities of edges based on junction types

Definition at line 817 of file NBNodeCont.cpp.

References myNodes.

Referenced by NBNetBuilder::compute().

std::map<std::string, NBNode*>::const_iterator NBNodeCont::end ( ) const [inline]

Returns the pointer to the end of the stored nodes.

Returns:
The iterator to the end of stored nodes

Definition at line 144 of file NBNodeCont.h.

References myNodes.

Referenced by NBNetBuilder::compute(), NWWriter_XML::writeEdgesAndConnections(), NWWriter_SUMO::writeNetwork(), NWWriter_OpenDrive::writeNetwork(), NWWriter_MATSim::writeNetwork(), and NWWriter_XML::writeNodes().

bool NBNodeCont::erase ( NBNode *  node) throw ()

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 146 of file NBNodeCont.cpp.

Referenced by merge(), NIVissimEdge::remapOneOfNodes(), removeIsolatedRoads(), and removeUnwishedNodes().

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

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 157 of file NBNodeCont.cpp.

Referenced by NIXMLNodesHandler::deleteNode().

void NBNodeCont::generateNodeClusters ( SUMOReal  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
in,filled]into The container to store the clusters in

Definition at line 383 of file NBNodeCont.cpp.

References Position::distanceTo(), NBNode::getEdges(), NBEdge::getFromNode(), NBNode::getPosition(), NBEdge::getToNode(), NBNode::hasIncoming(), and myNodes.

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

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

get all node names

Definition at line 1277 of file NBNodeCont.cpp.

References myNodes.

std::string NBNodeCont::getFreeID ( )

Definition at line 838 of file NBNodeCont.cpp.

References retrieve(), and size().

Referenced by NIXMLEdgesHandler::insertNodeChecking().

void NBNodeCont::guessTLs ( OptionsCont &  oc,
NBTrafficLightLogicCont &  tlc 
)

Guesses which junctions or junction clusters shall be controlled by tls.

Parameters:
[in]ocThe options that steer the guessing process
filled]tlc The traffic lights control into which new traffic light definitions shall be stored
Todo:
Recheck exception handling

Definition at line 627 of file NBNodeCont.cpp.

References OptionsCont::exists(), generateNodeClusters(), OptionsCont::getBool(), NBNode::getControllingTLS(), NBNode::getIncomingEdges(), OptionsCont::getStringVector(), NBTrafficLightLogicCont::insert(), NBNode::isNearDistrict(), OptionsCont::isSet(), NBNode::isTLControlled(), myNodes, NBNode::removeTrafficLights(), retrieve(), setAsTLControlled(), shouldBeTLSControlled(), SUMOReal, toString(), and WRITE_WARNING.

Referenced by NBNetBuilder::compute().

bool NBNodeCont::insert ( NBNode *  node) throw ()

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 110 of file NBNodeCont.cpp.

bool NBNodeCont::insert ( const std::string &  id,
const Position &  position 
) throw ()

Inserts a node into the map.

Parameters:
[in]idThe node's id
[in]positionThe node's position
Returns:
Whether the node could be added (no other with the same id or position is stored)

Definition at line 84 of file NBNodeCont.cpp.

Position NBNodeCont::insert ( const std::string &  id) throw ()

Inserts a node into the map.

Parameters:
[in]idThe node's id
Returns:
Whether the node could be added (no other with the same id is stored)

Definition at line 96 of file NBNodeCont.cpp.

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

Joins edges connecting the same nodes.

Parameters:
in,opt.changed] dc The districts container to update
in,opt.changed] ec The edge container to remove the edges from
in,opt.changed] tc The traffic lights container to update
Postcondition:
No two edges with same geometry connecting same nodes exist

Definition at line 186 of file NBNodeCont.cpp.

References NBEdge::getLoadedLength(), NBEdge::getSpeed(), NBEdge::getToNode(), NBEdge::isNearEnough2BeJoined2(), NBEdgeCont::joinSameNodeConnectingEdges(), myNodes, and SUMOReal.

Referenced by NBNetBuilder::compute().

unsigned int NBNodeCont::joinJunctions ( SUMOReal  maxdist,
NBDistrictCont &  dc,
NBEdgeCont &  ec,
NBTrafficLightLogicCont &  tlc 
)

Joins junctions that are very close together.

Definition at line 483 of file NBNodeCont.cpp.

References generateNodeClusters(), Named::getID(), NBNode::getIncomingEdges(), NBNode::getOutgoingEdges(), joinNodeClusters(), and myJoinExclusions.

Referenced by NBNetBuilder::compute().

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

Joins loaded junction clusters (see NIXMLNodesHandler)

Definition at line 460 of file NBNodeCont.cpp.

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

Referenced by NBNetBuilder::compute().

void NBNodeCont::joinNodeClusters ( NodeClusters  clusters,
NBDistrictCont &  dc,
NBEdgeCont &  ec,
NBTrafficLightLogicCont &  tlc 
) [private]
void NBNodeCont::joinTLS ( NBTrafficLightLogicCont &  tlc)

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

Parameters:
changed]tlc The traffic lights control for adding/removing new/prior tls
Todo:
Recheck exception handling

Definition at line 727 of file NBNodeCont.cpp.

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

Referenced by NBNetBuilder::compute().

bool NBNodeCont::mayNeedOffRamp ( OptionsCont &  oc,
NBNode *  cur 
) const [private]
bool NBNodeCont::mayNeedOnRamp ( OptionsCont &  oc,
NBNode *  cur 
) const [private]
void NBNodeCont::merge ( NBNode *  moved,
NBNode *  target,
NBDistrictCont &  dc,
NBEdgeCont &  ec 
) [private]

Definition at line 568 of file NBNodeCont.cpp.

References erase(), NBNode::getIncomingEdges(), NBNode::getOutgoingEdges(), and remapEdge().

Referenced by joinNodeClusters().

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

invalidated assignment operator

void NBNodeCont::printBuiltNodesStatistics ( ) const throw ()

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 1237 of file NBNodeCont.cpp.

References myNodes, NODETYPE_DEAD_END, NODETYPE_DISTRICT, NODETYPE_NOJUNCTION, NODETYPE_PRIORITY_JUNCTION, NODETYPE_RIGHT_BEFORE_LEFT, NODETYPE_TRAFFIC_LIGHT, NODETYPE_UNKNOWN, toString(), and WRITE_MESSAGE.

Referenced by NBNetBuilder::compute().

void NBNodeCont::remapEdge ( NBEdge *  oldEdge,
NBNode *  from,
NBNode *  to,
NBDistrictCont &  dc,
NBEdgeCont &  ec 
) [private]
void NBNodeCont::removeDummyEdges ( NBDistrictCont &  dc,
NBEdgeCont &  ec,
NBTrafficLightLogicCont &  tc 
)

Removes dummy edges (edges lying completely within a node)

Parameters:
in,opt.changed] dc The districts container to update
in,opt.changed] ec The edge container to remove the edges from
in,opt.changed] tc The traffic lights container to update
Postcondition:
Each edge is a uni-directional connection between two different nodes

Definition at line 173 of file NBNodeCont.cpp.

References myNodes, toString(), and WRITE_WARNING.

Referenced by NBNetBuilder::compute().

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:
in,opt.changed] dc The district container needed if edges shall be removed
in,opt.changed] ec The container with the edge to be tested
in,opt.changed] tc The traffic lights container to update

Definition at line 236 of file NBNodeCont.cpp.

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

Referenced by NBNetBuilder::compute().

unsigned int NBNodeCont::removeUnwishedNodes ( NBDistrictCont &  dc,
NBEdgeCont &  ec,
NBJoinedEdgesMap &  je,
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:
in,opt.changed] dc The district container needed if a node shall be removed
in,opt.changed] ec The edge container needed for joining edges
in,opt.changed] je The map of joined edges (changes are stored here)
in,opt.changed] tlc The traffic lights container to remove nodes from
[in]removeGeometryNodesWhether geometry nodes shall also be removed
Returns:
The number of removed nodes

Definition at line 330 of file NBNodeCont.cpp.

References NBEdge::append(), NBJoinedEdgesMap::appended(), begin(), NBNode::checkIsRemovable(), erase(), NBEdgeCont::erase(), NBNode::getEdgesToJoin(), Named::getID(), NBNode::getIncomingEdges(), NBNode::getOutgoingEdges(), NBEdge::getToNode(), myNodes, NBNode::replaceIncoming(), and NBTrafficLightLogicCont::replaceRemoved().

Referenced by NBNetBuilder::compute().

NBNode * NBNodeCont::retrieve ( const Position &  position,
SUMOReal  offset = 0. 
) const throw ()

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 132 of file NBNodeCont.cpp.

References NBNode::getPosition(), Position::x(), and Position::y().

void NBNodeCont::setAsTLControlled ( NBNode *  node,
NBTrafficLightLogicCont &  tlc,
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]idThe id of the tls to add
Todo:
Recheck exception handling

Definition at line 768 of file NBNodeCont.cpp.

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

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

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 599 of file NBNodeCont.cpp.

References SUMOReal.

Referenced by guessTLs().

unsigned int NBNodeCont::size ( ) const throw () [inline]

Returns the number of known nodes.

Returns:
The number of nodes stored in this container

Definition at line 281 of file NBNodeCont.h.

References myNodes.

Referenced by getFreeID(), NILoader::load(), and main().

void NBNodeCont::sortNodesEdges ( bool  leftHand)

sorts the nodes' edges

Definition at line 801 of file NBNodeCont.cpp.

References myNodes.

Referenced by NBNetBuilder::compute().


Field Documentation

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

Definition at line 390 of file NBNodeCont.h.

Referenced by addCluster2Join(), and joinLoadedClusters().

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

The extracted nodes which are kept for reference.

Definition at line 384 of file NBNodeCont.h.

Referenced by clear().

int NBNodeCont::myInternalID [private]

The running internal id.

Definition at line 375 of file NBNodeCont.h.

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

ids found in loaded join clusters used for error checking

Definition at line 393 of file NBNodeCont.h.

Referenced by addCluster2Join(), and addJoinExclusion().

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

Definition at line 387 of file NBNodeCont.h.

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


The documentation for this class was generated from the following files:
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Defines