Search in sources :

Example 11 with TemporalFilter

use of ddf.catalog.impl.filter.TemporalFilter in project ddf by codice.

the class OpenSearchQueryTest method testCompoundFilter.

@Test
public void testCompoundFilter() throws Exception {
    String searchTerm = "cat";
    String selectors = "//fileTitle,//nitf";
    OpenSearchQuery query = new OpenSearchQuery(null, 0, 10, "relevance", "desc", 30000, FILTER_BUILDER);
    query.addContextualFilter(searchTerm, selectors);
    String startDate = "2011-10-4T05:48:27.891-07:00";
    String endDate = "2011-10-4T06:18:27.581-07:00";
    String dateOffset = null;
    TemporalFilter temporalFilter = new TemporalFilter(startDate, endDate);
    LOGGER.debug(temporalFilter.toString());
    query.addTemporalFilter(startDate, endDate, dateOffset);
    String type = "nitf";
    String versions = "v20,invalid_version,*";
    query.addTypeFilter(type, versions);
    String lon = "10";
    String lat = "20";
    String radius = "5000";
    query.addSpatialDistanceFilter(lon, lat, radius);
// Filter filter = query.getFilter();
// String filterXml = getFilterAsXml( filter );
}
Also used : TemporalFilter(ddf.catalog.impl.filter.TemporalFilter) Test(org.junit.Test)

Example 12 with TemporalFilter

use of ddf.catalog.impl.filter.TemporalFilter in project ddf by codice.

the class OpenSearchQueryTest method testTemporalFilterAbsoluteSearch.

@Test
public void testTemporalFilterAbsoluteSearch() throws Exception {
    String startDate = "2011-10-4T05:48:27.891-07:00";
    String endDate = "2011-10-4T06:18:27.581-07:00";
    TemporalFilter temporalFilter = new TemporalFilter(startDate, endDate);
    LOGGER.debug(temporalFilter.toString());
    OpenSearchQuery query = new OpenSearchQuery(null, 0, 10, "relevance", "desc", 30000, FILTER_BUILDER);
    query.addTemporalFilter(temporalFilter);
    Filter filter = query.getFilter();
    // String filterXml = getFilterAsXml( filter );
    VerificationVisitor verificationVisitor = new VerificationVisitor();
    filter.accept(verificationVisitor, null);
    HashMap<String, FilterStatus> map = (HashMap<String, FilterStatus>) verificationVisitor.getMap();
    printFilterStatusMap(map);
    List<Filter> filters = getFilters(map, DuringImpl.class.getName());
    assertEquals(1, filters.size());
    verifyTemporalFilter(filters.get(0), startDate, endDate);
}
Also used : TemporalFilter(ddf.catalog.impl.filter.TemporalFilter) DuringImpl(org.geotools.filter.temporal.DuringImpl) TemporalFilter(ddf.catalog.impl.filter.TemporalFilter) BBoxSpatialFilter(org.codice.ddf.opensearch.query.filter.BBoxSpatialFilter) PolygonSpatialFilter(org.codice.ddf.opensearch.query.filter.PolygonSpatialFilter) Filter(org.opengis.filter.Filter) HashMap(java.util.HashMap) Test(org.junit.Test)

Example 13 with TemporalFilter

use of ddf.catalog.impl.filter.TemporalFilter in project ddf by codice.

the class OpenSearchQueryTest method testTemporalFilterAbsoluteSearchStringDates.

@Test
public void testTemporalFilterAbsoluteSearchStringDates() throws Exception {
    String startDate = "2011-10-4T05:48:27.891-07:00";
    String endDate = "2011-10-4T06:18:27.581-07:00";
    String dateOffset = null;
    TemporalFilter temporalFilter = new TemporalFilter(startDate, endDate);
    LOGGER.debug(temporalFilter.toString());
    OpenSearchQuery query = new OpenSearchQuery(null, 0, 10, "relevance", "desc", 30000, FILTER_BUILDER);
    query.addTemporalFilter(startDate, endDate, dateOffset);
    Filter filter = query.getFilter();
    // String filterXml = getFilterAsXml( filter );
    VerificationVisitor verificationVisitor = new VerificationVisitor();
    filter.accept(verificationVisitor, null);
    HashMap<String, FilterStatus> map = (HashMap<String, FilterStatus>) verificationVisitor.getMap();
    printFilterStatusMap(map);
    List<Filter> filters = getFilters(map, DuringImpl.class.getName());
    assertEquals(1, filters.size());
    verifyTemporalFilter(filters.get(0), startDate, endDate);
}
Also used : TemporalFilter(ddf.catalog.impl.filter.TemporalFilter) DuringImpl(org.geotools.filter.temporal.DuringImpl) TemporalFilter(ddf.catalog.impl.filter.TemporalFilter) BBoxSpatialFilter(org.codice.ddf.opensearch.query.filter.BBoxSpatialFilter) PolygonSpatialFilter(org.codice.ddf.opensearch.query.filter.PolygonSpatialFilter) Filter(org.opengis.filter.Filter) HashMap(java.util.HashMap) Test(org.junit.Test)

