use of oracle.spatial.geometry.JGeometry in project tests by datanucleus.
the class JGeometrySpatialTest method testBboxTest.
public void testBboxTest() throws SQLException {
PersistenceManager pm = pmf.getPersistenceManager();
Transaction tx = pm.currentTransaction();
try {
tx.begin();
JGeometry polygon = JGeometry.createLinearPolygon(new Object[] { new double[] { 86.0, 76.0, 120.0, 86.0, 120.0, 120.0, 86.0, 76.0 } }, 2, 4326);
Double tolerance = 0.005;
Query query = pm.newQuery(SampleGeometry.class, "id > 3000 && id < 4000 && Spatial.bboxTest(geom, :polygon, :tolerance)");
List list = (List) query.execute(polygon, tolerance);
assertEquals("Wrong number of geometries which pass the bbox test with a given point returned", 1, list.size());
assertTrue("Polygon 2 should be in the list of geometries which pass the bbox test with a given point", list.contains(getSamplePolygon(2)));
JGeometry polygon2 = JGeometry.createLinearPolygon(new Object[] { new double[] { 75.0, 75.0, 100.0, 75.0, 100.0, 55.0, 75.0, 75.0 } }, 2, 4326);
list = (List) query.execute(polygon2, tolerance);
assertEquals("Intersecting polygons should not be validated as a valid bboxtest", 0, list.size());
} finally {
tx.commit();
}
}
use of oracle.spatial.geometry.JGeometry in project tests by datanucleus.
the class JGeometrySpatialTest method testPolyFromWKB.
public void testPolyFromWKB() throws SQLException {
PersistenceManager pm = pmf.getPersistenceManager();
Transaction tx = pm.currentTransaction();
try {
tx.begin();
JGeometry geom = JGeometry.createLinearPolygon(new Object[] { new double[] { 75, 75, 100, 75, 100, 100, 75, 75 } }, 2, 4326);
Query query = pm.newQuery(SampleGeometry.class, "geom != null && Spatial.equals(geom, Spatial.polyFromWKB(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("Polygon 2 should be in the list of geometries with a given wkb", list.contains(getSamplePolygon(2)));
} finally {
tx.commit();
}
}
use of oracle.spatial.geometry.JGeometry in project tests by datanucleus.
the class JGeometrySpatialTest method testIntersection.
public void testIntersection() 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.intersection(geom, :lineString) != null");
List list = (List) query.execute(lineString);
assertEquals("Wrong number of geometries which intersect a given linestring returned", 1, list.size());
assertTrue("LineSting 1 should be in the list of geometries which intersect a given linestring", list.contains(getSampleLineString(1)));
query = pm.newQuery(SampleGeometry.class, "id == :id");
query.setResult("Spatial.intersection(geom, Spatial.geomFromText('LINESTRING(25.0 25.0, 25.0 75.0)', 4326))");
query.setUnique(true);
JGeometry intersection_read = (JGeometry) query.execute(new Long(getSampleLineString(1).getId()));
assertTrue("Returned intersection should be equal to the given point", intersection_read.getType() == JGeometry.GTYPE_POINT);
} finally {
tx.commit();
}
}
use of oracle.spatial.geometry.JGeometry in project tests by datanucleus.
the class JGeometrySpatialTest method testPointFromWKB.
public void testPointFromWKB() throws SQLException {
PersistenceManager pm = pmf.getPersistenceManager();
Transaction tx = pm.currentTransaction();
try {
tx.begin();
JGeometry geom = new JGeometry(75.0, 75.0, 4326);
Query query = pm.newQuery(SampleGeometry.class, "geom != null && Spatial.equals(geom, Spatial.pointFromWKB(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("Point 2 should be in the list of geometries with a given wkb", list.contains(getSamplePoint(2)));
} finally {
tx.commit();
}
}
use of oracle.spatial.geometry.JGeometry in project tests by datanucleus.
the class JGeometrySpatialTest method testUnion.
public void testUnion() throws SQLException {
PersistenceManager pm = pmf.getPersistenceManager();
Transaction tx = pm.currentTransaction();
try {
tx.begin();
JGeometry point = new JGeometry(50.0, 50.0, 4326);
Query query = pm.newQuery(SampleGeometry.class, "id > 1000 && id < 2000 && Spatial.union(geom, :point) != null");
List list = (List) query.execute(point);
assertEquals("Wrong number of geometries which can union with a given point returned", 2, list.size());
assertTrue("Point 1 should be in the list of geometries which can union with a given point", list.contains(getSamplePoint(1)));
assertTrue("Point 2 should be in the list of geometries which can union with a given point", list.contains(getSamplePoint(2)));
query = pm.newQuery(SampleGeometry.class, "id == :id");
query.setResult("Spatial.union(geom, Spatial.geomFromText('POINT(50.0 50.0)', 4326))");
query.setUnique(true);
JGeometry union_read = (JGeometry) query.execute(new Long(getSamplePoint(1).getId()));
assertTrue("Returned union should be a multipoint", union_read.getType() == JGeometry.GTYPE_MULTIPOINT);
} finally {
tx.commit();
}
}
Aggregations