Package org.opentrafficsim.kpi.sampling
Class Trajectory<G extends GtuData>
java.lang.Object
org.opentrafficsim.kpi.sampling.Trajectory<G>
- Type Parameters:
 G- GTU data type
Contains position, speed, acceleration and time data of a GTU, over some section. Position is relative to the start of the
 lane in the direction of travel.
 
 Copyright (c) 2013-2024 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. 
 BSD-style license. See OpenTrafficSim License.
 
- Author:
 - Alexander Verbraeck, Peter Knoppers, Wouter Schakel
 
- 
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordSpace-time view of a trajectory. - 
Constructor Summary
ConstructorsConstructorDescriptionTrajectory(GtuData gtu, Map<FilterDataType<?, ? super G>, Object> filterData, Set<ExtendedDataType<?, ?, ?, ? super G>> extendedData) Constructor. - 
Method Summary
Modifier and TypeMethodDescriptionvoidadd(org.djunits.value.vdouble.scalar.Length position, org.djunits.value.vdouble.scalar.Speed speed, org.djunits.value.vdouble.scalar.Acceleration acceleration, org.djunits.value.vdouble.scalar.Time time) Adds values of position, speed, acceleration and time.voidadd(org.djunits.value.vdouble.scalar.Length position, org.djunits.value.vdouble.scalar.Speed speed, org.djunits.value.vdouble.scalar.Acceleration acceleration, org.djunits.value.vdouble.scalar.Time time, G gtu) Adds values of position, speed, acceleration, time and extended data.intbinarySearchT(float time) Returns the last index with a time smaller than or equal to the given time.intbinarySearchX(float position) Returns the last index with a position smaller than or equal to the given position.booleancontains(ExtendedDataType<?, ?, ?, ?> extendedDataType) Returns whether ths extended data type is contained.booleancontains(FilterDataType<?, ?> filterDataType) Returns whether the filter data is contained.booleanfloat[]getA()Returns the acceleration array.floatgetA(int index) Returnsavalue of a single sample.org.djunits.value.vfloat.vector.FloatAccelerationVectorReturns strongly typed acceleration array.org.djunits.value.vdouble.scalar.AccelerationgetAccelerationAtPosition(org.djunits.value.vdouble.scalar.Length position) Returns an interpolated acceleration at the given position.org.djunits.value.vdouble.scalar.AccelerationgetAccelerationAtTime(org.djunits.value.vdouble.scalar.Time time) Returns an interpolated acceleration at the given time.<O,S> O getExtendedData(ExtendedDataType<?, O, S, ?> extendedDataType) Returns the output data of the extended data type.<T,S> T getExtendedData(ExtendedDataType<T, ?, S, ?> extendedDataType, int index) Returns extended data type value of a single sample.Set<ExtendedDataType<?,?, ?, ? super G>> Returns the included extended data types.<T> TgetFilterData(FilterDataType<T, ?> filterDataType) Returns the value of the filter data.Set<FilterDataType<?,? super G>> Returns the included filter data types.getGtuId()Returns the GTU id.Returns the GTU type id.org.djunits.value.vfloat.vector.FloatLengthVectorReturns strongly type position array.org.djunits.value.vdouble.scalar.LengthgetPositionAtTime(org.djunits.value.vdouble.scalar.Time time) Returns an interpolated position at the given time.Returns a space-time view of this trajectory.getSpaceTimeView(org.djunits.value.vdouble.scalar.Length startPosition, org.djunits.value.vdouble.scalar.Length endPosition, org.djunits.value.vdouble.scalar.Time startTime, org.djunits.value.vdouble.scalar.Time endTime) Returns a space-time view of this trajectory as contained within the defined space-time region.org.djunits.value.vfloat.vector.FloatSpeedVectorgetSpeed()Returns strongly typed speed array.org.djunits.value.vdouble.scalar.SpeedgetSpeedAtPosition(org.djunits.value.vdouble.scalar.Length position) Returns an interpolated speed at the given position.org.djunits.value.vdouble.scalar.SpeedgetSpeedAtTime(org.djunits.value.vdouble.scalar.Time time) Returns an interpolated speed at the given time.float[]getT()Returns the time array.floatgetT(int index) Returnstvalue of a single sample.org.djunits.value.vfloat.vector.FloatTimeVectorgetTime()Returns strongly typed time array.org.djunits.value.vdouble.scalar.TimegetTimeAtPosition(org.djunits.value.vdouble.scalar.Length position) Returns an interpolated time at the given position.org.djunits.value.vdouble.scalar.DurationReturns the total duration span.org.djunits.value.vdouble.scalar.LengthReturns the length of the data.float[]getV()Returns the speed array.floatgetV(int index) Returnsvvalue of a single sample.float[]getX()Returns the position array.floatgetX(int index) Returnsxvalue of a single sample.inthashCode()intsize()The size of the underlying data.subSet(org.djunits.value.vdouble.scalar.Length startPosition, org.djunits.value.vdouble.scalar.Length endPosition) Copies the trajectory but with a subset of the data.subSet(org.djunits.value.vdouble.scalar.Length startPosition, org.djunits.value.vdouble.scalar.Length endPosition, org.djunits.value.vdouble.scalar.Time startTime, org.djunits.value.vdouble.scalar.Time endTime) Copies the trajectory but with a subset of the data that is contained in the given space-time region.subSet(org.djunits.value.vdouble.scalar.Time startTime, org.djunits.value.vdouble.scalar.Time endTime) Copies the trajectory but with a subset of the data.toString() 
- 
Constructor Details
- 
Trajectory
public Trajectory(GtuData gtu, Map<FilterDataType<?, ? super G>, Object> filterData, Set<ExtendedDataType<?, ?, ?, ? super G>> extendedData) Constructor.- Parameters:
 gtu- GTU of this trajectory, only the id is stored.filterData- filter dataextendedData- types of extended data
 
 - 
 - 
