Class OTSLink

    • Constructor Detail

      • OTSLink

        public OTSLink​(Network network,
                       String id,
                       Node startNode,
                       Node endNode,
                       LinkType linkType,
                       OTSLine3D designLine)
                throws NetworkException
        Construct a new link.
        Parameters:
        network - Network; the network to which the link belongs
        id - String; the link id
        startNode - Node; start node (directional)
        endNode - Node; end node (directional)
        linkType - LinkType; Link type to indicate compatibility with GTU types
        designLine - OTSLine3D; the OTSLine3D design line of the Link
        Throws:
        NetworkException - if link already exists in the network, if name of the link is not unique, or if the start node or the end node of the link are not registered in the network.
      • OTSLink

        protected OTSLink​(Network newNetwork,
                          OTSLink link)
                   throws NetworkException
        Clone a link for a new network.
        Parameters:
        newNetwork - Network; the new network to which the clone belongs
        link - OTSLink; the link to clone from
        Throws:
        NetworkException - if link already exists in the network, if name of the link is not unique, or if the start node or the end node of the link are not registered in the network.
    • Method Detail

      • getDirectionality

        public final LongitudinalDirectionality getDirectionality​(GTUType gtuType)
        This method returns the directionality of the link for a GTU type. It might be that the link is FORWARD (from start node to end node) for the GTU type CAR, but BOTH for the GTU type BICYCLE (i.e., bicycles can also go from end node to start node). If there is no entry for the given GTU Type, the values of GTUType.ALL will be returned. If this entry is not present, LongitudinalDirectionality.NONE will be returned.
        Specified by:
        getDirectionality in interface Link
        Parameters:
        gtuType - GTUType; the GTU type to request the directionality for
        Returns:
        the longitudinal directionality of the link (FORWARD, BACKWARD, BOTH or NONE) for the given GTU type. NONE will be returned if no directionality is given.
      • addGTU

        public final void addGTU​(GTU gtu)
        Add a GTU to this link (e.g., for statistical purposes, or for a model on macro level). It is safe to add a GTU again. No warning or error will be given. The GTU_ADD_EVENT will only be fired when the GTU was not already on the link.
        Specified by:
        addGTU in interface Link
        Parameters:
        gtu - GTU; the GTU to add.
      • removeGTU

        public final void removeGTU​(GTU gtu)
        Remove a GTU from this link. It is safe to try to remove a GTU again. No warning or error will be given. The GTU_REMOVE_EVENT will only be fired when the GTU was on the link.
        Specified by:
        removeGTU in interface Link
        Parameters:
        gtu - GTU; the GTU to remove.
      • getGTUs

        public final Set<GTU> getGTUs()
        Provide a safe copy of the set of GTUs.
        Specified by:
        getGTUs in interface Link
        Returns:
        Set<GTU>; a safe copy of the set of GTUs
      • getGTUCount

        public final int getGTUCount()
        Provide the number of GTUs on this link.
        Specified by:
        getGTUCount in interface Link
        Returns:
        int; the number of GTUs on this link
      • getNetwork

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

        public final Node getStartNode()
        Specified by:
        getStartNode in interface Link
        Returns:
        start node.
      • getEndNode

        public final Node getEndNode()
        Specified by:
        getEndNode in interface Link
        Returns:
        end node.
      • getLinkType

        public final LinkType getLinkType()
        Specified by:
        getLinkType in interface Link
        Returns:
        the link type.
      • getDesignLine

        public final OTSLine3D getDesignLine()
        Specified by:
        getDesignLine in interface Link
        Returns:
        the design line.
      • getLength

        public final Length getLength()
        Specified by:
        getLength in interface Link
        Returns:
        length of the link.
      • hashCode

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

        public OTSLink clone​(OTSNetwork newNetwork)
                      throws NetworkException
        Clone the OTSLink 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