Class SamplerData<G extends GtuData>

java.lang.Object
org.djutils.data.Table
org.opentrafficsim.kpi.sampling.SamplerData<G>
Type Parameters:
G - gtu data type
All Implemented Interfaces:
Iterable<org.djutils.data.Row>, org.djutils.base.Identifiable

public class SamplerData<G extends GtuData> extends org.djutils.data.Table
SamplerData is a storage for trajectory data. Adding trajectory groups can only be done by subclasses. This is however not a guaranteed read-only class. Any type can obtain the lane directions and with those the coupled trajectory groups. Trajectories can be added to these trajectory groups. Data can also be added to the trajectories themselves.

Copyright (c) 2020-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
  • Constructor Details

    • SamplerData

      public SamplerData(Set<ExtendedDataType<?,?,?,? super G>> extendedDataTypes, Set<FilterDataType<?,? super G>> filterDataTypes)
      Constructor.
      Parameters:
      extendedDataTypes - Set<? extends ExtendedDataType<?, ?, ?, ? super G>>; extended data types.
      filterDataTypes - Set<FilterDataType<?, ? super G>>; filter data types.
  • Method Details

    • putTrajectoryGroup

      protected final void putTrajectoryGroup(LaneData<?> lane, TrajectoryGroup<G> trajectoryGroup)
      Stores a trajectory group with the lane direction.
      Parameters:
      lane - LaneData; lane direction
      trajectoryGroup - trajectory group for given lane direction
    • getLanes

      public final Set<LaneData<?>> getLanes()
      Returns the set of lane directions.
      Returns:
      Set<LaneData>; lane directions
    • contains

      public final boolean contains(LaneData<?> lane)
      Returns whether there is data for the give lane.
      Parameters:
      lane - LaneData; lane
      Returns:
      whether there is data for the give lane
    • getTrajectoryGroup

      public final TrajectoryGroup<G> getTrajectoryGroup(LaneData<?> lane)
      Returns the trajectory group of given lane.
      Parameters:
      lane - LaneData; lane
      Returns:
      trajectory group of given lane, null if none
    • writeToFile

      public final void writeToFile(String file)
      Write the contents of the sampler in to a file. By default this is zipped.
      Parameters:
      file - String; file
    • writeToFile

      public final void writeToFile(String file, SamplerData.Compression compression)
      Write the contents of the sampler in to a file.
      Parameters:
      file - String; file
      compression - Compression; how to compress the data
    • iterator

      public Iterator<org.djutils.data.Row> iterator()
    • isEmpty

      public boolean isEmpty()
      Specified by:
      isEmpty in class org.djutils.data.Table