Search in sources :

Example 1 with OracleSdoGeometryJdbcFieldDefinition

use of com.revolsys.oracle.recordstore.field.OracleSdoGeometryJdbcFieldDefinition in project com.revolsys.open by revolsys.

the class OracleRecordStore method appendEnvelopeIntersects.

private void appendEnvelopeIntersects(final Query query, final StringBuilder sql, final EnvelopeIntersects envelopeIntersects) {
    final FieldDefinition geometryField = query.getGeometryField();
    if (geometryField instanceof OracleSdoGeometryJdbcFieldDefinition) {
        sql.append("SDO_RELATE(");
        final QueryValue boundingBox1Value = envelopeIntersects.getBoundingBox1Value();
        if (boundingBox1Value == null) {
            sql.append("NULL");
        } else {
            boundingBox1Value.appendSql(query, this, sql);
        }
        sql.append(",");
        final QueryValue boundingBox2Value = envelopeIntersects.getBoundingBox2Value();
        if (boundingBox2Value == null) {
            sql.append("NULL");
        } else {
            boundingBox2Value.appendSql(query, this, sql);
        }
        sql.append(",'mask=ANYINTERACT querytype=WINDOW') = 'TRUE'");
    } else if (geometryField instanceof ArcSdeStGeometryFieldDefinition) {
        sql.append("SDE.ST_ENVINTERSECTS(");
        final QueryValue boundingBox1Value = envelopeIntersects.getBoundingBox1Value();
        if (boundingBox1Value == null) {
            sql.append("NULL");
        } else {
            boundingBox1Value.appendSql(query, this, sql);
        }
        sql.append(",");
        final QueryValue boundingBox2Value = envelopeIntersects.getBoundingBox2Value();
        if (boundingBox2Value == null) {
            sql.append("NULL");
        } else {
            boundingBox2Value.appendSql(query, this, sql);
        }
        sql.append(") = 1");
    } else {
        throw new IllegalArgumentException("Unknown geometry attribute type " + geometryField.getClass());
    }
}
Also used : OracleSdoGeometryJdbcFieldDefinition(com.revolsys.oracle.recordstore.field.OracleSdoGeometryJdbcFieldDefinition) FieldDefinition(com.revolsys.record.schema.FieldDefinition) OracleJdbcRowIdFieldDefinition(com.revolsys.oracle.recordstore.field.OracleJdbcRowIdFieldDefinition) ArcSdeStGeometryFieldDefinition(com.revolsys.oracle.recordstore.esri.ArcSdeStGeometryFieldDefinition) JdbcFieldDefinition(com.revolsys.jdbc.field.JdbcFieldDefinition) OracleSdoGeometryJdbcFieldDefinition(com.revolsys.oracle.recordstore.field.OracleSdoGeometryJdbcFieldDefinition) ArcSdeStGeometryFieldDefinition(com.revolsys.oracle.recordstore.esri.ArcSdeStGeometryFieldDefinition) QueryValue(com.revolsys.record.query.QueryValue)

Example 2 with OracleSdoGeometryJdbcFieldDefinition

use of com.revolsys.oracle.recordstore.field.OracleSdoGeometryJdbcFieldDefinition in project com.revolsys.open by revolsys.

the class OracleRecordStore method appendGeometryEqual2d.

private void appendGeometryEqual2d(final Query query, final StringBuilder sql, final GeometryEqual2d equals) {
    final FieldDefinition geometryField = query.getGeometryField();
    if (geometryField instanceof OracleSdoGeometryJdbcFieldDefinition) {
        sql.append("MDSYS.SDO_EQUAL(");
        final QueryValue geometry1Value = equals.getGeometry1Value();
        if (geometry1Value == null) {
            sql.append("NULL");
        } else {
            geometry1Value.appendSql(query, this, sql);
        }
        sql.append(",");
        final QueryValue geometry2Value = equals.getGeometry2Value();
        if (geometry2Value == null) {
            sql.append("NULL");
        } else {
            geometry2Value.appendSql(query, this, sql);
        }
        sql.append(") = 'TRUE'");
    } else if (geometryField instanceof ArcSdeStGeometryFieldDefinition) {
        sql.append("SDE.ST_EQUALS(");
        final QueryValue geometry1Value = equals.getGeometry1Value();
        if (geometry1Value == null) {
            sql.append("NULL");
        } else {
            geometry1Value.appendSql(query, this, sql);
        }
        sql.append(",");
        final QueryValue geometry2Value = equals.getGeometry2Value();
        if (geometry2Value == null) {
            sql.append("NULL");
        } else {
            geometry2Value.appendSql(query, this, sql);
        }
        sql.append(") = 1");
    } else {
        throw new IllegalArgumentException("Unknown geometry attribute type " + geometryField.getClass());
    }
}
Also used : OracleSdoGeometryJdbcFieldDefinition(com.revolsys.oracle.recordstore.field.OracleSdoGeometryJdbcFieldDefinition) FieldDefinition(com.revolsys.record.schema.FieldDefinition) OracleJdbcRowIdFieldDefinition(com.revolsys.oracle.recordstore.field.OracleJdbcRowIdFieldDefinition) ArcSdeStGeometryFieldDefinition(com.revolsys.oracle.recordstore.esri.ArcSdeStGeometryFieldDefinition) JdbcFieldDefinition(com.revolsys.jdbc.field.JdbcFieldDefinition) OracleSdoGeometryJdbcFieldDefinition(com.revolsys.oracle.recordstore.field.OracleSdoGeometryJdbcFieldDefinition) ArcSdeStGeometryFieldDefinition(com.revolsys.oracle.recordstore.esri.ArcSdeStGeometryFieldDefinition) QueryValue(com.revolsys.record.query.QueryValue)

