use of oracle.spatial.geometry.JGeometry in project tests by datanucleus.
the class JGeometrySpatialTest method testMPointFromWKB.
public void testMPointFromWKB() throws SQLException {
PersistenceManager pm = pmf.getPersistenceManager();
Transaction tx = pm.currentTransaction();
try {
tx.begin();
JGeometry geom = JGeometry.createMultiPoint(new Object[] { new double[] { 80.0, 76.0 }, new double[] { 90.0, 77.0 } }, 2, 4326);
Query query = pm.newQuery(SampleGeometry.class, "id > 3000 && id < 4000 && Spatial.contains(geom, Spatial.mPointFromWKB(Spatial.asBinary(:geom), Spatial.srid(:geom)))");
List list = (List) query.execute(geom);
assertEquals("Wrong number of geometries whitch overlap a multipoint constructed from given wkb returned", 1, list.size());
assertTrue("Polygon 2 should be in the list of geometries whitch overlap a multipoint constructed from given wkb", list.contains(getSamplePolygon(2)));
} finally {
tx.commit();
}
}
use of oracle.spatial.geometry.JGeometry in project tests by datanucleus.
the class JGeometrySpatialTest method testRelate.
public void testRelate() 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);
// crosses
String pattern = "T*T******";
Query query = pm.newQuery(SampleGeometry.class, "id > 2000 && id < 3000 && Spatial.relate(geom, :lineString, :pattern)");
List list = (List) query.execute(lineString, pattern);
assertEquals("Wrong number of geometries which are related to a given linestring returned (crosses)", 1, list.size());
assertTrue("LineString 1 should be in the list of geometries which are related to a given linestring (crosses)", list.contains(getSampleLineString(1)));
} finally {
tx.commit();
}
}
use of oracle.spatial.geometry.JGeometry in project tests by datanucleus.
the class JGeometrySpatialTest method testPointN.
public void testPointN() throws SQLException {
PersistenceManager pm = pmf.getPersistenceManager();
Transaction tx = pm.currentTransaction();
try {
tx.begin();
JGeometry point = new JGeometry(110.0, 10.0, 4326);
Short n = new Short((short) 3);
Query query = pm.newQuery(SampleGeometry.class, "id > 2000 && id < 3000 && Spatial.numPoints(geom) >= :n && Spatial.equals(Spatial.pointN(geom, :n), :point)");
List list = (List) query.execute(n, point);
assertEquals("Wrong number of geometries whose point no. " + n + " equals a given point returned", 1, list.size());
assertTrue("LineString 3 should be in the list of geometries whose point no. " + n + " equals a given point", list.contains(getSampleLineString(3)));
query = pm.newQuery(SampleGeometry.class, "id == :id");
query.setResult("Spatial.pointN(geom, 3)");
query.setUnique(true);
JGeometry point_read = (JGeometry) query.execute(new Long(getSampleLineString(3).getId()));
assertEquals("Returned third point should be equal to the given point", point, point_read);
} finally {
tx.commit();
}
}
use of oracle.spatial.geometry.JGeometry in project tests by datanucleus.
the class JGeometrySpatialTest method testIsEmpty.
public void testIsEmpty() 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.isEmpty(Spatial.intersection(geom, :linestring))");
List list = (List) query.execute(lineString);
assertEquals("Wrong number of geometries that do not intersect with a given linestring returned", 2, list.size());
assertTrue("LineString 2 should be in the list of geometries that do not intersect with a given linestring", list.contains(getSampleLineString(2)));
assertTrue("LineString 3 should be in the list of geometries that do not intersect with a given linestring", list.contains(getSampleLineString(3)));
} finally {
tx.commit();
}
}
use of oracle.spatial.geometry.JGeometry in project tests by datanucleus.
the class JGeometrySpatialTest method testStartPoint.
public void testStartPoint() throws SQLException {
PersistenceManager pm = pmf.getPersistenceManager();
Transaction tx = pm.currentTransaction();
try {
tx.begin();
JGeometry point = new JGeometry(50.0, 0.0, 4326);
Query query = pm.newQuery(SampleGeometry.class, "id > 2000 && id < 3000 && Spatial.equals(Spatial.startPoint(geom), :point)");
List list = (List) query.execute(point);
assertEquals("Wrong number of geometries with a given start point returned", 1, list.size());
assertTrue("LineString 2 should be in the list of geometries with a given start point", list.contains(getSampleLineString(2)));
query = pm.newQuery(SampleGeometry.class, "id == :id");
query.setResult("Spatial.startPoint(geom)");
query.setUnique(true);
JGeometry point_read = (JGeometry) query.execute(new Long(getSampleLineString(2).getId()));
assertEquals("Returned start point should be equal to the given point", point, point_read);
} finally {
tx.commit();
}
}
Aggregations