Search in sources :

Example 1 with Within

use of org.opengis.filter.spatial.Within in project polymap4-core by Polymap4.

the class LuceneQueryDialect method supports.

public static boolean supports(Filter _filter) {
    final List notSupported = new ArrayList();
    _filter.accept(new DefaultFilterVisitor() {

        public Object visit(Beyond filter, Object data) {
            notSupported.add(filter);
            return super.visit(filter, data);
        }

        public Object visit(Contains filter, Object data) {
            notSupported.add(filter);
            return super.visit(filter, data);
        }

        public Object visit(Crosses filter, Object data) {
            notSupported.add(filter);
            return super.visit(filter, data);
        }

        public Object visit(Disjoint filter, Object data) {
            notSupported.add(filter);
            return super.visit(filter, data);
        }

        public Object visit(Divide expression, Object data) {
            notSupported.add(expression);
            return super.visit(expression, data);
        }

        public Object visit(DWithin filter, Object data) {
            notSupported.add(filter);
            return super.visit(filter, data);
        }

        public Object visit(org.opengis.filter.expression.Function expression, Object data) {
            notSupported.add(expression);
            return super.visit(expression, data);
        }

        public Object visit(Intersects filter, Object data) {
            notSupported.add(filter);
            return super.visit(filter, data);
        }

        public Object visit(Multiply expression, Object data) {
            notSupported.add(expression);
            return super.visit(expression, data);
        }

        public Object visit(Overlaps filter, Object data) {
            notSupported.add(filter);
            return super.visit(filter, data);
        }

        public Object visit(Subtract expression, Object data) {
            notSupported.add(expression);
            return super.visit(expression, data);
        }

        public Object visit(Touches filter, Object data) {
            notSupported.add(filter);
            return super.visit(filter, data);
        }

        public Object visit(Within filter, Object data) {
            notSupported.add(filter);
            return super.visit(filter, data);
        }
    }, notSupported);
    return notSupported.isEmpty();
}
Also used : Overlaps(org.opengis.filter.spatial.Overlaps) DefaultFilterVisitor(org.geotools.filter.visitor.DefaultFilterVisitor) ArrayList(java.util.ArrayList) Beyond(org.opengis.filter.spatial.Beyond) Divide(org.opengis.filter.expression.Divide) Crosses(org.opengis.filter.spatial.Crosses) DWithin(org.opengis.filter.spatial.DWithin) Intersects(org.opengis.filter.spatial.Intersects) Multiply(org.opengis.filter.expression.Multiply) Contains(org.opengis.filter.spatial.Contains) DWithin(org.opengis.filter.spatial.DWithin) Within(org.opengis.filter.spatial.Within) Disjoint(org.opengis.filter.spatial.Disjoint) Subtract(org.opengis.filter.expression.Subtract) Touches(org.opengis.filter.spatial.Touches) List(java.util.List) ArrayList(java.util.ArrayList)

Example 2 with Within

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

the class FilterBuilderTest method withinGeoTest.

/**
 */
@Test
public void withinGeoTest() {
    FilterBuilder builder = new GeotoolsFilterBuilder();
    Filter filter = builder.attribute(Metacard.GEOGRAPHY).within().wkt(POINT_WKT);
    filter.accept(new DefaultFilterVisitor() {

        @Override
        public Object visit(Within filter, Object data) {
            Literal literalWrapper = (Literal) filter.getExpression2();
            Geometry geometry = (Geometry) literalWrapper.evaluate(null);
            geometry.getCentroid().getCoordinate();
            return super.visit(filter, data);
        }
    }, null);
}
Also used : Geometry(org.opengis.geometry.Geometry) DefaultFilterVisitor(org.geotools.filter.visitor.DefaultFilterVisitor) Filter(org.opengis.filter.Filter) FilterBuilder(ddf.catalog.filter.FilterBuilder) GeotoolsFilterBuilder(ddf.catalog.filter.proxy.builder.GeotoolsFilterBuilder) GeotoolsFilterBuilder(ddf.catalog.filter.proxy.builder.GeotoolsFilterBuilder) Literal(org.opengis.filter.expression.Literal) DWithin(org.opengis.filter.spatial.DWithin) Within(org.opengis.filter.spatial.Within) Test(org.junit.Test)

