use of org.eclipse.persistence.testing.tests.spatial.jgeometry.SQLReader in project eclipselink by eclipse-ee4j.
the class Query_SpatialOp_ExpReport_Tests method testSDORelateCircle.
/**
* SDO_RELATE using a with a circle of radius 10 around (0,0)
*/
public void testSDORelateCircle() throws Exception {
String sql = "select GID, GEOMETRY FROM WRAPPED_SPATIAL WS where mdsys.sdo_relate(ws.geometry.geom, " + "mdsys.sdo_geometry(3,null,null, " + "mdsys.sdo_elem_info_array(1,3,4), " + "mdsys.sdo_ordinate_array(-10,0, 0, 10, 10, 0)), " + "'MASK=ANYINTERACT QUERYTYPE=WINDOW') = 'TRUE' ORDER BY GID";
SQLReader reader = new SQLReader(session, sql);
populateTestGeometry(JGeometry.createCircle(-10, 0, 0, 10, 10, 0, 0));
ReadAllQuery raq = new ReadAllQuery(WrappedSpatial.class);
ExpressionBuilder eb = raq.getExpressionBuilder();
ExpressionBuilder eb2 = new ExpressionBuilder();
ReportQuery rq = new ReportQuery(WrappedSpatial.class, eb2);
rq.addItem("geom", eb2.get("geometry").getField("geom"));
rq.setSelectionCriteria(eb2.get("id").equal(6666));
Expression geom1 = eb.get("geometry").getField("geom");
SpatialParameters parameters = new SpatialParameters();
parameters.setMask(Mask.ANYINTERACT).setQueryType(QueryType.WINDOW);
Expression selectionCriteria = SpatialExpressionFactory.relate(geom1, rq, parameters);
selectionCriteria = selectionCriteria.and(eb.get("id").notEqual(6666));
raq.setSelectionCriteria(selectionCriteria);
raq.addAscendingOrdering("id");
List<Spatial> results = (List<Spatial>) session.executeQuery(raq);
String compareResult = reader.compare(results);
assertNull(compareResult, compareResult);
}
use of org.eclipse.persistence.testing.tests.spatial.jgeometry.SQLReader in project eclipselink by eclipse-ee4j.
the class Query_SpatialOp_ExpReport_Tests method testSDOWithinDistanceCircle.
/**
* SDO_WITHIN_DISTANCE using a with a circle of radius 10 around (0,0)
*/
public void testSDOWithinDistanceCircle() throws Exception {
String sql = "select GID, GEOMETRY FROM WRAPPED_SPATIAL WS where " + "mdsys.sdo_within_distance(ws.geometry.geom, " + "mdsys.sdo_geometry(3,null,null, " + "mdsys.sdo_elem_info_array(1,3,4), " + "mdsys.sdo_ordinate_array(-10,0, 0, 10, 10, 0)), " + "'DISTANCE=10') = 'TRUE' ORDER BY GID";
SQLReader reader = new SQLReader(session, sql);
populateTestGeometry(JGeometry.createCircle(-10, 0, 0, 10, 10, 0, 0));
ReadAllQuery raq = new ReadAllQuery(WrappedSpatial.class);
ExpressionBuilder eb = raq.getExpressionBuilder();
ExpressionBuilder eb2 = new ExpressionBuilder();
ReportQuery rq = new ReportQuery(WrappedSpatial.class, eb2);
rq.addItem("geom", eb2.get("geometry").getField("geom"));
rq.setSelectionCriteria(eb2.get("id").equal(6666));
Expression geom1 = eb.get("geometry").getField("geom");
SpatialParameters parameters = new SpatialParameters();
parameters.setDistance(10d);
Expression selectionCriteria = SpatialExpressionFactory.withinDistance(geom1, rq, parameters);
selectionCriteria = selectionCriteria.and(eb.get("id").notEqual(6666));
raq.setSelectionCriteria(selectionCriteria);
raq.addAscendingOrdering("id");
List<Spatial> results = (List<Spatial>) session.executeQuery(raq);
String compareResult = reader.compare(results);
assertNull(compareResult, compareResult);
}
use of org.eclipse.persistence.testing.tests.spatial.jgeometry.SQLReader in project eclipselink by eclipse-ee4j.
the class Query_SpatialOp_ExpReport_Tests method testSDORelateArbitraryLine.
/**
* SDO_RELATE using an arbitrary line string {(10,10), (20, 20), (30, 30), (45,45)}
*/
public void testSDORelateArbitraryLine() throws Exception {
String sql = "select GID, GEOMETRY FROM WRAPPED_SPATIAL WS where mdsys.sdo_relate(" + "ws.geometry.geom, mdsys.sdo_geometry(2,null,null, " + "mdsys.sdo_elem_info_array(1,2,1), " + "mdsys.sdo_ordinate_array(10,10, 20,20, 30,30, 45,45)), " + "'MASK=ANYINTERACT QUERYTYPE=WINDOW') = 'TRUE' ORDER BY GID";
SQLReader reader = new SQLReader(session, sql);
double[] points = new double[] { 10, 10, 20, 20, 30, 30, 45, 45 };
populateTestGeometry(JGeometry.createLinearLineString(points, 2, 0));
ReadAllQuery raq = new ReadAllQuery(WrappedSpatial.class);
ExpressionBuilder eb = raq.getExpressionBuilder();
ExpressionBuilder eb2 = new ExpressionBuilder();
ReportQuery rq = new ReportQuery(WrappedSpatial.class, eb2);
rq.addItem("geom", eb2.get("geometry").getField("geom"));
rq.setSelectionCriteria(eb2.get("id").equal(6666));
Expression geom1 = eb.get("geometry").getField("geom");
SpatialParameters parameters = new SpatialParameters();
parameters.setMask(Mask.ANYINTERACT).setQueryType(QueryType.WINDOW);
Expression selectionCriteria = SpatialExpressionFactory.relate(geom1, rq, parameters);
selectionCriteria = selectionCriteria.and(eb.get("id").notEqual(6666));
raq.setSelectionCriteria(selectionCriteria);
raq.addAscendingOrdering("id");
List<Spatial> results = (List<Spatial>) session.executeQuery(raq);
String compareResult = reader.compare(results);
assertNull(compareResult, compareResult);
}
Aggregations