Package org.opentrafficsim.kpi.sampling
Class Query<G extends GtuDataInterface>
- java.lang.Object
-
- org.opentrafficsim.kpi.sampling.Query<G>
-
- 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.
$LastChangedDate: 2015-07-24 02:58:59 +0200 (Fri, 24 Jul 2015) $, @version $Revision: 1147 $, by $Author: averbraeck $, initial version Sep 21, 2016
BSD-style license. See OpenTrafficSim License.- Author:
- Alexander Verbraeck, Peter Knoppers, Wouter Schakel
-
-
Constructor Summary
Constructors Constructor Description Query(Sampler<G> sampler, String id, String description, FilterDataSet filterDataSet)
Query(Sampler<G> sampler, String id, String description, FilterDataSet filterDataSet, Duration interval)
Query(Sampler<G> sampler, String id, String description, FilterDataSet filterDataSet, Frequency updateFrequency)
Query(Sampler<G> sampler, String id, String description, FilterDataSet filterDataSet, Frequency updateFrequency, Duration interval)
Constructor.Query(Sampler<G> sampler, String description, FilterDataSet filterDataSet)
Constructor.Query(Sampler<G> sampler, String description, FilterDataSet filterDataSet, Duration interval)
Constructor.Query(Sampler<G> sampler, String description, FilterDataSet filterDataSet, Frequency updateFrequency)
Constructor.Query(Sampler<G> sampler, String description, FilterDataSet filterDataSet, Frequency updateFrequency, Duration interval)
Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description 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.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.boolean
equals(Object obj)
String
getDescription()
Iterator<Map.Entry<FilterDataType<?>,Set<?>>>
getFilterDataSetIterator()
String
getId()
return the unique id for the query.Duration
getInterval()
Sampler<?>
getSampler()
Iterator<SpaceTimeRegion>
getSpaceTimeIterator()
<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.Frequency
getUpdateFrequency()
int
hashCode()
int
metaFilterSize()
int
spaceTimeRegionSize()
String
toString()
-
-
-
Constructor Detail
-
Query
public Query(Sampler<G> sampler, String id, String description, FilterDataSet filterDataSet)
- Parameters:
sampler
- Sampler<G>; samplerid
- String; iddescription
- String; descriptionfilterDataSet
- 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>; samplerid
- String; iddescription
- String; descriptionfilterDataSet
- filterDataSet; meta datainterval
- 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>; samplerid
- String; iddescription
- String; descriptionfilterDataSet
- filterDataSet; meta dataupdateFrequency
- 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>; 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> sampler, String description, FilterDataSet filterDataSet)
Constructor. The filter data types must be registered with the sampler.- Parameters:
sampler
- Sampler<G>; samplerdescription
- String; descriptionfilterDataSet
- 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>; 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> sampler, String description, FilterDataSet filterDataSet, Frequency updateFrequency)
Constructor. The filter data types must be registered with the sampler.- Parameters:
sampler
- Sampler<G>; samplerdescription
- String; descriptionfilterDataSet
- filterDataSet; filter dataupdateFrequency
- 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>; 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()
return the unique id for the query.- Specified by:
getId
in interfaceIdentifiable
- 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; linkdirection
- KpiGtuDirectionality; directionstartPosition
- Length; start positionendPosition
- Length; end positionstartTime
- Time; start timeendTime
- 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 directionstartPosition
- Length; start positionendPosition
- Length; end positionstartTime
- Time; start timeendTime
- 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. EachTrajectoryGroup
containsTrajectory
objects pertaining to aSpaceTimeRegion
from the query. ATrajectory
is only included if all the meta data of this query accepts the trajectory. This method usesTime.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. EachTrajectoryGroup
containsTrajectory
objects pertaining to aSpaceTimeRegion
from the query. ATrajectory
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 forendTime
- 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.
-
-