Search in sources :

Example 1 with Beyond

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

the class TestCswRecordMapperFilterVisitor method testVisitBeyond.

@Test
public void testVisitBeyond() {
    GeometryFactory geoFactory = new GeometryFactory();
    double val = 30;
    Expression pt1 = factory.literal(geoFactory.createPoint(new Coordinate(4, 5)));
    Expression pt2 = factory.literal(geoFactory.createPoint(new Coordinate(6, 7)));
    Beyond filter = factory.beyond(pt1, pt2, val, "kilometers");
    Beyond duplicate = (Beyond) visitor.visit(filter, null);
    assertThat(duplicate.getExpression1(), is(pt1));
    assertThat(duplicate.getExpression2(), is(pt2));
    assertThat(duplicate.getDistanceUnits(), is(UomOgcMapping.METRE.name()));
    assertThat(duplicate.getDistance(), is(1000 * val));
}
Also used : GeometryFactory(com.vividsolutions.jts.geom.GeometryFactory) Expression(org.opengis.filter.expression.Expression) Coordinate(com.vividsolutions.jts.geom.Coordinate) Beyond(org.opengis.filter.spatial.Beyond) CswQueryFactoryTest(org.codice.ddf.spatial.ogc.csw.catalog.endpoint.CswQueryFactoryTest) Test(org.junit.Test)

Example 2 with Beyond

use of org.opengis.filter.spatial.Beyond 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 3 with Beyond

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

the class FilterBuilderTest method beyond.

@Test
public void beyond() {
    FilterVisitor visitor = spy(new DefaultFilterVisitor() {
    });
    FilterBuilder builder = new GeotoolsFilterBuilder();
    Filter filter = builder.attribute(Metacard.GEOGRAPHY).beyond().wkt(POINT_WKT, 123.45d);
    filter.accept(visitor, null);
    filter = builder.attribute(Metacard.GEOGRAPHY).beyond().wkt(POINT_WKT);
    filter.accept(visitor, null);
    InOrder inOrder = inOrder(visitor);
    inOrder.verify(visitor, times(2)).visit(isA(Beyond.class), any());
// TODO check arguments
}
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) Beyond(org.opengis.filter.spatial.Beyond) Test(org.junit.Test)

Example 4 with Beyond

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

the class CswRecordMapperFilterVisitorTest method testVisitBeyond.

@Test
public void testVisitBeyond() {
    GeometryFactory geoFactory = new GeometryFactory();
    double val = 30;
    Expression pt1 = factory.literal(geoFactory.createPoint(new Coordinate(4, 5)));
    Expression pt2 = factory.literal(geoFactory.createPoint(new Coordinate(6, 7)));
    Beyond filter = factory.beyond(pt1, pt2, val, "kilometers");
    Beyond duplicate = (Beyond) visitor.visit(filter, null);
    assertThat(duplicate.getExpression1(), is(pt1));
    assertThat(duplicate.getExpression2(), is(pt2));
    assertThat(duplicate.getDistanceUnits(), is(UomOgcMapping.METRE.name()));
    assertThat(duplicate.getDistance(), is(1000 * val));
}
Also used : GeometryFactory(org.locationtech.jts.geom.GeometryFactory) Expression(org.opengis.filter.expression.Expression) Coordinate(org.locationtech.jts.geom.Coordinate) Beyond(org.opengis.filter.spatial.Beyond) CswQueryFactoryTest(org.codice.ddf.spatial.ogc.csw.catalog.endpoint.CswQueryFactoryTest) Test(org.junit.Test)

Aggregations

Beyond (org.opengis.filter.spatial.Beyond)4 Test (org.junit.Test)3 CswQueryFactoryTest (org.codice.ddf.spatial.ogc.csw.catalog.endpoint.CswQueryFactoryTest)2 DefaultFilterVisitor (org.geotools.filter.visitor.DefaultFilterVisitor)2 Expression (org.opengis.filter.expression.Expression)2 Coordinate (com.vividsolutions.jts.geom.Coordinate)1 GeometryFactory (com.vividsolutions.jts.geom.GeometryFactory)1 FilterBuilder (ddf.catalog.filter.FilterBuilder)1 GeotoolsFilterBuilder (ddf.catalog.filter.proxy.builder.GeotoolsFilterBuilder)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Coordinate (org.locationtech.jts.geom.Coordinate)1 GeometryFactory (org.locationtech.jts.geom.GeometryFactory)1 InOrder (org.mockito.InOrder)1 Filter (org.opengis.filter.Filter)1 FilterVisitor (org.opengis.filter.FilterVisitor)1 Divide (org.opengis.filter.expression.Divide)1 Multiply (org.opengis.filter.expression.Multiply)1 Subtract (org.opengis.filter.expression.Subtract)1 Contains (org.opengis.filter.spatial.Contains)1