Example 3 with OracleSdoGeometryJdbcFieldDefinition

use of com.revolsys.oracle.recordstore.field.OracleSdoGeometryJdbcFieldDefinition in project com.revolsys.open by revolsys.

the class OracleRecordStore method appendWithinDistance.

private void appendWithinDistance(final Query query, final StringBuilder sql, final WithinDistance withinDistance) {
    final FieldDefinition geometryField = query.getGeometryField();
    if (geometryField instanceof OracleSdoGeometryJdbcFieldDefinition) {
        sql.append("MDSYS.SDO_WITHIN_DISTANCE(");
        final QueryValue geometry1Value = withinDistance.getGeometry1Value();
        if (geometry1Value == null) {
            sql.append("NULL");
        } else {
            geometry1Value.appendSql(query, this, sql);
        }
        sql.append(", ");
        final QueryValue geometry2Value = withinDistance.getGeometry2Value();
        if (geometry2Value == null) {
            sql.append("NULL");
        } else {
            geometry2Value.appendSql(query, this, sql);
        }
        sql.append(",'distance = ' || ");
        final QueryValue distanceValue = withinDistance.getDistanceValue();
        if (distanceValue == null) {
            sql.append("0");
        } else {
            distanceValue.appendSql(query, this, sql);
        }
        sql.append(") = 'TRUE'");
    } else if (geometryField instanceof ArcSdeStGeometryFieldDefinition) {
        final Column column = (Column) withinDistance.getGeometry1Value();
        final GeometryFactory geometryFactory = column.getFieldDefinition().getRecordDefinition().getGeometryFactory();
        final Value geometry2Value = (Value) withinDistance.getGeometry2Value();
        final Value distanceValue = (Value) withinDistance.getDistanceValue();
        final Number distance = (Number) distanceValue.getValue();
        final Object geometryObject = geometry2Value.getValue();
        BoundingBox boundingBox;
        if (geometryObject instanceof BoundingBox) {
            boundingBox = (BoundingBox) geometryObject;
        } else if (geometryObject instanceof Geometry) {
            final Geometry geometry = (Geometry) geometryObject;
            boundingBox = geometry.getBoundingBox();
        } else {
            boundingBox = geometryFactory.newBoundingBoxEmpty();
        }
        boundingBox = boundingBox.expand(distance.doubleValue());
        boundingBox = boundingBox.convert(geometryFactory);
        sql.append("(SDE.ST_ENVINTERSECTS(");
        column.appendSql(query, this, sql);
        sql.append(",");
        sql.append(boundingBox.getMinX());
        sql.append(",");
        sql.append(boundingBox.getMinY());
        sql.append(",");
        sql.append(boundingBox.getMaxX());
        sql.append(",");
        sql.append(boundingBox.getMaxY());
        sql.append(") = 1 AND SDE.ST_DISTANCE(");
        column.appendSql(query, this, sql);
        sql.append(", ");
        geometry2Value.appendSql(query, this, sql);
        sql.append(") <= ");
        distanceValue.appendSql(query, this, sql);
        sql.append(")");
    } else {
        throw new IllegalArgumentException("Unknown geometry attribute type " + geometryField.getClass());
    }
}
Also used : Geometry(com.revolsys.geometry.model.Geometry) GeometryFactory(com.revolsys.geometry.model.GeometryFactory) OracleSdoGeometryJdbcFieldDefinition(com.revolsys.oracle.recordstore.field.OracleSdoGeometryJdbcFieldDefinition) Column(com.revolsys.record.query.Column) FieldDefinition(com.revolsys.record.schema.FieldDefinition) OracleJdbcRowIdFieldDefinition(com.revolsys.oracle.recordstore.field.OracleJdbcRowIdFieldDefinition) ArcSdeStGeometryFieldDefinition(com.revolsys.oracle.recordstore.esri.ArcSdeStGeometryFieldDefinition) JdbcFieldDefinition(com.revolsys.jdbc.field.JdbcFieldDefinition) OracleSdoGeometryJdbcFieldDefinition(com.revolsys.oracle.recordstore.field.OracleSdoGeometryJdbcFieldDefinition) BoundingBox(com.revolsys.geometry.model.BoundingBox) QueryValue(com.revolsys.record.query.QueryValue) Value(com.revolsys.record.query.Value) ArcSdeStGeometryFieldDefinition(com.revolsys.oracle.recordstore.esri.ArcSdeStGeometryFieldDefinition) QueryValue(com.revolsys.record.query.QueryValue)

Aggregations

JdbcFieldDefinition (com.revolsys.jdbc.field.JdbcFieldDefinition)3 ArcSdeStGeometryFieldDefinition (com.revolsys.oracle.recordstore.esri.ArcSdeStGeometryFieldDefinition)3 OracleJdbcRowIdFieldDefinition (com.revolsys.oracle.recordstore.field.OracleJdbcRowIdFieldDefinition)3 OracleSdoGeometryJdbcFieldDefinition (com.revolsys.oracle.recordstore.field.OracleSdoGeometryJdbcFieldDefinition)3 QueryValue (com.revolsys.record.query.QueryValue)3 FieldDefinition (com.revolsys.record.schema.FieldDefinition)3 BoundingBox (com.revolsys.geometry.model.BoundingBox)1 Geometry (com.revolsys.geometry.model.Geometry)1 GeometryFactory (com.revolsys.geometry.model.GeometryFactory)1 Column (com.revolsys.record.query.Column)1 Value (com.revolsys.record.query.Value)1