Package org.opentrafficsim.core.network
Class OTSNode
- java.lang.Object
-
- org.opentrafficsim.core.network.OTSNode
-
- All Implemented Interfaces:
Serializable
,Locatable
,Identifiable
,Drawable
,Node
public class OTSNode extends Object implements Node, Locatable, Serializable
The Node is a point with an id. It is used in the network to connect Links.Copyright (c) 2013-2022 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
BSD-style license. See OpenTrafficSim License.$LastChangedDate$, @version $Revision$, by $Author$, initial version Aug 19, 2014
- Author:
- Alexander Verbraeck, Peter Knoppers, Guus Tamminga
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static double
BOUNDINGRADIUS
Margin around node in m when computing bounding sphere.
-
Constructor Summary
Constructors Constructor Description OTSNode(Network network, String id, OTSPoint3D point)
Construction of a Node.OTSNode(Network network, String id, OTSPoint3D point, double heading)
Construction of a Node.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addConnection(GTUType gtuType, Link incomingLink, Link outgoingLink)
Add a single connection for a GTU type to the connections map.void
addConnections(GTUType gtuType, Link incomingLink, Set<Link> outgoingLinks)
Add a set of connections for a GTU type to the connections map.void
addLink(Link link)
Add a link to this Node.OTSNode
clone1(Network newNetwork)
Clone the OTSode for e.g., copying a network.OTSNode
clone2(Network newNetwork)
Complete the cloning of the OTSode for e.g., copying a network.boolean
equals(Object obj)
Bounds
getBounds()
double
getHeading()
String
getId()
ImmutableSet<Link>
getLinks()
DirectedPoint
getLocation()
Network
getNetwork()
Return the network in which this link is registered.OTSPoint3D
getPoint()
int
hashCode()
boolean
isCentroid()
Checks whether the node has only connector links going in and/or out, and no other links.boolean
isDirectionallyConnectedTo(GTUType gtuType, Node toNode)
Note: this method does not take into account explicitly defined connections, as the previous link is not given.Set<Link>
nextLinks(GTUType gtuType, Link prevLink)
Determine the links connecting from the previous link via this Node for the given GTU type.void
removeLink(Link link)
Remove a link from this Node.String
toString()
-
-
-
Field Detail
-
BOUNDINGRADIUS
public static final double BOUNDINGRADIUS
Margin around node in m when computing bounding sphere.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
OTSNode
public OTSNode(Network network, String id, OTSPoint3D point) throws NetworkException
Construction of a Node.- Parameters:
network
- Network; the network.id
- String; the id of the Node.point
- OTSPoint3D; the point with usually an x and y setting.- Throws:
NetworkException
- if node already exists in the network, or if name of the node is not unique.
-
OTSNode
public OTSNode(Network network, String id, OTSPoint3D point, double heading) throws NetworkException
Construction of a Node.- Parameters:
network
- Network; the network.id
- String; the id of the Node.point
- OTSPoint3D; the point with usually an x and y setting.heading
- double; heading- Throws:
NetworkException
- if node already exists in the network, or if name of the node is not unique.
-
-
Method Detail
-
getNetwork
public final Network getNetwork()
Return the network in which this link is registered. Cannot be null.- Specified by:
getNetwork
in interfaceNode
- Returns:
- Network; the network in which this link is registered
-
getId
public final String getId()
- Specified by:
getId
in interfaceIdentifiable
- Specified by:
getId
in interfaceNode
- Returns:
- node id.
-
getPoint
public final OTSPoint3D getPoint()
-
getHeading
public double getHeading()
- Specified by:
getHeading
in interfaceNode
- Returns:
- heading.
-
addLink
public final void addLink(Link link)
Add a link to this Node.
-
removeLink
public final void removeLink(Link link)
Remove a link from this Node.- Specified by:
removeLink
in interfaceNode
- Parameters:
link
- Link; the link to remove.
-
addConnection
public final void addConnection(GTUType gtuType, Link incomingLink, Link outgoingLink) throws NetworkException
Add a single connection for a GTU type to the connections map. The data structures will be created if it does not exist yet.- Parameters:
gtuType
- GTUType; the GTU type for which this connection is madeincomingLink
- Link; the link that connects to this NodeoutgoingLink
- Link; the link that the GTU can use to depart from this Node when coming from the incoming link- Throws:
NetworkException
- in case one of the links is not (correctly) connected to this Node
-
addConnections
public final void addConnections(GTUType gtuType, Link incomingLink, Set<Link> outgoingLinks) throws NetworkException
Add a set of connections for a GTU type to the connections map. The data structures will be created if it does not exist yet.- Parameters:
gtuType
- GTUType; the GTU type for which this connection is madeincomingLink
- Link; the link that connects to this NodeoutgoingLinks
- Set<Link>; a set of links that the GTU can use to depart from this Node when coming from the incoming link- Throws:
NetworkException
- in case one of the links is not (correctly) connected to this Node
-
getLinks
public final ImmutableSet<Link> getLinks()
-
nextLinks
public final Set<Link> nextLinks(GTUType gtuType, Link prevLink) throws NetworkException
Determine the links connecting from the previous link via this Node for the given GTU type.- Specified by:
nextLinks
in interfaceNode
- Parameters:
gtuType
- GTUType; the GTU type to determine the next links forprevLink
- Link; the incoming link to the Node- Returns:
- a set of links connecting from the previous link via this Node for the given GTU type
- Throws:
NetworkException
- if the incoming link is not connected to this node for the given GTU type
-
isDirectionallyConnectedTo
public final boolean isDirectionallyConnectedTo(GTUType gtuType, Node toNode)
Note: this method does not take into account explicitly defined connections, as the previous link is not given.
Check if the current node is linked to the given Node in the specified direction for the given GTUType. This can mean there is a Link from this node to toNode, and the LongitudinalDirectionality for the Link between this node and toNode is FORWARD or BOTH; or there is a Link from toNode to this node, and the LongitudinalDirectionality for the Link between toNode and this node is BACKWARD or BOTH for the provided GTUType.- Specified by:
isDirectionallyConnectedTo
in interfaceNode
- Parameters:
gtuType
- GTUType; the GTU type to check the connection for.toNode
- Node; the to node- Returns:
- whether two nodes are linked in the specified direction.
-
isCentroid
public boolean isCentroid()
Checks whether the node has only connector links going in and/or out, and no other links.- Specified by:
isCentroid
in interfaceNode
- Returns:
- boolean; whether the node is a centroid, i.e. it only has connector links going in and out
-
getLocation
public DirectedPoint getLocation()
- Specified by:
getLocation
in interfaceLocatable
- Specified by:
getLocation
in interfaceNode
-
getBounds
public Bounds getBounds()
-
clone1
public OTSNode clone1(Network newNetwork) throws NetworkException
Clone the OTSode for e.g., copying a network.- Parameters:
newNetwork
- Network; the new network to which the clone belongs- Returns:
- a clone of this object
- Throws:
NetworkException
- in case the cloning fails
-
clone2
public OTSNode clone2(Network newNetwork) throws NetworkException
Complete the cloning of the OTSode for e.g., copying a network. Call this method after all the links have been constructed in the new network.- Parameters:
newNetwork
- Network; the new network to which the clone belongs- Returns:
- the completed clone
- Throws:
NetworkException
- in case the cloning fails
-
-