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-2019 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
BSD-style license. See OpenTrafficSim License.

$LastChangedDate: 2019-06-30 03:14:38 +0200 (Sun, 30 Jun 2019) $, @version $Revision: 5552 $, by $Author: averbraeck $, initial version Aug 19, 2014

Author:
Alexander Verbraeck, Peter Knoppers, Guus Tamminga
See Also:
Serialized Form
  • Field Details

  • Constructor Details

    • 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 Details

    • getNetwork

      public final Network getNetwork()
      Return the network in which this link is registered. Cannot be null.
      Specified by:
      getNetwork in interface Node
      Returns:
      Network; the network in which this link is registered
    • getId

      public final String getId()
      Specified by:
      getId in interface Identifiable
      Specified by:
      getId in interface Node
      Returns:
      node id.
    • getPoint

      public final OTSPoint3D getPoint()
      Specified by:
      getPoint in interface Node
      Returns:
      point.
    • getHeading

      public double getHeading()
      Specified by:
      getHeading in interface Node
      Returns:
      heading.
    • addLink

      public final void addLink​(Link link)
      Add a link to this Node.
      Specified by:
      addLink in interface Node
      Parameters:
      link - Link; the link to add.
    • removeLink

      public final void removeLink​(Link link)
      Remove a link from this Node.
      Specified by:
      removeLink in interface Node
      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 made
      incomingLink - Link; the link that connects to this Node
      outgoingLink - 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 made
      incomingLink - Link; the link that connects to this Node
      outgoingLinks - 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()
      Specified by:
      getLinks in interface Node
      Returns:
      a safe copy of the links connected to this Node
    • 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 interface Node
      Parameters:
      gtuType - GTUType; the GTU type to determine the next links for
      prevLink - 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 interface Node
      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.
    • getLocation

      public DirectedPoint getLocation()
      Specified by:
      getLocation in interface Locatable
    • getBounds

      public javax.media.j3d.Bounds getBounds()
      Specified by:
      getBounds in interface Locatable
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals​(Object obj)
      Overrides:
      equals in class Object
    • clone1

      public OTSNode clone1​(Network newNetwork, SimulatorInterface.TimeDoubleUnit newSimulator) throws NetworkException
      Clone the OTSode for e.g., copying a network.
      Parameters:
      newNetwork - Network; the new network to which the clone belongs
      newSimulator - 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 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
      newSimulator - SimulatorInterface.TimeDoubleUnit; the new simulator for this network
      Returns:
      the completed clone
      Throws:
      NetworkException - in case the cloning fails