use of ddf.catalog.impl.filter.SpatialDistanceFilter 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.SpatialDistanceFilter in project ddf by codice.
the class TestOpenSearchSiteUtil method populateNullGeospatial.
/**
* Verify that passing in null will still remove the parameters from the URL.
*/
@Test
public void populateNullGeospatial() throws Exception {
SpatialDistanceFilter spatial = null;
WebClient webClient = WebClient.create(url.toString());
OpenSearchSiteUtil.populateGeospatial(webClient, spatial, true, Arrays.asList("q,src,mr,start,count,mt,dn,lat,lon,radius,bbox,polygon,dtstart,dtend,dateName,filter,sort".split(",")));
URI urlStr = webClient.getCurrentURI();
assertTrue(urlStr.toString().indexOf(OpenSearchSiteUtil.GEO_LAT) == -1);
assertTrue(urlStr.toString().indexOf(OpenSearchSiteUtil.GEO_LON) == -1);
assertTrue(urlStr.toString().indexOf(OpenSearchSiteUtil.GEO_RADIUS) == -1);
}
use of ddf.catalog.impl.filter.SpatialDistanceFilter in project ddf by codice.
the class MockQuery method addSpatialDistanceFilter.
public void addSpatialDistanceFilter(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(Metacard.ANY_GEO, geometry, Double.parseDouble(radius), UomOgcMapping.METRE.getSEString());
filters.add(filter);
this.filter = getFilter();
}
}
use of ddf.catalog.impl.filter.SpatialDistanceFilter in project ddf by codice.
the class TestOpenSearchSiteUtil method populateLatLonRadGeospatial.
@Test
public void populateLatLonRadGeospatial() throws Exception {
String lat = "43.25";
String lon = "-123.45";
String radius = "10000";
String wktPoint = "POINT(" + lon + " " + lat + ")";
SpatialDistanceFilter spatial = new SpatialDistanceFilter(wktPoint, radius);
WebClient webClient = WebClient.create(url.toString());
OpenSearchSiteUtil.populateGeospatial(webClient, spatial, false, Arrays.asList("q,src,mr,start,count,mt,dn,lat,lon,radius,bbox,polygon,dtstart,dtend,dateName,filter,sort".split(",")));
String urlStr = webClient.getCurrentURI().toString();
assertTrue(urlStr.indexOf(lat) != -1);
assertTrue(urlStr.indexOf(lon) != -1);
assertTrue(urlStr.indexOf(radius) != -1);
assertTrue(urlStr.indexOf(OpenSearchSiteUtil.GEO_LAT) != -1);
assertTrue(urlStr.indexOf(OpenSearchSiteUtil.GEO_LON) != -1);
assertTrue(urlStr.indexOf(OpenSearchSiteUtil.GEO_RADIUS) != -1);
try {
new URL(urlStr.toString());
} catch (MalformedURLException mue) {
fail("URL is not valid: " + mue.getMessage());
}
LOGGER.info("URL after lat lon geospatial population: {}", urlStr.toString());
}
use of ddf.catalog.impl.filter.SpatialDistanceFilter in project ddf by codice.
the class OpenSearchQuery method addSpatialDistanceFilter.
public void addSpatialDistanceFilter(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(Metacard.ANY_GEO, geometry, Double.parseDouble(radius), UomOgcMapping.METRE.name());
LOGGER.debug("Adding spatial filter");
filters.add(filter);
}
}
Aggregations