Search in sources :

Example 1 with TemporalConstraints

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

the class ExtractTimeFilterVisitorTest method testAfter.

@Test
public void testAfter() throws CQLException, ParseException {
    final ExtractTimeFilterVisitor visitor = new ExtractTimeFilterVisitor();
    final Date time = DateUtilities.parseISO("2005-05-19T20:32:56Z");
    final Filter filter = CQL.toFilter("when after 2005-05-19T20:32:56Z");
    final Query query = new Query("type", filter);
    TemporalConstraints range = (TemporalConstraints) query.getFilter().accept(visitor, null);
    assertNotNull(range);
    assertEquals(new Date(time.getTime() + 1), range.getStartRange().getStartTime());
    range = (TemporalConstraints) query.getFilter().accept(visitorWithDescriptor, null);
    assertNotNull(range);
    assertEquals(new Date(time.getTime() + 1), range.getStartRange().getStartTime());
    assertEquals("when", range.getName());
}
Also used : Query(org.geotools.data.Query) Filter(org.opengis.filter.Filter) TemporalConstraints(org.locationtech.geowave.core.geotime.store.query.TemporalConstraints) ExtractTimeFilterVisitor(org.locationtech.geowave.core.geotime.util.ExtractTimeFilterVisitor) Date(java.util.Date) Test(org.junit.Test)

Example 2 with TemporalConstraints

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

the class ExtractTimeFilterVisitorTest method testGreaterThan.

@Test
public void testGreaterThan() throws CQLException, ParseException {
    final ExtractTimeFilterVisitor visitor = new ExtractTimeFilterVisitor();
    final Date stimeNotEqual = new Date(DateUtilities.parseISO("2005-05-19T20:32:56Z").getTime() + 1);
    final Date stime = DateUtilities.parseISO("2005-05-19T20:32:56Z");
    Filter filter = ECQL.toFilter("when > 2005-05-19T20:32:56Z");
    Query query = new Query("type", filter);
    TemporalConstraints range = (TemporalConstraints) query.getFilter().accept(visitor, null);
    assertNotNull(range);
    assertEquals(stimeNotEqual, range.getStartRange().getStartTime());
    assertEquals(TemporalRange.END_TIME, range.getEndRange().getEndTime());
    assertEquals("when", range.getName());
    filter = ECQL.toFilter("2005-05-19T20:32:56Z < when");
    query = new Query("type", filter);
    range = (TemporalConstraints) query.getFilter().accept(visitor, null);
    assertNotNull(range);
    assertEquals(stimeNotEqual, range.getStartRange().getStartTime());
    assertEquals(TemporalRange.END_TIME, range.getEndRange().getEndTime());
    assertEquals("when", range.getName());
    filter = ECQL.toFilter("2005-05-19T20:32:56Z <= when");
    query = new Query("type", filter);
    range = (TemporalConstraints) query.getFilter().accept(visitor, null);
    assertNotNull(range);
    assertEquals(stime, range.getStartRange().getStartTime());
    assertEquals(TemporalRange.END_TIME, range.getEndRange().getEndTime());
    assertEquals("when", range.getName());
}
Also used : Query(org.geotools.data.Query) Filter(org.opengis.filter.Filter) TemporalConstraints(org.locationtech.geowave.core.geotime.store.query.TemporalConstraints) ExtractTimeFilterVisitor(org.locationtech.geowave.core.geotime.util.ExtractTimeFilterVisitor) Date(java.util.Date) Test(org.junit.Test)

Example 3 with TemporalConstraints

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

the class ExtractTimeFilterVisitorTest method testBefore.

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

Example 4 with TemporalConstraints

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

the class ExtractTimeFilterVisitorTest method testEqual.