Method Details
- 
add
public void add(org.djunits.value.vdouble.scalar.Length position, org.djunits.value.vdouble.scalar.Speed speed, org.djunits.value.vdouble.scalar.Acceleration acceleration, org.djunits.value.vdouble.scalar.Time time) Adds values of position, speed, acceleration and time.- Parameters:
 position- position is relative to the start of the lane in the direction of the design line, i.e. irrespective of the travel direction, also when trajectories have been truncated at a position x > 0speed- speedacceleration- accelerationtime- time
 - 
add
public void add(org.djunits.value.vdouble.scalar.Length position, org.djunits.value.vdouble.scalar.Speed speed, org.djunits.value.vdouble.scalar.Acceleration acceleration, org.djunits.value.vdouble.scalar.Time time, G gtu) Adds values of position, speed, acceleration, time and extended data.- Parameters:
 position- position is relative to the start of the lane in the direction of the design linespeed- speedacceleration- accelerationtime- timegtu- gtu to add extended data for
 - 
size
public int size()The size of the underlying data.- Returns:
 - size of the underlying trajectory data
 
 - 
getGtuId
Returns the GTU id.- Returns:
 - GTU id
 
 - 
getGtuTypeId
Returns the GTU type id.- Returns:
 - GTU type id
 
 - 
getX
public float[] getX()Returns the position array.- Returns:
 - si position values.
 
 - 
getV
public float[] getV()Returns the speed array.- Returns:
 - si speed values
 
 - 
getA
public float[] getA()Returns the acceleration array.- Returns:
 - si acceleration values
 
 - 
getT
public float[] getT()Returns the time array.- Returns:
 - si time values
 
 - 
binarySearchX
public int binarySearchX(float position) Returns the last index with a position smaller than or equal to the given position.- Parameters:
 position- position- Returns:
 - last index with a position smaller than or equal to the given position
 
 - 
binarySearchT
public int binarySearchT(float time) Returns the last index with a time smaller than or equal to the given time.- Parameters:
 time- time- Returns:
 - last index with a time smaller than or equal to the given time
 
 - 
getX
public float getX(int index) Returnsxvalue of a single sample.- Parameters:
 index- index- Returns:
 xvalue of a single sample
 - 
getV
public float getV(int index) Returnsvvalue of a single sample.- Parameters:
 index- index- Returns:
 vvalue of a single sample
 - 
getA
public float getA(int index) Returnsavalue of a single sample.- Parameters:
 index- index- Returns:
 avalue of a single sample
 - 
getT
public float getT(int index) Returnstvalue of a single sample.- Parameters:
 index- index- Returns:
 tvalue of a single sample
 - 
getExtendedData
Returns extended data type value of a single sample.- Type Parameters:
 T- scalar type of extended data typeS- storage type of extended data type- Parameters:
 extendedDataType- data type from which to retrieve the dataindex- index for which to retrieve the data- Returns:
 - extended data type value of a single sample
 
 - 
getPosition
public org.djunits.value.vfloat.vector.FloatLengthVector getPosition()Returns strongly type position array.- Returns:
 - strongly typed position array.
 
 - 
getSpeed
public org.djunits.value.vfloat.vector.FloatSpeedVector getSpeed()Returns strongly typed speed array.- Returns:
 - strongly typed speed array.
 
 - 
getAcceleration
public org.djunits.value.vfloat.vector.FloatAccelerationVector getAcceleration()Returns strongly typed acceleration array.- Returns:
 - strongly typed acceleration array.
 
 - 
getTime
public org.djunits.value.vfloat.vector.FloatTimeVector getTime()Returns strongly typed time array.- Returns:
 - strongly typed time array.
 
 - 
getTotalLength
public org.djunits.value.vdouble.scalar.Length getTotalLength()Returns the length of the data.- Returns:
 - total length of this trajectory
 
 - 
getTotalDuration
public org.djunits.value.vdouble.scalar.Duration getTotalDuration()Returns the total duration span.- Returns:
 - total duration of this trajectory
 
 - 
contains
Returns whether the filter data is contained.- Parameters:
 filterDataType- filter data type- Returns:
 - whether the trajectory contains the filter data of give type
 
 - 
getFilterData
Returns the value of the filter data.- Type Parameters:
 T- class of filter data- Parameters:
 filterDataType- filter data type- Returns:
 - value of filter data
 
 - 
