Class SamplerData<G extends GtuDataInterface>

  • Type Parameters:
    G - gtu data type
    All Implemented Interfaces:
    Iterable<Record>, Identifiable, Table

    public class SamplerData<G extends GtuDataInterface>
    extends AbstractTable
    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-2020 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 Detail

      • SamplerData

        public SamplerData​(Collection<Column<?>> columns)
        Constructor.
        Parameters:
        columns - Collection<Column<?>>; columns
    • Method Detail

      • putTrajectoryGroup

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

        public final Set<KpiLaneDirection> getLaneDirections()
        Returns the set of lane directions.
        Returns:
        Set<KpiLaneDirection>; lane directions
      • contains

        public final boolean contains​(KpiLaneDirection kpiLaneDirection)
        Returns whether there is data for the give lane direction.
        Parameters:
        kpiLaneDirection - KpiLaneDirection; lane direction
        Returns:
        whether there is data for the give lane direction
      • getTrajectoryGroup

        public final TrajectoryGroup<G> getTrajectoryGroup​(KpiLaneDirection kpiLaneDirection)
        Returns the trajectory group of given lane direction.
        Parameters:
        kpiLaneDirection - KpiLaneDirection; lane direction
        Returns:
        trajectory group of given lane direction, 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 and numeric data is formated %.3f.
        Parameters:
        file - String; file
      • writeToFile

        public final void writeToFile​(String file,
                                      String format,
                                      SamplerData.CompressionMethod compression)
        Write the contents of the sampler in to a file.
        Parameters:
        file - String; file
        format - String; number format, as used in String.format()
        compression - CompressionMethod; how to compress the data
      • loadFromFile

        public static SamplerData<?> loadFromFile​(String file)
        Loads sampler data from a file. There are a few limitations with respect to live sampled data:
        1. The number of decimals in numeric data is equal to the stored format.
        2. All extended data types are stored as String.
        3. Meta data types are not recognized, and hence stored as extended data types. Values are always stored as String.
        Parameters:
        file - String; file
        Returns:
        Sampler data from file
      • loadFromFile

        public static SamplerData<?> loadFromFile​(String file,
                                                  Set<ExtendedDataType<?,​?,​?,​?>> extendedDataTypes,
                                                  Set<FilterDataType<?>> metaDataTypes)
        Loads sampler data from a file. There are a few limitations with respect to live sampled data:
        1. The number of decimals in numeric data is equal to the stored format.
        2. All extended data types are stored as String, unless recognized by id as provided.
        3. Meta data types are not recognized, and hence stored as extended data types, unless recognized by id as provided. Values are always stored as String.
        Parameters:
        file - String; file
        extendedDataTypes - Set<ExtendedDataType<?, ?, ?, ?>>; extended data types
        metaDataTypes - Set<MetaDataType<?>>; meta data types
        Returns:
        Sampler data from file
      • isEmpty

        public boolean isEmpty()
        Returns whether the table is empty.
        Returns:
        whether the table is empty