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

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

    public final class Query<G extends GtuData,​L extends LaneData>
    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 filter data of trajectories, e.g. only include trajectories of trucks.

    Copyright (c) 2013-2023 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

      • 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,
                     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,
                     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,
                     Frequency updateFrequency,
                     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,
                     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,
                     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,
                     Frequency updateFrequency,
                     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 Detail

      • getId

        public String getId()
        Returns 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 the description.
        Returns:
        String; description
      • getUpdateFrequency

        public Frequency getUpdateFrequency()
        Returns the update frequency.
        Returns:
        Frequency; updateFrequency.
      • getInterval

        public 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,
                                           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 - 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,
                                       Length startPosition,
                                       Length endPosition,
                                       Time startTime,
                                       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​(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​(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 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