use of org.opengis.geometry.Geometry 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
com.vividsolutions.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 org.opengis.geometry.Geometry in project ddf by codice.
the class CopyFilterDelegateTest method testSpatialDWithin.
@Test
public void testSpatialDWithin() {
Geometry polygonGeometry = wktToGeometry(POLYGON_WKT);
assertFilterEquals(FF.dwithin(TEST_PROPERTY_VALUE, polygonGeometry, DISTANCE_10, UomOgcMapping.METRE.name()));
}
use of org.opengis.geometry.Geometry in project ddf by codice.
the class CopyFilterDelegateTest method testSpatialBeyond.
@Test
public void testSpatialBeyond() {
Geometry polygonGeometry = wktToGeometry(POLYGON_WKT);
assertFilterEquals(FF.beyond(TEST_PROPERTY_VALUE, polygonGeometry, DISTANCE_10, UomOgcMapping.METRE.name()));
}
use of org.opengis.geometry.Geometry in project ddf by codice.
the class FilterBuilderTest method withinGeoTest.
/**
*
*/
@Test
public void withinGeoTest() {
FilterBuilder builder = new GeotoolsFilterBuilder();
Filter filter = builder.attribute(Metacard.GEOGRAPHY).within().wkt(POINT_WKT);
filter.accept(new DefaultFilterVisitor() {
@Override
public Object visit(Within filter, Object data) {
Literal literalWrapper = (Literal) filter.getExpression2();
Geometry geometry = (Geometry) literalWrapper.evaluate(null);
geometry.getCentroid().getCoordinate();
return super.visit(filter, data);
}
}, null);
}
use of org.opengis.geometry.Geometry in project ddf by codice.
the class FilterAdapterTest method testSpatialWrappedGeometry.
@Test
public void testSpatialWrappedGeometry() throws com.vividsolutions.jts.io.ParseException {
WKTReader reader = new WKTReader();
com.vividsolutions.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("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("intersects(Test,wkt(" + MULTIPOLYGON_WKT + "))", FF.intersects(TEST_PROPERTY_VALUE, geometry));
assertFilterEquals("within(Test,wkt(" + MULTIPOLYGON_WKT + "))", FF.within(TEST_PROPERTY_VALUE, geometry));
}
Aggregations