use of com.vividsolutions.jts.geom.Geometry in project hibernate-orm by hibernate.
the class GeometryEquality method test.
private boolean test(Geometry geom1, Geometry geom2, boolean ignoreSRID) {
if (geom1 == null) {
return geom2 == null;
}
if (geom1.isEmpty()) {
return geom2.isEmpty();
}
if (!ignoreSRID && !equalSRID(geom1, geom2)) {
return false;
}
if (geom1 instanceof GeometryCollection) {
if (!(geom2 instanceof GeometryCollection)) {
return false;
}
GeometryCollection expectedCollection = (GeometryCollection) geom1;
GeometryCollection receivedCollection = (GeometryCollection) geom2;
for (int partIndex = 0; partIndex < expectedCollection.getNumGeometries(); partIndex++) {
Geometry partExpected = expectedCollection.getGeometryN(partIndex);
Geometry partReceived = receivedCollection.getGeometryN(partIndex);
if (!test(partExpected, partReceived, true)) {
return false;
}
}
return true;
} else {
return testSimpleGeometryEquality(geom1, geom2);
}
}
use of com.vividsolutions.jts.geom.Geometry in project hibernate-orm by hibernate.
the class TestStoreRetrieveUsingJTS method retrieveAndCompare.
private void retrieveAndCompare(Map<Integer, GeomEntity> stored) {
int id = -1;
Transaction tx = null;
Session session = null;
try {
session = openSession();
tx = session.beginTransaction();
for (GeomEntity storedEntity : stored.values()) {
id = storedEntity.getId();
GeomEntity retrievedEntity = (GeomEntity) session.get(GeomEntity.class, id);
Geometry retrievedGeometry = retrievedEntity.getGeom();
Geometry storedGeometry = storedEntity.getGeom();
String msg = createFailureMessage(storedEntity.getId(), storedGeometry, retrievedGeometry);
assertTrue(msg, geometryEquality.test(storedGeometry, retrievedGeometry));
}
tx.commit();
} catch (Exception e) {
if (tx != null) {
tx.rollback();
}
throw new RuntimeException(String.format("Failure on case: %d", id), e);
} finally {
if (session != null) {
session.close();
}
}
}
use of com.vividsolutions.jts.geom.Geometry in project series-rest-api by 52North.
the class FeatureOutputSerializer method encodeGeometry.
private Object encodeGeometry(GeoJSONFeature value) {
try {
final GeoJSONEncoder enc = new GeoJSONEncoder();
final Geometry geometry = value.getGeometry();
return enc.encodeGeometry(geometry);
} catch (GeoJSONException e) {
LOGGER.error("could not properly encode geometry.", e);
return null;
}
}
use of com.vividsolutions.jts.geom.Geometry in project series-rest-api by 52North.
the class TransformingGeometryOutputService method transformInline.
private void transformInline(IoParameters query, GeometryInfo info) {
Geometry geometry = info.getGeometry();
info.setGeometry(transformationService.transform(geometry, query));
}
use of com.vividsolutions.jts.geom.Geometry in project series-rest-api by 52North.
the class TransformingPlatformOutputService method transformInline.
private void transformInline(IoParameters query, PlatformOutput platform) {
Geometry geometry = platform.getGeometry();
platform.setGeometry(transformationService.transform(geometry, query));
}
Aggregations