changeset 263:031ef9649cd1

Added SFS-Support to ArcSDE-Query-Part geo-backend/trunk@210 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Tim Englich <tim.englich@intevation.de>
date Tue, 13 Oct 2009 08:57:19 +0000 (2009-10-13)
parents fcfa9d2de572
children 5bbdbc0bbddc
files geo-backend/ChangeLog geo-backend/pom.xml geo-backend/src/main/java/de/intevation/gnv/geobackend/sde/datasources/ArcSDEStatement.java geo-backend/src/main/java/de/intevation/gnv/geobackend/sde/datasources/ArcSDEUtils.java geo-backend/src/main/java/de/intevation/gnv/geobackend/sde/datasources/Row.java geo-backend/src/test/ressources/QueryExecutorTestCase.properties
diffstat 6 files changed, 206 insertions(+), 237 deletions(-) [+]
line wrap: on
line diff
--- a/geo-backend/ChangeLog	Wed Oct 07 10:26:33 2009 +0000
+++ b/geo-backend/ChangeLog	Tue Oct 13 08:57:19 2009 +0000
@@ -1,3 +1,16 @@
+2009-10-13  Tim Englich  <tim.englich@intevation.de>
+
+	* src/test/ressources/QueryExecutorTestCase.properties: 
+	  Added SFS-Conformal Query
+	* pom.xml:
+	  Added dependency to JTS 1.9
+	* src/main/java/de/intevation/gnv/geobackend/sde/datasources/ArcSDEStatement.java (executeQuery): 
+	  Added Spatial-Query-Support for ArcSDE
+	* src/main/java/de/intevation/gnv/geobackend/sde/datasources/ArcSDEUtils.java (createPoints): 
+	  Switched Method Signature to JTS-Geometry-Support
+	* src/main/java/de/intevation/gnv/geobackend/sde/datasources/Row.java (getStringValue): 
+	  Added String-Support for GeometryObjects
+
 2009-10-07	Sascha L. Teichmann	<sascha.teichmann@intevation.de>
 
 	RELEASE 0.1
@@ -19,143 +32,32 @@
 	* src/main/java/de/intevation/gnv/geobackend/util/DateUtils.java (DATE_PATTERN) Edited:
 	  Make the Constants assessible for other Parts of the Project to reduce the TouchPoints for
 	  Dateformats.
-	  
-2009-09-24	Tim Englich	<tim.englich@intevation.de>
+
+2009-09-24  Tim Englich  <tim.englich@intevation.de>
 
 	* src/main/java/de/intevation/gnv/geobackend/base/ResultDescriptor.java Edited, 
 	  src/main/java/de/intevation/gnv/geobackend/base/Result.java Edited, 
 	  src/main/java/de/intevation/gnv/geobackend/base/DefaultResultDescriptor.java Edited,  
 	  src/main/java/de/intevation/gnv/geobackend/base/DefaultResult.java Edited:
 	  Make Classes Serializable for Storing in ArtifactDatabase 
-	  
-2009-09-21	Tim Englich	<tim.englich@intevation.de>
+
+2009-09-21  Tim Englich  <tim.englich@intevation.de>
 
 	* src/main/java/de/intevation/gnv/geobackend/base/DefaultResult.java: 
-	  Added formatted Date handling in getString Method
-
-2009-09-21	Tim Englich	<tim.englich@intevation.de>
-
+	  Added formatted Date Handling in getString Method
 	* src/test/ressources/QueryExecutorTestCase.properties Edited, 
 	  src/test/java/de/intevation/gnv/geobackend/base/query/QueryExecutorTestCase.java Edited:
 	  Some tests for Spatialqueries added 
-
 	* src/main/java/de/intevation/gnv/geobackend/base/query/DefaultQueryExceutor.java Edited: 
 	  Put the final Querystring into a Logmessage
-	  
-2009-09-09	Tim Englich	<tim.englich@intevation.de>
 
