Class Query<G extends GtuData,L extends LaneData<L>>

java.lang.Object
org.opentrafficsim.kpi.sampling.Query<G,L>
Type Parameters:
G - gtu data type
L - lane data type
All Implemented Interfaces:
org.djutils.base.Identifiable

public final class Query<G extends GtuData,L extends LaneData<L>> extends Object implements org.djutils.base.Identifiable
A query defines which subset of trajectory information should be included. This is in terms of space-time regions, and in terms of filter data of trajectories, e.g. only include trajectories of trucks.

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
  • Constructor Details

    • Query

      public Query(Sampler<G,L> sampler, String id, String description, FilterDataSet filterDataSet)
      Constructor.
      Parameters:
      sampler - Sampler<G, L>; sampler
      id - String; id
      description - String; description
      filterDataSet - FilterDataSet; filter data
      Throws:
      NullPointerException - if sampling, description or filterDataSet is null
    • Query

      public Query(Sampler<G,L> sampler, String id, String description, FilterDataSet filterDataSet, org.djunits.value.vdouble.scalar.Duration interval)
      Constructor with time interval.
      Parameters:
      sampler - Sampler<G, L>; sampler
      id - String; id
      description - String; description
      filterDataSet - FilterDataSet; filter data
      interval - Duration; interval to gather statistics over
      Throws:
      NullPointerException - if sampling, description or filterDataSet is null
    • Query

      public Query(Sampler<G,L> sampler, String id, String description, FilterDataSet filterDataSet, org.djunits.value.vdouble.scalar.Frequency updateFrequency)
      Constructor with update frequency.
      Parameters:
      sampler - Sampler<G, L>; sampler
      id - String; id
      description - String; description
      filterDataSet - FilterDataSet; filter data
      updateFrequency - Frequency; update frequency
      Throws:
      NullPointerException - if sampling, description or filterDataSet is null
    • Query

      public Query(Sampler<G,L> sampler, String id, String description, FilterDataSet filterDataSet, org.djunits.value.vdouble.scalar.Frequency updateFrequency, org.djunits.value.vdouble.scalar.Duration interval)
      Constructor with time interval and update frequency.
      Parameters:
      sampler - Sampler<G, L>; sampler
      id - String; id
      description - String; description
      filterDataSet - FilterDataSet; filter data
      updateFrequency - Frequency; update frequency
      interval - Duration; interval to gather statistics over
      Throws:
      NullPointerException - if sampling, description or filterDataSet is null
    • Query

      public Query(Sampler<G,L> sampler, String description, FilterDataSet filterDataSet)
      Constructor without id.
      Parameters:
      sampler - Sampler<G, L>; sampler
      description - String; description
      filterDataSet - FilterDataSet; filter data
      Throws:
      NullPointerException - if sampling, description or filterDataSet is null
    • Query

      public Query(Sampler<G,L> sampler, String description, FilterDataSet filterDataSet, org.djunits.value.vdouble.scalar.Duration interval)
      Constructor without id, with time interval.
      Parameters:
      sampler - Sampler<G, L>; sampler
      description - String; description
      filterDataSet - filterDataSet; filter data
      interval - Duration; interval to gather statistics over
      Throws:
      NullPointerException - if sampling, description or filterDataSet is null
    • Query

      public Query(Sampler<G,L> sampler, String description, FilterDataSet filterDataSet, org.djunits.value.vdouble.scalar.Frequency updateFrequency)
      Constructor without id, with time update frequency.
      Parameters:
      sampler - Sampler<G, L>; sampler
      description - String; description
      filterDataSet - filterDataSet; filter data
      updateFrequency - Frequency; update frequency
      Throws:
      NullPointerException - if sampling, description or filterDataSet is null
    • Query

      public Query(Sampler<G,L> sampler, String description, FilterDataSet filterDataSet, org.djunits.value.vdouble.scalar.Frequency updateFrequency, org.djunits.value.vdouble.scalar.Duration interval)
      Constructor without id, with time interval and update frequency.
      Parameters:
      sampler - Sampler<G, L>; sampler
      description - String; description
      filterDataSet - filterDataSet; filter data
      updateFrequency - Frequency; update frequency
      interval - Duration; interval to gather statistics over
      Throws:
      NullPointerException - if sampling, description or filterDataSet is null
  • Method Details

    • getId

      public String getId()
      Returns the unique id for the query.
      Specified by:
      getId in interface org.djutils.base.Identifiable
      Returns:
      String; the unique id for the query
    • getDescription

      public String getDescription()
      Returns the description.
      Returns:
      String; description
    • getUpdateFrequency

      public org.djunits.value.vdouble.scalar.Frequency getUpdateFrequency()
      Returns the update frequency.
      Returns:
      Frequency; updateFrequency.
    • getInterval

      public org.djunits.value.vdouble.scalar.Duration getInterval()
      Returns the time interval.
      Returns:
      Duration; interval.
    • filterSize

      public int filterSize()
      Returns the number of filter datas.
      Returns:
      int; number of filter data entries
    • getFilterDataSetIterator

      public Iterator<Map.Entry<FilterDataType<?,?>,Set<?>>> getFilterDataSetIterator()
      Returns an iterator over the filter datas and the related data sets.
      Returns:
      Iterator<Entry<FilterDataType<?, ?>, Set<?>>>; iterator over filter data entries, removal is not allowed
    • addSpaceTimeRegionLink

      public void addSpaceTimeRegionLink(LinkData<? extends L> link, 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)
      Defines a region in space and time for which this query is valid. All lanes in the link are included.
      Parameters:
      link - LinkData<? extends L>; link
      startPosition - Length; start position
      endPosition - Length; end position
      startTime - Time; start time
      endTime - Time; end time
    • addSpaceTimeRegion

      public void addSpaceTimeRegion(L lane, 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)
      Defines a region in space and time for which this query is valid.
      Parameters:
      lane - L; lane
      startPosition - Length; start position
      endPosition - Length; end position
      startTime - Time; start time
      endTime - Time; end time
    • spaceTimeRegionSize

      public int spaceTimeRegionSize()
      Returns the number of space-time regions.
      Returns:
      int; number of space-time regions
    • getSpaceTimeIterator

      public Iterator<SpaceTimeRegion<? extends L>> getSpaceTimeIterator()
      Returns an iterator over the space-time regions.
      Returns:
      Iterator<SpaceTimeRegion<? extends L>>; iterator over space-time regions, removal is not allowed
    • getTrajectoryGroups

      public <T> List<TrajectoryGroup<G>> getTrajectoryGroups(org.djunits.value.vdouble.scalar.Time endTime)
      Returns a list of TrajectoryGroups in accordance with the query. Each TrajectoryGroup contains Trajectory objects pertaining to a SpaceTimeRegion from the query. A Trajectory is only included if all the filter data of this query accepts the trajectory. This method uses Time.ZERO as start.
      Type Parameters:
      T - underlying class of filter data type and its value
      Parameters:
      endTime - Time; end time of interval to get trajectory groups for
      Returns:
      List<TrajectoryGroup<G>>; list of trajectory groups in accordance with the query
    • getTrajectoryGroups

      public <T> List<TrajectoryGroup<G>> getTrajectoryGroups(org.djunits.value.vdouble.scalar.Time startTime, org.djunits.value.vdouble.scalar.Time endTime)
      Returns a list of TrajectoryGroups in accordance with the query. Each TrajectoryGroup contains Trajectory objects pertaining to a SpaceTimeRegion from the query. A Trajectory is only included if all the filter data of this query accepts the trajectory.
      Type Parameters:
      T - underlying class of filter data type and its value
      Parameters:
      startTime - Time; start time of interval to get trajectory groups for
      endTime - Time; start time of interval to get trajectory groups for
      Returns:
      List<TrajectoryGroup<G>>; list of trajectory groups in accordance with the query
    • getSampler

      public Sampler<G,L> getSampler()
      Returns the sampler.
      Returns:
      Sampler<G, L>; sampler.
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object