public QueryBuilder < GeometryIndex , GeometryIndexKey > queryBuilder ( GeometryEnvelope envelope ) { QueryBuilder < GeometryIndex , GeometryIndexKey > qb = geometryIndexDao . queryBuilder ( ) ; try { double minX = envelope . getMinX ( ) - tolerance ; double maxX = envelope . getMaxX ( ) + tolerance ; double minY = envelope . getMinY ( ) - tolerance ; double maxY = envelope . getMaxY ( ) + tolerance ; Where < GeometryIndex , GeometryIndexKey > where = qb . where ( ) ; where . eq ( GeometryIndex . COLUMN_TABLE_NAME , tableName ) . and ( ) . le ( GeometryIndex . COLUMN_MIN_X , maxX ) . and ( ) . ge ( GeometryIndex . COLUMN_MAX_X , minX ) . and ( ) . le ( GeometryIndex . COLUMN_MIN_Y , maxY ) . and ( ) . ge ( GeometryIndex . COLUMN_MAX_Y , minY ) ; if ( envelope . hasZ ( ) ) { double minZ = envelope . getMinZ ( ) - tolerance ; double maxZ = envelope . getMaxZ ( ) + tolerance ; where . and ( ) . le ( GeometryIndex . COLUMN_MIN_Z , maxZ ) . and ( ) . ge ( GeometryIndex . COLUMN_MAX_Z , minZ ) ; } if ( envelope . hasM ( ) ) { double minM = envelope . getMinM ( ) - tolerance ; double maxM = envelope . getMaxM ( ) + tolerance ; where . and ( ) . le ( GeometryIndex . COLUMN_MIN_M , maxM ) . and ( ) . ge ( GeometryIndex . COLUMN_MAX_M , minM ) ; } } catch ( SQLException e ) { throw new GeoPackageException ( "Failed to build query for Geometry Indices. GeoPackage: " + geoPackage . getName ( ) + ", Table Name: " + tableName + ", Column Name: " + columnName , e ) ; } return qb ; }
Build a query builder to query for Geometry Index objects within the Geometry Envelope