Search in sources :

Example 1 with Intersects

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

the class TestCswRecordMapperFilterVisitor method testIntersectsUtm.

@Test
public void testIntersectsUtm() throws FactoryException, TransformException {
    double lon = 33.45;
    double lat = 25.22;
    double easting = 545328.48;
    double northing = 2789384.24;
    CoordinateReferenceSystem sourceCRS = CRS.decode("EPSG:32636");
    GeometryFactory geoFactory = new GeometryFactory();
    Geometry utmPoint = geoFactory.createPoint(new Coordinate(easting, northing));
    utmPoint.setUserData(sourceCRS);
    Expression pt1 = factory.literal(geoFactory.createPoint(new Coordinate(1, 2)));
    Expression pt2 = factory.literal(utmPoint);
    Intersects filter = factory.intersects(pt1, pt2);
    visitor.visit(filter, null);
    assertThat(pt2, instanceOf(Literal.class));
    Literal literalExpression = (Literal) pt2;
    assertThat(literalExpression.getValue(), instanceOf(Geometry.class));
    Geometry geometry = (Geometry) literalExpression.getValue();
    assertThat(geometry.getCoordinates()[0].x, closeTo(lon, .00001));
    assertThat(geometry.getCoordinates()[0].y, closeTo(lat, .00001));
}
Also used : Geometry(com.vividsolutions.jts.geom.Geometry) GeometryFactory(com.vividsolutions.jts.geom.GeometryFactory) Coordinate(com.vividsolutions.jts.geom.Coordinate) Expression(org.opengis.filter.expression.Expression) Intersects(org.opengis.filter.spatial.Intersects) Literal(org.opengis.filter.expression.Literal) CoordinateReferenceSystem(org.opengis.referencing.crs.CoordinateReferenceSystem) CswQueryFactoryTest(org.codice.ddf.spatial.ogc.csw.catalog.endpoint.CswQueryFactoryTest) Test(org.junit.Test)

Example 2 with Intersects

use of org.opengis.filter.spatial.Intersects 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 Intersects

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

the class OpenSearchFilterVisitorTest method testIntersectsAndNest.

@Test
public void testIntersectsAndNest() {
    Intersects intersectsFilter = (Intersects) geotoolsFilterBuilder.attribute(SPATIAL_ATTRIBUTE_NAME).intersecting().wkt(WKT_POLYGON);
    OpenSearchFilterVisitorObject openSearchFilterVisitorObject = new OpenSearchFilterVisitorObject();
    openSearchFilterVisitorObject.setCurrentNest(NestedTypes.AND);
    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 4 with Intersects

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

the class OpenSearchFilterVisitorTest method testIntersects.

@Test
public void testIntersects() {
    Intersects intersectsFilter = (Intersects) geotoolsFilterBuilder.attribute(SPATIAL_ATTRIBUTE_NAME).intersecting().wkt(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)

Example 5 with Intersects

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

the class OpenSearchFilterVisitorTest method testIntersectsWithMultipolygon.

@Test
public void testIntersectsWithMultipolygon() {
    Intersects intersectsFilter = (Intersects) geotoolsFilterBuilder.attribute(SPATIAL_ATTRIBUTE_NAME).intersecting().wkt(WKT_MULTI_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_MULTI_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