Search in sources :

Example 1 with TemporalConstraintsSet

use of org.locationtech.geowave.core.geotime.store.query.TemporalConstraintsSet in project geowave by locationtech.

the class ExtractTimeFilterVisitorTest method testNotBetween.

@Test
public void testNotBetween() throws CQLException, ParseException {
    final ExtractTimeFilterVisitor visitor = new ExtractTimeFilterVisitor();
    final Date sTime2 = new Date(DateUtilities.parseISO("2005-05-19T20:32:56Z").getTime() + 1);
    final Date eTime1 = new Date(DateUtilities.parseISO("2005-05-17T20:32:56Z").getTime() - 1);
    final Filter filter = CQL.toFilter("not (when before 2005-05-17T20:32:56Z or when after 2005-05-19T20:32:56Z)");
    final Query query = new Query("type", filter);
    final TemporalConstraintsSet rangeSet = (TemporalConstraintsSet) query.getFilter().accept(visitor, null);
    assertNotNull(rangeSet);
    assertEquals(eTime1, rangeSet.getConstraintsFor("when").getStartRange().getStartTime());
    assertEquals(new Date(sTime2.getTime() - 1), rangeSet.getConstraintsFor("when").getStartRange().getEndTime());
}
Also used : Query(org.geotools.data.Query) Filter(org.opengis.filter.Filter) TemporalConstraintsSet(org.locationtech.geowave.core.geotime.store.query.TemporalConstraintsSet) ExtractTimeFilterVisitor(org.locationtech.geowave.core.geotime.util.ExtractTimeFilterVisitor) Date(java.util.Date) Test(org.junit.Test)

Example 2 with TemporalConstraintsSet

use of org.locationtech.geowave.core.geotime.store.query.TemporalConstraintsSet in project geowave by locationtech.

the class ExtractTimeFilterVisitorTest method testBeforeOrDuring.

@Test
public void testBeforeOrDuring() throws CQLException, ParseException {
    final ExtractTimeFilterVisitor visitor = new ExtractTimeFilterVisitor();
    final Date stime = new Date(DateUtilities.parseISO("2005-05-19T21:32:56Z").getTime() - 1);
    final Filter filter = CQL.toFilter("when BEFORE OR DURING 2005-05-19T20:32:56Z/2005-05-19T21:32:56Z");
    final Query query = new Query("type", filter);
    TemporalConstraintsSet rangeSet = (TemporalConstraintsSet) query.getFilter().accept(visitor, null);
    assertNotNull(rangeSet);
    assertEquals(TemporalRange.START_TIME, rangeSet.getConstraintsFor("when").getStartRange().getStartTime());
    assertEquals(stime, rangeSet.getConstraintsFor("when").getEndRange().getEndTime());
    rangeSet = (TemporalConstraintsSet) query.getFilter().accept(visitorWithDescriptor, null);
    assertNotNull(rangeSet);
    assertEquals(TemporalRange.START_TIME, rangeSet.getConstraintsFor("when").getStartRange().getStartTime());
    assertEquals(stime, rangeSet.getConstraintsFor("when").getEndRange().getEndTime());
}
Also used : Query(org.geotools.data.Query) Filter(org.opengis.filter.Filter) TemporalConstraintsSet(org.locationtech.geowave.core.geotime.store.query.TemporalConstraintsSet) ExtractTimeFilterVisitor(org.locationtech.geowave.core.geotime.util.ExtractTimeFilterVisitor) Date(java.util.Date) Test(org.junit.Test)

Example 3 with TemporalConstraintsSet

use of org.locationtech.geowave.core.geotime.store.query.TemporalConstraintsSet in project geowave by locationtech.

the class ExtractTimeFilterVisitorTest method testDuringOrAfter.

