Package org.opentrafficsim.kpi.sampling
Class Query<G extends GtuData,L extends LaneData>
- java.lang.Object
-
- org.opentrafficsim.kpi.sampling.Query<G,L>
-
- Type Parameters:
G- gtu data typeL- 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 Summary
Constructors Constructor Description Query(Sampler<G,L> sampler, String id, String description, FilterDataSet filterDataSet)Constructor.Query(Sampler<G,L> sampler, String id, String description, FilterDataSet filterDataSet, Duration interval)Constructor with time interval.Query(Sampler<G,L> sampler, String id, String description, FilterDataSet filterDataSet, Frequency updateFrequency)Constructor with update frequency.Query(Sampler<G,L> sampler, String id, String description, FilterDataSet filterDataSet, Frequency updateFrequency, Duration interval)Constructor with time interval and update frequency.Query(Sampler<G,L> sampler, String description, FilterDataSet filterDataSet)Constructor without id.Query(Sampler<G,L> sampler, String description, FilterDataSet filterDataSet, Duration interval)Constructor without id, with time interval.Query(Sampler<G,L> sampler, String description, FilterDataSet filterDataSet, Frequency updateFrequency)Constructor without id, with time update frequency.Query(Sampler<G,L> sampler, String description, FilterDataSet filterDataSet, Frequency updateFrequency, Duration interval)Constructor without id, with time interval and update frequency.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddSpaceTimeRegion(L lane, Length startPosition, Length endPosition, Time startTime, Time endTime)Defines a region in space and time for which this query is valid.voidaddSpaceTimeRegionLink(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.booleanequals(Object obj)intfilterSize()Returns the number of filter datas.StringgetDescription()Returns the description.Iterator<Map.Entry<FilterDataType<?>,Set<?>>>getFilterDataSetIterator()Returns an iterator over the filter datas and the related data sets.StringgetId()Returns the unique id for the query.DurationgetInterval()Returns the time interval.Sampler<G,L>getSampler()Returns the sampler.Iterator<SpaceTimeRegion<? extends L>>getSpaceTimeIterator()Returns an iterator over the space-time regions.<T> List<TrajectoryGroup<G>>getTrajectoryGroups(Time endTime)Returns a list of TrajectoryGroups in accordance with the query.<T> List<TrajectoryGroup<G>>getTrajectoryGroups(Time startTime, Time endTime)Returns a list of TrajectoryGroups in accordance with the query.FrequencygetUpdateFrequency()Returns the update frequency.inthashCode()intspaceTimeRegionSize()Returns the number of space-time regions.StringtoString()
-
-
-
Constructor Detail
-
Query
public Query(Sampler<G,L> sampler, String id, String description, FilterDataSet filterDataSet)
Constructor.- Parameters:
sampler- Sampler<G, L>; samplerid- String; iddescription- String; descriptionfilterDataSet- 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>; samplerid- String; iddescription- String; descriptionfilterDataSet- FilterDataSet; filter datainterval- 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>; samplerid- String; iddescription- String; descriptionfilterDataSet- FilterDataSet; filter dataupdateFrequency- 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>; samplerid- String; iddescription- String; descriptionfilterDataSet- FilterDataSet; filter dataupdateFrequency- Frequency; update frequencyinterval- 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>; samplerdescription- String; descriptionfilterDataSet- 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>; samplerdescription- String; descriptionfilterDataSet- filterDataSet; filter datainterval- 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>; samplerdescription- String; descriptionfilterDataSet- filterDataSet; filter dataupdateFrequency- 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>; samplerdescription- String; descriptionfilterDataSet- filterDataSet; filter dataupdateFrequency- Frequency; update frequencyinterval- 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:
getIdin interfaceIdentifiable- 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>; linkstartPosition- Length; start positionendPosition- Length; end positionstartTime- Time; start timeendTime- 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; lanestartPosition- Length; start positionendPosition- Length; end positionstartTime- Time; start timeendTime- 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. EachTrajectoryGroupcontainsTrajectoryobjects pertaining to aSpaceTimeRegionfrom the query. ATrajectoryis only included if all the filter data of this query accepts the trajectory. This method usesTime.ZEROas 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. EachTrajectoryGroupcontainsTrajectoryobjects pertaining to aSpaceTimeRegionfrom the query. ATrajectoryis 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 forendTime- Time; start time of interval to get trajectory groups for- Returns:
- List<TrajectoryGroup<G>>; list of trajectory groups in accordance with the query
-
-