Mercurial > dive4elements > gnv-client
diff geo-backend/src/main/java/de/intevation/gnv/geobackend/sde/datasources/ArcSDEStatement.java @ 885:1c3efbd2fc5a
Removes trailing whitespace.
geo-backend/trunk@850 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Mon, 29 Mar 2010 07:49:16 +0000 |
parents | 12f88239fb33 |
children | 8b442223741c |
line wrap: on
line diff
--- a/geo-backend/src/main/java/de/intevation/gnv/geobackend/sde/datasources/ArcSDEStatement.java Fri Mar 26 15:23:03 2010 +0000 +++ b/geo-backend/src/main/java/de/intevation/gnv/geobackend/sde/datasources/ArcSDEStatement.java Mon Mar 29 07:49:16 2010 +0000 @@ -47,12 +47,12 @@ * the logger, used to log exceptions and additonaly information */ private static Logger log = Logger.getLogger(ArcSDEStatement.class); - + /** * The Connection to the ArcSDE-Backend */ private ArcSDEConnection connection = null; - + /** * Constructor * @param connection the Connection to the ArcSDE-Backend. @@ -133,7 +133,7 @@ try { SeQuery query = null; if (statement.toLowerCase().contains("st_astext") || statement.toLowerCase().contains("intersects")){ - + String[] values = statement.toLowerCase().split("where", 2); String where = values.length > 1 ? values[1].trim() : ""; String[] tableNames = values[0].substring(values[0].indexOf("from")).replaceFirst("from", "").toUpperCase().trim().split(", "); @@ -150,7 +150,7 @@ byClause = where.substring(byClausePos); where = where.substring(0,byClausePos); } - + for (int i = 0; i < returnFields.length; i++){ returnFields[i] = returnFields[i].trim(); if (returnFields[i].startsWith("st_astext(")){ @@ -159,11 +159,11 @@ geometryColumnName = returnFields[i]; } } - + for (int i = 0; i < tableNames.length; i++){ tableNames[i] = tableNames[i].trim(); } - + Geometry g = null; int pos = where.indexOf("intersects"); if (pos >= 0 ){ @@ -188,13 +188,13 @@ wkt = intersectsStmt.substring(intersectsStmt.indexOf("\""), intersectsStmt.lastIndexOf("\"")).replace("\"", "").trim(); } g = new WKTReader().read(wkt.toUpperCase()); - + if (geometryColumnName == null){ geometryColumnName = "SHAPE"; // TODO dynamisch aus Intersects auslesen. } - + } - + return this.executeQuery(this.connection.getSeConnection(), tableNames, geometryColumnName, where, g, returnFields,byClause); }else{ query = new SeQuery(this.connection.getSeConnection()); @@ -202,19 +202,19 @@ query.execute(); return this.handleResultSet(query,false,null); } - + } catch (Exception e) { log.error(e,e); throw new SQLException(e.getMessage()); } - - + + } /** * This Methods Executes the ArcSDE Query if Spatial-Restrictions * are given * @param con The Connection to the ArcSDE-Backend. - * @param pLayername The Name of tables which should be used in the Query + * @param pLayername The Name of tables which should be used in the Query * @param pSpatialColumnName the Name of the Spatial Column. * @param pWhere The where-Clause to limit the Data * @param g the Geometry to limit the Data @@ -231,16 +231,16 @@ try { // get the layer for querying boolean isRaster = pSpatialColumnName.equalsIgnoreCase("raster"); - + SeShapeFilter[] filters = null; if (g != null){ if (!isRaster){ SeLayer lLayer = new SeLayer(con, pLayername[0], pSpatialColumnName); SeShape shape = new SeShape(); shape.setCoordRef(lLayer.getCoordRef()); - + SDEPoint[] lPoints = new ArcSDEUtils().createPoints(g); - + int searchMode = SeFilter.METHOD_AI; if (g instanceof Polygon){ shape.generatePolygon(lPoints.length, 1, null, lPoints); @@ -251,7 +251,7 @@ shape.generateLine(lPoints.length, 1, null, lPoints); searchMode = SeFilter.METHOD_LCROSS; } - + SeShapeFilter filter = new SeShapeFilter(pLayername[0], pSpatialColumnName, shape,searchMode); filters = new SeShapeFilter[1]; @@ -262,14 +262,14 @@ SeQuery spatialQuery = null; SeSqlConstruct sqlCons = new SeSqlConstruct(pLayername, pWhere); spatialQuery = new SeQuery(con);//, pReturnFields, sqlCons); - + SeQueryInfo queryInfo = new SeQueryInfo(); queryInfo.setColumns(pReturnFields); - + if (byClause != null){ queryInfo.setByClause(byClause); } - + queryInfo.setConstruct(sqlCons); spatialQuery.prepareQueryInfo(queryInfo); @@ -280,11 +280,11 @@ spatialQuery.setSpatialConstraints(SeQuery.SE_OPTIMIZE, false, filters); } - + if (!isRaster){ spatialQuery.execute(); } - + return this.handleResultSet(spatialQuery,isRaster,g); } catch (Exception e) { @@ -293,7 +293,7 @@ }else{ log.error(e.getMessage(), e); } - + throw new SQLException(e.getMessage()); } } @@ -472,19 +472,19 @@ */ public void setQueryTimeout(int arg0) throws SQLException { } - + /** * This Method fetches all Rows from the SeQuery-Object and convert it into * an @see java.sql.ResultSet. - * + * * @param pSeQuery the Queryobject where the Data should be fetched from. * @param isRaster Flag which indicates if the Result is Rasterdata. * @param geometry The Geometry which might be used to limit the data. * @return an java.sql:ResultSet which contains the Data. * @throws SeException */ - private ResultSet handleResultSet(SeQuery pSeQuery, - boolean isRaster, + private ResultSet handleResultSet(SeQuery pSeQuery, + boolean isRaster, Geometry geometry) throws SeException { boolean debug = log.isDebugEnabled(); @@ -517,7 +517,7 @@ Row lBackingRow = new Row(lNumCols); for (int i = 0; i < lNumCols; i++) { lBackingRow.addObject( - removers[i].filter(row.getObject(i)), + removers[i].filter(row.getObject(i)), i); } lSet.addRow(lBackingRow); @@ -544,18 +544,18 @@ SeRaster raster = attr.getRasterInfo(); SeRasterBand [] bands = raster.getBands(); SeRasterBand rasterBand = bands[0]; - + SeExtent extent = rasterBand.getExtent(); double x = ((Point)geometry).getX(); double y = ((Point)geometry).getY(); boolean isPointInRaster = - x >= extent.getMinX() && x <= extent.getMaxX() + x >= extent.getMinX() && x <= extent.getMaxX() && y >= extent.getMinY() && y <= extent.getMaxY(); - + if (isPointInRaster){ - + if (row == null){ pSeQuery.execute(); row = pSeQuery.fetch(); @@ -566,7 +566,7 @@ SDEPoint origin = rasterBand.getTileOrigin(); - double maxX = origin.getX() < midX + double maxX = origin.getX() < midX ? extent.getMaxX() : extent.getMinX(); @@ -665,6 +665,6 @@ */ public <T> T unwrap(Class<T> iface) throws SQLException { return null; - + } }