Class Query<G extends GtuDataInterface>

  • Type Parameters:
    G - gtu data type
    All Implemented Interfaces:
    Identifiable

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

    Copyright (c) 2013-2020 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
    BSD-style license. See OpenTrafficSim License.

    $LastChangedDate: 2015-07-24 02:58:59 +0200 (Fri, 24 Jul 2015) $, @version $Revision: 1147 $, by $Author: averbraeck $, initial version Sep 21, 2016
    Author:
    Alexander Verbraeck, Peter Knoppers, Wouter Schakel
    • Constructor Detail

      • Query

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

        public Query​(Sampler<G> sampler,
                     String id,
                     String description,
                     FilterDataSet filterDataSet,
                     Duration interval)
        Parameters:
        sampler - Sampler<G>; sampler
        id - String; id
        description - String; description
        filterDataSet - filterDataSet; meta data
        interval - Duration; interval to gather statistics over
        Throws:
        NullPointerException - if sampling, description or filterDataSet is null
      • Query

        public Query​(Sampler<G> sampler,
                     String id,
                     String description,
                     FilterDataSet filterDataSet,
                     Frequency updateFrequency)
        Parameters:
        sampler - Sampler<G>; sampler
        id - String; id
        description - String; description
        filterDataSet - filterDataSet; meta data
        updateFrequency - Frequency; update frequency
        Throws:
        NullPointerException - if sampling, description or filterDataSet is null
      • Query

        public Query​(Sampler<G> sampler,
                     String id,
                     String description,
                     FilterDataSet filterDataSet,
                     Frequency updateFrequency,
                     Duration interval)
        Constructor. The filter data types must be registered with the sampler.
        Parameters:
        sampler - Sampler<G>; 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> sampler,
                     String description,
                     FilterDataSet filterDataSet)
        Constructor. The filter data types must be registered with the sampler.
        Parameters:
        sampler - Sampler<G>; sampler
        description - String; description
        filterDataSet - filterDataSet; filter data
        Throws:
        NullPointerException - if sampling, description or filterDataSet is null
      • Query

        public Query​(Sampler<G> sampler,
                     String description,
                     FilterDataSet filterDataSet,
                     Duration interval)
        Constructor. The filter data types must be registered with the sampler.
        Parameters:
        sampler - Sampler<G>; 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> sampler,
                     String description,
                     FilterDataSet filterDataSet,
                     Frequency updateFrequency)
        Constructor. The filter data types must be registered with the sampler.
        Parameters:
        sampler - Sampler<G>; 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> sampler,
                     String description,
                     FilterDataSet filterDataSet,
                     Frequency updateFrequency,
                     Duration interval)
        Constructor. The filter data types must be registered with the sampler.
        Parameters:
        sampler - Sampler<G>; 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 Detail

      • getId

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

        public String getDescription()
        Returns:
        description
      • getUpdateFrequency

        public Frequency getUpdateFrequency()
        Returns:
        updateFrequency.
      • getInterval

        public Duration getInterval()
        Returns:
        interval.
      • metaFilterSize

        public int metaFilterSize()
        Returns:
        number of meta data entries
      • getFilterDataSetIterator

        public Iterator<Map.Entry<FilterDataType<?>,​Set<?>>> getFilterDataSetIterator()
        Returns:
        iterator over filter data entries, removal is not allowed
      • addSpaceTimeRegionLink

        public void addSpaceTimeRegionLink​(LinkDataInterface link,
                                           KpiGtuDirectionality direction,
                                           Length startPosition,
                                           Length endPosition,
                                           Time startTime,
                                           Time endTime)
        Defines a region in space and time for which this query is valid. All lanes in the link are included.
        Parameters:
        link - LinkDataInterface; link
        direction - KpiGtuDirectionality; direction
        startPosition - Length; start position
        endPosition - Length; end position
        startTime - Time; start time
        endTime - Time; end time
      • addSpaceTimeRegion

        public void addSpaceTimeRegion​(KpiLaneDirection laneDirection,
                                       Length startPosition,
                                       Length endPosition,
                                       Time startTime,
                                       Time endTime)
        Defines a region in space and time for which this query is valid.
        Parameters:
        laneDirection - KpiLaneDirection; lane direction
        startPosition - Length; start position
        endPosition - Length; end position
        startTime - Time; start time
        endTime - Time; end time
      • spaceTimeRegionSize

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

        public Iterator<SpaceTimeRegion> getSpaceTimeIterator()
        Returns:
        iterator over space-time regions, removal is not allowed
      • getTrajectoryGroups

        public <T> List<TrajectoryGroup<G>> getTrajectoryGroups​(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 meta data of this query accepts the trajectory. This method uses Time.ZERO as start.
        Type Parameters:
        T - underlying class of meta data type and its value
        Parameters:
        endTime - Time; end time of interval to get trajectory groups for
        Returns:
        list of trajectory groups in accordance with the query
      • getTrajectoryGroups

        public <T> List<TrajectoryGroup<G>> getTrajectoryGroups​(Time startTime,
                                                                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 meta data of this query accepts the trajectory.
        Type Parameters:
        T - underlying class of meta 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 of trajectory groups in accordance with the query
      • getSampler

        public Sampler<?> getSampler()
        Returns:
        sampling.
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object