use of ddf.catalog.impl.filter.SpatialFilter in project ddf by codice.
the class OpenSearchQuery method addSpatialFilter.
private void addSpatialFilter(SpatialFilter spatialFilter) {
Geometry geometry = spatialFilter.getGeometry();
if (geometry != null) {
Filter filter = FILTER_FACTORY.intersects(Metacard.ANY_GEO, geometry);
LOGGER.debug("Adding spatial filter");
filters.add(filter);
}
}
use of ddf.catalog.impl.filter.SpatialFilter in project ddf by codice.
the class OpenSearchSource method applyFilters.
private void applyFilters(OpenSearchFilterVisitor visitor, WebClient client) {
TemporalFilter temporalFilter = visitor.getTemporalSearch();
if (temporalFilter != null) {
LOGGER.debug("startDate = {}", temporalFilter.getStartDate());
LOGGER.debug("endDate = {}", temporalFilter.getEndDate());
OpenSearchSiteUtil.populateTemporal(client, temporalFilter, parameters);
}
SpatialFilter spatialFilter = visitor.getSpatialSearch();
if (spatialFilter != null) {
if (spatialFilter instanceof SpatialDistanceFilter) {
try {
OpenSearchSiteUtil.populateGeospatial(client, (SpatialDistanceFilter) spatialFilter, shouldConvertToBBox, parameters);
} catch (UnsupportedQueryException e) {
LOGGER.debug("Problem with populating geospatial criteria. ", e);
}
} else {
try {
OpenSearchSiteUtil.populateGeospatial(client, spatialFilter, shouldConvertToBBox, parameters);
} catch (UnsupportedQueryException e) {
LOGGER.debug("Problem with populating geospatial criteria. ", e);
}
}
}
if (localQueryOnly) {
client.replaceQueryParam(URL_SRC_PARAMETER, LOCAL_SEARCH_PARAMETER);
} else {
client.replaceQueryParam(URL_SRC_PARAMETER, "");
}
}
use of ddf.catalog.impl.filter.SpatialFilter in project ddf by codice.
the class MockQuery method addSpatialFilter.
public void addSpatialFilter(String geometryWkt) {
SpatialFilter spatialFilter = new SpatialFilter(geometryWkt);
Geometry geometry = spatialFilter.getGeometry();
if (geometry != null) {
Filter filter = FILTER_FACTORY.contains(Metacard.ANY_GEO, geometry);
filters.add(filter);
this.filter = getFilter();
}
}
use of ddf.catalog.impl.filter.SpatialFilter in project ddf by codice.
the class OpenSearchFilterVisitor method visit.
/**
* Contains filter maps to a Polygon or BBox Spatial search criteria.
*/
@Override
public Object visit(Contains filter, Object data) {
LOGGER.trace("ENTERING: Contains 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.SurfaceImpl@64a7c45e</ogc:Literal>
Literal literalWrapper = (Literal) filter.getExpression2();
Object geometryExpression = literalWrapper.getValue();
StringBuffer geometryWkt = new StringBuffer();
if (geometryExpression instanceof SurfaceImpl) {
SurfaceImpl polygon = (SurfaceImpl) literalWrapper.evaluate(null);
Coordinate[] coords = polygon.getJTSGeometry().getCoordinates();
geometryWkt.append("POLYGON((");
for (int i = 0; i < coords.length; i++) {
geometryWkt.append(coords[i].x);
geometryWkt.append(" ");
geometryWkt.append(coords[i].y);
if (i != (coords.length - 1)) {
geometryWkt.append(",");
}
}
geometryWkt.append("))");
this.spatialSearch = new SpatialFilter(geometryWkt.toString());
LOGGER.debug("geometryWkt = [{}]", geometryWkt.toString());
filters.add(filter);
} else {
LOGGER.debug("Only POLYGON geometry WKT for Contains filter is supported");
}
} else {
LOGGER.debug(ONLY_AND_MSG);
}
LOGGER.trace("EXITING: Contains filter");
return super.visit(filter, data);
}
use of ddf.catalog.impl.filter.SpatialFilter in project ddf by codice.
the class OpenSearchFilterVisitor method visit.
/**
* Intersects filter maps to a Polygon or BBox Spatial search criteria.
*/
@Override
public Object visit(Intersects filter, Object data) {
LOGGER.trace("ENTERING: Intersects 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.SurfaceImpl@64a7c45e</ogc:Literal>
Literal literalWrapper = (Literal) filter.getExpression2();
Object geometryExpression = literalWrapper.getValue();
StringBuffer geometryWkt = new StringBuffer();
if (geometryExpression instanceof SurfaceImpl) {
SurfaceImpl polygon = (SurfaceImpl) literalWrapper.evaluate(null);
Coordinate[] coords = polygon.getJTSGeometry().getCoordinates();
geometryWkt.append("POLYGON((");
for (int i = 0; i < coords.length; i++) {
geometryWkt.append(coords[i].x);
geometryWkt.append(" ");
geometryWkt.append(coords[i].y);
if (i != (coords.length - 1)) {
geometryWkt.append(",");
}
}
geometryWkt.append("))");
this.spatialSearch = new SpatialFilter(geometryWkt.toString());
LOGGER.debug("geometryWkt = [{}]", geometryWkt.toString());
filters.add(filter);
} else {
LOGGER.debug("Only POLYGON geometry WKT for Intersects filter is supported");
}
} else {
LOGGER.debug(ONLY_AND_MSG);
}
LOGGER.trace("EXITING: Intersects filter");
return super.visit(filter, data);
}
Aggregations