diff geo-backend/src/main/java/de/intevation/gnv/geobackend/sde/datasources/ArcSDEUtils.java @ 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
parents e4eacd613356
children 0b813ae17173
line wrap: on
line diff
--- 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;
+        }
 
     }
 }

http://dive4elements.wald.intevation.org