Search in sources :

Example 31 with Spatial

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

the class Query_SpatialOp_ExpReport_Tests method testSDOFilterRectangleNullParams.

public void testSDOFilterRectangleNullParams() throws Exception {
    String sql = "select GID, GEOMETRY from SIMPLE_SPATIAL where mdsys.sdo_filter(" + "geometry, 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 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(SimpleSpatial.class);
    ExpressionBuilder eb = raq.getExpressionBuilder();
    Expression geom1 = eb.get("geometry");
    ExpressionBuilder eb2 = new ExpressionBuilder();
    ReportQuery rq = new ReportQuery(SimpleSpatial.class, eb2);
    rq.addAttribute("geometry");
    rq.setSelectionCriteria(eb2.get("id").equal(6666));
    Expression selectionCriteria = SpatialExpressionFactory.filter(geom1, rq, new SpatialParameters(""));
    selectionCriteria = selectionCriteria.and(eb.get("id").notEqual(6666));
    raq.setSelectionCriteria(selectionCriteria);
    raq.addAscendingOrdering("id");
    List<Spatial> results = (List) session.executeQuery(raq);
    String compareResult = reader.compare(results);
    assertNull(compareResult, compareResult);
}
Also used : Expression(org.eclipse.persistence.expressions.Expression) SimpleSpatial(org.eclipse.persistence.testing.models.spatial.jgeometry.SimpleSpatial) Spatial(org.eclipse.persistence.testing.models.spatial.jgeometry.wrapped.Spatial) ReportQuery(org.eclipse.persistence.queries.ReportQuery) SpatialParameters(org.eclipse.persistence.expressions.spatial.SpatialParameters) ReadAllQuery(org.eclipse.persistence.queries.ReadAllQuery) List(java.util.List) ExpressionBuilder(org.eclipse.persistence.expressions.ExpressionBuilder)

Example 32 with Spatial

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

the class Query_SpatialOp_ExpReport_Tests method testSDOWithinDistanceRectangle.

/**
 * SDO_WITHIN_DISTANCE using a dynamic rectangular window with lower left
 * and upper right coordinates of {(1,1), (20,20)}
 */
public void testSDOWithinDistanceRectangle() throws Exception {
    String sql = "select GID, GEOMETRY from SIMPLE_SPATIAL where mdsys.sdo_within_distance(" + "geometry, mdsys.sdo_geometry(3,null,null, mdsys.sdo_elem_info_array(1,3,3), " + "mdsys.sdo_ordinate_array(1,1, 20, 20)), " + "'DISTANCE=10') = '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(SimpleSpatial.class);
    ExpressionBuilder eb = raq.getExpressionBuilder();
    Expression geom1 = eb.get("geometry");
    ExpressionBuilder eb2 = new ExpressionBuilder();
    ReportQuery rq = new ReportQuery(SimpleSpatial.class, eb2);
    rq.addAttribute("geometry");
    rq.setSelectionCriteria(eb2.get("id").equal(6666));
    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) session.executeQuery(raq);
    String compareResult = reader.compare(results);
    assertNull(compareResult, compareResult);
}
Also used : Expression(org.eclipse.persistence.expressions.Expression) SimpleSpatial(org.eclipse.persistence.testing.models.spatial.jgeometry.SimpleSpatial) Spatial(org.eclipse.persistence.testing.models.spatial.jgeometry.wrapped.Spatial) ReportQuery(org.eclipse.persistence.queries.ReportQuery) SpatialParameters(org.eclipse.persistence.expressions.spatial.SpatialParameters) ReadAllQuery(org.eclipse.persistence.queries.ReadAllQuery) List(java.util.List) ExpressionBuilder(org.eclipse.persistence.expressions.ExpressionBuilder)

Example 33 with Spatial

