use of org.geotools.geometry.GeometryBuilder in project ddf by codice.
the class OpenSearchQueryTest method testWktParserPolygon.
@Test
@Ignore
public void testWktParserPolygon() throws Exception {
String geometryWkt = "POLYGON(( 0 10, 0 30, 20 30, 20 10, 0 10 ))";
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);
double[] coords = geometry.getCentroid().getCoordinate();
LOGGER.debug("coords[0] = {}, coords[1] = {}", coords[0], coords[1]);
// String geometryWkt2 = "POINT( 10 20 )";
String geometryWkt2 = "POLYGON(( 10 15, 10 25, 15 25, 15 15, 10 15 ))";
builder = new GeometryBuilder(DefaultGeographicCRS.WGS84);
WKTParser parser2 = new WKTParser(builder);
// This fixed the NPE in parser.parse() - seems GeoTools has bug with
// keeping the CRS hint set ...
parser2.setFactory(new PrimitiveFactoryImpl(DefaultGeographicCRS.WGS84));
Geometry geometry2 = parser2.parse(geometryWkt2);
double[] coords2 = geometry2.getCentroid().getCoordinate();
LOGGER.debug("coords[0] = {}, coords[1] = {}", coords2[0], coords2[1]);
// This fails - why?
assertTrue(geometry.contains(geometry2));
}
use of org.geotools.geometry.GeometryBuilder 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