-	* target/**: Removed.
-
-2009-09-09	Tim Englich	<tim.englich@intevation.de>
+2009-09-09  Tim Englich  <tim.englich@intevation.de>
 
 	* src/main/java/de/intevation/gnv/geobackend/base/DefaultResult.java (getDate):
-	  Instance Check for DateValues
-
+	 . Intance Check for DateValues
 	* src/main/java/de/intevation/gnv/geobackend/sde/datasources/SDEResultSet.java (next):
 	  Logging removed because the performance slowdown fetching many ResultSets 
 
-2009-09-04	Tim Englich	<tim.englich@intevation.de>
-
-	* pom.xml: Edited GroupID changed
-	
-2009-09-04	Tim Englich	<tim.englich@intevation.de>
-
-	* pom.xml: Edited
-	  Buildplugins for Maven-Compiler and Maven-Eclipse Plugin integrated.
-
-2009-09-04	Tim Englich	<tim.englich@intevation.de>
-
-	* src/main/java/de/intevation/gnv/geobackend/base/query/QueryExecutorBase.java (setFilterValues): Edited
-	  Fixed Bug using replaceFirst an ?. You hav to put a ? in [].
-
-	* src/test/java/de/intevation/gnv/geobackend/base/query/QueryExecutorTestCase.java (testQueryExecutor): Edited
-	Further TestCase using a where clause implemented. More asserts testimg the number of Results integrated
+2009-09-04  Tim Englich  <tim.englich@intevation.de>
 
-	* src/test/ressources/QueryExecutorTestCase.properties: Edited
-	Statement Fetching only one Mesh integrated.
-	  
-2009-09-04	Tim Englich	<tim.englich@intevation.de>
-	
-	* src/test/java/de/intevation/gnv/geobackend/sde/datasources/ArcSDEConnectionPoolTestCase.java: Edited
-	  Changed Tabs against 4 Spaces. Commennts written
-	
-	* src/main/java/de/intevation/gnv/geobackend/base/connectionpool/ConnectionPoolFactory.java: Edited,
-	* src/main/java/de/intevation/gnv/geobackend/base/connectionpool/ConnectionPool.java: Edited
-	
-	Changed Tabs against 4 Spaces
-	
-	* src/test/ressources/QueryExecutorTestCase.properties: 
-	  Create a Testpropertiesfile with Samplestatements for the Testcase QueryExecutorTestCase.
-	
-	* src/main/java/de/intevation/gnv/geobackend/sde/datasources/SDEResultSet.java: Edited:
-	  The Method getResultSetMetaData modified to return an Instance of the ArcSDEResultSetMetaData-Class
-	
-	* src/main/java/de/intevation/gnv/geobackend/sde/datasources/ArcSDEResultSetMetaData.java: 
-	  Implementation of the java.sql.ResultSetMetaData Interface for wrapping the Metainformations of an 
-	  ArcSDE-ResultSet
-	
-	* src/test/java/de/intevation/gnv/geobackend/base/query/QueryExecutorTestCase.java:  Testfall
-	  Testcase for the Inteface QueryExecuor implemented. This Testcats should test the fundamental Functions of the
-	  Impelmentation of this interface. currently the DefaulQueryExecutor is used to fetch Resukts from the MEDIAN.MESH
-	  Table from BSH.
-	
-	* src/main/java/de/intevation/gnv/geobackend/base/query/container/exception/QueryContainerException.java, 
-	  src/main/java/de/intevation/gnv/geobackend/base/query/container/QueryContainerFactory.java, 
-	  src/main/java/de/intevation/gnv/geobackend/base/query/container/DefaultQueryContainer.java,
-	  src/main/java/de/intevation/gnv/geobackend/base/query/container/QueryContainer.java:
-	  Container for central providing of configured Datastorequeries.
-	  An instance can be instantiated using the factory.
-	
-	* src/main/java/de/intevation/gnv/geobackend/base/query/QueryExecutorFactory.java,
-	  src/main/java/de/intevation/gnv/geobackend/base/query/QueryExecutorBase.java, 
-	  src/main/java/de/intevation/gnv/geobackend/base/query/DefaultQueryExceutor.java, 
-	  src/main/java/de/intevation/gnv/geobackend/base/query/QueryExecutor.java: 
-	  Implementation of an Infrastructure for querying Datastores.
-	  An Instance can be instantiated using the factory.
-	
-	* src/main/java/de/intevation/gnv/geobackend/base/query/exception/QueryException.java, 
-	  src/main/java/de/intevation/gnv/geobackend/base/DefaultResult.java, 
-	  src/main/java/de/intevation/gnv/geobackend/base/DefaultResultDescriptor.java, 
-	  src/main/java/de/intevation/gnv/geobackend/base/ResultDescriptor.java, 
-	  src/main/java/de/intevation/gnv/geobackend/base/Result.java: 
-	  Implementation of an Containerinfrastrucure for storing of ResultSets of Querys
-
-2009-09-02	Tim Englich	<tim.englich@intevaion.de>
-
-	* Changelog: Changelog adjusted
-	 
-2009-09-02	Tim Englich	<tim.englich@intevaion.de>
-
-	* src/main/java/de/intevation/gnv/geobackend/base/connectionpool/ConnectionPool.java,
-	  src/main/java/de/intevation/gnv/geobackend/base/connectionpool/ConnectionPoolFactory.java,
-	  src/main/java/de/intevation/gnv/geobackend/base/connectionpool/exception/ConnectionException.java,
-	  src/main/java/de/intevation/gnv/geobackend/sde/datasources/exception/ConnectionException.java,
-	  src/main/java/de/intevation/gnv/geobackend/sde/connectionpool/ArcSDEConnectionPool.java,
-	  src/main/java/de/intevation/gnv/geobackend/sde/connectionpool/ArcSDEPoolableObjectFactory.java,
-	  src/main/java/de/intevation/gnv/geobackend/sde/datasources/ArcSDEConnection.java,
-	  src/main/java/de/intevation/gnv/geobackend/sde/datasources/ArcSDEStatement.java:
-	  New classes based on java.sql.* interface structure.
-
-	* src/test/java/de/intevation/gnv/geobackend/sde/datasources/ArcSDEConnectionPoolTestCase.java,
-	  src/test/ressources/ArcSDEConnectionPoolTestCase.properties:
-	  Test class for new data access layer.
-
-	* src/main/java/de/intevation/gnv/geobackend/sde/datasources/ArcSDEConnectionPool.java,
-	  src/main/java/de/intevation/gnv/geobackend/sde/datasources/SDEConnection.java,
-	  src/main/java/de/intevation/gnv/geobackend/sde/datasources/SDEDatasource.java,
-	  src/main/java/de/intevation/gnv/geobackend/sde/datasources/exception/ConnectionException.java:
-	  Removed obsolete access classes.
-
-	* src/main/java/de/intevation/gnv/geobackend/sde/datasources/ArcSDEUtils.java,
-	  src/main/java/de/intevation/gnv/geobackend/sde/datasources/ResultSet.java,
-	  src/main/java/de/intevation/gnv/geobackend/sde/datasources/SDEQuery.java,
-	  src/main/java/de/intevation/gnv/geobackend/sde/datasources/SDEResultSet.java:
-	  Modified: adjusted classes to fit the new infrastructure.
-
-2009-09-02	Tim Englich	<tim.englich@intevaion.de>
-
-	Java project generated, Import of SDE-Datasources 
-	Revision 101 from Repository of principal de/intevation/gnv/geobackend/sde/datasources/**/* 
-
-	* README, Changelog, Changes, NEWS, TODO: New. Initial setup
-	* pom.xml: Add dependencies
+	* pom.xml: 
\ No newline at end of file
--- a/geo-backend/pom.xml	Wed Oct 07 10:26:33 2009 +0000
+++ b/geo-backend/pom.xml	Tue Oct 13 08:57:19 2009 +0000
@@ -4,7 +4,8 @@
   <groupId>de.intevation.bsh</groupId>
   <artifactId>geo-backend</artifactId>
   <packaging>jar</packaging>
