use of oracle.spatial.geometry.JGeometry in project tests by datanucleus.
the class JGeometrySpatialTest method testContains.
public void testContains() throws SQLException {
PersistenceManager pm = pmf.getPersistenceManager();
Transaction tx = pm.currentTransaction();
try {
tx.begin();
JGeometry point = new JGeometry(30.0, 30.0, 4326);
Query query = pm.newQuery(SampleGeometry.class, "id > 3000 && id < 4000 && Spatial.contains(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();
}
}
use of oracle.spatial.geometry.JGeometry in project tests by datanucleus.
the class JGeometrySpatialTest method testGeometryN.
public void testGeometryN() throws SQLException {
PersistenceManager pm = pmf.getPersistenceManager();
Transaction tx = pm.currentTransaction();
try {
tx.begin();
Query query = pm.newQuery(SampleGeometry.class, "id > 7000 && id < 8000 && Spatial.geometryType(Spatial.geometryN(geom, 1)).toUpperCase() == 'ST_POINT'");
List list = (List) query.execute();
assertEquals("Wrong number of collections whose first geometry is equal to a given point returned", 2, list.size());
assertTrue("Collection 1 should be in the list of collections whose first geometry is a point", list.contains(getSampleGeometryCollection(2)));
assertTrue("Collection 2 should be in the list of collections whose first geometry is a point", list.contains(getSampleGeometryCollection(2)));
query = pm.newQuery(SampleGeometry.class, "id == :id");
query.setResult("Spatial.geometryN(geom, 1)");
query.setUnique(true);
JGeometry point_read = (JGeometry) query.execute(new Long(getSampleGeometryCollection(2).getId()));
assertTrue("First geometry of Collection 2 should be a point", point_read.getType() == JGeometry.GTYPE_POINT);
} finally {
tx.commit();
}
}
use of oracle.spatial.geometry.JGeometry in project tests by datanucleus.
the class JGeometrySpatialTest method testDisjoint.
public void testDisjoint() throws SQLException {
PersistenceManager pm = pmf.getPersistenceManager();
Transaction tx = pm.currentTransaction();
try {
tx.begin();
JGeometry polygon = JGeometry.createLinearPolygon(new Object[] { new double[] { 10.0, 10.0, 40.0, 10.0, 40.0, 40.0, 10.0, 40.0, 10.0, 10.0 } }, 2, 4326);
Query query = pm.newQuery(SampleGeometry.class, "id > 3000 && id < 4000 && Spatial.disjoint(geom, :polygon)");
List list = (List) query.execute(polygon);
assertEquals("Wrong number of geometries which are disjoint from a given polygon returned", 1, list.size());
assertTrue("Polygon 2 should be in the list of geometries which are disjoint from a given polygon", list.contains(getSamplePolygon(2)));
} finally {
tx.commit();
}
}
use of oracle.spatial.geometry.JGeometry in project tests by datanucleus.
the class JGeometrySpatialTest method testPointOnSurfaceMethod.
public void testPointOnSurfaceMethod() throws SQLException {
PersistenceManager pm = pmf.getPersistenceManager();
Transaction tx = pm.currentTransaction();
try {
tx.begin();
double tolerance = 0.005;
Query query = pm.newQuery(SampleGeometry.class, "id > 3000 && id < 4000 && Spatial.pointOnSurface(geom, :tolerance) != null");
List list = (List) query.execute(tolerance);
assertEquals("Wrong number of geometries with a point on the surface returned", 2, list.size());
assertTrue("Polygon 1 should be in the list of geometries with a point on the surface", list.contains(getSamplePolygon(1)));
assertTrue("Polygon 2 should be in the list of geometries with a point on the surface", list.contains(getSamplePolygon(2)));
query = pm.newQuery(SampleGeometry.class, "id == :id");
query.setResult("Spatial.pointOnSurface(geom, 0.005)");
query.setUnique(true);
JGeometry pointOnSurface = (JGeometry) query.execute(new Long(getSamplePolygon(1).getId()));
assertNotNull("Polygon 1 should have a point on the surface", pointOnSurface);
assertTrue("Returned geometry should be a point", pointOnSurface.getType() == JGeometry.GTYPE_POINT);
} finally {
tx.commit();
}
}
use of oracle.spatial.geometry.JGeometry in project tests by datanucleus.
the class JGeometrySpatialTest method testEndPoint.
public void testEndPoint() throws SQLException {
PersistenceManager pm = pmf.getPersistenceManager();
Transaction tx = pm.currentTransaction();
try {
tx.begin();
JGeometry point = new JGeometry(110.0, 45.0, 4326);
Query query = pm.newQuery(SampleGeometry.class, "id > 2000 && id < 3000 && Spatial.equals(Spatial.endPoint(geom), :point)");
List list = (List) query.execute(point);
assertEquals("Wrong number of geometries with a given end point returned", 1, list.size());
assertTrue("LineString 3 should be in the list of geometries with a given end point", list.contains(getSampleLineString(3)));
query = pm.newQuery(SampleGeometry.class, "id == :id");
query.setResult("Spatial.endPoint(geom)");
query.setUnique(true);
JGeometry point_read = (JGeometry) query.execute(new Long(getSampleLineString(3).getId()));
assertEquals("Returned end point should be equal to the given point", point, point_read);
} finally {
tx.commit();
}
}
Aggregations