use of org.postgis.Geometry in project tests by datanucleus.
the class PgGeometrySpatialTest method testBoundary.
@Datastore(POSTGRESQL)
public void testBoundary() throws SQLException {
PersistenceManager pm = pmf.getPersistenceManager();
Transaction tx = pm.currentTransaction();
try {
tx.begin();
LineString boundary = new LineString("SRID=4326;LINESTRING(75 75,100 75,100 100,75 75)");
Query query = pm.newQuery(SamplePolygon.class, "geom != null && Spatial.equals(Spatial.boundary(geom), :boundary)");
List list = (List) query.execute(boundary);
assertEquals("Wrong number of geometries with a given boundary returned", 1, list.size());
assertTrue("Polygon 2 should be in the list of geometries with a given boundary", list.contains(getSamplePolygon(2)));
query = pm.newQuery(SamplePolygon.class, "id == :id");
query.setResult("Spatial.boundary(geom)");
query.setUnique(true);
Geometry boundary_read = (Geometry) query.execute(new Long(getSamplePolygon(2).getId()));
assertEquals("Boundary of Polygon 2 should be equal to a given boundary", boundary, boundary_read);
} finally {
tx.commit();
}
}
Aggregations