Search in sources :

Example 6 with Intersects

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

the class OpenSearchFilterVisitorTest method testIntersectsWithMultipolygonECQL.

@Test
public void testIntersectsWithMultipolygonECQL() throws CQLException {
    Intersects multipolygonFilter = (Intersects) ECQL.toFilter(ECQL_MULTIPOLYGON);
    OpenSearchFilterVisitorObject openSearchFilterVisitorObject = new OpenSearchFilterVisitorObject();
    openSearchFilterVisitorObject.setCurrentNest(NestedTypes.OR);
    OpenSearchFilterVisitorObject result = (OpenSearchFilterVisitorObject) openSearchFilterVisitor.visit(multipolygonFilter, openSearchFilterVisitorObject);
    assertThat(result.getPointRadiusSearches(), is(empty()));
    assertThat(result.getGeometrySearches(), contains(hasToString(is(WKT_MULTI_POLYGON))));
}
Also used : Intersects(org.opengis.filter.spatial.Intersects) Test(org.junit.Test)

Example 7 with Intersects

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

the class OpenSearchFilterVisitorTest method testIntersectsWithCollection.

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

Example 8 with Intersects

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

the class FilterBuilderTest method intersects.

@Test
public void intersects() {
    FilterVisitor visitor = spy(new DefaultFilterVisitor() {
    });
    FilterBuilder builder = new GeotoolsFilterBuilder();
    Filter filter = builder.attribute(Metacard.GEOGRAPHY).intersecting().wkt(POINT_WKT);
    filter.accept(visitor, null);
    InOrder inOrder = inOrder(visitor);
    inOrder.verify(visitor, times(1)).visit(isA(Intersects.class), any());
}
Also used : InOrder(org.mockito.InOrder) DefaultFilterVisitor(org.geotools.filter.visitor.DefaultFilterVisitor) DefaultFilterVisitor(org.geotools.filter.visitor.DefaultFilterVisitor) FilterVisitor(org.opengis.filter.FilterVisitor) Filter(org.opengis.filter.Filter) FilterBuilder(ddf.catalog.filter.FilterBuilder) GeotoolsFilterBuilder(ddf.catalog.filter.proxy.builder.GeotoolsFilterBuilder) GeotoolsFilterBuilder(ddf.catalog.filter.proxy.builder.GeotoolsFilterBuilder) Intersects(org.opengis.filter.spatial.Intersects) Test(org.junit.Test)

Example 9 with Intersects

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

the class OpenSearchFilterVisitorTest method testIntersectsOrNest.

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

Example 10 with Intersects

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

the class OpenSearchFilterVisitorTest method testIntersectsCqlFilter.

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

Aggregations

Intersects (org.opengis.filter.spatial.Intersects)15 Test (org.junit.Test)14 Literal (org.opengis.filter.expression.Literal)3 CswQueryFactoryTest (org.codice.ddf.spatial.ogc.csw.catalog.endpoint.CswQueryFactoryTest)2 DefaultFilterVisitor (org.geotools.filter.visitor.DefaultFilterVisitor)2 Geometry (org.locationtech.jts.geom.Geometry)2 Filter (org.opengis.filter.Filter)2 Expression (org.opengis.filter.expression.Expression)2 Contains (org.opengis.filter.spatial.Contains)2 DWithin (org.opengis.filter.spatial.DWithin)2 CoordinateReferenceSystem (org.opengis.referencing.crs.CoordinateReferenceSystem)2 Coordinate (com.vividsolutions.jts.geom.Coordinate)1 Geometry (com.vividsolutions.jts.geom.Geometry)1 GeometryFactory (com.vividsolutions.jts.geom.GeometryFactory)1 FilterBuilder (ddf.catalog.filter.FilterBuilder)1 GeotoolsFilterBuilder (ddf.catalog.filter.proxy.builder.GeotoolsFilterBuilder)1 TemporalFilter (ddf.catalog.impl.filter.TemporalFilter)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 BBoxSpatialFilter (org.codice.ddf.opensearch.endpoint.query.filter.BBoxSpatialFilter)1