use of org.geotools.geometry.text.WKTParser in project ddf by codice.
the class CopyFilterDelegateTest method wktToGeometry.
private Geometry wktToGeometry(String wkt) {
GeometryBuilder geometryBuilder = new GeometryBuilder(DefaultGeographicCRS.WGS84);
WKTParser wktParser = new WKTParser(geometryBuilder);
wktParser.setFactory(new PrimitiveFactoryImpl(DefaultGeographicCRS.WGS84));
Geometry geometry = null;
try {
geometry = wktParser.parse(wkt);
} catch (ParseException e) {
fail();
}
return geometry;
}
use of org.geotools.geometry.text.WKTParser 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]);
}
Aggregations