-  <version>1.0-SNAPSHOT</version>
+  
+   <version>1.0-SNAPSHOT</version>
   <name>geo-backend</name>
   <url>http://maven.apache.org</url>
   <build>
@@ -60,5 +61,17 @@
       <artifactId>commons-pool</artifactId>
       <version>1.5.2</version>
     </dependency>
+    <dependency>
+      <groupId>com.vividsolutions</groupId>
+      <artifactId>jts</artifactId>
+      <version>1.9</version>
+    </dependency>
   </dependencies>
+  <repositories>
+    <repository>
+      <id>gt2.repo</id>
+      <name>GeoTools2 Repository including JTS</name>
+      <url>http://maven.geotools.fr/repository</url>
+    </repository>
+  </repositories>
 </project>
--- a/geo-backend/src/main/java/de/intevation/gnv/geobackend/sde/datasources/ArcSDEStatement.java	Wed Oct 07 10:26:33 2009 +0000
+++ b/geo-backend/src/main/java/de/intevation/gnv/geobackend/sde/datasources/ArcSDEStatement.java	Tue Oct 13 08:57:19 2009 +0000
@@ -1,7 +1,7 @@
 /**
 		*
 		*/
-		package de.intevation.gnv.geobackend.sde.datasources;
+	package de.intevation.gnv.geobackend.sde.datasources;
 
 import java.sql.Connection;
 import java.sql.ResultSet;
