use of org.postgis.Point in project tests by datanucleus.
the class PgGeometryMappingTest method testPointMapping.
public void testPointMapping() throws SQLException {
if (!runTestsForDatastore()) {
return;
}
Point point = new Point("SRID=4326;POINT(10 10)");
SamplePoint samplePoint;
SamplePoint samplePoint_read;
PersistenceManager pm = pmf.getPersistenceManager();
Transaction tx = pm.currentTransaction();
Object id = null;
try {
tx.begin();
samplePoint = new SamplePoint(1001, "Point 1", point);
pm.makePersistent(samplePoint);
id = JDOHelper.getObjectId(samplePoint);
samplePoint = (SamplePoint) pm.detachCopy(samplePoint);
tx.commit();
} finally {
if (tx.isActive()) {
tx.rollback();
}
pm.close();
}
pm = pmf.getPersistenceManager();
tx = pm.currentTransaction();
try {
tx.begin();
samplePoint_read = (SamplePoint) pm.getObjectById(id, true);
assertEquals(samplePoint, samplePoint_read);
tx.commit();
} finally {
if (tx.isActive()) {
tx.rollback();
}
pm.close();
}
}
use of org.postgis.Point in project tests by datanucleus.
the class PgGeometryMappingTest method testGeometryMapping.
public void testGeometryMapping() throws SQLException {
if (!runTestsForDatastore()) {
return;
}
Point point = new Point("SRID=4326;POINT(10 10)");
SampleGeometry sampleGeometry;
SampleGeometry sampleGeometry_read;
PersistenceManager pm = pmf.getPersistenceManager();
Transaction tx = pm.currentTransaction();
Object id = null;
try {
tx.begin();
sampleGeometry = new SampleGeometry(1001, "Geometry (Point)", point);
pm.makePersistent(sampleGeometry);
id = JDOHelper.getObjectId(sampleGeometry);
sampleGeometry = (SampleGeometry) pm.detachCopy(sampleGeometry);
tx.commit();
} finally {
if (tx.isActive()) {
tx.rollback();
}
pm.close();
}
pm = pmf.getPersistenceManager();
tx = pm.currentTransaction();
try {
tx.begin();
sampleGeometry_read = (SampleGeometry) pm.getObjectById(id, true);
assertEquals(sampleGeometry, sampleGeometry_read);
tx.commit();
} finally {
if (tx.isActive()) {
tx.rollback();
}
pm.close();
}
}
use of org.postgis.Point in project tests by datanucleus.
the class PgGeometryMySQLTest method testMbrWithin.
public void testMbrWithin() throws SQLException {
if (!runTestsForDatastore()) {
return;
}
PersistenceManager pm = pmf.getPersistenceManager();
Transaction tx = pm.currentTransaction();
try {
tx.begin();
Point point = new Point("SRID=4326;POINT(30 30)");
Query query = pm.newQuery(SamplePolygon.class, "geom != null && MySQL.mbrWithin(:point, geom)");
List list = (List) query.execute(point);
assertEquals("Wrong number of geometries where a given point is within returned", 1, list.size());
assertTrue("Polygon 1 should be in the list of geometries where a given point is within", list.contains(getSamplePolygon(1)));
} finally {
tx.commit();
}
}
use of org.postgis.Point in project tests by datanucleus.
the class PgGeometryMySQLTest method testMbrTouches.
public void testMbrTouches() throws SQLException {
if (!runTestsForDatastore()) {
return;
}
PersistenceManager pm = pmf.getPersistenceManager();
Transaction tx = pm.currentTransaction();
try {
tx.begin();
Point point = new Point("SRID=4326;POINT(75 75)");
Query query = pm.newQuery(SamplePolygon.class, "geom != null && MySQL.mbrTouches(:point, geom)");
List list = (List) query.execute(point);
assertEquals("Wrong number of geometries which are touched by a given point returned", 2, list.size());
assertTrue("Polygon 1 should be in the list of geometries which are touched by a given point", list.contains(getSamplePolygon(1)));
assertTrue("Polygon 2 should be in the list of geometries which are touched by a given point", list.contains(getSamplePolygon(2)));
} finally {
tx.commit();
}
}
use of org.postgis.Point in project tests by datanucleus.
the class PgGeometryMySQLTest method testMbrContains.
public void testMbrContains() throws SQLException {
if (!runTestsForDatastore()) {
return;
}
PersistenceManager pm = pmf.getPersistenceManager();
Transaction tx = pm.currentTransaction();
try {
tx.begin();
Point point = new Point("SRID=4326;POINT(30 30)");
Query query = pm.newQuery(SamplePolygon.class, "geom != null && MySQL.mbrContains(geom, :point)");
List list = (List) query.execute(point);
assertEquals("Wrong number of geometries which contain a given point returned", 1, list.size());
assertTrue("Polygon 1 should be in the list of geometries which contain a given point", list.contains(getSamplePolygon(1)));
} finally {
tx.commit();
}
}
Aggregations