Package org.opentrafficsim.kpi.sampling
Class Query<G extends GtuData,L extends LaneData<L>>
java.lang.Object
org.opentrafficsim.kpi.sampling.Query<G,L>
- Type Parameters:
G
- gtu data typeL
- 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 Summary
ConstructorDescriptionConstructor.Query
(Sampler<G, L> sampler, String id, String description, FilterDataSet filterDataSet, org.djunits.value.vdouble.scalar.Duration interval) Constructor with time interval.Query
(Sampler<G, L> sampler, String id, String description, FilterDataSet filterDataSet, org.djunits.value.vdouble.scalar.Frequency updateFrequency) Constructor with update frequency.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.Constructor without id.Query
(Sampler<G, L> sampler, String description, FilterDataSet filterDataSet, org.djunits.value.vdouble.scalar.Duration interval) Constructor without id, with time interval.Query
(Sampler<G, L> sampler, String description, FilterDataSet filterDataSet, org.djunits.value.vdouble.scalar.Frequency updateFrequency) Constructor without id, with time update frequency.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. -
Method Summary
Modifier and TypeMethodDescriptionvoid
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.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.boolean
int
Returns the number of filter datas.Returns the description.Iterator<Map.Entry<FilterDataType<?,
?>, Set<?>>> Returns an iterator over the filter datas and the related data sets.getId()
Returns the unique id for the query.org.djunits.value.vdouble.scalar.Duration
Returns the time interval.Returns the sampler.Iterator<SpaceTimeRegion<? extends L>>
Returns an iterator over the space-time regions.<T> List<TrajectoryGroup<G>>
getTrajectoryGroups
(org.djunits.value.vdouble.scalar.Time endTime) Returns a list of TrajectoryGroups in accordance with the query.<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.org.djunits.value.vdouble.scalar.Frequency
Returns the update frequency.int
hashCode()
int
Returns the number of space-time regions.toString()
-
Constructor Details
-
Query
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, org.djunits.value.vdouble.scalar.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, org.djunits.value.vdouble.scalar.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, 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>; 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
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, org.djunits.value.vdouble.scalar.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, org.djunits.value.vdouble.scalar.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, 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>; 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 Details
-
getId
Returns the unique id for the query.- Specified by:
getId
in interfaceorg.djutils.base.Identifiable
- Returns:
- String; the unique id for the query
-
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
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>; linkstartPosition
- Length; start positionendPosition
- Length; end positionstartTime
- Time; start timeendTime
- 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; 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
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. EachTrajectoryGroup
containsTrajectory
objects pertaining to aSpaceTimeRegion
from the query. ATrajectory
is only included if all the filter data of this query accepts the trajectory. This method usesTime.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. EachTrajectoryGroup
containsTrajectory
objects pertaining to aSpaceTimeRegion
from the query. ATrajectory
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 forendTime
- Time; start time of interval to get trajectory groups for- Returns:
- List<TrajectoryGroup<G>>; list of trajectory groups in accordance with the query
-
getSampler
Returns the sampler.- Returns:
- Sampler<G, L>; sampler.
-
hashCode
public int hashCode() -
equals
-
toString
-