use of org.postgis.MultiPoint in project tests by datanucleus.
the class PgGeometryMappingTest method testMultiPointMapping.
public void testMultiPointMapping() throws SQLException {
if (!runTestsForDatastore()) {
return;
}
MultiPoint multipoint = new MultiPoint("SRID=4326;MULTIPOINT(10 10,75 75)");
SampleMultiPoint sampleMultiPoint;
SampleMultiPoint sampleMultiPoint_read;
PersistenceManager pm = pmf.getPersistenceManager();
Transaction tx = pm.currentTransaction();
Object id = null;
try {
tx.begin();
sampleMultiPoint = new SampleMultiPoint(4001, "MultiPoint", multipoint);
pm.makePersistent(sampleMultiPoint);
id = JDOHelper.getObjectId(sampleMultiPoint);
sampleMultiPoint = (SampleMultiPoint) pm.detachCopy(sampleMultiPoint);
tx.commit();
} finally {
if (tx.isActive()) {
tx.rollback();
}
pm.close();
}
pm = pmf.getPersistenceManager();
tx = pm.currentTransaction();
try {
tx.begin();
sampleMultiPoint_read = (SampleMultiPoint) pm.getObjectById(id, true);
assertEquals(sampleMultiPoint, sampleMultiPoint_read);
tx.commit();
} finally {
if (tx.isActive()) {
tx.rollback();
}
pm.close();
}
}
use of org.postgis.MultiPoint in project tests by datanucleus.
the class PgGeometrySpatialTest method testMPointFromWKB.
public void testMPointFromWKB() throws SQLException {
PersistenceManager pm = pmf.getPersistenceManager();
Transaction tx = pm.currentTransaction();
try {
tx.begin();
MultiPoint geom = new MultiPoint("SRID=4326;MULTIPOINT(10 10,75 75)");
Short n = new Short((short) 1);
Query query = pm.newQuery(SamplePoint.class, "geom != null && Spatial.equals(geom, Spatial.geometryN(Spatial.mPointFromWKB(Spatial.asBinary(:geom), Spatial.srid(:geom)), :n))");
List list = (List) query.execute(geom, n);
assertEquals("Wrong number of geometries with a given wkb returned", 1, list.size());
assertTrue("Point 1 should be in the list of geometries with a given wkb", list.contains(getSamplePoint(1)));
} finally {
tx.commit();
}
}
use of org.postgis.MultiPoint in project tests by datanucleus.
the class PgGeometrySpatialTest method testUnion.
@Datastore(POSTGRESQL)
public void testUnion() throws SQLException {
PersistenceManager pm = pmf.getPersistenceManager();
Transaction tx = pm.currentTransaction();
try {
tx.begin();
Point point = new Point("SRID=4326;POINT(50 50)");
MultiPoint union = new MultiPoint("SRID=4326;MULTIPOINT(10 10,50 50)");
Query query = pm.newQuery(SamplePoint.class, "geom != null && Spatial.asText(Spatial.union(geom, :point)) == Spatial.asText(:union)");
List list = (List) query.execute(point, union);
assertEquals("Wrong number of geometries whose union with a given point is equal to a given multipoint returned", 1, list.size());
assertTrue("Point 1 should be in the list of geometries whose union with a given point is equal to a given multipoint", list.contains(getSamplePoint(1)));
query = pm.newQuery(SamplePoint.class, "id == :id");
query.setResult("Spatial.union(geom, Spatial.geomFromText('POINT(50 50)', 4326))");
query.setUnique(true);
Geometry union_read = (Geometry) query.execute(new Long(getSamplePoint(1).getId()));
assertEquals("Returned union should be equal to the given multipoint", union, union_read);
} finally {
tx.commit();
}
}
Aggregations