@Test
public void testDuringOrAfter() throws CQLException, ParseException {
    final ExtractTimeFilterVisitor visitor = new ExtractTimeFilterVisitor();
    final Date stime = new Date(DateUtilities.parseISO("2005-05-19T20:32:56Z").getTime() + 1);
    final Filter filter = CQL.toFilter("when DURING OR AFTER 2005-05-19T20:32:56Z/2005-05-19T21:32:56Z");
    final Query query = new Query("type", filter);
    TemporalConstraintsSet rangeSet = (TemporalConstraintsSet) query.getFilter().accept(visitor, null);
    assertNotNull(rangeSet);
    assertEquals(stime, rangeSet.getConstraintsFor("when").getStartRange().getStartTime());
    assertEquals(TemporalRange.END_TIME, rangeSet.getConstraintsFor("when").getEndRange().getEndTime());
    rangeSet = (TemporalConstraintsSet) query.getFilter().accept(visitorWithDescriptor, null);
    assertNotNull(rangeSet);
    assertEquals(stime, rangeSet.getConstraintsFor("when").getStartRange().getStartTime());
    assertEquals(TemporalRange.END_TIME, rangeSet.getConstraintsFor("when").getEndRange().getEndTime());
}
Also used : Query(org.geotools.data.Query) Filter(org.opengis.filter.Filter) TemporalConstraintsSet(org.locationtech.geowave.core.geotime.store.query.TemporalConstraintsSet) ExtractTimeFilterVisitor(org.locationtech.geowave.core.geotime.util.ExtractTimeFilterVisitor) Date(java.util.Date) Test(org.junit.Test)

Example 4 with TemporalConstraintsSet

use of org.locationtech.geowave.core.geotime.store.query.TemporalConstraintsSet in project geowave by locationtech.

the class GeoWaveFeatureCollection method getQueryConstraints.

protected QueryConstraints getQueryConstraints() throws TransformException, FactoryException {
    final ReferencedEnvelope referencedEnvelope = getEnvelope(query);
    final Geometry jtsBounds;
    final TemporalConstraintsSet timeBounds;
    if (reader.getGeoWaveFilter() == null || query.getHints().containsKey(SubsampleProcess.SUBSAMPLE_ENABLED)) {
        jtsBounds = getBBox(query, referencedEnvelope);
        timeBounds = getBoundedTime(query);
    } else {
        // This will be handled by the geowave filter
        jtsBounds = null;
        timeBounds = null;
    }
    Integer limit = getLimit(query);
    final Integer startIndex = getStartIndex(query);
    // limit becomes a 'soft' constraint since GeoServer will inforce
    // the limit
    final Long max = (limit != null) ? limit.longValue() + (startIndex == null ? 0 : startIndex.longValue()) : null;
    // limit only used if less than an integer max value.
    limit = ((max != null) && (max.longValue() < Integer.MAX_VALUE)) ? max.intValue() : null;
    return new QueryConstraints(jtsBounds, timeBounds, referencedEnvelope, limit);
}
Also used : Geometry(org.locationtech.jts.geom.Geometry) ReferencedEnvelope(org.geotools.geometry.jts.ReferencedEnvelope) TemporalConstraintsSet(org.locationtech.geowave.core.geotime.store.query.TemporalConstraintsSet)

Example 5 with TemporalConstraintsSet

use of org.locationtech.geowave.core.geotime.store.query.TemporalConstraintsSet in project geowave by locationtech.

the class QueryIndexHelperTest method testComposeQueryWithTimeRange.