Example 3 with Within

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

the class TestCswRecordMapperFilterVisitor method testVisitBBox.

@Test
public void testVisitBBox() {
    BBOX filter = factory.bbox(attrExpr, 0, 0, 10, 20, "EPSG:4269");
    String polygon = "POLYGON ((0 0, 0 20, 10 20, 10 0, 0 0))";
    Object obj = visitor.visit(filter, null);
    assertThat(obj, instanceOf(Within.class));
    Within duplicate = (Within) obj;
    assertThat(duplicate.getExpression1(), is(attrExpr));
    assertThat(duplicate.getExpression2().toString(), is(polygon));
}
Also used : BBOX(org.opengis.filter.spatial.BBOX) DWithin(org.opengis.filter.spatial.DWithin) Within(org.opengis.filter.spatial.Within) CswQueryFactoryTest(org.codice.ddf.spatial.ogc.csw.catalog.endpoint.CswQueryFactoryTest) Test(org.junit.Test)

Example 4 with Within

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

the class FilterBuilderTest method within.

@Test
public void within() {
    FilterVisitor visitor = spy(new DefaultFilterVisitor() {
    });
    FilterBuilder builder = new GeotoolsFilterBuilder();
    Filter filter = builder.attribute(Metacard.GEOGRAPHY).within().wkt(POINT_WKT);
    filter.accept(visitor, null);
    filter = builder.attribute(Metacard.GEOGRAPHY).is().within().wkt(MULTIPOLYGON_WKT);
    filter.accept(visitor, null);
    InOrder inOrder = inOrder(visitor);
    inOrder.verify(visitor, times(2)).visit(isA(Within.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) DWithin(org.opengis.filter.spatial.DWithin) Within(org.opengis.filter.spatial.Within) Test(org.junit.Test)

Example 5 with Within

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

the class CswRecordMapperFilterVisitorTest method testVisitBBox.

@Test
public void testVisitBBox() {
    BBOX filter = factory.bbox(attrExpr, 0, 0, 10, 20, "EPSG:4326");
    String polygon = "POLYGON ((0 0, 0 20, 10 20, 10 0, 0 0))";
    Object obj = visitor.visit(filter, null);
    assertThat(obj, instanceOf(Within.class));
    Within duplicate = (Within) obj;
    assertThat(duplicate.getExpression1(), is(attrExpr));
    assertThat(duplicate.getExpression2().toString(), is(polygon));
}
Also used : BBOX(org.opengis.filter.spatial.BBOX) DWithin(org.opengis.filter.spatial.DWithin) Within(org.opengis.filter.spatial.Within) CswQueryFactoryTest(org.codice.ddf.spatial.ogc.csw.catalog.endpoint.CswQueryFactoryTest) Test(org.junit.Test)

Aggregations

DWithin (org.opengis.filter.spatial.DWithin)5 Within (org.opengis.filter.spatial.Within)5 Test (org.junit.Test)4 DefaultFilterVisitor (org.geotools.filter.visitor.DefaultFilterVisitor)3 FilterBuilder (ddf.catalog.filter.FilterBuilder)2 GeotoolsFilterBuilder (ddf.catalog.filter.proxy.builder.GeotoolsFilterBuilder)2 CswQueryFactoryTest (org.codice.ddf.spatial.ogc.csw.catalog.endpoint.CswQueryFactoryTest)2 Filter (org.opengis.filter.Filter)2 BBOX (org.opengis.filter.spatial.BBOX)2 ArrayList (java.util.ArrayList)1 List (java.util.List)1 InOrder (org.mockito.InOrder)1 FilterVisitor (org.opengis.filter.FilterVisitor)1 Divide (org.opengis.filter.expression.Divide)1 Literal (org.opengis.filter.expression.Literal)1 Multiply (org.opengis.filter.expression.Multiply)1 Subtract (org.opengis.filter.expression.Subtract)1 Beyond (org.opengis.filter.spatial.Beyond)1 Contains (org.opengis.filter.spatial.Contains)1 Crosses (org.opengis.filter.spatial.Crosses)1