@@ -11,10 +11,22 @@
 
 import org.apache.log4j.Logger;
 
+import com.esri.sde.sdk.client.SDEPoint;
 import com.esri.sde.sdk.client.SeColumnDefinition;
+import com.esri.sde.sdk.client.SeConnection;
+import com.esri.sde.sdk.client.SeCoordinateReference;
 import com.esri.sde.sdk.client.SeException;
+import com.esri.sde.sdk.client.SeFilter;
+import com.esri.sde.sdk.client.SeLayer;
 import com.esri.sde.sdk.client.SeQuery;
 import com.esri.sde.sdk.client.SeRow;
+import com.esri.sde.sdk.client.SeShape;
+import com.esri.sde.sdk.client.SeShapeFilter;
+import com.esri.sde.sdk.client.SeSqlConstruct;
+import com.vividsolutions.jts.geom.Geometry;
+import com.vividsolutions.jts.geom.GeometryFactory;
+import com.vividsolutions.jts.io.WKTReader;
+
 
 		/**
  * @author Tim Englich <tim.englich@intevation.de>
@@ -111,17 +123,87 @@
 	 */
 	public ResultSet executeQuery(String statement) throws SQLException {
 		try {
-	        SeQuery query = new SeQuery(this.connection.getSeConnection());
-	        query.prepareSql(statement);
-	        query.execute();
-	        return this.handleResultSet(query);
-		} catch (SeException e) {
+		    SeQuery query = null;
+	        if (statement.toLowerCase().contains("st_astext")){
+	            
+	            String[] values =  statement.toLowerCase().split("where", 2);
+	            String where = values.length > 1 ? values[1].trim() : "";
+	            values = values[0].split("from", 2);
+	            String layerName = values[1].toUpperCase().trim();
+	            String[] returnFields  = values[0].replaceAll("select", "").trim().split(",");
+	            String geometryColumnName = "N/N";
+	            for (int i = 0; i < returnFields.length; i++){
+	                returnFields[i] = returnFields[i].trim();
+	                if (returnFields[i].startsWith("st_astext(")){
+	                    returnFields[i] = returnFields[i].replaceAll("st_astext", "");
+	                    returnFields[i] = returnFields[i].substring(1, returnFields[i].length()-1);
+	                    geometryColumnName = returnFields[i];
+	                }
+	            }
+	            Geometry g = null;
+	            int pos = where.indexOf("intersects");
+	            if (pos > 0 ){
+	                String substr =  where.substring(pos);
+	                where = where.substring(0,where.lastIndexOf("and")); // TODO auch or unterst�tzen
+	                String intersectsStmt = substr.substring(0, substr.lastIndexOf(")")); // Annahme r�umliches Stmt steht am Ende
+	                String wkt = intersectsStmt.substring(intersectsStmt.indexOf("\""), intersectsStmt.lastIndexOf("\"")).replace("\"", "").trim();
+	                g = new WKTReader().read(wkt);
+	                
+	            }
+	            return this.executeQuery(this.connection.getSeConnection(), layerName, geometryColumnName, where, g, returnFields);
+	        }else{
+	            query = new SeQuery(this.connection.getSeConnection());
+	            query.prepareSql(statement);
+	            query.execute();
+	            return this.handleResultSet(query);
+	        }
+	       
+		} catch (Exception e) {
 	        log.error(e,e);
 	        throw new SQLException(e.getMessage());
         }
         
         
 	}
