Search in sources :

Example 6 with SpatialDistanceFilter

use of ddf.catalog.impl.filter.SpatialDistanceFilter in project ddf by codice.

the class OpenSearchFilterVisitor method visit.

/**
     * DWithin filter maps to a Point/Radius distance Spatial search criteria.
     */
@Override
public Object visit(DWithin filter, Object data) {
    LOGGER.trace("ENTERING: DWithin filter");
    if (currentNest == null || NestedTypes.AND.equals(currentNest)) {
        // The geometric point is wrapped in a <Literal> element, so have to
        // get geometry expression as literal and then evaluate it to get
        // the geometry.
        // Example:
        // <ogc:Literal>org.geotools.geometry.jts.spatialschema.geometry.primitive.PointImpl@dc33f184</ogc:Literal>
        Literal literalWrapper = (Literal) filter.getExpression2();
        // Luckily we know what type the geometry expression should be, so
        // we
        // can cast it
        PointImpl point = (PointImpl) literalWrapper.evaluate(null);
        double[] coords = point.getCentroid().getCoordinate();
        double distance = filter.getDistance();
        LOGGER.debug("point: coords[0] = {},   coords[1] = {}", coords[0], coords[1]);
        LOGGER.debug("radius = {}", distance);
        this.spatialSearch = new SpatialDistanceFilter(coords[0], coords[1], distance);
        filters.add(filter);
    } else {
        LOGGER.debug(ONLY_AND_MSG);
    }
    LOGGER.trace("EXITING: DWithin filter");
    return super.visit(filter, data);
}
Also used : PropertyIsEqualToLiteral(ddf.catalog.filter.impl.PropertyIsEqualToLiteral) Literal(org.opengis.filter.expression.Literal) SpatialDistanceFilter(ddf.catalog.impl.filter.SpatialDistanceFilter) PointImpl(org.geotools.geometry.jts.spatialschema.geometry.primitive.PointImpl)

Example 7 with SpatialDistanceFilter

use of ddf.catalog.impl.filter.SpatialDistanceFilter in project ddf by codice.

the class OpenSearchQuery method addPointRadiusSpatialFilter.

public void addPointRadiusSpatialFilter(String lon, String lat, String radius) {
    SpatialDistanceFilter distanceFilter = new SpatialDistanceFilter(lon, lat, radius);
    Geometry geometry = distanceFilter.getGeometry();
    if (geometry != null) {
        Filter filter = FILTER_FACTORY.dwithin(OpenSearchConstants.SUPPORTED_SPATIAL_SEARCH_TERM, geometry, Double.parseDouble(radius), UomOgcMapping.METRE.name());
        LOGGER.trace("Adding spatial filter");
        spatialFilters.add(filter);
    }
}
Also used : Geometry(org.opengis.geometry.Geometry) PolygonSpatialFilter(org.codice.ddf.opensearch.endpoint.query.filter.PolygonSpatialFilter) SpatialFilter(ddf.catalog.impl.filter.SpatialFilter) TemporalFilter(ddf.catalog.impl.filter.TemporalFilter) SpatialDistanceFilter(ddf.catalog.impl.filter.SpatialDistanceFilter) Filter(org.opengis.filter.Filter) BBoxSpatialFilter(org.codice.ddf.opensearch.endpoint.query.filter.BBoxSpatialFilter) SpatialDistanceFilter(ddf.catalog.impl.filter.SpatialDistanceFilter)

Aggregations

SpatialDistanceFilter (ddf.catalog.impl.filter.SpatialDistanceFilter)7 SpatialFilter (ddf.catalog.impl.filter.SpatialFilter)4 TemporalFilter (ddf.catalog.impl.filter.TemporalFilter)4 Filter (org.opengis.filter.Filter)3 Geometry (org.opengis.geometry.Geometry)3 WebClient (org.apache.cxf.jaxrs.client.WebClient)2 Test (org.junit.Test)2 PropertyIsEqualToLiteral (ddf.catalog.filter.impl.PropertyIsEqualToLiteral)1 UnsupportedQueryException (ddf.catalog.source.UnsupportedQueryException)1 MalformedURLException (java.net.MalformedURLException)1 URI (java.net.URI)1 URL (java.net.URL)1 BBoxSpatialFilter (org.codice.ddf.opensearch.endpoint.query.filter.BBoxSpatialFilter)1 PolygonSpatialFilter (org.codice.ddf.opensearch.endpoint.query.filter.PolygonSpatialFilter)1 BBoxSpatialFilter (org.codice.ddf.opensearch.query.filter.BBoxSpatialFilter)1 PolygonSpatialFilter (org.codice.ddf.opensearch.query.filter.PolygonSpatialFilter)1 PointImpl (org.geotools.geometry.jts.spatialschema.geometry.primitive.PointImpl)1 Matchers.containsString (org.hamcrest.Matchers.containsString)1 Literal (org.opengis.filter.expression.Literal)1