Class OTSNode

    • 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 interface Node
        Returns:
        Network; the network in which this link is registered
      • 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.
      • 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 interface Node
        Returns:
        boolean; whether the node is a centroid, i.e. it only has connector links going in and out
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object
      • 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