Example 14 with TemporalFilter

use of ddf.catalog.impl.filter.TemporalFilter in project ddf by codice.

the class OpenSearchQueryTest method testContextualTemporalFilter.

@Test
public void testContextualTemporalFilter() throws Exception {
    String searchTerm = "cat";
    String selector = null;
    OpenSearchQuery query = new OpenSearchQuery(null, 0, 10, "relevance", "desc", 30000, FILTER_BUILDER);
    query.addContextualFilter(searchTerm, selector);
    String startDate = "2011-10-4T05:48:27.891-07:00";
    String endDate = "2011-10-4T06:18:27.581-07:00";
    String dateOffset = null;
    TemporalFilter temporalFilter = new TemporalFilter(startDate, endDate);
    LOGGER.debug(temporalFilter.toString());
    query.addTemporalFilter(startDate, endDate, dateOffset);
    Filter filter = query.getFilter();
    // String filterXml = getFilterAsXml( filter );
    VerificationVisitor verificationVisitor = new VerificationVisitor();
    filter.accept(verificationVisitor, null);
    HashMap<String, FilterStatus> map = (HashMap<String, FilterStatus>) verificationVisitor.getMap();
    List<Filter> andFilters = getFilters(map, AndImpl.class.getName());
    assertEquals(1, andFilters.size());
    AndImpl andFilter = (AndImpl) andFilters.get(0);
    List<Filter> childFilters = andFilter.getChildren();
    assertTrue(childFilters.size() == 2);
    verifyContextualFilter(childFilters.get(0), "anyText", searchTerm);
    verifyTemporalFilter(childFilters.get(1), startDate, endDate);
}
Also used : TemporalFilter(ddf.catalog.impl.filter.TemporalFilter) TemporalFilter(ddf.catalog.impl.filter.TemporalFilter) BBoxSpatialFilter(org.codice.ddf.opensearch.query.filter.BBoxSpatialFilter) PolygonSpatialFilter(org.codice.ddf.opensearch.query.filter.PolygonSpatialFilter) Filter(org.opengis.filter.Filter) HashMap(java.util.HashMap) AndImpl(org.geotools.filter.AndImpl) Test(org.junit.Test)

Example 15 with TemporalFilter

use of ddf.catalog.impl.filter.TemporalFilter in project ddf by codice.

the class MockQuery method addTemporalFilter.

public void addTemporalFilter(String dateStart, String dateEnd, String dateOffset) {
    TemporalFilter temporalFilter = null;
    if (dateStart != null || dateEnd != null) {
        temporalFilter = new TemporalFilter(dateStart, dateEnd);
    } else if (dateOffset != null) {
        temporalFilter = new TemporalFilter(Long.parseLong(dateOffset));
    }
    addTemporalFilter(temporalFilter);
}
Also used : TemporalFilter(ddf.catalog.impl.filter.TemporalFilter)

Aggregations

TemporalFilter (ddf.catalog.impl.filter.TemporalFilter)15 Test (org.junit.Test)8 Filter (org.opengis.filter.Filter)8 BBoxSpatialFilter (org.codice.ddf.opensearch.query.filter.BBoxSpatialFilter)7 PolygonSpatialFilter (org.codice.ddf.opensearch.query.filter.PolygonSpatialFilter)7 HashMap (java.util.HashMap)5 Date (java.util.Date)4 DuringImpl (org.geotools.filter.temporal.DuringImpl)4 Period (org.opengis.temporal.Period)4 SpatialDistanceFilter (ddf.catalog.impl.filter.SpatialDistanceFilter)3 SpatialFilter (ddf.catalog.impl.filter.SpatialFilter)3 DefaultInstant (org.geotools.temporal.object.DefaultInstant)2 DefaultPeriod (org.geotools.temporal.object.DefaultPeriod)2 DefaultPeriodDuration (org.geotools.temporal.object.DefaultPeriodDuration)2 DefaultPosition (org.geotools.temporal.object.DefaultPosition)2 Literal (org.opengis.filter.expression.Literal)2 Instant (org.opengis.temporal.Instant)2 PeriodDuration (org.opengis.temporal.PeriodDuration)2 PropertyIsEqualToLiteral (ddf.catalog.filter.impl.PropertyIsEqualToLiteral)1 UnsupportedQueryException (ddf.catalog.source.UnsupportedQueryException)1