Package org.opentrafficsim.core.network
Class LinkLocation
- java.lang.Object
-
- org.opentrafficsim.core.network.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.
$LastChangedDate: 2020-04-01 12:03:44 +0200 (Wed, 01 Apr 2020) $, @version $Revision: 6424 $, by $Author: pknoppers $, initial version Oct 22, 2014
BSD-style license. See OpenTrafficSim License.- Author:
- Alexander Verbraeck, Peter Knoppers
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description LinkLocation(Link link, double fractionalLongitudinalPosition)Construct a new LinkLocation.LinkLocation(Link link, Length position)Construct a new LinkLocation.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Lengthdistance(LinkLocation loc)Returns the distance to another LinkLocation.doublegetFractionalLongitudinalPosition()Retrieve the fractional longitudinal position.LinkgetLink()Retrieve the link.LengthgetLongitudinalPosition()Retrieve the longitudinal position.StringtoString()
-
-
-
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.
-
-