@Test
public void testEqual() throws CQLException, ParseException {
    final ExtractTimeFilterVisitor visitor = new ExtractTimeFilterVisitor();
    final Date etime = DateUtilities.parseISO("2005-05-19T21:32:56Z");
    final Filter filter = ECQL.toFilter("when = 2005-05-19T21:32:56Z");
    final Query query = new Query("type", filter);
    final TemporalConstraints range = (TemporalConstraints) query.getFilter().accept(visitor, null);
    assertNotNull(range);
    assertEquals(etime, range.getStartRange().getStartTime());
    assertEquals(etime, range.getEndRange().getEndTime());
}
Also used : Query(org.geotools.data.Query) Filter(org.opengis.filter.Filter) TemporalConstraints(org.locationtech.geowave.core.geotime.store.query.TemporalConstraints) ExtractTimeFilterVisitor(org.locationtech.geowave.core.geotime.util.ExtractTimeFilterVisitor) Date(java.util.Date) Test(org.junit.Test)

Example 5 with TemporalConstraints

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

the class ExtractTimeFilterVisitorTest method testLessThan.

@Test
public void testLessThan() throws CQLException, ParseException {
    final ExtractTimeFilterVisitor visitor = new ExtractTimeFilterVisitor();
    final Date etimeNotEqual = new Date(DateUtilities.parseISO("2005-05-19T21:32:56Z").getTime() - 1);
    final Date etime = DateUtilities.parseISO("2005-05-19T21:32:56Z");
    Filter filter = ECQL.toFilter("when < 2005-05-19T21:32:56Z");
    Query query = new Query("type", filter);
    TemporalConstraints range = (TemporalConstraints) query.getFilter().accept(visitor, null);
    assertNotNull(range);
    assertEquals(TemporalRange.START_TIME, range.getStartRange().getStartTime());
    assertEquals(etimeNotEqual, range.getEndRange().getEndTime());
    assertEquals("when", range.getName());
    filter = ECQL.toFilter(" 2005-05-19T21:32:56Z > when");
    query = new Query("type", filter);
    range = (TemporalConstraints) query.getFilter().accept(visitor, null);
    assertNotNull(range);
    assertEquals(TemporalRange.START_TIME, range.getStartRange().getStartTime());
    assertEquals(etimeNotEqual, range.getEndRange().getEndTime());
    assertEquals("when", range.getName());
    filter = ECQL.toFilter(" 2005-05-19T21:32:56Z >= when");
    query = new Query("type", filter);
    range = (TemporalConstraints) query.getFilter().accept(visitor, null);
    assertNotNull(range);
    assertEquals(TemporalRange.START_TIME, range.getStartRange().getStartTime());
    assertEquals(etime, range.getEndRange().getEndTime());
    assertEquals("when", range.getName());
}
Also used : Query(org.geotools.data.Query) Filter(org.opengis.filter.Filter) TemporalConstraints(org.locationtech.geowave.core.geotime.store.query.TemporalConstraints) ExtractTimeFilterVisitor(org.locationtech.geowave.core.geotime.util.ExtractTimeFilterVisitor) Date(java.util.Date) Test(org.junit.Test)

Aggregations

TemporalConstraints (org.locationtech.geowave.core.geotime.store.query.TemporalConstraints)34 TemporalRange (org.locationtech.geowave.core.geotime.store.query.TemporalRange)24 Date (java.util.Date)11 Test (org.junit.Test)8 Filter (org.opengis.filter.Filter)7 Query (org.geotools.data.Query)6 ExtractTimeFilterVisitor (org.locationtech.geowave.core.geotime.util.ExtractTimeFilterVisitor)6 TemporalConstraintsSet (org.locationtech.geowave.core.geotime.store.query.TemporalConstraintsSet)4 FeatureDataAdapter (org.locationtech.geowave.adapter.vector.FeatureDataAdapter)2 TimeRangeStatistic (org.locationtech.geowave.core.geotime.store.statistics.TimeRangeStatistic)2 TimeRangeValue (org.locationtech.geowave.core.geotime.store.statistics.TimeRangeStatistic.TimeRangeValue)2 SimpleFeature (org.opengis.feature.simple.SimpleFeature)2 Timestamp (java.sql.Timestamp)1 ConstraintsByClass (org.locationtech.geowave.core.store.query.constraints.BasicQueryByClass.ConstraintsByClass)1 ExcludeFilter (org.opengis.filter.ExcludeFilter)1 IncludeFilter (org.opengis.filter.IncludeFilter)1 Instant (org.opengis.temporal.Instant)1 Period (org.opengis.temporal.Period)1 Position (org.opengis.temporal.Position)1