use of org.eclipse.persistence.testing.models.spatial.jgeometry.wrapped.Spatial in project eclipselink by eclipse-ee4j.
the class SpatialJPQLTestSuite method testSDOWithinDistanceArbitraryLine.
/**
* SDO_WITHIN_DISTANCE using an arbitrary line string {(10,10), (20, 20), (30, 30), (45,45)}
*/
public void testSDOWithinDistanceArbitraryLine() throws Exception {
String sql = "select ID, JGEOMETRY from JPA_JGEOMETRY where " + "mdsys.sdo_within_distance(jgeometry, " + "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)), " + "'DISTANCE=10') = 'TRUE' ORDER BY ID";
SQLReader reader = new SQLReader(getServerSession(STRUCT_CONVERTER_PU), sql);
JGeometry line = JGeometry.createLinearLineString(new double[] { 10, 10, 20, 20, 30, 30, 45, 45 }, 2, 0);
EntityManager em = createEntityManager(STRUCT_CONVERTER_PU);
Query query = em.createQuery("SELECT ss FROM SimpleSpatial ss WHERE FUNC('mdsys.sdo_WITHIN_DISTANCE', ss.JGeometry, :otherGeometry, :params) = 'TRUE' ORDER BY ss.id ASC");
query.setParameter("otherGeometry", line);
query.setParameter("params", "DISTANCE=10");
List<Spatial> results = query.getResultList();
String compareResult = reader.compare(results);
assertNull(compareResult, compareResult);
}
use of org.eclipse.persistence.testing.models.spatial.jgeometry.wrapped.Spatial in project eclipselink by eclipse-ee4j.
the class SpatialJPQLTestSuite method testSDORelateRectangle2.
/**
* SDO_RELATE using a dynamic rectangular window with lower left
* and upper right coordinates of {(1,1), (20,20)}
* Build jpql string with all mdsys.sdo_ functions found in the control query.
*/
public void testSDORelateRectangle2() throws Exception {
String sql = "select ID, JGEOMETRY from JPA_JGEOMETRY where mdsys.sdo_relate(jgeometry, " + "mdsys.sdo_geometry(3,null,null, mdsys.sdo_elem_info_array(1,3,3), " + "mdsys.sdo_ordinate_array(1,1, 20, 20)), " + "'MASK=ANYINTERACT QUERYTYPE=WINDOW') = 'TRUE' ORDER BY ID";
SQLReader reader = new SQLReader(getServerSession(STRUCT_CONVERTER_PU), sql);
String otherGeometry = "FUNC('mdsys.sdo_geometry', 3, null, null, FUNC('mdsys.sdo_elem_info_array', 1, 3, 3), FUNC('mdsys.sdo_ordinate_array', 1, 1, 20, 20))";
EntityManager em = createEntityManager(STRUCT_CONVERTER_PU);
Query query = em.createQuery("SELECT ss FROM SimpleSpatial ss WHERE FUNC('mdsys.sdo_RELATE', ss.JGeometry, " + otherGeometry + ", :params) = 'TRUE' ORDER BY ss.id ASC");
query.setParameter("params", "MASK=ANYINTERACT QUERYTYPE=WINDOW");
query.setHint(QueryHints.BIND_PARAMETERS, "false");
List<Spatial> results = query.getResultList();
String compareResult = reader.compare(results);
assertNull(compareResult, compareResult);
}
use of org.eclipse.persistence.testing.models.spatial.jgeometry.wrapped.Spatial in project eclipselink by eclipse-ee4j.
the class SpatialJPQLTestSuite method testSDOWithinDistanceNullParamsMatchingCircle1004.
/**
* SDO_WITHIN_DISTANCE with NULL params matching a known circle geometry (1004)
*/
public void testSDOWithinDistanceNullParamsMatchingCircle1004() throws Exception {
String sql = "select ID, JGEOMETRY from JPA_JGEOMETRY where " + "mdsys.sdo_within_distance(jgeometry, mdsys.sdo_geometry(3, " + "NULL, null, mdsys.sdo_elem_info_array(1,3,4), " + "mdsys.sdo_ordinate_array(1, 0, 0, 1, 0, -1)), " + "NULL) = 'TRUE' ORDER BY ID";
SQLReader reader = new SQLReader(getServerSession(STRUCT_CONVERTER_PU), sql);
JGeometry circle = JGeometry.createCircle(1, 0, 0, 1, 0, -1, 0);
EntityManager em = createEntityManager(STRUCT_CONVERTER_PU);
Query query = em.createQuery("SELECT ss FROM SimpleSpatial ss WHERE FUNC('mdsys.sdo_WITHIN_DISTANCE', ss.JGeometry, :otherGeometry, :params) = 'TRUE' ORDER BY ss.id ASC");
query.setParameter("otherGeometry", circle);
query.setParameter("params", null);
List<Spatial> results = query.getResultList();
String compareResult = reader.compare(results);
assertNull(compareResult, compareResult);
}
use of org.eclipse.persistence.testing.models.spatial.jgeometry.wrapped.Spatial in project eclipselink by eclipse-ee4j.
the class SpatialJPQLTestSuite method testSDOFilterArbitraryLine.
/**
* SDO_FILTER using an arbitrary line string {(10,10), (20, 20), (30, 30), (45,45)}
*/
public void testSDOFilterArbitraryLine() throws Exception {
String sql = "select ID, JGEOMETRY from JPA_JGEOMETRY where mdsys.sdo_filter(" + "jgeometry, 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)), " + "'QUERYTYPE=WINDOW') = 'TRUE' ORDER BY ID";
SQLReader reader = new SQLReader(getServerSession(STRUCT_CONVERTER_PU), sql);
JGeometry line = JGeometry.createLinearLineString(new double[] { 10, 10, 20, 20, 30, 30, 45, 45 }, 2, 0);
EntityManager em = createEntityManager(STRUCT_CONVERTER_PU);
Query query = em.createQuery("SELECT ss FROM SimpleSpatial ss WHERE FUNC('mdsys.sdo_FILTER', ss.JGeometry, :otherGeometry, :params) = 'TRUE' ORDER BY ss.id ASC");
query.setParameter("otherGeometry", line);
query.setParameter("params", "QUERYTYPE=WINDOW");
List<Spatial> results = query.getResultList();
String compareResult = reader.compare(results);
assertNull(compareResult, compareResult);
}
use of org.eclipse.persistence.testing.models.spatial.jgeometry.wrapped.Spatial in project eclipselink by eclipse-ee4j.
the class Query_SpatialOp_ExpReport_Tests method testSDOFilterRectangle.
/**
* SDO_Filter using a dynamic rectangular window with lower left
* and upper right coordinates of {(1,1), (20,20)}
*/
public void testSDOFilterRectangle() throws Exception {
String sql = "select GID, GEOMETRY FROM WRAPPED_SPATIAL WS where mdsys.sdo_filter(" + "ws.geometry.geom, mdsys.sdo_geometry(3,null,null, " + "mdsys.sdo_elem_info_array(1,3,3), " + "mdsys.sdo_ordinate_array(1,1, 20, 20)), " + "'QUERYTYPE=WINDOW') = 'TRUE' ORDER BY GID";
SQLReader reader = new SQLReader(session, sql);
double[] points = new double[] { 1, 1, 1, 20, 10, 20, 20, 1, 1, 1 };
populateTestGeometry(JGeometry.createLinearPolygon(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.addAttribute("geometry.geom");
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.setQueryType(QueryType.WINDOW);
Expression selectionCriteria = SpatialExpressionFactory.filter(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