+	
+    private ResultSet executeQuery(SeConnection con, String pLayername,
+                                   String pSpatialColumnName, String pWhere,
+                                   Geometry g, String[] pReturnFields)
+                                                                              throws SQLException {
+        log.debug("executeQuery()");
+        try {
+            // get the layer for querying
+            SeLayer lLayer = new SeLayer(con, pLayername, pSpatialColumnName);
+            SeCoordinateReference cref = lLayer.getCoordRef();
+
+            SeShape shape = new SeShape();
+            shape.setCoordRef(lLayer.getCoordRef());
+            SDEPoint[] lPoints = new ArcSDEUtils().createPoints(g);
+
+            shape.generatePolygon(lPoints.length, 1, null, lPoints);
+            SeShapeFilter filter = new SeShapeFilter(pLayername,
+                    pSpatialColumnName, shape, SeFilter.METHOD_AI);
+            SeShapeFilter[] filters = new SeShapeFilter[1];
+            filters[0] = filter;
+
+            SeQuery spatialQuery = null;
+            SeSqlConstruct sqlCons = new SeSqlConstruct(pLayername, pWhere);
+            spatialQuery = new SeQuery(con, pReturnFields, sqlCons);
+            spatialQuery.prepareQuery();
+            /*
+             * Set spatial constraints
+             */
+            spatialQuery.setSpatialConstraints(SeQuery.SE_OPTIMIZE, false,
+                    filters);
+            spatialQuery.execute();
+
+            return this.handleResultSet(spatialQuery);
+
+        } catch (Exception e) {
+            log.error(e.getMessage(), e);
+            throw new SQLException(e.getMessage());
+        }
+    }
 
 	/**
 	 * @see java.sql.Statement#executeUpdate(java.lang.String)
--- a/geo-backend/src/main/java/de/intevation/gnv/geobackend/sde/datasources/ArcSDEUtils.java	Wed Oct 07 10:26:33 2009 +0000
+++ b/geo-backend/src/main/java/de/intevation/gnv/geobackend/sde/datasources/ArcSDEUtils.java	Tue Oct 13 08:57:19 2009 +0000
@@ -21,23 +21,19 @@
 
 import com.esri.sde.sdk.client.SDEPoint;
 import com.esri.sde.sdk.client.SeColumnDefinition;
-import com.esri.sde.sdk.client.SeConnection;
 import com.esri.sde.sdk.client.SeError;
 import com.esri.sde.sdk.client.SeException;
-import com.esri.sde.sdk.client.SeQuery;
-import com.esri.sde.sdk.client.SeQueryInfo;
-import com.esri.sde.sdk.client.SeSqlConstruct;
 import com.esri.sde.sdk.client.SeTable;
-
-import de.intevation.gnv.geobackend.base.connectionpool.exception.ConnectionException;
-import de.intevation.gnv.geobackend.sde.datasources.exception.TechnicalException;
+import com.vividsolutions.jts.geom.Coordinate;
+import com.vividsolutions.jts.geom.Geometry;
+import com.vividsolutions.jts.geom.Polygon;
 
 /**
  * The class <code>ArcSDEUtils</code> fulfills the following purposes:
  * <ol>
  * <li></li>
  * </ol>
- *
+ * 
  * @author blume
  * @version 1.0
  * @serial 1.0
@@ -51,53 +47,6 @@
      */
     private static Logger sLogger = Logger.getLogger(ArcSDEUtils.class);
 
