Search in sources :

Example 1 with ExtractTimeFilterVisitor

use of org.locationtech.geowave.core.geotime.util.ExtractTimeFilterVisitor 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 ExtractTimeFilterVisitor

use of org.locationtech.geowave.core.geotime.util.ExtractTimeFilterVisitor 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 ExtractTimeFilterVisitor

use of org.locationtech.geowave.core.geotime.util.ExtractTimeFilterVisitor 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 ExtractTimeFilterVisitor

use of org.locationtech.geowave.core.geotime.util.ExtractTimeFilterVisitor 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 5 with ExtractTimeFilterVisitor

use of org.locationtech.geowave.core.geotime.util.ExtractTimeFilterVisitor 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)

Aggregations

ExtractTimeFilterVisitor (org.locationtech.geowave.core.geotime.util.ExtractTimeFilterVisitor)15 Query (org.geotools.data.Query)14 Test (org.junit.Test)14 Filter (org.opengis.filter.Filter)14 Date (java.util.Date)13 TemporalConstraintsSet (org.locationtech.geowave.core.geotime.store.query.TemporalConstraintsSet)8 TemporalConstraints (org.locationtech.geowave.core.geotime.store.query.TemporalConstraints)6 Collection (java.util.Collection)1 CompareOperation (org.locationtech.geowave.core.geotime.store.query.filter.SpatialQueryFilter.CompareOperation)1 ExtractAttributesFilter (org.locationtech.geowave.core.geotime.util.ExtractAttributesFilter)1 ExtractGeometryFilterVisitorResult (org.locationtech.geowave.core.geotime.util.ExtractGeometryFilterVisitorResult)1 GeoConstraintsWrapper (org.locationtech.geowave.core.geotime.util.GeometryUtils.GeoConstraintsWrapper)1 TimeDescriptors (org.locationtech.geowave.core.geotime.util.TimeDescriptors)1 ConstraintsByClass (org.locationtech.geowave.core.store.query.constraints.BasicQueryByClass.ConstraintsByClass)1 BasicQueryCompareOperation (org.locationtech.geowave.core.store.query.filter.BasicQueryFilter.BasicQueryCompareOperation)1 Geometry (org.locationtech.jts.geom.Geometry)1 AttributeDescriptor (org.opengis.feature.type.AttributeDescriptor)1 CoordinateReferenceSystem (org.opengis.referencing.crs.CoordinateReferenceSystem)1