use of oracle.spatial.geometry.JGeometry in project tests by datanucleus.
the class JGeometrySpatialTest method testGeomCollFromWKB.
public void testGeomCollFromWKB() throws SQLException {
PersistenceManager pm = pmf.getPersistenceManager();
Transaction tx = pm.currentTransaction();
try {
tx.begin();
int gtype = JGeometry.GTYPE_COLLECTION;
int srid = 4326;
int[] elemInfo = { 1, 1, 1, 3, 2, 1, 7, 1003, 1 };
double[] ordinates = { 10.0, 10.0, 0.0, 50.0, 100.0, 50.0, 25.0, 25.0, 75.0, 25.0, 75.0, 75.0, 25.0, 75.0, 25.0, 25.0 };
JGeometry geom = new JGeometry(gtype, srid, elemInfo, ordinates);
Query query = pm.newQuery(SampleGeometry.class, "id > 7000 && id < 8000 && Spatial.equals(geom, Spatial.geomCollFromWKB(Spatial.asBinary(:geom), Spatial.srid(:geom)))");
List list = (List) query.execute(geom);
assertEquals("Wrong number of geometries with a given wkb returned", 1, list.size());
assertTrue("Collection 1 should be in the list of geometries with a given wkb", list.contains(getSampleGeometryCollection(1)));
} finally {
tx.commit();
}
}
use of oracle.spatial.geometry.JGeometry in project tests by datanucleus.
the class JGeometrySpatialTest method testEquals.
public void testEquals() throws SQLException {
PersistenceManager pm = pmf.getPersistenceManager();
Transaction tx = pm.currentTransaction();
try {
tx.begin();
JGeometry polygon = JGeometry.createLinearPolygon(new Object[] { new double[] { 75.0, 75.0, 100.0, 75.0, 100.0, 100.0, 75.0, 75.0 } }, 2, 4326);
Query query = pm.newQuery(SampleGeometry.class, "id > 3000 && id < 4000 && Spatial.equals(geom, :polygon)");
List list = (List) query.execute(polygon);
assertEquals("Wrong number of geometries which are equal to a given polygon returned", 1, list.size());
assertTrue("Polygon 2 should be in the list of geometries which are equal to 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 testCentroid.
public void testCentroid() throws SQLException {
PersistenceManager pm = pmf.getPersistenceManager();
Transaction tx = pm.currentTransaction();
try {
tx.begin();
Query query = pm.newQuery(SampleGeometry.class, "id > 3000 && id < 4000 && Spatial.centroid(geom) != null");
List list = (List) query.execute();
assertEquals("Wrong number of geometries whith have a centroid returned", 2, list.size());
assertTrue("Polygon 1 should be in the list of geometries with a centroid", list.contains(getSamplePolygon(1)));
assertTrue("Polygon 2 should be in the list of geometries with a centroid", list.contains(getSamplePolygon(2)));
query = pm.newQuery(SampleGeometry.class, "id == :id");
query.setResult("Spatial.centroid(geom)");
query.setUnique(true);
JGeometry centroid_read = (JGeometry) query.execute(new Long(getSamplePolygon(1).getId()));
assertTrue("Centroid of Polygon 1 should be a point", centroid_read.getType() == JGeometry.GTYPE_POINT);
} finally {
tx.commit();
}
}
use of oracle.spatial.geometry.JGeometry in project tests by datanucleus.
the class JGeometrySpatialTest method testConvexHull.
public void testConvexHull() throws SQLException {
PersistenceManager pm = pmf.getPersistenceManager();
Transaction tx = pm.currentTransaction();
try {
tx.begin();
Query query = pm.newQuery(SampleGeometry.class, "id > 2000 && id < 3000 && !Spatial.isEmpty(Spatial.convexHull(geom))");
List list = (List) query.execute();
assertEquals("Wrong number of geometries for which a convex hull can be calculated returned", 1, list.size());
assertTrue("LineSting 3 should be in the list of geometries with a given convex hull", list.contains(getSampleLineString(3)));
query = pm.newQuery(SampleGeometry.class, "id == :id");
query.setResult("Spatial.convexHull(geom)");
query.setUnique(true);
JGeometry convexHull_read = (JGeometry) query.execute(new Long(getSampleLineString(3).getId()));
assertEquals("Returned convex hull should be of type polygon", JGeometry.GTYPE_POLYGON, convexHull_read.getType());
} finally {
tx.commit();
}
}
use of oracle.spatial.geometry.JGeometry in project tests by datanucleus.
the class JGeometrySpatialTest method testLineFromWKB.
public void testLineFromWKB() throws SQLException {
PersistenceManager pm = pmf.getPersistenceManager();
Transaction tx = pm.currentTransaction();
try {
tx.begin();
JGeometry geom = JGeometry.createLinearLineString(new double[] { 0, 50, 100, 50 }, 2, 4326);
Query query = pm.newQuery(SampleGeometry.class, "geom != null && Spatial.equals(geom, Spatial.lineFromWKB(Spatial.asBinary(:geom), Spatial.srid(:geom)))");
List list = (List) query.execute(geom);
assertEquals("Wrong number of geometries with a given wkb returned", 1, list.size());
assertTrue("LineString 1 should be in the list of geometries with a given wkb", list.contains(getSampleLineString(1)));
} finally {
tx.commit();
}
}
Aggregations