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: 2022-02-09 18:05:59 +0100 (Wed, 09 Feb 2022) $, @version $Revision: 7012 $, by $Author: averbraeck $, 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 doubleBOUNDINGRADIUSMargin 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 voidaddConnection(GTUType gtuType, Link incomingLink, Link outgoingLink)Add a single connection for a GTU type to the connections map.voidaddConnections(GTUType gtuType, Link incomingLink, Set<Link> outgoingLinks)Add a set of connections for a GTU type to the connections map.voidaddLink(Link link)Add a link to this Node.OTSNodeclone1(Network newNetwork)Clone the OTSode for e.g., copying a network.OTSNodeclone2(Network newNetwork)Complete the cloning of the OTSode for e.g., copying a network.booleanequals(Object obj)BoundsgetBounds()doublegetHeading()StringgetId()ImmutableSet<Link>getLinks()DirectedPointgetLocation()NetworkgetNetwork()Return the network in which this link is registered.OTSPoint3DgetPoint()inthashCode()booleanisCentroid()Checks whether the node has only connector links going in and/or out, and no other links.booleanisDirectionallyConnectedTo(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.voidremoveLink(Link link)Remove a link from this Node.StringtoString()
-
-
-
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:
getNetworkin interfaceNode- Returns:
- Network; the network in which this link is registered
-
getId
public final String getId()
- Specified by:
getIdin interfaceIdentifiable- Specified by:
getIdin interfaceNode- Returns:
- node id.
-
getPoint
public final OTSPoint3D getPoint()
-
getHeading
public double getHeading()
- Specified by:
getHeadingin 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:
removeLinkin 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:
nextLinksin 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:
isDirectionallyConnectedToin 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:
isCentroidin 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:
getLocationin interfaceLocatable- Specified by:
getLocationin 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
-
-