getFilterDataTypes
Returns the included filter data types.- Returns:
 - included filter data types
 
 - 
contains
Returns whether ths extended data type is contained.- Parameters:
 extendedDataType- extended data type- Returns:
 - whether the trajectory contains the extended data of give type
 
 - 
getExtendedData
public <O,S> O getExtendedData(ExtendedDataType<?, O, throws SamplingExceptionS, ?> extendedDataType) Returns the output data of the extended data type.- Type Parameters:
 O- output typeS- storage type- Parameters:
 extendedDataType- extended data type to return- Returns:
 - values of extended data type
 - Throws:
 SamplingException- if the extended data type is not in the trajectory
 - 
getExtendedDataTypes
Returns the included extended data types.- Returns:
 - included extended data types
 
 - 
getSpaceTimeView
Returns a space-time view of this trajectory. This is much more efficient thangetX()as no array is copied. The limitation is that only distance and time (and mean speed) in the space-time view can be obtained.- Returns:
 - space-time view of this trajectory
 
 - 
getSpaceTimeView
public Trajectory.SpaceTimeView getSpaceTimeView(org.djunits.value.vdouble.scalar.Length startPosition, org.djunits.value.vdouble.scalar.Length endPosition, org.djunits.value.vdouble.scalar.Time startTime, org.djunits.value.vdouble.scalar.Time endTime) Returns a space-time view of this trajectory as contained within the defined space-time region. This is much more efficient thansubSet()as no trajectory is copied. The limitation is that only distance and time (and mean speed) in the space-time view can be obtained.- Parameters:
 startPosition- start positionendPosition- end positionstartTime- start timeendTime- end time- Returns:
 - space-time view of this trajectory
 
 - 
subSet
public Trajectory<G> subSet(org.djunits.value.vdouble.scalar.Length startPosition, org.djunits.value.vdouble.scalar.Length endPosition) Copies the trajectory but with a subset of the data. Longitudinal entry is only true if the original trajectory has true, and the subset is from the start.- Parameters:
 startPosition- start positionendPosition- end position- Returns:
 - subset of the trajectory
 - Throws:
 NullPointerException- if an input is nullIllegalArgumentException- of minLength is smaller than maxLength
 - 
subSet
public Trajectory<G> subSet(org.djunits.value.vdouble.scalar.Time startTime, org.djunits.value.vdouble.scalar.Time endTime) Copies the trajectory but with a subset of the data.- Parameters:
 startTime- start timeendTime- end time- Returns:
 - subset of the trajectory
 - Throws:
 NullPointerException- if an input is nullIllegalArgumentException- of minTime is smaller than maxTime
 - 
subSet
public Trajectory<G> subSet(org.djunits.value.vdouble.scalar.Length startPosition, org.djunits.value.vdouble.scalar.Length endPosition, org.djunits.value.vdouble.scalar.Time startTime, org.djunits.value.vdouble.scalar.Time endTime) Copies the trajectory but with a subset of the data that is contained in the given space-time region.- Parameters:
 startPosition- start positionendPosition- end positionstartTime- start timeendTime- end time- Returns:
 - subset of the trajectory
 - Throws:
 NullPointerException- if an input is nullIllegalArgumentException- of minLength/Time is smaller than maxLength/Time
 - 
getTimeAtPosition
public org.djunits.value.vdouble.scalar.Time getTimeAtPosition(org.djunits.value.vdouble.scalar.Length position) Returns an interpolated time at the given position.- Parameters:
 position- position- Returns:
 - interpolated time at the given position
 
 - 
getSpeedAtPosition
public org.djunits.value.vdouble.scalar.Speed getSpeedAtPosition(org.djunits.value.vdouble.scalar.Length position) Returns an interpolated speed at the given position.- Parameters:
 position- position- Returns:
 - interpolated speed at the given position
 
 - 
getAccelerationAtPosition
public org.djunits.value.vdouble.scalar.Acceleration getAccelerationAtPosition(org.djunits.value.vdouble.scalar.Length position) Returns an interpolated acceleration at the given position.- Parameters:
 position- position- Returns:
 - interpolated acceleration at the given position
 
 - 
getPositionAtTime
public org.djunits.value.vdouble.scalar.Length getPositionAtTime(org.djunits.value.vdouble.scalar.Time time) Returns an interpolated position at the given time.- Parameters:
 time- time- Returns:
 - interpolated position at the given time
 
 - 
getSpeedAtTime
public org.djunits.value.vdouble.scalar.Speed getSpeedAtTime(org.djunits.value.vdouble.scalar.Time time) Returns an interpolated speed at the given time.- Parameters:
 time- time- Returns:
 - interpolated speed at the given time
 
 - 
getAccelerationAtTime
public org.djunits.value.vdouble.scalar.Acceleration getAccelerationAtTime(org.djunits.value.vdouble.scalar.Time time) Returns an interpolated acceleration at the given time.- Parameters:
 time- time- Returns:
 - interpolated acceleration at the given time
 
 - 
hashCode
public int hashCode() - 
equals
 - 
toString
 
 -