tim@266: package de.intevation.gnv.geobackend.sde.datasources;
tim@130:
tim@263: import com.esri.sde.sdk.client.SDEPoint;
tim@130: import com.esri.sde.sdk.client.SeColumnDefinition;
tim@263: import com.esri.sde.sdk.client.SeConnection;
tim@130: import com.esri.sde.sdk.client.SeException;
tim@543: import com.esri.sde.sdk.client.SeExtent;
tim@263: import com.esri.sde.sdk.client.SeFilter;
tim@263: import com.esri.sde.sdk.client.SeLayer;
tim@130: import com.esri.sde.sdk.client.SeQuery;
tim@267: import com.esri.sde.sdk.client.SeQueryInfo;
tim@543: import com.esri.sde.sdk.client.SeRaster;
tim@543: import com.esri.sde.sdk.client.SeRasterAttr;
tim@543: import com.esri.sde.sdk.client.SeRasterBand;
tim@543: import com.esri.sde.sdk.client.SeRasterConstraint;
tim@543: import com.esri.sde.sdk.client.SeRasterTile;
tim@130: import com.esri.sde.sdk.client.SeRow;
tim@263: import com.esri.sde.sdk.client.SeShape;
tim@263: import com.esri.sde.sdk.client.SeShapeFilter;
tim@263: import com.esri.sde.sdk.client.SeSqlConstruct;
sascha@886:
tim@263: import com.vividsolutions.jts.geom.Geometry;
tim@879: import com.vividsolutions.jts.geom.LineString;
tim@383: import com.vividsolutions.jts.geom.Point;
tim@383: import com.vividsolutions.jts.geom.Polygon;
sascha@886:
tim@263: import com.vividsolutions.jts.io.WKTReader;
tim@263:
sascha@555: import de.intevation.gnv.geobackend.util.RedundancyRemover;
sascha@555:
sascha@886: import java.sql.Connection;
sascha@886: import java.sql.ResultSet;
sascha@886: import java.sql.SQLException;
sascha@886: import java.sql.SQLWarning;
sascha@886: import java.sql.Statement;
sascha@886:
sascha@886: import org.apache.log4j.Logger;
sascha@886:
sascha@547: /**
tim@884: * This Class wrapps an SDE-Statment to an java.sql.Statement.
tim@884: * This Class also handles the SDE-Specific -Spatial-Queries and
tim@884: * RasterQueries.
sascha@887: * @author Tim Englich
sascha@887: * @author Sascha L. Teichmann
tim@130: */
tim@130: public class ArcSDEStatement implements Statement {
tim@130:
tim@884: /**
tim@130: * the logger, used to log exceptions and additonaly information
tim@130: */
tim@130: private static Logger log = Logger.getLogger(ArcSDEStatement.class);
sascha@885:
tim@884: /**
tim@884: * The Connection to the ArcSDE-Backend
tim@884: */
tim@884: private ArcSDEConnection connection = null;
sascha@885:
tim@884: /**
tim@884: * Constructor
tim@884: * @param connection the Connection to the ArcSDE-Backend.
tim@884: */
tim@884: public ArcSDEStatement(ArcSDEConnection connection) {
tim@884: this.connection = connection;
tim@884: }
tim@130:
tim@884: /**
tim@884: * @see java.sql.Statement#addBatch(java.lang.String)
tim@884: */
tim@884: public void addBatch(String arg0) throws SQLException {
tim@884: }
tim@884:
tim@884: /**
tim@884: * @see java.sql.Statement#cancel()
tim@884: */
tim@884: public void cancel() throws SQLException {
tim@884: }
tim@884:
tim@884: /**
tim@884: * @see java.sql.Statement#clearBatch()
tim@884: */
tim@884: public void clearBatch() throws SQLException {
tim@884: }
tim@884:
tim@884: /**
tim@884: * @see java.sql.Statement#clearWarnings()
tim@884: */
tim@884: public void clearWarnings() throws SQLException {
tim@884: }
tim@884:
tim@884: /**
tim@884: * @see java.sql.Statement#close()
tim@884: */
tim@884: public void close() throws SQLException {
tim@884: }
tim@884:
tim@884: /**
tim@884: * @see java.sql.Statement#execute(java.lang.String)
tim@884: */
tim@884: public boolean execute(String arg0) throws SQLException {
tim@884: return false;
tim@884: }
tim@884:
tim@884: /**
tim@884: * @see java.sql.Statement#execute(java.lang.String, int)
tim@884: */
tim@884: public boolean execute(String arg0, int arg1) throws SQLException {
tim@884: return false;
tim@884: }
tim@884:
tim@884: /**
tim@884: * @see java.sql.Statement#execute(java.lang.String, int[])
tim@884: */
tim@884: public boolean execute(String arg0, int[] arg1) throws SQLException {
tim@884: return false;
tim@884: }
tim@884:
tim@884: /**
tim@884: * @see java.sql.Statement#execute(java.lang.String, java.lang.String[])
tim@884: */
tim@884: public boolean execute(String arg0, String[] arg1) throws SQLException {
tim@884: return false;
tim@884: }
tim@884:
tim@884: /**
tim@884: * @see java.sql.Statement#executeBatch()
tim@884: */
tim@884: public int[] executeBatch() throws SQLException {
tim@884: return null;
tim@884: }
tim@884:
tim@884: /**
tim@884: * @see java.sql.Statement#executeQuery(java.lang.String)
tim@884: */
tim@884: public ResultSet executeQuery(String statement) throws SQLException {
tim@884: try {
tim@884: SeQuery query = null;
tim@884: if (statement.toLowerCase().contains("st_astext") || statement.toLowerCase().contains("intersects")){
sascha@885:
tim@884: String[] values = statement.toLowerCase().split("where", 2);
tim@884: String where = values.length > 1 ? values[1].trim() : "";
tim@884: String[] tableNames = values[0].substring(values[0].indexOf("from")).replaceFirst("from", "").toUpperCase().trim().split(", ");
tim@884: String columnValueString = values[0].substring(0, values[0].indexOf("from")).trim();
tim@884: columnValueString = columnValueString.replaceFirst("select", "").trim();
tim@884: String[] returnFields = columnValueString.split(", ");
tim@884: String geometryColumnName = null;
tim@884: String byClause = null;
tim@884: int byClausePos = where.indexOf("group by");
tim@884: if (byClausePos < 0){
tim@884: byClausePos = where.indexOf("order by");
tim@884: }
tim@884: if (byClausePos > 0){
tim@884: byClause = where.substring(byClausePos);
tim@884: where = where.substring(0,byClausePos);
tim@884: }
sascha@885:
tim@884: for (int i = 0; i < returnFields.length; i++){
tim@884: returnFields[i] = returnFields[i].trim();
tim@884: if (returnFields[i].startsWith("st_astext(")){
tim@884: returnFields[i] = returnFields[i].replaceAll("st_astext", "");
tim@884: returnFields[i] = returnFields[i].substring(1, returnFields[i].length()-1);
tim@884: geometryColumnName = returnFields[i];
tim@884: }
tim@884: }
sascha@885:
tim@884: for (int i = 0; i < tableNames.length; i++){
tim@884: tableNames[i] = tableNames[i].trim();
tim@884: }
sascha@885:
tim@884: Geometry g = null;
tim@884: int pos = where.indexOf("intersects");
tim@884: if (pos >= 0 ){
tim@884: String substr = where.substring(pos);
tim@884: where = where.substring(0,where.lastIndexOf("intersects"));
tim@884: int andPos = where.lastIndexOf("and");
tim@884: if (andPos < 0){
tim@884: andPos = 0;
tim@884: }
tim@884: where = where.substring(0,andPos); // TODO support or also
tim@884: String intersectsStmt = substr.substring(0, substr.lastIndexOf(")")); // Spatial-Statment is the last one
tim@884: String wkt = null;
tim@884: if (intersectsStmt.contains("select")){
tim@884: // Anstelle eines WKT ist ein InnerSelect zum Bestimmen der Comparatorgeometrie gegeben.
tim@884: String stmt = intersectsStmt.substring(intersectsStmt.indexOf("select"),intersectsStmt.lastIndexOf(")"));
tim@884: ResultSet resultSet = this.executeQuery(stmt);
tim@884: if (resultSet != null && resultSet.next()){
tim@884: // TODO: Support the selection of more than one Geometry
tim@884: wkt = resultSet.getString("SHAPE");
tim@884: }
tim@884: }else{
tim@884: wkt = intersectsStmt.substring(intersectsStmt.indexOf("\""), intersectsStmt.lastIndexOf("\"")).replace("\"", "").trim();
tim@884: }
tim@884: g = new WKTReader().read(wkt.toUpperCase());
sascha@885:
tim@884: if (geometryColumnName == null){
tim@884: geometryColumnName = "SHAPE"; // TODO dynamisch aus Intersects auslesen.
tim@884: }
sascha@885:
tim@884: }
sascha@885:
tim@884: return this.executeQuery(this.connection.getSeConnection(), tableNames, geometryColumnName, where, g, returnFields,byClause);
tim@884: }else{
tim@884: query = new SeQuery(this.connection.getSeConnection());
tim@884: query.prepareSql(statement);
tim@884: query.execute();
tim@884: return this.handleResultSet(query,false,null);
tim@884: }
sascha@885:
tim@884: } catch (Exception e) {
tim@884: log.error(e,e);
tim@884: throw new SQLException(e.getMessage());
tim@130: }
sascha@885:
sascha@885:
tim@884: }
tim@884: /**
tim@884: * This Methods Executes the ArcSDE Query if Spatial-Restrictions
tim@884: * are given
tim@884: * @param con The Connection to the ArcSDE-Backend.
sascha@885: * @param pLayername The Name of tables which should be used in the Query
tim@884: * @param pSpatialColumnName the Name of the Spatial Column.
tim@884: * @param pWhere The where-Clause to limit the Data
tim@884: * @param g the Geometry to limit the Data
tim@884: * @param pReturnFields the Fileds that should be fetched from the Database
tim@884: * @param byClause the byClaus to order the Results.
tim@884: * @return the @see java.sql.ResultSet with the Data which was retrieved.
tim@884: * @throws SQLException
tim@884: */
tim@267: private ResultSet executeQuery(SeConnection con, String[] pLayername,
tim@263: String pSpatialColumnName, String pWhere,
tim@267: Geometry g, String[] pReturnFields, String byClause)
tim@263: throws SQLException {
tim@263: log.debug("executeQuery()");
tim@263: try {
tim@263: // get the layer for querying
tim@543: boolean isRaster = pSpatialColumnName.equalsIgnoreCase("raster");
sascha@885:
tim@266: SeShapeFilter[] filters = null;
tim@266: if (g != null){
tim@543: if (!isRaster){
tim@543: SeLayer lLayer = new SeLayer(con, pLayername[0], pSpatialColumnName);
tim@543: SeShape shape = new SeShape();
tim@543: shape.setCoordRef(lLayer.getCoordRef());
sascha@885:
tim@543: SDEPoint[] lPoints = new ArcSDEUtils().createPoints(g);
sascha@885:
tim@543: int searchMode = SeFilter.METHOD_AI;
tim@543: if (g instanceof Polygon){
tim@543: shape.generatePolygon(lPoints.length, 1, null, lPoints);
tim@543: }else if (g instanceof Point){
tim@543: shape.generatePoint(1, lPoints);
tim@543: searchMode = SeFilter.METHOD_PC;
tim@879: }else if (g instanceof LineString){
tim@879: shape.generateLine(lPoints.length, 1, null, lPoints);
tim@879: searchMode = SeFilter.METHOD_LCROSS;
tim@543: }
sascha@885:
tim@543: SeShapeFilter filter = new SeShapeFilter(pLayername[0],
tim@543: pSpatialColumnName, shape,searchMode);
tim@543: filters = new SeShapeFilter[1];
tim@543: filters[0] = filter;
tim@383: }
tim@266: }
tim@263:
tim@263: SeQuery spatialQuery = null;
tim@263: SeSqlConstruct sqlCons = new SeSqlConstruct(pLayername, pWhere);
tim@267: spatialQuery = new SeQuery(con);//, pReturnFields, sqlCons);
sascha@885:
tim@267: SeQueryInfo queryInfo = new SeQueryInfo();
tim@267: queryInfo.setColumns(pReturnFields);
sascha@885:
tim@267: if (byClause != null){
tim@267: queryInfo.setByClause(byClause);
tim@267: }
sascha@885:
tim@267: queryInfo.setConstruct(sqlCons);
tim@267: spatialQuery.prepareQueryInfo(queryInfo);
tim@267:
tim@263: /*
tim@263: * Set spatial constraints
tim@263: */
tim@266: if (filters != null){
tim@266: spatialQuery.setSpatialConstraints(SeQuery.SE_OPTIMIZE, false,
tim@266: filters);
tim@266: }
sascha@885:
tim@543: if (!isRaster){
tim@543: spatialQuery.execute();
tim@543: }
sascha@885:
tim@543: return this.handleResultSet(spatialQuery,isRaster,g);
tim@263:
tim@263: } catch (Exception e) {
tim@267: if (e instanceof SeException){
tim@267: ArcSDEUtils.printError((SeException)e);
tim@267: }else{
tim@267: log.error(e.getMessage(), e);
tim@267: }
sascha@885:
tim@263: throw new SQLException(e.getMessage());
tim@263: }
tim@263: }
tim@130:
tim@884: /**
tim@884: * @see java.sql.Statement#executeUpdate(java.lang.String)
tim@884: */
tim@884: public int executeUpdate(String arg0) throws SQLException {
tim@884: return 0;
tim@884: }
tim@130:
tim@884: /**
tim@884: * @see java.sql.Statement#executeUpdate(java.lang.String, int)
tim@884: */
tim@884: public int executeUpdate(String arg0, int arg1) throws SQLException {
tim@884: return 0;
tim@884: }
tim@130:
tim@884: /**
tim@884: * @see java.sql.Statement#executeUpdate(java.lang.String, int[])
tim@884: */
tim@884: public int executeUpdate(String arg0, int[] arg1) throws SQLException {
tim@884: return 0;
tim@884: }
tim@130:
tim@884: /**
tim@884: * @see java.sql.Statement#executeUpdate(java.lang.String, java.lang.String[])
tim@884: */
tim@884: public int executeUpdate(String arg0, String[] arg1) throws SQLException {
tim@884: return 0;
tim@884: }
tim@130:
tim@884: /**
tim@884: * @see java.sql.Statement#getConnection()
tim@884: */
tim@884: public Connection getConnection() throws SQLException {
tim@884: return this.connection;
tim@884: }
tim@130:
tim@884: /**
tim@884: * @see java.sql.Statement#getFetchDirection()
tim@884: */
tim@884: public int getFetchDirection() throws SQLException {
tim@884: return 0;
tim@884: }
sascha@547:
tim@884: /**
tim@884: * @see java.sql.Statement#getFetchSize()
tim@884: */
tim@884: public int getFetchSize() throws SQLException {
tim@884: return 0;
tim@884: }
tim@884:
tim@884: /**
tim@884: * @see java.sql.Statement#getGeneratedKeys()
tim@884: */
tim@884: public ResultSet getGeneratedKeys() throws SQLException {
tim@884: return null;
tim@884: }
tim@884:
tim@884: /**
tim@884: * @see java.sql.Statement#getMaxFieldSize()
tim@884: */
tim@884: public int getMaxFieldSize() throws SQLException {
tim@884: return 0;
tim@884: }
tim@884:
tim@884: /**
tim@884: * @see java.sql.Statement#getMaxRows()
tim@884: */
tim@884: public int getMaxRows() throws SQLException {
tim@884: return 0;
tim@884: }
tim@884:
tim@884: /**
tim@884: * @see java.sql.Statement#getMoreResults()
tim@884: */
tim@884: public boolean getMoreResults() throws SQLException {
tim@884: return false;
tim@884: }
tim@884:
tim@884: /**
tim@884: * @see java.sql.Statement#getMoreResults(int)
tim@884: */
tim@884: public boolean getMoreResults(int arg0) throws SQLException {
tim@884: return false;
tim@884: }
tim@884:
tim@884: /**
tim@884: * @see java.sql.Statement#getQueryTimeout()
tim@884: */
tim@884: public int getQueryTimeout() throws SQLException {
tim@884: return 0;
tim@884: }
tim@884:
tim@884: /**
tim@884: * @see java.sql.Statement#getResultSet()
tim@884: */
tim@884: public ResultSet getResultSet() throws SQLException {
tim@884: return null;
tim@884: }
tim@884:
tim@884: /**
tim@884: * @see java.sql.Statement#getResultSetConcurrency()
tim@884: */
tim@884: public int getResultSetConcurrency() throws SQLException {
tim@884: return 0;
tim@884: }
tim@884:
tim@884: /**
tim@884: * @see java.sql.Statement#getResultSetHoldability()
tim@884: */
tim@884: public int getResultSetHoldability() throws SQLException {
tim@884: return 0;
tim@884: }
tim@884:
tim@884: /**
tim@884: * @see java.sql.Statement#getResultSetType()
tim@884: */
tim@884: public int getResultSetType() throws SQLException {
tim@884: return 0;
tim@884: }
tim@884:
tim@884: /**
tim@884: * @see java.sql.Statement#getUpdateCount()
tim@884: */
tim@884: public int getUpdateCount() throws SQLException {
tim@884: return 0;
tim@884: }
tim@884:
tim@884: /**
tim@884: * @see java.sql.Statement#getWarnings()
tim@884: */
tim@884: public SQLWarning getWarnings() throws SQLException {
tim@884: return null;
tim@884: }
tim@884:
tim@884: /**
tim@884: * @see java.sql.Statement#setCursorName(java.lang.String)
tim@884: */
tim@884: public void setCursorName(String arg0) throws SQLException {
tim@884: }
tim@884:
tim@884: /**
tim@884: * @see java.sql.Statement#setEscapeProcessing(boolean)
tim@884: */
tim@884: public void setEscapeProcessing(boolean arg0) throws SQLException {
tim@884: }
tim@884:
tim@884: /**
tim@884: * @see java.sql.Statement#setFetchDirection(int)
tim@884: */
tim@884: public void setFetchDirection(int arg0) throws SQLException {
tim@884: }
tim@884:
tim@884: /**
tim@884: * @see java.sql.Statement#setFetchSize(int)
tim@884: */
tim@884: public void setFetchSize(int arg0) throws SQLException {
tim@884: }
tim@884:
tim@884: /**
tim@884: * @see java.sql.Statement#setMaxFieldSize(int)
tim@884: */
tim@884: public void setMaxFieldSize(int arg0) throws SQLException {
tim@884: }
tim@884:
tim@884: /**
tim@884: * @see java.sql.Statement#setMaxRows(int)
tim@884: */
tim@884: public void setMaxRows(int arg0) throws SQLException {
tim@884: }
tim@884:
tim@884: /**
tim@884: * @see java.sql.Statement#setQueryTimeout(int)
tim@884: */
tim@884: public void setQueryTimeout(int arg0) throws SQLException {
tim@884: }
sascha@885:
tim@884: /**
tim@884: * This Method fetches all Rows from the SeQuery-Object and convert it into
tim@884: * an @see java.sql.ResultSet.
sascha@885: *
tim@884: * @param pSeQuery the Queryobject where the Data should be fetched from.
tim@884: * @param isRaster Flag which indicates if the Result is Rasterdata.
tim@884: * @param geometry The Geometry which might be used to limit the data.
tim@884: * @return an java.sql:ResultSet which contains the Data.
tim@884: * @throws SeException
tim@884: */
sascha@885: private ResultSet handleResultSet(SeQuery pSeQuery,
sascha@885: boolean isRaster,
tim@884: Geometry geometry) throws SeException {
sascha@547: boolean debug = log.isDebugEnabled();
sascha@547:
sascha@547: if (debug) {
sascha@547: log.debug("ArcSDEStatement.handleResultSet()");
sascha@547: }
sascha@547:
ingo@1123: SDEResultSet lSet = isRaster
ingo@1123: ? new UncacheableSDEResultSet()
ingo@1123: : new SDEResultSet();
sascha@555: SeRow row = null;
tim@130: int lCount;
tim@543: if (!isRaster){
sascha@555: RedundancyRemover [] removers = null;
sascha@555: SeColumnDefinition [] lCols = null;
sascha@555:
tim@543: for (lCount = 0; (row = pSeQuery.fetch()) != null; lCount++) {
tim@543: // one time execution
tim@543: if (lCount == 0) {
tim@543: // analyze cols of result set
sascha@555: lCols = row.getColumns();
tim@543: for (SeColumnDefinition lCol : lCols) {
sascha@547: lSet.addCol(new ColDefinition(lCol.getName(), lCol.getType()));
sascha@547: // notice: esri-types have been copied into colDefinition class!
tim@543: }
sascha@555: removers = new RedundancyRemover[lCols.length];
sascha@555: for (int i = 0; i < removers.length; ++i) {
sascha@555: removers[i] = new RedundancyRemover();
sascha@555: }
tim@130: }
tim@543: short lNumCols = row.getNumColumns();
tim@543: Row lBackingRow = new Row(lNumCols);
tim@543: for (int i = 0; i < lNumCols; i++) {
sascha@555: lBackingRow.addObject(
sascha@885: removers[i].filter(row.getObject(i)),
sascha@555: i);
tim@543: }
tim@543: lSet.addRow(lBackingRow);
tim@130: }
sascha@555:
sascha@555: if (debug && removers != null) {
sascha@555: log.debug("datasets: " + lCount);
sascha@555: StringBuilder sb = new StringBuilder("removed redundancy: ");
sascha@555: float percent = 100f/lCount;
sascha@555: for (int i = 0; i < removers.length; ++i) {
sascha@555: if (i > 0) sb.append(", ");
sascha@555: sb.append(lCols[i].getName())
sascha@555: .append(": ").append(removers[i].numRemoved())
sascha@555: .append(" (").append(removers[i].numRemoved()*percent)
sascha@555: .append("%)");
sascha@555: }
sascha@555: log.debug(sb.toString());
sascha@555: }
tim@543: }else{
tim@543: try {
tim@544: pSeQuery.execute();
tim@544: row = pSeQuery.fetch();
sascha@547: SeRasterAttr attr = row.getRaster(0);
sascha@547: SeRaster raster = attr.getRasterInfo();
sascha@547: SeRasterBand [] bands = raster.getBands();
sascha@547: SeRasterBand rasterBand = bands[0];
sascha@885:
tim@543: SeExtent extent = rasterBand.getExtent();
sascha@547:
tim@543: double x = ((Point)geometry).getX();
tim@543: double y = ((Point)geometry).getY();
sascha@547:
sascha@547: boolean isPointInRaster =
sascha@885: x >= extent.getMinX() && x <= extent.getMaxX()
sascha@547: && y >= extent.getMinY() && y <= extent.getMaxY();
sascha@885:
tim@543: if (isPointInRaster){
sascha@885:
tim@544: if (row == null){
tim@544: pSeQuery.execute();
tim@544: row = pSeQuery.fetch();
tim@544: }
sascha@547:
sascha@547: double midX = 0.5d*(extent.getMinX() + extent.getMaxX());
sascha@547: double midY = 0.5d*(extent.getMinY() + extent.getMaxY());
sascha@547:
sascha@547: SDEPoint origin = rasterBand.getTileOrigin();
sascha@547:
sascha@885: double maxX = origin.getX() < midX
sascha@547: ? extent.getMaxX()
sascha@547: : extent.getMinX();
sascha@547:
sascha@547: double maxY = origin.getY() < midY
sascha@547: ? extent.getMaxY()
sascha@547: : extent.getMinY();
sascha@547:
sascha@547: double mx = rasterBand.getBandWidth()/(maxX-origin.getX());
sascha@547: double bx = -origin.getX()*mx;
sascha@547: double px = mx*x + bx;
sascha@547:
sascha@547: double my = rasterBand.getBandHeight()/(maxY-origin.getY());
sascha@547: double by = -origin.getY()*my;
sascha@547: double py = my*y + by;
sascha@547:
tim@544: SeRasterConstraint constraint = new SeRasterConstraint();
sascha@547: constraint.setLevel(0); // best resolution
sascha@547: constraint.setBands(rasterBand.getBandNumber());
sascha@547: int tx = (int)Math.floor(px / rasterBand.getTileWidth());
sascha@547: int ty = (int)Math.floor(py / rasterBand.getTileHeight());
sascha@547: constraint.setEnvelope(tx, ty, tx, ty);
sascha@547:
tim@544: pSeQuery.queryRasterTile(constraint);
tim@544: SeRasterTile tile = row.getRasterTile();
sascha@547:
sascha@547: if (tile != null){
tim@544: double[] tileValues = new double[tile.getNumPixels()];
tim@544: tileValues = tile.getPixels(tileValues);
sascha@547: lSet.addCol(new ColDefinition("tile", ColDefinition.FLOAT64));
tim@544: Row lBackingRow = new Row(1);
sascha@547:
sascha@547: double wx1 = (rasterBand.getTileWidth()*tx - bx)/mx;
sascha@547: double wx2 = (rasterBand.getTileWidth()*(tx+1) - bx)/mx;
sascha@547: double mxt = (rasterBand.getTileWidth()-1e-5d)/(wx2 - wx1);
sascha@547: double bxt = -wx1*mxt;
sascha@547:
sascha@547: double wy1 = (rasterBand.getTileHeight()*ty - by)/my;
sascha@547: double wy2 = (rasterBand.getTileHeight()*(ty+1) - by)/my;
sascha@547: double myt = (rasterBand.getTileHeight()-1e-5d)/(wy2 - wy1);
sascha@547: double byt = -wy1*myt;
sascha@547:
sascha@547: RasterObject ro = new RasterObject(
sascha@547: mxt, bxt,
sascha@547: myt, byt,
sascha@547: tile.getColumnIndex(),
sascha@547: tile.getRowIndex(),
sascha@547: tileValues,
sascha@547: rasterBand.getTileWidth(),
sascha@547: rasterBand.getTileHeight());
sascha@547: lBackingRow.addObject(ro, 0);
tim@544: lSet.addRow(lBackingRow);
sascha@547:
tim@544: }
sascha@547: }
sascha@547: else{
sascha@547: log.debug("The Query doesn't deliver any Information " +
sascha@547: "because the Point is located outside the Raster.");
tim@543: }
tim@543: } catch (Exception e) {
tim@543: log.error(e,e);
tim@130: }
tim@130: }
tim@130: pSeQuery.close();
tim@130: return lSet;
tim@130: }
tim@130:
tim@884: /**
tim@884: * @see java.sql.Statement#isClosed()
tim@884: */
tim@380: public boolean isClosed() throws SQLException {
tim@380: return false;
tim@380: }
tim@380:
tim@884: /**
tim@884: * @see java.sql.Statement#isPoolable()
tim@884: */
tim@380: public boolean isPoolable() throws SQLException {
tim@380: return false;
tim@380: }
tim@380:
tim@884: /**
tim@884: * @see java.sql.Statement#setPoolable(boolean)
tim@884: */
tim@380: public void setPoolable(boolean arg0) throws SQLException {
tim@380: }
tim@380:
tim@884: /**
tim@884: * @see java.sql.Wrapper#isWrapperFor(java.lang.Class)
tim@884: */
tim@380: public boolean isWrapperFor(Class> iface) throws SQLException {
tim@380: return false;
tim@380: }
tim@380:
tim@884: /**
tim@884: * @see java.sql.Wrapper#unwrap(java.lang.Class)
tim@884: */
tim@380: public T unwrap(Class iface) throws SQLException {
tim@380: return null;
sascha@885:
tim@380: }
tim@130: }