use of org.eclipse.persistence.testing.models.spatial.jgeometry.wrapped.Spatial 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 SIMPLE_SPATIAL where mdsys.sdo_relate(" + "geometry, 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(SimpleSpatial.class);
    ExpressionBuilder eb = raq.getExpressionBuilder();
    Expression geom1 = eb.get("geometry");
    ExpressionBuilder eb2 = new ExpressionBuilder();
    ReportQuery rq = new ReportQuery(SimpleSpatial.class, eb2);
    rq.addAttribute("geometry");
    rq.setSelectionCriteria(eb2.get("id").equal(6666));
    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) session.executeQuery(raq);
    String compareResult = reader.compare(results);
    assertNull(compareResult, compareResult);
}
Also used : Expression(org.eclipse.persistence.expressions.Expression) SimpleSpatial(org.eclipse.persistence.testing.models.spatial.jgeometry.SimpleSpatial) Spatial(org.eclipse.persistence.testing.models.spatial.jgeometry.wrapped.Spatial) ReportQuery(org.eclipse.persistence.queries.ReportQuery) SpatialParameters(org.eclipse.persistence.expressions.spatial.SpatialParameters) ReadAllQuery(org.eclipse.persistence.queries.ReadAllQuery) List(java.util.List) ExpressionBuilder(org.eclipse.persistence.expressions.ExpressionBuilder)

Example 34 with Spatial

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

the class Query_SpatialOp_ExpReport_Tests method testSDOWithinDistanceRectangleUsingMaxResolution.

public void testSDOWithinDistanceRectangleUsingMaxResolution() throws Exception {
    String sql = "select GID, GEOMETRY from SIMPLE_SPATIAL where mdsys.sdo_within_distance(" + "geometry, mdsys.sdo_geometry(3,null,null, mdsys.sdo_elem_info_array(1,3,3), " + "mdsys.sdo_ordinate_array(1,1, 20, 20)), " + "'DISTANCE=10 MAX_RESOLUTION=5') = '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(SimpleSpatial.class);
    ExpressionBuilder eb = raq.getExpressionBuilder();
    Expression geom1 = eb.get("geometry");
    ExpressionBuilder eb2 = new ExpressionBuilder();
    ReportQuery rq = new ReportQuery(SimpleSpatial.class, eb2);
    rq.addAttribute("geometry");
    rq.setSelectionCriteria(eb2.get("id").equal(6666));
    SpatialParameters parameters = new SpatialParameters();
    parameters.setDistance(10d).setMaxResolution(5);
    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) session.executeQuery(raq);
    String compareResult = reader.compare(results);
    assertNull(compareResult, compareResult);
}
Also used : Expression(org.eclipse.persistence.expressions.Expression) SimpleSpatial(org.eclipse.persistence.testing.models.spatial.jgeometry.SimpleSpatial) Spatial(org.eclipse.persistence.testing.models.spatial.jgeometry.wrapped.Spatial) ReportQuery(org.eclipse.persistence.queries.ReportQuery) SpatialParameters(org.eclipse.persistence.expressions.spatial.SpatialParameters) ReadAllQuery(org.eclipse.persistence.queries.ReadAllQuery) List(java.util.List) ExpressionBuilder(org.eclipse.persistence.expressions.ExpressionBuilder)

Example 35 with Spatial

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 SIMPLE_SPATIAL where mdsys.sdo_filter(" + "geometry, 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(SimpleSpatial.class);
    ExpressionBuilder eb = raq.getExpressionBuilder();
    Expression geom1 = eb.get("geometry");
    ExpressionBuilder eb2 = new ExpressionBuilder();
    ReportQuery rq = new ReportQuery(SimpleSpatial.class, eb2);
    rq.addAttribute("geometry");
    rq.setSelectionCriteria(eb2.get("id").equal(6666));
    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) session.executeQuery(raq);
    String compareResult = reader.compare(results);
    assertNull(compareResult, compareResult);
}
Also used : Expression(org.eclipse.persistence.expressions.Expression) SimpleSpatial(org.eclipse.persistence.testing.models.spatial.jgeometry.SimpleSpatial) Spatial(org.eclipse.persistence.testing.models.spatial.jgeometry.wrapped.Spatial) ReportQuery(org.eclipse.persistence.queries.ReportQuery) SpatialParameters(org.eclipse.persistence.expressions.spatial.SpatialParameters) ReadAllQuery(org.eclipse.persistence.queries.ReadAllQuery) List(java.util.List) ExpressionBuilder(org.eclipse.persistence.expressions.ExpressionBuilder)

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