use of org.datanucleus.samples.jtsgeometry.SampleGeometryCollection3D in project tests by datanucleus.
the class JtsGeometry3dMappingTest method testGeometryCollection3DMapping.
public void testGeometryCollection3DMapping() throws SQLException, ParseException {
if (!runTestsForDatastore()) {
return;
}
SampleGeometryCollection3D sampleGeometryCollection;
SampleGeometryCollection3D sampleGeometryCollection_read;
PersistenceManager pm = pmf.getPersistenceManager();
Transaction tx = pm.currentTransaction();
Object id = null;
try {
Point point = geomFactory.createPoint(new Coordinate(10.0, 10.0, 100.0));
LineString linestring = geomFactory.createLineString(new Coordinate[] { new Coordinate(0.0, 50.0, 100.0), new Coordinate(100.0, 50.0, 100.0) });
LinearRing extRing = geomFactory.createLinearRing(new Coordinate[] { new Coordinate(25.0, 25.0, 100), new Coordinate(75.0, 25.0, 100.0), new Coordinate(75.0, 75.0, 100.0), new Coordinate(25.0, 75.0, 100.0), new Coordinate(25.0, 25.0, 100) });
Polygon polygon = geomFactory.createPolygon(extRing, null);
GeometryCollection collection = geomFactory.createGeometryCollection(new Geometry[] { point, linestring, polygon });
sampleGeometryCollection = new SampleGeometryCollection3D(7101, "Collection of 3-dimensional geometries", collection);
pm.makePersistent(sampleGeometryCollection);
id = JDOHelper.getObjectId(sampleGeometryCollection);
sampleGeometryCollection = (SampleGeometryCollection3D) pm.detachCopy(sampleGeometryCollection);
tx.commit();
} finally {
if (tx.isActive()) {
tx.rollback();
}
pm.close();
}
pm = pmf.getPersistenceManager();
tx = pm.currentTransaction();
try {
tx.begin();
sampleGeometryCollection_read = (SampleGeometryCollection3D) pm.getObjectById(id, true);
assertEquals(sampleGeometryCollection, sampleGeometryCollection_read);
tx.commit();
} finally {
if (tx.isActive()) {
tx.rollback();
}
pm.close();
}
}
Aggregations