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-2020 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
BSD-style license. See OpenTrafficSim License.
$LastChangedDate: 2020-02-04 16:40:30 +0100 (Tue, 04 Feb 2020) $, @version $Revision: 6252 $, by $Author: pknoppers $,
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
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, SimulatorInterface.TimeDoubleUnit newSimulator)Clone the OTSode for e.g., copying a network.OTSNodeclone2(Network newNetwork, SimulatorInterface.TimeDoubleUnit newSimulator)Complete the cloning of the OTSode for e.g., copying a network.booleanequals(Object obj)javax.media.j3d.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 Details
-
BOUNDINGRADIUS
public static final double BOUNDINGRADIUSMargin around node in m when computing bounding sphere.- See Also:
- Constant Field Values
-
-
Constructor Details
-
OTSNode
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 NetworkExceptionConstruction 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 Details
-
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
- Specified by:
getIdin interfaceIdentifiable- Specified by:
getIdin interfaceNode- Returns:
- node id.
-
getPoint
-
getHeading
public double getHeading()- Specified by:
getHeadingin interfaceNode- Returns:
- heading.
-
addLink
Add a link to this Node. -
removeLink
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 NetworkExceptionAdd 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 NetworkExceptionAdd 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
-
nextLinks
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
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
- Specified by:
getLocationin interfaceLocatable
-
getBounds
public javax.media.j3d.Bounds getBounds() -
toString
-
hashCode
public int hashCode() -
equals
-
clone1
public OTSNode clone1(Network newNetwork, SimulatorInterface.TimeDoubleUnit newSimulator) throws NetworkExceptionClone the OTSode for e.g., copying a network.- Parameters:
newNetwork- Network; the new network to which the clone belongsnewSimulator- SimulatorInterface.TimeDoubleUnit; the new simulator for this network- Returns:
- a clone of this object
- Throws:
NetworkException- in case the cloning fails
-
clone2
public OTSNode clone2(Network newNetwork, SimulatorInterface.TimeDoubleUnit newSimulator) throws NetworkExceptionComplete 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 belongsnewSimulator- SimulatorInterface.TimeDoubleUnit; the new simulator for this network- Returns:
- the completed clone
- Throws:
NetworkException- in case the cloning fails
-