use of org.eclipse.persistence.testing.tests.spatial.jgeometry.SQLReader in project eclipselink by eclipse-ee4j.
the class Query_SpatialOp_ExpExp_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();
// Expression geom1 = SpatialOperator.getExpression("geometry.geom", eb);
ExpressionBuilder eb2 = new ExpressionBuilder(WrappedSpatial.class);
/* Expression geom2 = SpatialOperator.getExpression("geometry.geom", eb2);
SpatialOperator relate =
SpatialOperator.relate().setMask(Mask.ANYINTERACT).setQueryType(QueryType.WINDOW);
raq.setSelectionCriteria(relate.buildExpression(geom1,
geom2).and(eb.get("id").notEqual(6666).and(eb2.get("id").equal(6666))));
*/
SpatialParameters parameters = new SpatialParameters();
parameters.setMask(Mask.ANYINTERACT).setQueryType(QueryType.WINDOW);
Expression selectionCriteria = SpatialExpressionFactory.relate(eb.get("geometry").getField("geom"), eb2.get("geometry").getField("geom"), parameters);
selectionCriteria = selectionCriteria.and(eb.get("id").notEqual(6666).and(eb2.get("id").equal(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_ExpExp_Tests method testSDOFilterCircle.
/**
* SDO_FILTER using a with a circle of radius 10 around (0,0)
*/
public void testSDOFilterCircle() 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,4), " + "mdsys.sdo_ordinate_array(-10,0, 0, 10, 10, 0)), " + "'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();
// Expression geom1 = SpatialOperator.getExpression("geometry.geom", eb);
ExpressionBuilder eb2 = new ExpressionBuilder(WrappedSpatial.class);
/* Expression geom2 = SpatialOperator.getExpression("geometry.geom", eb2);
SpatialOperator filter =
SpatialOperator.filter().setQueryType(QueryType.WINDOW);
raq.setSelectionCriteria(filter.buildExpression(geom1,
geom2).and(eb.get("id").notEqual(6666).and(eb2.get("id").equal(6666))));
*/
SpatialParameters parameters = new SpatialParameters();
parameters.setQueryType(QueryType.WINDOW);
Expression selectionCriteria = SpatialExpressionFactory.filter(eb.get("geometry").getField("geom"), eb2.get("geometry").getField("geom"), parameters);
selectionCriteria = selectionCriteria.and(eb.get("id").notEqual(6666).and(eb2.get("id").equal(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_ExpExp_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 WRAPPED_SPATIAL WS where mdsys.sdo_within_distance(" + "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)), " + "'DISTANCE=10') = 'TRUE' ORDER BY GID";
SQLReader reader = new SQLReader(session, sql);
populateTestGeometry(JGeometry.createLinearPolygon(new double[] { 1, 1, 1, 20, 10, 20, 20, 1, 1, 1 }, 2, 0));
ReadAllQuery raq = new ReadAllQuery(WrappedSpatial.class);
ExpressionBuilder eb = raq.getExpressionBuilder();
// Expression geom1 = SpatialOperator.getExpression("geometry.geom", eb);
ExpressionBuilder eb2 = new ExpressionBuilder(WrappedSpatial.class);
/* Expression geom2 = SpatialOperator.getExpression("geometry.geom", eb2);
SpatialOperator wd = SpatialOperator.withinDistance().setDistance(10d);
raq.setSelectionCriteria(wd.buildExpression(geom1,
geom2).and(eb.get("id").notEqual(6666).and(eb2.get("id").equal(6666))));
*/
SpatialParameters parameters = new SpatialParameters();
parameters.setDistance(10d);
Expression selectionCriteria = SpatialExpressionFactory.withinDistance(eb.get("geometry").getField("geom"), eb2.get("geometry").getField("geom"), parameters);
selectionCriteria = selectionCriteria.and(eb.get("id").notEqual(6666).and(eb2.get("id").equal(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_ExpExp_Tests method testSDOWithinDistanceNullParamsMatchingCircle1004.
/**
* SDO_WITHIN_DISTANCE with NULL params matching a known circle geometry (1004)
*/
public void testSDOWithinDistanceNullParamsMatchingCircle1004() 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(1, 0, 0, 1, 0, -1)), " + "NULL) = 'TRUE' ORDER BY GID";
SQLReader reader = new SQLReader(session, sql);
populateTestGeometry(JGeometry.createCircle(1, 0, 0, 1, 0, -1, 0));
ReadAllQuery raq = new ReadAllQuery(WrappedSpatial.class);
ExpressionBuilder eb = raq.getExpressionBuilder();
// Expression geom1 = SpatialOperator.getExpression("geometry.geom", eb);
ExpressionBuilder eb2 = new ExpressionBuilder(WrappedSpatial.class);
/* Expression geom2 = SpatialOperator.getExpression("geometry.geom", eb2);
SpatialOperator wd = SpatialOperator.withinDistance();
raq.setSelectionCriteria(wd.buildExpression(geom1,
geom2).and(eb.get("id").notEqual(6666).and(eb2.get("id").equal(6666))));
*/
Expression selectionCriteria = SpatialExpressionFactory.withinDistance(eb.get("geometry").getField("geom"), eb2.get("geometry").getField("geom"), new SpatialParameters(""));
selectionCriteria = selectionCriteria.and(eb.get("id").notEqual(6666).and(eb2.get("id").equal(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_ExpExp_Tests 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 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,3), " + "mdsys.sdo_ordinate_array(1,1, 20, 20)), " + "'MASK=ANYINTERACT QUERYTYPE=WINDOW') = 'TRUE' ORDER BY GID";
SQLReader reader = new SQLReader(session, sql);
populateTestGeometry(JGeometry.createLinearPolygon(new double[] { 1, 1, 1, 20, 10, 20, 20, 1, 1, 1 }, 2, 0));
ReadAllQuery raq = new ReadAllQuery(WrappedSpatial.class);
ExpressionBuilder eb = raq.getExpressionBuilder();
// Expression geom1 = SpatialOperator.getExpression("geometry.geom", eb);
ExpressionBuilder eb2 = new ExpressionBuilder(WrappedSpatial.class);
/* Expression geom2 = SpatialOperator.getExpression("geometry.geom", eb2);
SpatialOperator relate =
SpatialOperator.relate().setMask(Mask.ANYINTERACT).setQueryType(QueryType.WINDOW);
raq.setSelectionCriteria(relate.buildExpression(geom1,
geom2).and(eb.get("id").notEqual(6666).and(eb2.get("id").equal(6666))));
*/
SpatialParameters parameters = new SpatialParameters();
parameters.setMask(Mask.ANYINTERACT).setQueryType(QueryType.WINDOW);
Expression selectionCriteria = SpatialExpressionFactory.relate(eb.get("geometry").getField("geom"), eb2.get("geometry").getField("geom"), parameters);
selectionCriteria = selectionCriteria.and(eb.get("id").notEqual(6666).and(eb2.get("id").equal(6666)));
raq.setSelectionCriteria(selectionCriteria);
raq.addAscendingOrdering("id");
List<Spatial> results = (List<Spatial>) session.executeQuery(raq);
String compareResult = reader.compare(results);
assertNull(compareResult, compareResult);
}
Aggregations