-
-    /**
-     * @param pTable e.g. "BSH.ARCMARINE_TIMESERIES_VIEW"
-     * @param pWhere where-Clause (can be empty, null-case not tested)
-     */
-    public void getTableStats(String pTable, String pWhere) {
-        sLogger.debug("getTableStats()");
-        SeConnection conn = null;
-        SeTable.SeTableStats tableStats;
-        try {
-            conn = getConnection();
-            SeTable table = new SeTable(conn, pTable);
-
-            SeSqlConstruct sqlCons = new SeSqlConstruct(table.getQualifiedName());
-            sqlCons.setWhere(pWhere);
-            SeQuery query = new SeQuery(conn);
-            SeQueryInfo queryInfo = new SeQueryInfo();
-            queryInfo.setConstruct(sqlCons);
-            int mask = SeTable.SeTableStats.SE_ALL_STATS;
-            int maxDistinct = 0;
-
-            SeColumnDefinition[] colDefs = table.describe();
-
-            for (SeColumnDefinition lColDef : colDefs) {
-                sLogger.debug(lColDef.getName() + " - " + ArcSDEUtils.resolveType(lColDef.getType()));
-            }
-
-
-            tableStats = query.calculateTableStatistics(colDefs[1].getName(), mask, queryInfo, maxDistinct);
-            displayStats(tableStats);
-
-
-        } catch (SeException e) {
-            printError(e);
-        } catch (ConnectionException e) {
-            sLogger.error(e.getMessage(), e);
-            e.printError();
-        } catch (TechnicalException e) {
-            sLogger.error(e.getMessage(), e);
-        } finally {
-            // return connection
-            returnConnection(conn);
-        }
-
-    }// End method getTableStats
-
-
     public void displayStats(SeTable.SeTableStats tableStats) {
 
         sLogger.debug("\n--> Table Statistics\n");
@@ -107,59 +56,63 @@
             sLogger.debug("No of rows - " + tableStats.getCount());
             sLogger.debug("Maximum Value - " + tableStats.getMax());
             sLogger.debug("Minimum Value - " + tableStats.getMin());
-            sLogger.debug("No of distinct values - " + tableStats.getNumDistinct());
+            sLogger.debug("No of distinct values - "
+                          + tableStats.getNumDistinct());
             sLogger.debug("Standard Deviation - " + tableStats.getStdDev());
 
-            sLogger.debug("Distinct type - " + ArcSDEUtils.resolveType(tableStats.getDistinctType()));
+            sLogger.debug("Distinct type - "
+                          + ArcSDEUtils.resolveType(tableStats
+                                  .getDistinctType()));
 
             int[] distinctFreq = tableStats.getDistinctValueFrequencies();
             Vector distinctValues = tableStats.getDistinctValues();
             sLogger.debug("Distinct values & their frequencies : ");
             for (int i = 0; i < distinctFreq.length; i++)
-                sLogger.debug(distinctValues.elementAt(i) + " - " + distinctFreq[i]);
+                sLogger.debug(distinctValues.elementAt(i) + " - "
+                              + distinctFreq[i]);
         }// End if
 
     }// End displayStats
 
-
     /**
-     * Takes an integer corresponding to an ArcSDE data type
-     * and returns a string description of the type.
-     *
-     * @param type SDE data type bit-mask.
+     * Takes an integer corresponding to an ArcSDE data type and returns a
+     * string description of the type.
+     * 
+     * @param type
+     *            SDE data type bit-mask.
      */
     public static String resolveType(int type) {
 
         String typeName = "Invalid Type";
         switch (type) {
 
-            case SeColumnDefinition.TYPE_SMALLINT:
-                typeName = "Small Int";
-                break;
-            case SeColumnDefinition.TYPE_INTEGER:
-                typeName = "Int";
-                break;
-            case SeColumnDefinition.TYPE_FLOAT:
-                typeName = "Float";
-                break;
-            case SeColumnDefinition.TYPE_DOUBLE:
-                typeName = "Double";
-                break;
-            case SeColumnDefinition.TYPE_STRING:
-                typeName = "String";
-                break;
-            case SeColumnDefinition.TYPE_BLOB:
-                typeName = "Blob";
-                break;
-            case SeColumnDefinition.TYPE_DATE:
-                typeName = "Date";
-                break;
-            case SeColumnDefinition.TYPE_SHAPE:
-                typeName = "Shape";
-                break;
-            case SeColumnDefinition.TYPE_RASTER:
-                typeName = "Raster";
-                break;
+        case SeColumnDefinition.TYPE_SMALLINT:
+            typeName = "Small Int";
+            break;
+        case SeColumnDefinition.TYPE_INTEGER:
+            typeName = "Int";
+            break;
+        case SeColumnDefinition.TYPE_FLOAT:
+            typeName = "Float";
+            break;
+        case SeColumnDefinition.TYPE_DOUBLE:
+            typeName = "Double";
+            break;
+        case SeColumnDefinition.TYPE_STRING:
+            typeName = "String";
+            break;
+        case SeColumnDefinition.TYPE_BLOB:
+            typeName = "Blob";
+            break;
+        case SeColumnDefinition.TYPE_DATE:
+            typeName = "Date";
+            break;
+        case SeColumnDefinition.TYPE_SHAPE:
+            typeName = "Shape";
+            break;
+        case SeColumnDefinition.TYPE_RASTER:
+            typeName = "Raster";
+            break;
         }
         return typeName;
     }// End method resolveType
