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());
}
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());
}
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());
}
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);
}
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());
}
Aggregations