use of org.opengis.geometry.Geometry 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 org.opengis.geometry.Geometry 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 org.opengis.geometry.Geometry 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);
}
}
use of org.opengis.geometry.Geometry in project ddf by codice.
the class OpenSearchQueryTest method testWktParser.
@Test
public void testWktParser() throws Exception {
String geometryWkt = "POINT( 48.44 -123.37)";
GeometryBuilder builder = new GeometryBuilder(DefaultGeographicCRS.WGS84);
WKTParser parser = new WKTParser(builder);
// This fixed the NPE in parser.parse() - seems GeoTools has bug with
// keeping the CRS hint set ...
parser.setFactory(new PrimitiveFactoryImpl(DefaultGeographicCRS.WGS84));
Geometry geometry = parser.parse(geometryWkt);
CoordinateReferenceSystem crs = geometry.getCoordinateReferenceSystem();
assertNotNull(crs);
String geometryWkt2 = "POINT( 48.44 -123.37)";
builder = new GeometryBuilder(DefaultGeographicCRS.WGS84);
WKTParser parser2 = new WKTParser(builder);
Geometry geometry2 = parser2.parse(geometryWkt2);
assertTrue(geometry2.intersects(geometry));
double[] coords = geometry.getCentroid().getCoordinate();
LOGGER.debug("coords[0] = {}, coords[1] = {}", coords[0], coords[1]);
}
use of org.opengis.geometry.Geometry in project ddf by codice.
the class SpatialFilter method getGeometry.
public Geometry getGeometry() {
Geometry geometry = null;
try {
if (geometryWkt.toLowerCase(Locale.US).startsWith("multi") || geometryWkt.toLowerCase(Locale.US).trim().indexOf("geometrycollection") != -1) {
// WKTParser does not currently support MultiPolygon,
// MultiLineString, or MultiPoint
com.vividsolutions.jts.geom.Geometry geo = reader.read(geometryWkt);
geometry = new JTSGeometryWrapper(geo);
} else {
geometry = parser.parse(geometryWkt);
}
} catch (ParseException e) {
LOGGER.debug("Unable to compute geometry for WKT = {}", this.geometryWkt, e);
} catch (com.vividsolutions.jts.io.ParseException e) {
LOGGER.debug("Unable to read multi geometry for WKT = {}", this.geometryWkt, e);
}
return geometry;
}
Aggregations