use of oracle.spatial.geometry.JGeometry in project tests by datanucleus.
the class JGeometrySpatialTest method testCrosses.
public void testCrosses() throws SQLException {
PersistenceManager pm = pmf.getPersistenceManager();
Transaction tx = pm.currentTransaction();
try {
tx.begin();
JGeometry lineString = JGeometry.createLinearLineString(new double[] { 25.0, 25.0, 25.0, 75.0 }, 2, 4326);
Query query = pm.newQuery(SampleGeometry.class, "id > 2000 && id < 3000 && Spatial.crosses(geom, :lineString)");
List list = (List) query.execute(lineString);
assertEquals("Wrong number of geometries which are crossed by a given linestring returned", 1, list.size());
assertTrue("LineString 1 should be in the list of geometries which are crossed by a given linestring", list.contains(getSampleLineString(1)));
} finally {
tx.commit();
}
}
use of oracle.spatial.geometry.JGeometry in project tests by datanucleus.
the class JGeometrySpatialTest method testTouches.
public void testTouches() throws SQLException {
PersistenceManager pm = pmf.getPersistenceManager();
Transaction tx = pm.currentTransaction();
try {
tx.begin();
JGeometry point = new JGeometry(75.0, 75.0, 4326);
Query query = pm.newQuery(SampleGeometry.class, "id > 3000 && id < 4000 && Spatial.touches(: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 oracle.spatial.geometry.JGeometry in project tests by datanucleus.
the class JGeometry3dMMappingTest method testPoint3DMapping.
public void testPoint3DMapping() throws SQLException {
if (!runTestsForDatastore()) {
return;
}
JGeometry point = new JGeometry(10.0, 10.0, 100.0, 4326);
SampleGeometryM samplePoint;
SampleGeometryM samplePoint_read;
PersistenceManager pm = pmf.getPersistenceManager();
Transaction tx = pm.currentTransaction();
Object id = null;
try {
tx.begin();
samplePoint = new SampleGeometryM(1201, "Point 3D", point);
pm.makePersistent(samplePoint);
id = JDOHelper.getObjectId(samplePoint);
samplePoint = (SampleGeometryM) pm.detachCopy(samplePoint);
tx.commit();
} finally {
if (tx.isActive()) {
tx.rollback();
}
pm.close();
}
pm = pmf.getPersistenceManager();
tx = pm.currentTransaction();
try {
tx.begin();
samplePoint_read = (SampleGeometryM) pm.getObjectById(id, true);
assertEquals(samplePoint, samplePoint_read);
tx.commit();
} finally {
if (tx.isActive()) {
tx.rollback();
}
pm.close();
}
}
use of oracle.spatial.geometry.JGeometry in project tests by datanucleus.
the class JGeometry3dMMappingTest method testPointMMapping.
public void testPointMMapping() throws SQLException {
if (!runTestsForDatastore()) {
return;
}
// point with measure in third dimension
int gtype = 3301;
int srid = 4326;
int[] elemInfo = { 1, 1, 1 };
double[] ordinates = { 10.0, 10.0, 100.0 };
JGeometry point = new JGeometry(gtype, srid, elemInfo, ordinates);
SampleGeometry3D samplePoint;
SampleGeometry3D samplePoint_read;
PersistenceManager pm = pmf.getPersistenceManager();
Transaction tx = pm.currentTransaction();
Object id = null;
try {
tx.begin();
samplePoint = new SampleGeometry3D(1101, "Point with measure", point);
pm.makePersistent(samplePoint);
id = JDOHelper.getObjectId(samplePoint);
samplePoint = (SampleGeometry3D) pm.detachCopy(samplePoint);
tx.commit();
} finally {
if (tx.isActive()) {
tx.rollback();
}
pm.close();
}
pm = pmf.getPersistenceManager();
tx = pm.currentTransaction();
try {
tx.begin();
samplePoint_read = (SampleGeometry3D) pm.getObjectById(id, true);
assertEquals(samplePoint, samplePoint_read);
tx.commit();
} finally {
if (tx.isActive()) {
tx.rollback();
}
pm.close();
}
}
use of oracle.spatial.geometry.JGeometry in project tests by datanucleus.
the class JGeometryMappingTest method testMultiPointMapping.
public void testMultiPointMapping() throws SQLException {
if (!runTestsForDatastore()) {
return;
}
JGeometry multipoint = JGeometry.createMultiPoint(new Object[] { new double[] { 10, 10 }, new double[] { 75, 75 } }, 2, 4326);
SampleGeometry sampleMultiPoint;
SampleGeometry sampleMultiPoint_read;
PersistenceManager pm = pmf.getPersistenceManager();
Transaction tx = pm.currentTransaction();
Object id = null;
try {
tx.begin();
sampleMultiPoint = new SampleGeometry(4001, "MultiPoint", multipoint);
pm.makePersistent(sampleMultiPoint);
id = JDOHelper.getObjectId(sampleMultiPoint);
sampleMultiPoint = (SampleGeometry) pm.detachCopy(sampleMultiPoint);
tx.commit();
} finally {
if (tx.isActive()) {
tx.rollback();
}
pm.close();
}
pm = pmf.getPersistenceManager();
tx = pm.currentTransaction();
try {
tx.begin();
sampleMultiPoint_read = (SampleGeometry) pm.getObjectById(id, true);
assertEquals(sampleMultiPoint, sampleMultiPoint_read);
tx.commit();
} finally {
if (tx.isActive()) {
tx.rollback();
}
pm.close();
}
}
Aggregations