Class LinkLocation

  • All Implemented Interfaces:
    Serializable

    public class LinkLocation
    extends Object
    implements Serializable
    A LinkLocation packs a Link and a fractional longitudinal position.

    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-04-01 12:03:44 +0200 (Wed, 01 Apr 2020) $, @version $Revision: 6424 $, by $Author: pknoppers $, initial version Oct 22, 2014
    Author:
    Alexander Verbraeck, Peter Knoppers
    See Also:
    Serialized Form
    • Constructor Detail

      • LinkLocation

        public LinkLocation​(Link link,
                            double fractionalLongitudinalPosition)
        Construct a new LinkLocation. TODO decide if we should throw an exception when fractionalLongitudinalPosition is out of range.
        Parameters:
        link - Link; The link of the location of a point relative to the GTU.
        fractionalLongitudinalPosition - double; The fractional position (between 0.0 and 1.0) of the reference point on the link.
      • LinkLocation

        public LinkLocation​(Link link,
                            Length position)
        Construct a new LinkLocation. TODO decide if we should throw an exception when position is out of range.
        Parameters:
        link - Link; The link of the location of a point relative to the GTU.
        position - Length; The position as a length of the reference point on the link.
    • Method Detail

      • getLink

        public final Link getLink()
        Retrieve the link.
        Returns:
        Link; the link
      • getFractionalLongitudinalPosition

        public final double getFractionalLongitudinalPosition()
        Retrieve the fractional longitudinal position.
        Returns:
        double; fractionalLongitudinalPosition; a value in (0.0, 1.0)
      • getLongitudinalPosition

        public final Length getLongitudinalPosition()
        Retrieve the longitudinal position.
        Returns:
        Length; position as a length as a traveled length on this link
      • distance

        public final Length distance​(LinkLocation loc)
        Returns the distance to another LinkLocation. If the other location is in front of us, the distance is positive. If it is behind us, it is negative. TODO decide if we should throw an exception if the links are not the same.
        Parameters:
        loc - LinkLocation; the link location to find the distance to.
        Returns:
        the distance to another LinkLocation.