Search in sources :

Example 1 with Spatial

use of org.eclipse.persistence.testing.models.spatial.jgeometry.wrapped.Spatial in project eclipselink by eclipse-ee4j.

the class SpatialJPQLTestSuite method testSDOWithinDistanceCircle.

/**
 * SDO_WITHIN_DISTANCE using a with a circle of radius 10 around (0,0)
 */
public void testSDOWithinDistanceCircle() 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(-10,0, 0, 10, 10, 0)), " + "'DISTANCE=10') = 'TRUE' ORDER BY ID";
    SQLReader reader = new SQLReader(getServerSession(STRUCT_CONVERTER_PU), sql);
    JGeometry circle = JGeometry.createCircle(-10, 0, 0, 10, 10, 0, 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", "DISTANCE=10");
    List<Spatial> results = query.getResultList();
    String compareResult = reader.compare(results);
    assertNull(compareResult, compareResult);
}
Also used : EntityManager(jakarta.persistence.EntityManager) Query(jakarta.persistence.Query) Spatial(org.eclipse.persistence.testing.models.spatial.jgeometry.wrapped.Spatial) SimpleSpatial(org.eclipse.persistence.testing.models.jpa.structconverter.SimpleSpatial) JGeometry(oracle.spatial.geometry.JGeometry)

Example 2 with Spatial

use of org.eclipse.persistence.testing.models.spatial.jgeometry.wrapped.Spatial in project eclipselink by eclipse-ee4j.

the class SpatialJPQLTestSuite method testSDORelateRectangle.

/**
 * SDO_RELATE using a dynamic rectangular window with lower left
 * and upper right coordinates of {(1,1), (20,20)}
 */
public void testSDORelateRectangle() 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);
    JGeometry rectangle = JGeometry.createLinearPolygon(new double[] { 1, 1, 1, 20, 10, 20, 20, 1, 1, 1 }, 2, 0);
    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("otherGeometry", rectangle);
    query.setParameter("params", "MASK=ANYINTERACT QUERYTYPE=WINDOW");
    List<Spatial> results = query.getResultList();
    String compareResult = reader.compare(results);
    assertNull(compareResult, compareResult);
}
Also used : EntityManager(jakarta.persistence.EntityManager) Query(jakarta.persistence.Query) Spatial(org.eclipse.persistence.testing.models.spatial.jgeometry.wrapped.Spatial) SimpleSpatial(org.eclipse.persistence.testing.models.jpa.structconverter.SimpleSpatial) JGeometry(oracle.spatial.geometry.JGeometry)

Example 3 with Spatial

use of org.eclipse.persistence.testing.models.spatial.jgeometry.wrapped.Spatial in project eclipselink by eclipse-ee4j.

the class SpatialJPQLTestSuite method testSDOFilterRectangleNullParams.

