Search in sources :

Example 6 with Contains

use of org.opengis.filter.spatial.Contains in project ddf by codice.

the class OpenSearchFilterVisitorTest method testContainsWithPoint.

@Test
public void testContainsWithPoint() {
    Contains containsFilter = (Contains) geotoolsFilterBuilder.attribute(SPATIAL_ATTRIBUTE_NAME).containing().wkt(WKT_POINT);
    OpenSearchFilterVisitorObject openSearchFilterVisitorObject = new OpenSearchFilterVisitorObject();
    openSearchFilterVisitorObject.setCurrentNest(NestedTypes.AND);
    OpenSearchFilterVisitorObject result = (OpenSearchFilterVisitorObject) openSearchFilterVisitor.visit(containsFilter, openSearchFilterVisitorObject);
    assertThat(result.getPointRadiusSearches(), is(empty()));
    assertThat(result.getGeometrySearches(), contains(hasToString(is(WKT_POINT))));
}
Also used : Contains(org.opengis.filter.spatial.Contains) Test(org.junit.Test)

Example 7 with Contains

use of org.opengis.filter.spatial.Contains in project ddf by codice.

the class OpenSearchFilterVisitorTest method testContainsCqlFilter.

@Test
public void testContainsCqlFilter() throws CQLException {
    Contains containsFilter = (Contains) ECQL.toFilter("(CONTAINS(" + SPATIAL_ATTRIBUTE_NAME + ", " + WKT_POLYGON + "))");
    OpenSearchFilterVisitorObject openSearchFilterVisitorObject = new OpenSearchFilterVisitorObject();
    openSearchFilterVisitorObject.setCurrentNest(NestedTypes.AND);
    OpenSearchFilterVisitorObject result = (OpenSearchFilterVisitorObject) openSearchFilterVisitor.visit(containsFilter, openSearchFilterVisitorObject);
    assertThat(result.getGeometrySearches(), contains(hasToString(is(WKT_POLYGON))));
}
Also used : Contains(org.opengis.filter.spatial.Contains) Test(org.junit.Test)

Example 8 with Contains

use of org.opengis.filter.spatial.Contains in project ddf by codice.

the class OpenSearchFilterVisitorTest method testContainsNullNest.

@Test
public void testContainsNullNest() {
    Contains containsFilter = (Contains) geotoolsFilterBuilder.attribute(SPATIAL_ATTRIBUTE_NAME).containing().wkt(WKT_POLYGON);
    OpenSearchFilterVisitorObject openSearchFilterVisitorObject = new OpenSearchFilterVisitorObject();
    OpenSearchFilterVisitorObject result = (OpenSearchFilterVisitorObject) openSearchFilterVisitor.visit(containsFilter, openSearchFilterVisitorObject);
    assertThat(result.getGeometrySearches(), contains(hasToString(is(WKT_POLYGON))));
}
Also used : Contains(org.opengis.filter.spatial.Contains) Test(org.junit.Test)

Example 9 with Contains

use of org.opengis.filter.spatial.Contains in project ddf by codice.

the class OpenSearchFilterVisitorTest method testContainsOrNest.

@Test
public void testContainsOrNest() {
    Contains containsFilter = (Contains) geotoolsFilterBuilder.attribute(SPATIAL_ATTRIBUTE_NAME).containing().wkt(WKT_POLYGON);
    OpenSearchFilterVisitorObject openSearchFilterVisitorObject = new OpenSearchFilterVisitorObject();
    openSearchFilterVisitorObject.setCurrentNest(NestedTypes.OR);
    OpenSearchFilterVisitorObject result = (OpenSearchFilterVisitorObject) openSearchFilterVisitor.visit(containsFilter, openSearchFilterVisitorObject);
    assertThat(result.getPointRadiusSearches(), is(empty()));
    assertThat(result.getGeometrySearches(), contains(hasToString(is(WKT_POLYGON))));
}
Also used : Contains(org.opengis.filter.spatial.Contains) Test(org.junit.Test)

Example 10 with Contains

use of org.opengis.filter.spatial.Contains in project ddf by codice.

the class OpenSearchFilterVisitorTest method testMultipleFilters.

/**
 * Test that the {@link OpenSearchFilterVisitorObject} is populated with multiple filters.
 * Combines the {@link Filter}s from {@link #testDuringDates} and {@link #testContains()}.
 */
@Test
public void testMultipleFilters() {
    During duringFilter = (During) geotoolsFilterBuilder.attribute(TEMPORAL_ATTRIBUTE_NAME).during().dates(START_DATE, END_DATE);
    Contains containsFilter = (Contains) geotoolsFilterBuilder.attribute(SPATIAL_ATTRIBUTE_NAME).containing().wkt(WKT_POLYGON);
    And andFilter = geotoolsFilterBuilder.allOf(duringFilter, containsFilter);
    OpenSearchFilterVisitorObject openSearchFilterVisitorObject = new OpenSearchFilterVisitorObject();
    openSearchFilterVisitorObject.setCurrentNest(NestedTypes.AND);
    OpenSearchFilterVisitorObject result = (OpenSearchFilterVisitorObject) openSearchFilterVisitor.visit(andFilter, openSearchFilterVisitorObject);
    assertThat(result.getTemporalSearch(), allOf(is(notNullValue()), hasProperty("startDate", is(START_DATE)), hasProperty("endDate", is(END_DATE))));
    assertThat(result.getGeometrySearches(), contains(hasToString(is(WKT_POLYGON))));
}
Also used : And(org.opengis.filter.And) Contains(org.opengis.filter.spatial.Contains) During(org.opengis.filter.temporal.During) Test(org.junit.Test)

Aggregations

Contains (org.opengis.filter.spatial.Contains)11 Test (org.junit.Test)10 And (org.opengis.filter.And)2 DWithin (org.opengis.filter.spatial.DWithin)2 Intersects (org.opengis.filter.spatial.Intersects)2 During (org.opengis.filter.temporal.During)2 Geometry (com.vividsolutions.jts.geom.Geometry)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 DefaultTransaction (org.geotools.data.DefaultTransaction)1 FileDataStoreFactorySpi (org.geotools.data.FileDataStoreFactorySpi)1 Query (org.geotools.data.Query)1 Transaction (org.geotools.data.Transaction)1 ShapefileDataStore (org.geotools.data.shapefile.ShapefileDataStore)1 SimpleFeatureCollection (org.geotools.data.simple.SimpleFeatureCollection)1 SimpleFeatureIterator (org.geotools.data.simple.SimpleFeatureIterator)1 SimpleFeatureStore (org.geotools.data.simple.SimpleFeatureStore)1 SimpleFeatureBuilder (org.geotools.feature.simple.SimpleFeatureBuilder)1