@@ -187,24 +140,21 @@
 
     }// End printError
 
-    private SeConnection getConnection() throws TechnicalException {
-        //DatasourceConnection lConnection = ConnectionPoolManager.getInstance().getConnection(ConnectionPoolManager.CON_SDE);
-        //return ((SDEConnection) lConnection).getConnection();
-        return null;
-    }
-
-    private void returnConnection(SeConnection pConnection) {
-        //ConnectionPoolManager.getInstance().returnConnection(pConnection);
-    }
-
-    public static SDEPoint[] createPoints(double[][] pPoints) {
+    public SDEPoint[] createPoints(Geometry g) {
         sLogger.debug("createPoints()");
-        SDEPoint[] lSDEPoints = new SDEPoint[pPoints.length];
-        for (int i = 0; i < pPoints.length; i++) {
-            double[] lPoint = pPoints[i];
-            lSDEPoints[i] = new SDEPoint(lPoint[0], lPoint[1]);
+        Coordinate[] coords = null;
+        if (g instanceof Polygon) {
+            coords = ((Polygon) g).getCoordinates();
         }
-        return lSDEPoints;
+        if (coords != null){
+            SDEPoint[] lSDEPoints = new SDEPoint[coords.length];
+            for (int i = 0; i < coords.length; i++) {
+                lSDEPoints[i] = new SDEPoint(coords[i].x, coords[i].y);
+            }
+            return lSDEPoints;
+        }else{
+            return null;
+        }
 
     }
 }
--- a/geo-backend/src/main/java/de/intevation/gnv/geobackend/sde/datasources/Row.java	Wed Oct 07 10:26:33 2009 +0000
+++ b/geo-backend/src/main/java/de/intevation/gnv/geobackend/sde/datasources/Row.java	Tue Oct 13 08:57:19 2009 +0000
@@ -97,7 +97,13 @@
      */
     public Object getValue(int pPos) throws TechnicalException {
         if (pPos < mObjects.length) {
-            return mObjects[pPos];
+            
+            Object o =  mObjects[pPos];
+            if (o instanceof SeShape){
+                return this.getPosValue(pPos);
+            }else{
+                return o;
+            }
         } else {
             throw new TechnicalException("Cannot access this field position. Size is: " + mObjects.length);
         }
@@ -148,7 +154,14 @@
      */
     public String getStringValue(int pPos) throws TechnicalException {
         try {
-            return (String) getValue(pPos);
+            Object o = this.getValue(pPos);
+            String returnValue = null;
+            if (o instanceof SeShape){
+                returnValue = this.getPosValue(pPos);
+            }else{
+                returnValue = (String)o;
+            }
+            return returnValue;
         } catch (ClassCastException e) {
             throw new TechnicalException("Could not cast this value to the String Type. Object is of value type: " + getValue(pPos).getClass().getName());
         }
@@ -229,7 +242,7 @@
     	SDEPoint mPoint[];
     	double lat,lon;
     	try {
-    		val = (SeShape) getValue(pPos);
+    		val = (SeShape) this.mObjects[pPos];
     		aList = val.getAllPoints(0,false);
     		mPoint = (SDEPoint[])aList.get(0);
     		lat = mPoint[0].getY();
--- a/geo-backend/src/test/ressources/QueryExecutorTestCase.properties	Wed Oct 07 10:26:33 2009 +0000
+++ b/geo-backend/src/test/ressources/QueryExecutorTestCase.properties	Tue Oct 13 08:57:19 2009 +0000
@@ -9,4 +9,13 @@
 timeseries_interval=select min(tv.TIMEVALUE) MIN, max(tv.TIMEVALUE) MAX from MEDIAN.TIMESERIES t , MEDIAN.TIMESERIESVALUE tv where tv.TIMESERIESID = t.TIMESERIESID and tv.MEASUREMENTID IN ( ? ) AND t.PARAMETERID IN ( ? )
 
 
- spatial_query=SELECT FEATUREID, SHAPE FROM  MEDIAN.MESHPOINT WHERE MESHID = 3 AND KPOSITION = 1
\ No newline at end of file
+ 
+ spatial_query=SELECT FEATUREID, \
+        ST_ASTEXT(SHAPE) \
+    FROM MEDIAN.MESHPOINT \
+    WHERE MESHID  in \
+        (SELECT DISTINCT m.MESHID \
+         FROM MEDIAN.MESH m \
+         WHERE M.OBJECTID = M.OBJECTID) AND \
+         KPOSITION = 1 AND \
+         INTERSECTS(SHAPE,"POLYGON((6.483333296817733 56.50000002211891,6.483012102287745 56.50981053688071,6.48205002744038 56.51957897448855,6.480451095589132 56.52926359306454,6.478222179894658 56.538822818368885,6.475372835726546 56.54821591435217,6.471915300663454 56.557402480241024,6.46786415921693 56.56634328872852,6.463237181021697 56.57500011833619,6.458053812093169 56.583335585775785,6.452336348293812 56.591314319415915,6.446109264780915 56.59890195345352,6.439399383644684 56.60606613374233,6.432235203355873 56.61277601487856,6.424647569318296 56.61900309839146,6.416668835678138 56.62472056219082,6.408333368238544 56.629903931119344,6.399676538630871 56.63453090931458,6.390735730143376 56.6385820507611,6.381549164254523 56.64203958582419,6.372156068271238 56.644888929992305,6.362596842966894 56.64711784568678,6.352912224390906 56.64871677753803,6.34314378678306 56.64967885238539,6.333333272021264 56.65000004691538,6.323522757259468 56.64967885238539,6.31375431965165 56.64871677753803,6.304069701075662 56.64711784568678,6.29451047577129 56.644888929992305,6.285117379788005 56.64203958582419,6.27593081389918 56.6385820507611,6.266990005411657 56.63453090931458,6.258333343442075 56.629903931119344,6.24999770836439 56.62472056219082,6.24201897472426 56.61900309839146,6.234431340686655 56.61277601487856,6.227267160397872 56.60606613374233,6.220557279261612 56.59890195345352,6.214330195748715 56.591314319415915,6.2086127319493585 56.583335585775785,6.203429363020831 56.57500011833619,6.198802384825626 56.56634328872852,6.194751243379102 56.557402480241024,6.19129370831601 56.54821591435217,6.188444364147898 56.538822818368885,6.186215448453396 56.52926359306454,6.184616516602176 56.51957897448855,6.183654441754783 56.50981053688071,6.183333247224795 56.50000002211891,6.183654441754783 56.490189507357115,6.184616516602176 56.4804210697493,6.186215448453396 56.47073645117331,6.188444364147898 56.46117722586894,6.19129370831601 56.45178412988565,6.194751243379102 56.44259756399683,6.198802384825626 56.433656755509304,6.203429363020831 56.42500009353972,6.2086127319493585 56.41666445846204,6.214330195748715 56.40868572482191,6.220557279261612 56.4010980907843,6.227267160397872 56.39393391049552,6.234431340686655 56.38722402935926,6.24201897472426 56.38099694584636,6.24999770836439 56.375279482047006,6.258333343442075 56.37009611311848,6.266990005411657 56.36546913492327,6.27593081389918 56.36141799347675,6.285117379788005 56.35796045841366,6.29451047577129 56.355111114245545,6.304069701075662 56.35288219855104,6.31375431965165 56.351283266699795,6.323522757259468 56.35032119185243,6.333333272021264 56.34999999732244,6.34314378678306 56.35032119185243,6.352912224390906 56.351283266699795,6.362596842966894 56.35288219855104,6.372156068271238 56.355111114245545,6.381549164254523 56.35796045841366,6.390735730143376 56.36141799347675,6.399676538630871 56.36546913492327,6.408333368238544 56.37009611311848,6.416668835678138 56.375279482047006,6.424647569318296 56.38099694584636,6.432235203355873 56.38722402935926,6.439399383644684 56.39393391049552,6.446109264780915 56.4010980907843,6.452336348293812 56.40868572482191,6.458053812093169 56.41666445846204,6.463237181021697 56.42500009353972,6.46786415921693 56.433656755509304,6.471915300663454 56.44259756399683,6.475372835726546 56.45178412988565,6.478222179894658 56.46117722586894,6.480451095589132 56.47073645117331,6.48205002744038 56.4804210697493,6.483012102287745 56.490189507357115,6.483333296817733 56.50000002211891))")
\ No newline at end of file

http://dive4elements.wald.intevation.org