@Test
public void testComposeQueryWithTimeRange() throws ParseException {
    final TestStatisticsCache statsCache = new TestStatisticsCache();
    final TimeRangeStatistic startStats = new TimeRangeStatistic("type", "start");
    final TimeRangeValue startValue = startStats.createEmpty();
    statsCache.putFieldStatistic(TimeRangeStatistic.STATS_TYPE, "start", startValue);
    final TimeRangeStatistic endStats = new TimeRangeStatistic("type", "end");
    final TimeRangeValue endValue = endStats.createEmpty();
    statsCache.putFieldStatistic(TimeRangeStatistic.STATS_TYPE, "end", endValue);
    final Date statsStart1 = DateUtilities.parseISO("2005-05-18T20:32:56Z");
    final Date statsStart2 = DateUtilities.parseISO("2005-05-20T20:32:56Z");
    final Date statsEnd1 = DateUtilities.parseISO("2005-05-21T20:32:56Z");
    final Date statsEnd2 = DateUtilities.parseISO("2005-05-24T20:32:56Z");
    final SimpleFeature firstRangFeature = createFeature(statsStart1, statsEnd1);
    FeatureDataAdapter adapter = new FeatureDataAdapter(firstRangFeature.getFeatureType());
    startValue.entryIngested(adapter, firstRangFeature);
    endValue.entryIngested(adapter, firstRangFeature);
    final SimpleFeature secondRangFeature = createFeature(statsStart2, statsEnd2);
    startValue.entryIngested(adapter, secondRangFeature);
    endValue.entryIngested(adapter, secondRangFeature);
    final Date stime = DateUtilities.parseISO("2005-05-18T20:32:56Z");
    final Date etime = DateUtilities.parseISO("2005-05-19T20:32:56Z");
    final TemporalConstraintsSet constraintsSet = new TemporalConstraintsSet();
    constraintsSet.getConstraintsForRange("start", "end").add(new TemporalRange(stime, etime));
    final BasicQueryByClass query = new BasicQueryByClass(QueryIndexHelper.composeConstraints(statsCache, rangeType, rangeTimeDescriptors, factory.toGeometry(factory.createPoint(new Coordinate(27.25, 41.25)).getEnvelopeInternal()), constraintsSet));
    final List<MultiDimensionalNumericData> nd = query.getIndexConstraints(SPATIAL_TEMPORAL_INDEX);
    assertEquals(stime.getTime(), nd.get(0).getDataPerDimension()[2].getMin().longValue());
    assertEquals(etime.getTime(), nd.get(0).getDataPerDimension()[2].getMax().longValue());
    final BasicQueryByClass query1 = new BasicQueryByClass(QueryIndexHelper.composeConstraints(statsCache, rangeType, rangeTimeDescriptors, factory.toGeometry(factory.createPoint(new Coordinate(27.25, 41.25)).getEnvelopeInternal()), null));
    final List<MultiDimensionalNumericData> nd1 = query1.getIndexConstraints(SPATIAL_TEMPORAL_INDEX);
    assertEquals(statsStart1.getTime(), nd1.get(0).getDataPerDimension()[2].getMin().longValue());
    assertEquals(statsEnd2.getTime(), nd1.get(0).getDataPerDimension()[2].getMax().longValue());
}
Also used : MultiDimensionalNumericData(org.locationtech.geowave.core.index.numeric.MultiDimensionalNumericData) Coordinate(org.locationtech.jts.geom.Coordinate) TemporalConstraintsSet(org.locationtech.geowave.core.geotime.store.query.TemporalConstraintsSet) TemporalRange(org.locationtech.geowave.core.geotime.store.query.TemporalRange) TimeRangeStatistic(org.locationtech.geowave.core.geotime.store.statistics.TimeRangeStatistic) TimeRangeValue(org.locationtech.geowave.core.geotime.store.statistics.TimeRangeStatistic.TimeRangeValue) FeatureDataAdapter(org.locationtech.geowave.adapter.vector.FeatureDataAdapter) Date(java.util.Date) SimpleFeature(org.opengis.feature.simple.SimpleFeature) BasicQueryByClass(org.locationtech.geowave.core.store.query.constraints.BasicQueryByClass) Test(org.junit.Test)

Aggregations

TemporalConstraintsSet (org.locationtech.geowave.core.geotime.store.query.TemporalConstraintsSet)17 Test (org.junit.Test)13 Date (java.util.Date)12 Filter (org.opengis.filter.Filter)11 Query (org.geotools.data.Query)9 ExtractTimeFilterVisitor (org.locationtech.geowave.core.geotime.util.ExtractTimeFilterVisitor)8 TemporalRange (org.locationtech.geowave.core.geotime.store.query.TemporalRange)6 TemporalConstraints (org.locationtech.geowave.core.geotime.store.query.TemporalConstraints)5 FeatureDataAdapter (org.locationtech.geowave.adapter.vector.FeatureDataAdapter)4 TimeRangeStatistic (org.locationtech.geowave.core.geotime.store.statistics.TimeRangeStatistic)4 TimeRangeValue (org.locationtech.geowave.core.geotime.store.statistics.TimeRangeStatistic.TimeRangeValue)4 SimpleFeature (org.opengis.feature.simple.SimpleFeature)4 MultiDimensionalNumericData (org.locationtech.geowave.core.index.numeric.MultiDimensionalNumericData)2 Coordinate (org.locationtech.jts.geom.Coordinate)2 ExcludeFilter (org.opengis.filter.ExcludeFilter)2 IncludeFilter (org.opengis.filter.IncludeFilter)2 FilterFactoryImpl (org.geotools.filter.FilterFactoryImpl)1 ReferencedEnvelope (org.geotools.geometry.jts.ReferencedEnvelope)1 BoundingBoxStatistic (org.locationtech.geowave.core.geotime.store.statistics.BoundingBoxStatistic)1 BoundingBoxValue (org.locationtech.geowave.core.geotime.store.statistics.BoundingBoxStatistic.BoundingBoxValue)1