public void testSDOFilterRectangleNullParams() throws Exception {
    String sql = "select ID, JGEOMETRY from JPA_JGEOMETRY where mdsys.sdo_filter(" + "jgeometry, mdsys.sdo_geometry(3,null,null, " + "mdsys.sdo_elem_info_array(1,3,3), " + "mdsys.sdo_ordinate_array(1,1, 20, 20)), " + "NULL) = 'TRUE' ORDER BY ID";
    SQLReader reader = new SQLReader(getServerSession(STRUCT_CONVERTER_PU), sql);
    JGeometry rectangle = JGeometry.createLinearPolygon(new double[] { 1, 1, 1, 20, 10, 20, 20, 1, 1, 1 }, 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", rectangle);
    query.setParameter("params", null);
    List<Spatial> results = query.getResultList();
    String compareResult = reader.compare(results);
    assertNull(compareResult, compareResult);
}
Also used : EntityManager(jakarta.persistence.EntityManager) Query(jakarta.persistence.Query) Spatial(org.eclipse.persistence.testing.models.spatial.jgeometry.wrapped.Spatial) SimpleSpatial(org.eclipse.persistence.testing.models.jpa.structconverter.SimpleSpatial) JGeometry(oracle.spatial.geometry.JGeometry)

Example 4 with Spatial

use of org.eclipse.persistence.testing.models.spatial.jgeometry.wrapped.Spatial in project eclipselink by eclipse-ee4j.

the class SpatialJPQLTestSuite 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 ID, JGEOMETRY from JPA_JGEOMETRY where mdsys.sdo_relate(" + "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)), " + "'MASK=ANYINTERACT 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_RELATE', ss.JGeometry, :otherGeometry, :params) = 'TRUE' ORDER BY ss.id ASC");
    query.setParameter("otherGeometry", line);
    query.setParameter("params", "MASK=ANYINTERACT QUERYTYPE=WINDOW");
    List<Spatial> results = query.getResultList();
    String compareResult = reader.compare(results);
    assertNull(compareResult, compareResult);
}
Also used : EntityManager(jakarta.persistence.EntityManager) Query(jakarta.persistence.Query) Spatial(org.eclipse.persistence.testing.models.spatial.jgeometry.wrapped.Spatial) SimpleSpatial(org.eclipse.persistence.testing.models.jpa.structconverter.SimpleSpatial) JGeometry(oracle.spatial.geometry.JGeometry)

Example 5 with Spatial

use of org.eclipse.persistence.testing.models.spatial.jgeometry.wrapped.Spatial in project eclipselink by eclipse-ee4j.

the class SpatialJPQLTestSuite method testSDORelateCircle.

/**
 * SDO_RELATE using a with a circle of radius 10 around (0,0)
 */
public void testSDORelateCircle() 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,4), " + "mdsys.sdo_ordinate_array(-10,0, 0, 10, 10, 0)), " + "'MASK=ANYINTERACT QUERYTYPE=WINDOW') = 'TRUE' ORDER BY ID";
    SQLReader reader = new SQLReader(getServerSession(STRUCT_CONVERTER_PU), sql);
    JGeometry circle = JGeometry.createCircle(-10, 0, 0, 10, 10, 0, 0);
    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("otherGeometry", circle);
    query.setParameter("params", "MASK=ANYINTERACT QUERYTYPE=WINDOW");
    List<Spatial> results = query.getResultList();
    String compareResult = reader.compare(results);
    assertNull(compareResult, compareResult);
}
Also used : EntityManager(jakarta.persistence.EntityManager) Query(jakarta.persistence.Query) Spatial(org.eclipse.persistence.testing.models.spatial.jgeometry.wrapped.Spatial) SimpleSpatial(org.eclipse.persistence.testing.models.jpa.structconverter.SimpleSpatial) JGeometry(oracle.spatial.geometry.JGeometry)

Aggregations

Spatial (org.eclipse.persistence.testing.models.spatial.jgeometry.wrapped.Spatial)102 List (java.util.List)86 ReadAllQuery (org.eclipse.persistence.queries.ReadAllQuery)82 Expression (org.eclipse.persistence.expressions.Expression)78 ExpressionBuilder (org.eclipse.persistence.expressions.ExpressionBuilder)78 SpatialParameters (org.eclipse.persistence.expressions.spatial.SpatialParameters)76 SimpleSpatial (org.eclipse.persistence.testing.models.spatial.jgeometry.SimpleSpatial)46 WrappedSpatial (org.eclipse.persistence.testing.models.spatial.jgeometry.wrapped.WrappedSpatial)45 JGeometry (oracle.spatial.geometry.JGeometry)43 SQLReader (org.eclipse.persistence.testing.tests.spatial.jgeometry.SQLReader)43 ReportQuery (org.eclipse.persistence.queries.ReportQuery)26 EntityManager (jakarta.persistence.EntityManager)14 Query (jakarta.persistence.Query)14 SimpleSpatial (org.eclipse.persistence.testing.models.jpa.structconverter.SimpleSpatial)14 DataReadQuery (org.eclipse.persistence.queries.DataReadQuery)1