use of ddf.catalog.impl.filter.JTSGeometryWrapper in project ddf by codice.
the class GeotoolsBuilder method toGeometry.
public Geometry toGeometry(String wkt) {
Geometry geometry = null;
try {
if (wkt.toLowerCase(Locale.US).startsWith("multi") || wkt.toLowerCase(Locale.US).trim().indexOf("geometrycollection") != -1) {
// WKTParser does not currently support MultiPolygon,
// MultiLineString, or MultiPoint
org.locationtech.jts.geom.Geometry geo = reader.read(wkt);
geometry = new JTSGeometryWrapper(geo);
} else {
geometry = parser.parse(wkt);
}
} catch (ParseException | java.text.ParseException e) {
LOGGER.debug("Unable to compute geometry for WKT = {}", wkt, e);
}
return geometry;
}
use of ddf.catalog.impl.filter.JTSGeometryWrapper in project ddf by codice.
the class FilterAdapterTest method testSpatialWrappedGeometry.
@Test
public void testSpatialWrappedGeometry() throws org.locationtech.jts.io.ParseException {
WKTReader reader = new WKTReader();
org.locationtech.jts.geom.Geometry geo = reader.read(MULTIPOLYGON_WKT);
Geometry geometry = new JTSGeometryWrapper(geo);
assertFilterEquals("beyond(Test,wkt(" + MULTIPOLYGON_WKT + "),10.0)", FF.beyond(TEST_PROPERTY_VALUE, geometry, DISTANCE_10, UomOgcMapping.METRE.name()));
assertFilterEquals("beyond(Test,wkt(" + MULTIPOLYGON_WKT + "),0.001)", FF.beyond(TEST_PROPERTY_VALUE, geometry, DISTANCE_001, UomOgcMapping.METRE.name()));
assertFilterEquals("contains(Test,wkt(" + MULTIPOLYGON_WKT + "))", FF.contains(TEST_PROPERTY_VALUE, geometry));
assertFilterEquals("dwithin(Test,wkt(" + MULTIPOLYGON_WKT + "),10.0)", FF.dwithin(TEST_PROPERTY_VALUE, geometry, DISTANCE_10, UomOgcMapping.METRE.name()));
assertFilterEquals("dwithin(Test,wkt(" + MULTIPOLYGON_WKT + "),0.001)", FF.dwithin(TEST_PROPERTY_VALUE, geometry, DISTANCE_001, UomOgcMapping.METRE.name()));
assertFilterEquals("intersects(Test,wkt(" + MULTIPOLYGON_WKT + "))", FF.intersects(TEST_PROPERTY_VALUE, geometry));
assertFilterEquals("within(Test,wkt(" + MULTIPOLYGON_WKT + "))", FF.within(TEST_PROPERTY_VALUE, geometry));
}
Aggregations