use of com.vividsolutions.jts.geom.Geometry in project ddf by codice.
the class TestWfs10JTStoGML200Converter method testTwo.
@Test
public void testTwo() throws Exception {
Geometry geometryFromWkt = getGeometryFromWkt(GEOMETRYCOLLECTION);
String gml = Wfs10JTStoGML200Converter.convertGeometryCollectionToGML(geometryFromWkt);
GeometryCollectionType geometryCollectionType = (GeometryCollectionType) Wfs10JTStoGML200Converter.convertGMLToGeometryType(gml, Wfs10Constants.GEOMETRY_COLLECTION);
JAXBElement<GeometryCollectionType> jaxbElement = (JAXBElement<GeometryCollectionType>) Wfs10JTStoGML200Converter.convertGeometryTypeToJAXB(geometryCollectionType);
assertFalse(jaxbElement == null);
}
use of com.vividsolutions.jts.geom.Geometry in project ddf by codice.
the class GeoJsonMetacardTransformer method convertValue.
private static Object convertValue(Serializable value, AttributeType.AttributeFormat format) throws CatalogTransformerException {
if (value == null) {
return null;
}
switch(format) {
case BOOLEAN:
return value;
case DATE:
SimpleDateFormat dateFormat = new SimpleDateFormat(ISO_8601_DATE_FORMAT);
dateFormat.setTimeZone(TimeZone.getTimeZone("GMT"));
return dateFormat.format((Date) value);
case BINARY:
byte[] bytes = (byte[]) value;
String base64 = DatatypeConverter.printBase64Binary(bytes);
return base64;
case DOUBLE:
case LONG:
case FLOAT:
case INTEGER:
case SHORT:
case STRING:
case XML:
return value.toString();
case GEOMETRY:
WKTReader reader = new WKTReader();
try {
Geometry geometry = reader.read(value.toString());
CompositeGeometry geoJsonGeometry = CompositeGeometry.getCompositeGeometry(geometry);
if (geoJsonGeometry == null) {
throw new CatalogTransformerException("Could not perform transform: unsupported geometry [" + value + "]");
}
return geoJsonGeometry.toJsonMap();
} catch (ParseException e) {
throw new CatalogTransformerException("Could not perform transform: could not parse geometry [" + value + "]", e);
}
case OBJECT:
default:
return null;
}
}
use of com.vividsolutions.jts.geom.Geometry in project ddf by codice.
the class TestGeoJsonInputTransformer method testLineStringGeo.
@Test
public void testLineStringGeo() throws IOException, CatalogTransformerException, ParseException {
InputStream inputStream = new ByteArrayInputStream(sampleLineStringJsonText().getBytes());
Metacard metacard = transformer.transform(inputStream);
verifyBasics(metacard);
WKTReader reader = new WKTReader();
Geometry geometry = reader.read(metacard.getLocation());
Coordinate[] coords = geometry.getCoordinates();
assertThat(coords[0].x, is(30.0));
assertThat(coords[0].y, is(10.0));
assertThat(coords[1].x, is(10.0));
assertThat(coords[1].y, is(30.0));
assertThat(coords[2].x, is(40.0));
assertThat(coords[2].y, is(40.0));
}
use of com.vividsolutions.jts.geom.Geometry in project ddf by codice.
the class OverlayMetacardTransformer method parseBoundary.
private List<Vector> parseBoundary(String location) throws CatalogTransformerException {
final Geometry geometry = parseGeometry(location);
if (!canHandleGeometry(geometry)) {
throw new CatalogTransformerException("The Image boundary is not a rectangle");
}
final Coordinate[] coordinates = geometry.getCoordinates();
List<Vector> boundary = new ArrayList<>();
// Using indices rather than for-each because the first coordinate is duplicated.
for (int i = 0; i < 4; i++) {
boundary.add(new BasicVector(new double[] { coordinates[i].x, coordinates[i].y }));
}
return boundary;
}
use of com.vividsolutions.jts.geom.Geometry in project ddf by codice.
the class PredicateTest method testGeospatialEvaluatorPointRadiusNotContains.
@Test
public void testGeospatialEvaluatorPointRadiusNotContains() throws Exception {
LOGGER.debug("************************** START: testGeospatialEvaluator_PointRadius_NotContains() ***********************");
// WKT specifies points in LON LAT order
String geometryWkt = "POINT (44.5 34.5)";
String operation = "point_radius";
double distance = 5000.0;
double radiusInDegrees = (distance * 180.0) / (Math.PI * EQUATORIAL_RADIUS_IN_METERS);
GeospatialPredicate predicate = new GeospatialPredicate(geometryWkt, operation, radiusInDegrees);
Geometry geoCriteria = predicate.getGeoCriteria();
LOGGER.debug("geoCriteria.toText() {}", geoCriteria.toText());
String geospatialXml = "<gml:Polygon xmlns:gml=\"http://www.opengis.net/gml\" gml:id=\"BGE-1\">\n" + " <gml:exterior>\n" + " <gml:LinearRing>\n" + " <gml:pos>24.0 22.0</gml:pos>\n" + " <gml:pos>23.0 22.0</gml:pos>\n" + " <gml:pos>23.0 24.0</gml:pos>\n" + " <gml:pos>24.0 24.0</gml:pos>\n" + " <gml:pos>24.0 22.0</gml:pos>\n" + " </gml:LinearRing>\n" + " </gml:exterior>\n" + "</gml:Polygon>";
Geometry input = GeospatialEvaluator.buildGeometry(geospatialXml);
LOGGER.debug("input.toText() = {}", input.toText());
GeospatialEvaluationCriteria gec = new GeospatialEvaluationCriteriaImpl(geoCriteria, operation, input, radiusInDegrees);
boolean status = GeospatialEvaluator.evaluate(gec);
assertFalse(status);
LOGGER.debug("************************** END: testGeospatialEvaluator_PointRadius_NotContains() ***********************");
}
Aggregations