svn - r34339 - in trunk/modules/plugin/arcsde/datastore/src: main/java/org/geotools/arcsde/raster/gce main/java/org/geotools/arcsde/raster/info main/java/org/geotools/arcsde/raster/io main/java/org/geotools/arcsde/raster/jai test/java/org/geotools/arcsde/raster/gce test/java/org/geotools/arcsde/raster/io

1 message Options
Embed this post
Permalink
svn_geotools

svn - r34339 - in trunk/modules/plugin/arcsde/datastore/src: main/java/org/geotools/arcsde/raster/gce main/java/org/geotools/arcsde/raster/info main/java/org/geotools/arcsde/raster/io main/java/org/geotools/arcsde/raster/jai test/java/org/geotools/arcsde/raster/gce test/java/org/geotools/arcsde/raster/io

Reply Threaded More More options
Print post
Permalink
Author: groldan
Date: 2009-11-06 14:44:57 -0500 (Fri, 06 Nov 2009)
New Revision: 34339

Removed:
   trunk/modules/plugin/arcsde/datastore/src/main/java/org/geotools/arcsde/raster/jai/ArcSDETiledImageInputStream.java
Modified:
   trunk/modules/plugin/arcsde/datastore/src/main/java/org/geotools/arcsde/raster/gce/ArcSDEGridCoverage2DReaderJAI.java
   trunk/modules/plugin/arcsde/datastore/src/main/java/org/geotools/arcsde/raster/gce/ArcSDERasterFormat.java
   trunk/modules/plugin/arcsde/datastore/src/main/java/org/geotools/arcsde/raster/info/RasterCellType.java
   trunk/modules/plugin/arcsde/datastore/src/main/java/org/geotools/arcsde/raster/io/NativeTileReader.java
   trunk/modules/plugin/arcsde/datastore/src/main/java/org/geotools/arcsde/raster/io/PromotingTileReader.java
   trunk/modules/plugin/arcsde/datastore/src/main/java/org/geotools/arcsde/raster/io/TileFetchCommand.java
   trunk/modules/plugin/arcsde/datastore/src/main/java/org/geotools/arcsde/raster/io/TileInfo.java
   trunk/modules/plugin/arcsde/datastore/src/main/java/org/geotools/arcsde/raster/io/TileReader.java
   trunk/modules/plugin/arcsde/datastore/src/main/java/org/geotools/arcsde/raster/jai/ArcSDETiledRenderedImage.java
   trunk/modules/plugin/arcsde/datastore/src/test/java/org/geotools/arcsde/raster/gce/ArcSDEGridCoverage2DReaderJAILegacyOnlineTest.java
   trunk/modules/plugin/arcsde/datastore/src/test/java/org/geotools/arcsde/raster/gce/ArcSDEGridCoverage2DReaderJAIOnlineTest.java
   trunk/modules/plugin/arcsde/datastore/src/test/java/org/geotools/arcsde/raster/gce/RasterTestData.java
   trunk/modules/plugin/arcsde/datastore/src/test/java/org/geotools/arcsde/raster/io/BitmaskToNoDataConverterTest.java
Log:
GEOT-2616, readers for missing types and using DataBuffer data to fetch tile data into to avoid duplicating buffers

Modified: trunk/modules/plugin/arcsde/datastore/src/main/java/org/geotools/arcsde/raster/gce/ArcSDEGridCoverage2DReaderJAI.java
===================================================================
--- trunk/modules/plugin/arcsde/datastore/src/main/java/org/geotools/arcsde/raster/gce/ArcSDEGridCoverage2DReaderJAI.java 2009-11-06 19:42:43 UTC (rev 34338)
+++ trunk/modules/plugin/arcsde/datastore/src/main/java/org/geotools/arcsde/raster/gce/ArcSDEGridCoverage2DReaderJAI.java 2009-11-06 19:44:57 UTC (rev 34339)
@@ -55,6 +55,7 @@
 import org.geotools.coverage.CoverageFactoryFinder;
 import org.geotools.coverage.GridSampleDimension;
 import org.geotools.coverage.TypeMap;
+//import org.geotools.coverage.grid.GeneralGridRange;
 import org.geotools.coverage.grid.GeneralGridEnvelope;
 import org.geotools.coverage.grid.GridCoverage2D;
 import org.geotools.coverage.grid.GridEnvelope2D;
@@ -129,6 +130,7 @@
         super.originalEnvelope = rasterInfo.getOriginalEnvelope();
 
         GeneralGridEnvelope gridRange = rasterInfo.getOriginalGridRange();
+        //super.originalGridRange = new GeneralGridRange(gridRange.toRectangle());
         super.originalGridRange = new GridEnvelope2D(gridRange.toRectangle());
 
         super.coverageName = rasterInfo.getRasterTable();

Modified: trunk/modules/plugin/arcsde/datastore/src/main/java/org/geotools/arcsde/raster/gce/ArcSDERasterFormat.java
===================================================================
--- trunk/modules/plugin/arcsde/datastore/src/main/java/org/geotools/arcsde/raster/gce/ArcSDERasterFormat.java 2009-11-06 19:42:43 UTC (rev 34338)
+++ trunk/modules/plugin/arcsde/datastore/src/main/java/org/geotools/arcsde/raster/gce/ArcSDERasterFormat.java 2009-11-06 19:44:57 UTC (rev 34339)
@@ -19,10 +19,8 @@
 
 import java.io.File;
 import java.io.IOException;
-import java.net.MalformedURLException;
 import java.net.URI;
 import java.net.URISyntaxException;
-import java.net.URL;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.WeakHashMap;
@@ -314,7 +312,7 @@
             }
         } else if (input instanceof File) {
             String path = ((File) input).getPath();
-            while(path.indexOf('\\') > -1){
+            while (path.indexOf('\\') > -1) {
                 path = path.replace('\\', '/');
             }
             URI uri;
@@ -322,7 +320,7 @@
                 uri = new URI(path);
             } catch (URISyntaxException e) {
                 throw new IllegalArgumentException(path);
-            }
+            }
             coverageUrl = uri.toString();
             if (LOGGER.isLoggable(Level.FINE)) {
                 LOGGER.fine("connectiong via file-hack to ArcSDE Raster: " + coverageUrl);

Modified: trunk/modules/plugin/arcsde/datastore/src/main/java/org/geotools/arcsde/raster/info/RasterCellType.java
===================================================================
--- trunk/modules/plugin/arcsde/datastore/src/main/java/org/geotools/arcsde/raster/info/RasterCellType.java 2009-11-06 19:42:43 UTC (rev 34338)
+++ trunk/modules/plugin/arcsde/datastore/src/main/java/org/geotools/arcsde/raster/info/RasterCellType.java 2009-11-06 19:44:57 UTC (rev 34339)
@@ -44,7 +44,8 @@
             Float.MAX_VALUE)), //
     TYPE_32BIT_S(32, DataBuffer.TYPE_INT, true, NumberRange.create(Integer.MIN_VALUE,
             Integer.MAX_VALUE)), //
-    TYPE_32BIT_U(32, DataBuffer.TYPE_INT, false, NumberRange.create(0L, (long) Math.pow(2, 32) - 1)), //
+    TYPE_32BIT_U(64, DataBuffer.TYPE_DOUBLE, false, NumberRange.create(0D,
+            (double) Math.pow(2, 32) - 1)), //
     TYPE_4BIT(4, DataBuffer.TYPE_BYTE, false, NumberRange.create((byte) 0,
             (byte) Math.pow(2, 4) - 1)), //
     TYPE_64BIT_REAL(64, DataBuffer.TYPE_DOUBLE, true, NumberRange.create(Double.MIN_VALUE,

Modified: trunk/modules/plugin/arcsde/datastore/src/main/java/org/geotools/arcsde/raster/io/NativeTileReader.java
===================================================================
--- trunk/modules/plugin/arcsde/datastore/src/main/java/org/geotools/arcsde/raster/io/NativeTileReader.java 2009-11-06 19:42:43 UTC (rev 34338)
+++ trunk/modules/plugin/arcsde/datastore/src/main/java/org/geotools/arcsde/raster/io/NativeTileReader.java 2009-11-06 19:44:57 UTC (rev 34339)
@@ -67,7 +67,7 @@
 
     private ISession session;
 
-    private TileFetchCommand tileFetchCommand;
+    // private TileFetchCommand tileFetchCommand;
 
     private boolean started;
 
@@ -83,6 +83,8 @@
 
     private final RasterCellType nativeCellType;
 
+    private QueryObjects queryObjects;
+
     /**
      * @see DefaultTiledRasterReader#nextRaster()
      */
@@ -261,12 +263,12 @@
      */
     private void execute() throws IOException {
         final Rectangle requestedTiles = this.requestedTiles;
-        this.tileFetchCommand = execute(requestedTiles);
+        this.queryObjects = execute(requestedTiles);
         this.started = true;
         this.lastTileX = this.lastTileY = -1;
     }
 
-    private TileFetchCommand execute(final Rectangle rasterTiles) throws IOException {
+    private QueryObjects execute(final Rectangle rasterTiles) throws IOException {
 
         final int rasterIndex = rasterInfo.getRasterIndex(rasterId);
         final int tileWidth = rasterInfo.getTileWidth(rasterId);
@@ -344,20 +346,148 @@
 
         final SeRow row = queryCommand.getSeRow();
 
-        final int numberOfBands = getNumberOfBands();
         final SeQuery preparedQuery = queryCommand.getPreparedQuery();
-        TileFetchCommand fetchCommand = new TileFetchCommand(preparedQuery, row, pixelsPerTile,
-                numberOfBands, nativeCellType);
-        return fetchCommand;
+
+        return new QueryObjects(preparedQuery, row);
     }
 
+    private static class QueryObjects {
+        SeQuery preparedQuery;
+
+        SeRow row;
+
+        public QueryObjects(SeQuery preparedQuery, SeRow row) {
+            this.preparedQuery = preparedQuery;
+            this.row = row;
+        }
+    }
+
     /**
      * @see org.geotools.arcsde.raster.io.TileReader#getTile(int, int)
      */
-    public TileInfo[] getTile(final int tileX, final int tileY) throws IOException {
+    // public TileInfo[] getTile(final int tileX, final int tileY) throws IOException {
+    // // System.err.println("getTile " + tileX + ", " + tileY);
+    // final TileInfo[] bandTiles = fetchTile(tileX, tileY);
+    //
+    // try {
+    // final int numberOfBands = getNumberOfBands();
+    // for (int bandN = 0; bandN < numberOfBands; bandN++) {
+    // final TileInfo tile = bandTiles[bandN];
+    // noData.setNoData(tile);
+    // }
+    //
+    // } catch (RuntimeException e) {
+    // dispose();
+    // throw e;
+    // }
+    //
+    // return bandTiles;
+    // }
 
-        final TileInfo[] bandTiles = fetchTile(tileX, tileY);
+    public TileInfo[] getTile(final int tileX, final int tileY, byte[][] data) throws IOException {
+        final int numberOfBands = getNumberOfBands();
+        if (data == null) {
+            data = new byte[numberOfBands][getPixelsPerTile()];
+        } else if (data.length != numberOfBands) {
+            throw new IllegalArgumentException("data shall be byte[" + numberOfBands + "],["
+                    + getPixelsPerTile() + "]");
+        }
+        TileInfo[] tileInfo = new TileInfo[numberOfBands];
+        TileInfo t;
+        for (int b = 0; b < numberOfBands; b++) {
+            t = new TileInfo(getPixelsPerTile());
+            t.setTileData(data[b]);
+            tileInfo[b] = t;
+        }
 
+        getTile(tileX, tileY, tileInfo);
+        return tileInfo;
+    }
+
+    public TileInfo[] getTile(int tileX, int tileY, short[][] data) throws IOException {
+        final int numberOfBands = getNumberOfBands();
+        if (data == null) {
+            data = new short[numberOfBands][getPixelsPerTile()];
+        } else if (data.length != numberOfBands) {
+            throw new IllegalArgumentException("data shall be byte[" + numberOfBands + "],["
+                    + getPixelsPerTile() + "]");
+        }
+        TileInfo[] tileInfo = new TileInfo[numberOfBands];
+        TileInfo t;
+        for (int b = 0; b < numberOfBands; b++) {
+            t = new TileInfo(getPixelsPerTile());
+            t.setTileData(data[b]);
+            tileInfo[b] = t;
+        }
+
+        getTile(tileX, tileY, tileInfo);
+        return tileInfo;
+    }
+
+    public TileInfo[] getTile(int tileX, int tileY, int[][] data) throws IOException {
+        final int numberOfBands = getNumberOfBands();
+        if (data == null) {
+            data = new int[numberOfBands][getPixelsPerTile()];
+        } else if (data.length != numberOfBands) {
+            throw new IllegalArgumentException("data shall be byte[" + numberOfBands + "],["
+                    + getPixelsPerTile() + "]");
+        }
+        TileInfo[] tileInfo = new TileInfo[numberOfBands];
+        TileInfo t;
+        for (int b = 0; b < numberOfBands; b++) {
+            t = new TileInfo(getPixelsPerTile());
+            t.setTileData(data[b]);
+            tileInfo[b] = t;
+        }
+
+        getTile(tileX, tileY, tileInfo);
+        return tileInfo;
+    }
+
+    public TileInfo[] getTile(int tileX, int tileY, float[][] data) throws IOException {
+        final int numberOfBands = getNumberOfBands();
+        if (data == null) {
+            data = new float[numberOfBands][getPixelsPerTile()];
+        } else if (data.length != numberOfBands) {
+            throw new IllegalArgumentException("data shall be byte[" + numberOfBands + "],["
+                    + getPixelsPerTile() + "]");
+        }
+        TileInfo[] tileInfo = new TileInfo[numberOfBands];
+        TileInfo t;
+        for (int b = 0; b < numberOfBands; b++) {
+            t = new TileInfo(getPixelsPerTile());
+            t.setTileData(data[b]);
+            tileInfo[b] = t;
+        }
+
+        getTile(tileX, tileY, tileInfo);
+        return tileInfo;
+    }
+
+    public TileInfo[] getTile(int tileX, int tileY, double[][] data) throws IOException {
+        final int numberOfBands = getNumberOfBands();
+        if (data == null) {
+            data = new double[numberOfBands][getPixelsPerTile()];
+        } else if (data.length != numberOfBands) {
+            throw new IllegalArgumentException("data shall be byte[" + numberOfBands + "],["
+                    + getPixelsPerTile() + "]");
+        }
+        TileInfo[] tileInfo = new TileInfo[numberOfBands];
+        TileInfo t;
+        for (int b = 0; b < numberOfBands; b++) {
+            t = new TileInfo(getPixelsPerTile());
+            t.setTileData(data[b]);
+            tileInfo[b] = t;
+        }
+
+        getTile(tileX, tileY, tileInfo);
+        return tileInfo;
+    }
+
+    private void getTile(final int tileX, final int tileY, TileInfo[] target) throws IOException {
+
+        final TileInfo[] bandTiles = fetchTile(tileX, tileY, target);
+
         try {
             final int numberOfBands = getNumberOfBands();
             for (int bandN = 0; bandN < numberOfBands; bandN++) {
@@ -369,28 +499,49 @@
             dispose();
             throw e;
         }
-
-        return bandTiles;
     }
 
     private int lastTileX = -1;
 
     private int lastTileY = -1;
 
-    private TileInfo[] fetchTile(final int tileX, final int tileY) throws IOException {
-        if(!started){
-            execute();
-        }
+    /**
+     * How many random tiles requested (ie, not consecutive) before re executing the original
+     * request as a rewind
+     */
+    private static final int RANDOM_THRESHOLD = 2;
+
+    private int nonConsecutiveCallCount;
+
+    private TileInfo[] fetchTile(final int tileX, final int tileY, TileInfo[] target)
+            throws IOException {
+
         TileInfo[] tileInfo = null;
 
         if (isConsecutive(tileX, tileY)) {
             while (lastTileX != tileX || lastTileY != tileY) {
-                tileInfo = nextTile();
+                tileInfo = nextTile(target);
             }
         } else {
-            tileInfo = fetchSingleTile(tileX, tileY);
+            if (nonConsecutiveCallCount == RANDOM_THRESHOLD) {
+                nonConsecutiveCallCount = 0;
+                if (LOGGER.isLoggable(Level.FINEST)) {
+                    LOGGER.finest("Number of random (non consecutive) tile request exceeded"
+                            + " predefined threshold. Rewind by executing original request again");
+                }
+                dispose();
+                return fetchTile(tileX, tileY, target);
+            } else {
+                nonConsecutiveCallCount++;
+                tileInfo = fetchSingleTile(tileX, tileY, target);
+            }
         }
 
+        if (lastTileX == getTilesWide() - 1 && lastTileY == getTilesHigh() - 1) {
+            dispose();
+            lastTileX = -1;
+            lastTileY = -1;
+        }
         return tileInfo;
     }
 
@@ -399,16 +550,22 @@
      *
      * @throws IOException
      */
-    private TileInfo[] fetchSingleTile(final int tileX, final int tileY) throws IOException {
-        LOGGER.info("fetchSingleTile " + tileX + ", " + tileY);
+    private TileInfo[] fetchSingleTile(final int tileX, final int tileY, TileInfo[] target)
+            throws IOException {
+        if (LOGGER.isLoggable(Level.FINEST)) {
+            LOGGER.finest("fetchSingleTile " + tileX + ", " + tileY);
+        }
+        // System.err.println("->fetchSingleTile " + tileX + ", " + tileY);
         final int rasterTileX = requestedTiles.x + tileX;
         final int rasterTileY = requestedTiles.y + tileY;
         final int width = 1;
         final int height = 1;
         final Rectangle requestTiles = new Rectangle(rasterTileX, rasterTileY, width, height);
 
-        final TileFetchCommand command = execute(requestTiles);
-        final SeQuery query = command.getQuery();
+        final QueryObjects singleTileQueryObjects = execute(requestTiles);
+        final SeQuery query = singleTileQueryObjects.preparedQuery;
+        final SeRow row = singleTileQueryObjects.row;
+        final TileFetchCommand command = new TileFetchCommand(row, nativeCellType, target);
         final TileInfo[] tile;
         try {
             tile = session.issue(command);
@@ -441,9 +598,15 @@
         return false;
     }
 
-    private TileInfo[] nextTile() throws IOException {
+    private TileInfo[] nextTile(final TileInfo[] target) throws IOException {
+        if (!started) {
+            execute();
+        }
         TileInfo[] nextTile;
         try {
+            SeRow row = queryObjects.row;
+            RasterCellType nativeType = nativeCellType;
+            TileFetchCommand tileFetchCommand = new TileFetchCommand(row, nativeType, target);
             nextTile = session.issue(tileFetchCommand);
         } catch (IOException e) {
             dispose();
@@ -466,9 +629,6 @@
             lastTileY++;
         }
 
-        if (lastTileX == getTilesWide() - 1 && lastTileY == getTilesHigh() - 1) {
-            dispose();
-        }
         return nextTile;
     }
 
@@ -483,9 +643,9 @@
                 LOGGER.finer("TileReader disposing " + session + " on Thread "
                         + Thread.currentThread().getName());
             }
-            if (tileFetchCommand != null) {
+            if (queryObjects != null) {
                 try {
-                    SeQuery preparedQuery = this.tileFetchCommand.getQuery();
+                    SeQuery preparedQuery = queryObjects.preparedQuery;
                     session.close(preparedQuery);
                 } catch (Exception e) {
                     LOGGER.log(Level.WARNING, "Closing tile reader's prepared Query", e);
@@ -499,7 +659,7 @@
             session = null;
 
             // get ready for more invocations
-            tileFetchCommand = null;
+            queryObjects = null;
             started = false;
         }
     }

Modified: trunk/modules/plugin/arcsde/datastore/src/main/java/org/geotools/arcsde/raster/io/PromotingTileReader.java
===================================================================
--- trunk/modules/plugin/arcsde/datastore/src/main/java/org/geotools/arcsde/raster/io/PromotingTileReader.java 2009-11-06 19:42:43 UTC (rev 34338)
+++ trunk/modules/plugin/arcsde/datastore/src/main/java/org/geotools/arcsde/raster/io/PromotingTileReader.java 2009-11-06 19:44:57 UTC (rev 34339)
@@ -21,6 +21,9 @@
 import static org.geotools.arcsde.raster.info.RasterCellType.TYPE_16BIT_U;
 import static org.geotools.arcsde.raster.info.RasterCellType.TYPE_1BIT;
 import static org.geotools.arcsde.raster.info.RasterCellType.TYPE_32BIT_S;
+import static org.geotools.arcsde.raster.info.RasterCellType.TYPE_32BIT_U;
+import static org.geotools.arcsde.raster.info.RasterCellType.TYPE_64BIT_REAL;
+import static org.geotools.arcsde.raster.info.RasterCellType.TYPE_8BIT_S;
 import static org.geotools.arcsde.raster.info.RasterCellType.TYPE_8BIT_U;
 
 import java.io.IOException;
@@ -98,66 +101,75 @@
     /**
      * @see org.geotools.arcsde.raster.io.TileReader#getTile(int, int)
      */
-    public TileInfo[] getTile(final int tileX, final int tileY) throws IOException {
+    // public TileInfo[] getTile(final int tileX, final int tileY) throws IOException {
+    // final int numberOfBands = getNumberOfBands();
+    // final TileInfo[] promotedBandInfo = new TileInfo[numberOfBands];
+    //
+    // try {
+    // final TileInfo[] nativeBandInfo = nativeReader.getTile(tileX, tileY);
+    //
+    // for (int bandN = 0; bandN < numberOfBands; bandN++) {
+    // TileInfo nativeData = nativeBandInfo[bandN];
+    //
+    // TileInfo promotedData = promoter.promote(nativeData);
+    //
+    // nativeBandInfo[bandN] = null;// release early release often...
+    //
+    // noData.setNoData(promotedData);
+    // promotedBandInfo[bandN] = promotedData;
+    // }
+    // } catch (IOException e) {
+    // dispose();
+    // throw e;
+    // } catch (RuntimeException e) {
+    // dispose();
+    // throw e;
+    // }
+    // return promotedBandInfo;
+    // }
+
+    private TileInfo[] setNoData(TileInfo[] tileInfos) {
         final int numberOfBands = getNumberOfBands();
         final TileInfo[] promotedBandInfo = new TileInfo[numberOfBands];
-
         try {
-            final TileInfo[] nativeBandInfo = nativeReader.getTile(tileX, tileY);
-
             for (int bandN = 0; bandN < numberOfBands; bandN++) {
-                TileInfo nativeData = nativeBandInfo[bandN];
-
+                TileInfo nativeData = tileInfos[bandN];
                 TileInfo promotedData = promoter.promote(nativeData);
-
-                nativeBandInfo[bandN] = null;// release early release often...
-
                 noData.setNoData(promotedData);
                 promotedBandInfo[bandN] = promotedData;
             }
-        } catch (IOException e) {
-            dispose();
-            throw e;
         } catch (RuntimeException e) {
             dispose();
             throw e;
         }
         return promotedBandInfo;
-        //
-        // final byte[] nativeTileData = tileInfo.getTileData();
-        // final byte[] tileData = new byte[getBytesPerTile()];
-        // try {
-        // final byte[] bitmaskData = tileInfo.getBitmaskData();
-        // final boolean hasNoDataPixels = bitmaskData.length > 0;
-        // final Long bandId = tileInfo.getBandId();
-        //
-        // final int numPixelsRead = tileInfo.getNumPixelsRead();
-        // if (numPixelsRead == 0) {
-        // noData.setAll(bandId, tileData);
-        // } else {
-        // final int numSamples = getPixelsPerTile();
-        // assert numPixelsRead == numSamples;
-        //
-        // for (int sampleN = 0; sampleN < numSamples; sampleN++) {
-        // if (hasNoDataPixels && noData.isNoData(sampleN, bitmaskData)) {
-        // noData.setNoData(bandId, sampleN, tileData);
-        // } else {
-        // promoter.promote(sampleN, nativeTileData, tileData);
-        // }
-        // }
-        // }
-        //
-        // } catch (RuntimeException e) {
-        // dispose();
-        // throw e;
-        // }
-        //
-        // TileInfo promotedTileInfo = new TileInfo(tileInfo.getBandId(), tileInfo.getColumnIndex(),
-        // tileInfo.getRowIndex(), tileInfo.getNumPixelsRead(), tileData, tileInfo
-        // .getBitmaskData());
-        // return promotedTileInfo;
     }
 
+    public TileInfo[] getTile(int tileX, int tileY, byte[][] data) throws IOException {
+        TileInfo[] tileInfos = nativeReader.getTile(tileX, tileY, data);
+        return setNoData(tileInfos);
+    }
+
+    public TileInfo[] getTile(int tileX, int tileY, short[][] data) throws IOException {
+        TileInfo[] tileInfos = nativeReader.getTile(tileX, tileY, data);
+        return setNoData(tileInfos);
+    }
+
+    public TileInfo[] getTile(int tileX, int tileY, int[][] data) throws IOException {
+        TileInfo[] tileInfos = nativeReader.getTile(tileX, tileY, data);
+        return setNoData(tileInfos);
+    }
+
+    public TileInfo[] getTile(int tileX, int tileY, float[][] data) throws IOException {
+        TileInfo[] tileInfos = nativeReader.getTile(tileX, tileY, data);
+        return setNoData(tileInfos);
+    }
+
+    public TileInfo[] getTile(int tileX, int tileY, double[][] data) throws IOException {
+        TileInfo[] tileInfos = nativeReader.getTile(tileX, tileY, data);
+        return setNoData(tileInfos);
+    }
+
     /**
      *
      * @author Gabriel Roldan
@@ -175,6 +187,14 @@
                 return new UcharToUshort();
             } else if (source == TYPE_16BIT_S && target == TYPE_32BIT_S) {
                 return new ShortToInt();
+            } else if (source == TYPE_8BIT_S && target == TYPE_16BIT_S) {
+                return new ByteToShort();
+            } else if (source == TYPE_16BIT_U && target == TYPE_32BIT_U) {
+                return new UShortToUInt();
+            } else if (source == TYPE_32BIT_U && target == TYPE_64BIT_REAL) {
+                return new UIntToDouble();
+            } else if (source == TYPE_32BIT_S && target == TYPE_64BIT_REAL) {
+                return new IntToDouble();
             }
 
             UnsupportedOperationException exception = new UnsupportedOperationException(
@@ -185,40 +205,18 @@
     }
 
     private static final class UcharToUshort extends SampleDepthPromoter {
-
-        // @Override
-        // public void promote(int sampleN, byte[] nativeTileData, byte[] tileData) {
-        // int pixArrayOffset = 2 * sampleN;
-        // tileData[pixArrayOffset] = 0;
-        // tileData[pixArrayOffset + 1] = (byte) ((nativeTileData[sampleN] >>> 0) & 0xFF);
-        // }
-
         @Override
         public TileInfo promote(final TileInfo nativeData) {
 
             short[] promotedPixels = nativeData.getTileDataAsUnsignedShorts();
+            nativeData.setTileData(promotedPixels);
 
-            TileInfo promotedTileInfo = new TileInfo(nativeData.getBandId(), nativeData
-                    .getColumnIndex(), nativeData.getRowIndex(), nativeData.getNumPixels(),
-                    nativeData.getNumPixelsRead(), nativeData.getBitmaskData());
-
-            promotedTileInfo.setTileData(promotedPixels);
-
-            return promotedTileInfo;
+            return nativeData;
         }
     }
 
     private static final class OneBitToUchar extends SampleDepthPromoter {
 
-        // @Override
-        // public void promote(int sampleN, byte[] nativeTileData, byte[] tileData) {
-        // int pixArrayOffset = sampleN / 8;
-        // int bit = sampleN % 8;
-        // int _byte = nativeTileData[pixArrayOffset];
-        // byte ucharvalue = (byte) ((_byte >> (7 - bit)) & 0x01);
-        // tileData[sampleN] = ucharvalue;
-        // }
-
         @Override
         public TileInfo promote(TileInfo nativeData) {
             // no need to promote, should be already stored as bytes
@@ -228,32 +226,80 @@
 
     private static final class ShortToInt extends SampleDepthPromoter {
 
-        // @Override
-        // public void promote(int sampleN, byte[] nativeTileData, byte[] tileData) {
-        // int pixArrayOffset = 4 * sampleN;
-        //
-        // tileData[pixArrayOffset] = 0;
-        // tileData[pixArrayOffset + 1] = 0;
-        // tileData[pixArrayOffset + 1] = (byte) ((nativeTileData[sampleN] >>> 8) & 0xFF);
-        // tileData[pixArrayOffset + 1] = (byte) ((nativeTileData[sampleN] >>> 0) & 0xFF);
-        // }
+        @Override
+        public TileInfo promote(TileInfo nativeData) {
 
+            int[] promotedPixels = nativeData.getTileDataAsIntegers();
+            nativeData.setTileData(promotedPixels);
+
+            return nativeData;
+        }
+    }
+
+    /**
+     * Promotes signed byte to signed short tile data
+     *
+     * @author Gabriel Roldan
+     */
+    private static final class ByteToShort extends SampleDepthPromoter {
         @Override
         public TileInfo promote(TileInfo nativeData) {
 
+            short[] promotedPixels = nativeData.getTileDataAsShorts();
+            nativeData.setTileData(promotedPixels);
+            return nativeData;
+        }
+    }
+
+    /**
+     * Promotes unsigned short to unsigned int tile data
+     *
+     * @author Gabriel Roldan
+     */
+    private static final class UShortToUInt extends SampleDepthPromoter {
+        @Override
+        public TileInfo promote(TileInfo nativeData) {
+
             int[] promotedPixels = nativeData.getTileDataAsIntegers();
+            nativeData.setTileData(promotedPixels);
 
-            TileInfo promotedTileInfo = new TileInfo(nativeData.getBandId(), nativeData
-                    .getColumnIndex(), nativeData.getRowIndex(), nativeData.getNumPixels(),
-                    nativeData.getNumPixelsRead(), nativeData.getBitmaskData());
+            return nativeData;
+        }
+    }
 
-            promotedTileInfo.setTileData(promotedPixels);
+    /**
+     * Promotes unsigned int to double tile data
+     *
+     * @author Gabriel Roldan
+     */
+    private static final class UIntToDouble extends SampleDepthPromoter {
+        @Override
+        public TileInfo promote(TileInfo nativeData) {
 
-            return promotedTileInfo;
+            double[] promotedPixels = nativeData.getTileDataAsDoubles();
+            nativeData.setTileData(promotedPixels);
+
+            return nativeData;
         }
     }
 
     /**
+     * Promotes int to double tile data
+     *
+     * @author Gabriel Roldan
+     */
+    private static final class IntToDouble extends SampleDepthPromoter {
+        @Override
+        public TileInfo promote(TileInfo nativeData) {
+
+            double[] promotedPixels = nativeData.getTileDataAsDoubles();
+            nativeData.setTileData(promotedPixels);
+
+            return nativeData;
+        }
+    }
+
+    /**
      * @see org.geotools.arcsde.raster.io.TileReader#dispose()
      */
     public void dispose() {

Modified: trunk/modules/plugin/arcsde/datastore/src/main/java/org/geotools/arcsde/raster/io/TileFetchCommand.java
===================================================================
--- trunk/modules/plugin/arcsde/datastore/src/main/java/org/geotools/arcsde/raster/io/TileFetchCommand.java 2009-11-06 19:42:43 UTC (rev 34338)
+++ trunk/modules/plugin/arcsde/datastore/src/main/java/org/geotools/arcsde/raster/io/TileFetchCommand.java 2009-11-06 19:44:57 UTC (rev 34339)
@@ -15,7 +15,6 @@
 
 import com.esri.sde.sdk.client.SeConnection;
 import com.esri.sde.sdk.client.SeException;
-import com.esri.sde.sdk.client.SeQuery;
 import com.esri.sde.sdk.client.SeRasterTile;
 import com.esri.sde.sdk.client.SeRow;
 
@@ -30,37 +29,23 @@
  */
 class TileFetchCommand extends Command<TileInfo[]> {
 
-    private final SeQuery preparedQuery;
-
     private final SeRow row;
 
-    private final int pixelsPerTile;
-
-    private final int numberOfBands;
-
     private final TileDataFetcher dataFetcher;
 
-    private final RasterCellType nativeType;
+    private TileInfo[] target;
 
-    public TileFetchCommand(final SeQuery preparedQuery, final SeRow row, final int pixelsPerTile,
-            final int numberOfBands, final RasterCellType nativeType) {
-        this.preparedQuery = preparedQuery;
+    public TileFetchCommand(final SeRow row, final RasterCellType nativeType, TileInfo[] target) {
         this.row = row;
-        this.pixelsPerTile = pixelsPerTile;
-        this.numberOfBands = numberOfBands;
-        this.nativeType = nativeType;
+        this.target = target;
         this.dataFetcher = getTileDataFetcher(nativeType);
     }
 
-    public SeQuery getQuery() {
-        return preparedQuery;
-    }
-
     @Override
     public TileInfo[] execute(ISession session, SeConnection connection) throws SeException,
             IOException {
 
-        TileInfo[] tilesPerBand = new TileInfo[numberOfBands];
+        final int numberOfBands = target.length;
 
         for (int bandN = 0; bandN < numberOfBands; bandN++) {
             SeRasterTile tile = row.getRasterTile();
@@ -70,19 +55,21 @@
             }
             final byte[] bitMaskData = tile.getBitMaskData();
             final int numPixelsRead = tile.getNumPixels();
+            final long bandId = tile.getBandId().longValue();
+            final int colIndex = tile.getColumnIndex();
+            final int rowIndex = tile.getRowIndex();
 
-            long bandId = tile.getBandId().longValue();
-            int colIndex = tile.getColumnIndex();
-            int rowIndex = tile.getRowIndex();
+            TileInfo bandData = target[bandN];
+            bandData.setBandId(bandId);
+            bandData.setColumnIndex(colIndex);
+            bandData.setRowIndex(rowIndex);
+            bandData.setNumPixelsRead(numPixelsRead);
+            bandData.setBitmaskData(bitMaskData);
 
-            TileInfo tileInfo = new TileInfo(bandId, colIndex, rowIndex, pixelsPerTile,
-                    numPixelsRead, bitMaskData);
-
-            dataFetcher.setTileData(pixelsPerTile, tile, tileInfo);
-
-            tilesPerBand[bandN] = tileInfo;
+            final int pixelsPerTile = bandData.getNumPixels();
+            dataFetcher.setTileData(pixelsPerTile, tile, bandData);
         }
-        return tilesPerBand;
+        return target;
     }
 
     private static Map<RasterCellType, TileDataFetcher> tileDataSetters = new HashMap<RasterCellType, TileDataFetcher>();
@@ -92,7 +79,14 @@
         tileDataSetters.put(TYPE_4BIT, byteTileSetter);
         tileDataSetters.put(TYPE_8BIT_S, byteTileSetter);
         tileDataSetters.put(TYPE_8BIT_U, byteTileSetter);
-        // tileDataSetters.put(RasterCellType.TYPE_16BIT_U, value)
+        tileDataSetters.put(RasterCellType.TYPE_16BIT_U, new UShortTileSetter());
+        tileDataSetters.put(RasterCellType.TYPE_16BIT_S, new ShortTileSetter());
+
+        tileDataSetters.put(RasterCellType.TYPE_32BIT_S, new IntegerTileSetter());
+        tileDataSetters.put(RasterCellType.TYPE_32BIT_U, new UnsignedIntegerTileSetter());
+
+        tileDataSetters.put(RasterCellType.TYPE_32BIT_REAL, new FloatTileSetter());
+        tileDataSetters.put(RasterCellType.TYPE_64BIT_REAL, new DoubleTileSetter());
     }
 
     private TileDataFetcher getTileDataFetcher(final RasterCellType pixelType) {
@@ -120,7 +114,7 @@
         @Override
         public void setTileData(final int numPixels, final SeRasterTile tile, TileInfo tileInfo) {
 
-            byte[] tileData = new byte[numPixels];
+            byte[] tileData = tileInfo.getTileDataAsBytes();
 
             final int numPixelsRead = tile.getNumPixels();
 
@@ -143,8 +137,6 @@
                     }
                 }
             }
-
-            tileInfo.setTileData(tileData);
         }
     }
 
@@ -155,7 +147,7 @@
         @Override
         public void setTileData(final int numPixels, final SeRasterTile tile, TileInfo tileInfo) {
 
-            byte[] tileData = new byte[numPixels];
+            byte[] tileData = tileInfo.getTileDataAsBytes();
 
             final int numPixelsRead = tile.getNumPixels();
 
@@ -170,8 +162,146 @@
                     throw new RuntimeException(e);
                 }
             }
+        }
+    }
 
-            tileInfo.setTileData(tileData);
+    private static final class UShortTileSetter extends TileDataFetcher {
+        @Override
+        public void setTileData(final int numPixels, final SeRasterTile tile, TileInfo tileInfo) {
+
+            short[] tileData = tileInfo.getTileDataAsUnsignedShorts();
+
+            final int numPixelsRead = tile.getNumPixels();
+
+            if (numPixelsRead > 0) {
+                if (numPixelsRead != numPixels) {
+                    throw new IllegalStateException("Expected num pixels read to be " + numPixels
+                            + " but got " + numPixelsRead);
+                }
+                try {
+                    int[] ints = new int[numPixels];
+                    tile.getPixels(ints);
+                    for (int i = 0; i < numPixels; i++) {
+                        tileData[i] = (short) ints[i];
+                    }
+                } catch (Exception e) {
+                    throw new RuntimeException(e);
+                }
+            }
         }
     }
+
+    private static final class ShortTileSetter extends TileDataFetcher {
+        @Override
+        public void setTileData(final int numPixels, final SeRasterTile tile, TileInfo tileInfo) {
+
+            short[] tileData = tileInfo.getTileDataAsShorts();
+
+            final int numPixelsRead = tile.getNumPixels();
+
+            if (numPixelsRead > 0) {
+                if (numPixelsRead != numPixels) {
+                    throw new IllegalStateException("Expected num pixels read to be " + numPixels
+                            + " but got " + numPixelsRead);
+                }
+                try {
+                    int[] ints = new int[numPixels];
+                    tile.getPixels(ints);
+                    for (int i = 0; i < numPixels; i++) {
+                        tileData[i] = (short) ints[i];
+                    }
+                } catch (Exception e) {
+                    throw new RuntimeException(e);
+                }
+            }
+        }
+    }
+
+    private static final class IntegerTileSetter extends TileDataFetcher {
+        @Override
+        public void setTileData(final int numPixels, final SeRasterTile tile, TileInfo tileInfo) {
+
+            int[] tileData = tileInfo.getTileDataAsIntegers();
+
+            final int numPixelsRead = tile.getNumPixels();
+
+            if (numPixelsRead > 0) {
+                if (numPixelsRead != numPixels) {
+                    throw new IllegalStateException("Expected num pixels read to be " + numPixels
+                            + " but got " + numPixelsRead);
+                }
+                try {
+                    tile.getPixels(tileData);
+                } catch (Exception e) {
+                    throw new RuntimeException(e);
+                }
+            }
+        }
+    }
+
+    private static final class UnsignedIntegerTileSetter extends TileDataFetcher {
+        @Override
+        public void setTileData(final int numPixels, final SeRasterTile tile, TileInfo tileInfo) {
+
+            double[] tileData = tileInfo.getTileDataAsDoubles();
+
+            final int numPixelsRead = tile.getNumPixels();
+
+            if (numPixelsRead > 0) {
+                if (numPixelsRead != numPixels) {
+                    throw new IllegalStateException("Expected num pixels read to be " + numPixels
+                            + " but got " + numPixelsRead);
+                }
+                try {
+                    tile.getPixels(tileData);
+                } catch (Exception e) {
+                    throw new RuntimeException(e);
+                }
+            }
+        }
+    }
+
+    private static final class FloatTileSetter extends TileDataFetcher {
+        @Override
+        public void setTileData(final int numPixels, final SeRasterTile tile, TileInfo tileInfo) {
+
+            float[] tileData = tileInfo.getTileDataAsFloats();
+
+            final int numPixelsRead = tile.getNumPixels();
+
+            if (numPixelsRead > 0) {
+                if (numPixelsRead != numPixels) {
+                    throw new IllegalStateException("Expected num pixels read to be " + numPixels
+                            + " but got " + numPixelsRead);
+                }
+                try {
+                    tile.getPixels(tileData);
+                } catch (Exception e) {
+                    throw new RuntimeException(e);
+                }
+            }
+        }
+    }
+
+    private static final class DoubleTileSetter extends TileDataFetcher {
+        @Override
+        public void setTileData(final int numPixels, final SeRasterTile tile, TileInfo tileInfo) {
+
+            double[] tileData = tileInfo.getTileDataAsDoubles();
+
+            final int numPixelsRead = tile.getNumPixels();
+
+            if (numPixelsRead > 0) {
+                if (numPixelsRead != numPixels) {
+                    throw new IllegalStateException("Expected num pixels read to be " + numPixels
+                            + " but got " + numPixelsRead);
+                }
+                try {
+                    tile.getPixels(tileData);
+                } catch (Exception e) {
+                    throw new RuntimeException(e);
+                }
+            }
+        }
+    }
 }
\ No newline at end of file

Modified: trunk/modules/plugin/arcsde/datastore/src/main/java/org/geotools/arcsde/raster/io/TileInfo.java
===================================================================
--- trunk/modules/plugin/arcsde/datastore/src/main/java/org/geotools/arcsde/raster/io/TileInfo.java 2009-11-06 19:42:43 UTC (rev 34338)
+++ trunk/modules/plugin/arcsde/datastore/src/main/java/org/geotools/arcsde/raster/io/TileInfo.java 2009-11-06 19:44:57 UTC (rev 34339)
@@ -6,15 +6,15 @@
 import java.awt.image.DataBuffer;
 
 public final class TileInfo {
-    private final long bandId;
+    private long bandId;
 
-    private final byte[] bitmaskData;
+    private byte[] bitmaskData;
 
-    private final int numPixelsRead;
+    private int numPixelsRead;
 
-    private final int columnIndex;
+    private int columnIndex;
 
-    private final int rowIndex;
+    private int rowIndex;
 
     private byte[] tileDataBytes;
 
@@ -28,14 +28,8 @@
 
     private final int numPixels;
 
-    public TileInfo(long bandId, int colIndex, int rowIndex, int numPixels, int numPixelsRead,
-            byte[] bitMaskData) {
-        this.bandId = bandId;
-        this.columnIndex = colIndex;
-        this.rowIndex = rowIndex;
-        this.numPixels = numPixels;
-        this.numPixelsRead = numPixelsRead;
-        this.bitmaskData = bitMaskData;
+    public TileInfo(int pixelsPerTile) {
+        this.numPixels = pixelsPerTile;
     }
 
     public Long getBandId() {
@@ -75,6 +69,7 @@
 
     public void setTileData(short[] pixelData) {
         this.tileDataShorts = pixelData;
+        this.tileDataBytes = null;
     }
 
     public void setTileData(int[] pixelData) {
@@ -90,56 +85,120 @@
     }
 
     public byte[] getTileDataAsBytes() {
-        if (tileDataBytes != null) {
-            return tileDataBytes;
+        if (tileDataBytes == null) {
+            tileDataBytes = new byte[numPixels];
         }
-        throw new UnsupportedOperationException();
+        return tileDataBytes;
     }
 
     public short[] getTileDataAsUnsignedShorts() {
-        if (tileDataShorts != null) {
-            return tileDataShorts;
+        if (tileDataShorts == null) {
+            tileDataShorts = new short[numPixels];
         }
+
+        // promote if necessary
         if (tileDataBytes != null) {
             final int length = tileDataBytes.length;
-            short[] data = new short[length];
             short val;
             for (int i = 0; i < length; i++) {
                 val = (short) (tileDataBytes[i] & 0xFF);
-                data[i] = val;
+                tileDataShorts[i] = val;
             }
-            tileDataShorts = data;
-            return tileDataShorts;
         }
-        throw new UnsupportedOperationException();
+        return tileDataShorts;
     }
 
-    public int[] getTileDataAsIntegers() {
-        if (tileDataInts != null) {
-            return tileDataInts;
+    public short[] getTileDataAsShorts() {
+        if (tileDataShorts == null) {
+            tileDataShorts = new short[numPixels];
         }
+        // promote if necessary
         if (tileDataBytes != null) {
             final int length = tileDataBytes.length;
-            int[] data = new int[length];
+            short val;
             for (int i = 0; i < length; i++) {
-                data[i] = tileDataBytes[i];
+                val = (short) tileDataBytes[i];
+                tileDataShorts[i] = val;
             }
-            tileDataInts = data;
         }
+
+        return tileDataShorts;
+    }
+
+    public int[] getTileDataAsIntegers() {
+        if (tileDataInts == null) {
+            tileDataInts = new int[numPixels];
+        }
+        // promote if necessary
         if (tileDataShorts != null) {
             final int length = tileDataShorts.length;
-            int[] data = new int[length];
             for (int i = 0; i < length; i++) {
-                data[i] = tileDataShorts[i];
+                tileDataInts[i] = tileDataShorts[i];
             }
-            tileDataInts = data;
+        } else if (tileDataBytes != null) {
+            final int length = tileDataBytes.length;
+            for (int i = 0; i < length; i++) {
+                tileDataInts[i] = tileDataBytes[i];
+            }
         }
-        if (tileDataInts == null) {
-            throw new UnsupportedOperationException();
-        }
         return tileDataInts;
     }
 
+    public float[] getTileDataAsFloats() {
+        if (tileDataFloats == null) {
+            tileDataFloats = new float[numPixels];
+        }
+        // promote if necessary
+        if (tileDataInts != null) {
+            final int length = tileDataInts.length;
+            for (int i = 0; i < length; i++) {
+                tileDataFloats[i] = tileDataInts[i];
+            }
+        } else if (tileDataShorts != null) {
+            final int length = tileDataShorts.length;
+            for (int i = 0; i < length; i++) {
+                tileDataFloats[i] = tileDataShorts[i];
+            }
+        } else if (tileDataBytes != null) {
+            final int length = tileDataBytes.length;
+            for (int i = 0; i < length; i++) {
+                tileDataFloats[i] = tileDataBytes[i];
+            }
+        }
+
+        return tileDataFloats;
+    }
+
+    public double[] getTileDataAsDoubles() {
+        if (tileDataDoubles == null) {
+            tileDataDoubles = new double[numPixels];
+        }
+        // promote if necessary
+        if (tileDataFloats != null) {
+            final int length = tileDataFloats.length;
+            for (int i = 0; i < length; i++) {
+                tileDataDoubles[i] = tileDataFloats[i];
+            }
+        } else if (tileDataInts != null) {
+            final int length = tileDataInts.length;
+            for (int i = 0; i < length; i++) {
+                tileDataDoubles[i] = tileDataInts[i];
+            }
+        } else if (tileDataShorts != null) {
+            final int length = tileDataShorts.length;
+            for (int i = 0; i < length; i++) {
+                tileDataDoubles[i] = tileDataShorts[i];
+            }
+        } else if (tileDataBytes != null) {
+            final int length = tileDataBytes.length;
+            for (int i = 0; i < length; i++) {
+                tileDataDoubles[i] = tileDataBytes[i];
+            }
+        }
+
+        return tileDataDoubles;
+    }
+
     public void setValue(int sampleN, Number value) {
         if (tileDataBytes != null) {
             tileDataBytes[sampleN] = value.byteValue();
@@ -196,4 +255,24 @@
             }
         }
     }
+
+    public void setBandId(final long bandId) {
+        this.bandId = bandId;
+    }
+
+    public void setColumnIndex(final int colIndex) {
+        this.columnIndex = colIndex;
+    }
+
+    public void setRowIndex(final int rowIndex) {
+        this.rowIndex = rowIndex;
+    }
+
+    public void setNumPixelsRead(final int numPixelsRead) {
+        this.numPixelsRead = numPixelsRead;
+    }
+
+    public void setBitmaskData(final byte[] bitMaskData) {
+        this.bitmaskData = bitMaskData;
+    }
 }
\ No newline at end of file

Modified: trunk/modules/plugin/arcsde/datastore/src/main/java/org/geotools/arcsde/raster/io/TileReader.java
===================================================================
--- trunk/modules/plugin/arcsde/datastore/src/main/java/org/geotools/arcsde/raster/io/TileReader.java 2009-11-06 19:42:43 UTC (rev 34338)
+++ trunk/modules/plugin/arcsde/datastore/src/main/java/org/geotools/arcsde/raster/io/TileReader.java 2009-11-06 19:44:57 UTC (rev 34339)
@@ -91,7 +91,7 @@
      * @throws {@link IllegalArgumentException} if tileData is not null and its size is less than
      *         {@link #getBytesPerTile()}
      */
-    public abstract TileInfo[] getTile(int tileX, int tileY) throws IOException;
+    //public abstract TileInfo[] getTile(int tileX, int tileY) throws IOException;
 
     /**
      * Disposes any resource being held by this TileReader, making the TileReader unusable and the
@@ -107,4 +107,14 @@
 
     public abstract int getMinTileY();
 
+    public abstract TileInfo[] getTile(int tileX, int tileY, byte[][] data) throws IOException;
+
+    public abstract TileInfo[] getTile(int tileX, int tileY, short[][] data) throws IOException;
+
+    public abstract TileInfo[] getTile(int tileX, int tileY, int[][] data) throws IOException;
+
+    public abstract TileInfo[] getTile(int tileX, int tileY, float[][] data) throws IOException;
+
+    public abstract TileInfo[] getTile(int tileX, int tileY, double[][] data) throws IOException;
+
 }
\ No newline at end of file

Deleted: trunk/modules/plugin/arcsde/datastore/src/main/java/org/geotools/arcsde/raster/jai/ArcSDETiledImageInputStream.java
===================================================================
--- trunk/modules/plugin/arcsde/datastore/src/main/java/org/geotools/arcsde/raster/jai/ArcSDETiledImageInputStream.java 2009-11-06 19:42:43 UTC (rev 34338)
+++ trunk/modules/plugin/arcsde/datastore/src/main/java/org/geotools/arcsde/raster/jai/ArcSDETiledImageInputStream.java 2009-11-06 19:44:57 UTC (rev 34339)
@@ -1,141 +0,0 @@
-/*
- *    GeoTools - The Open Source Java GIS Toolkit
- *    http://geotools.org
- *
- *    (C) 2002-2009, Open Source Geospatial Foundation (OSGeo)
- *
- *    This library is free software; you can redistribute it and/or
- *    modify it under the terms of the GNU Lesser General Public
- *    License as published by the Free Software Foundation;
- *    version 2.1 of the License.
- *
- *    This library is distributed in the hope that it will be useful,
- *    but WITHOUT ANY WARRANTY; without even the implied warranty of
- *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- *    Lesser General Public License for more details.
- *
- */
-package org.geotools.arcsde.raster.jai;
-
-import java.io.IOException;
-
-import javax.imageio.stream.ImageInputStream;
-import javax.imageio.stream.ImageInputStreamImpl;
-
-import org.geotools.arcsde.raster.io.TileInfo;
-import org.geotools.arcsde.raster.io.TileReader;
-
-/**
- * An {@link ImageInputStream} that reads ArcSDE raster tiles in a band interleaved order.
- *
- * @author Gabriel Roldan (OpenGeo)
- * @since 2.5.4
- * @version $Id$
- * @source $URL:
- *         http://svn.osgeo.org/geotools/trunk/modules/plugin/arcsde/datastore/src/main/java/org
- *         /geotools/arcsde/gce/ArcSDETiledImageInputStream.java $
- */
-@Deprecated
-final class ArcSDETiledImageInputStream extends ImageInputStreamImpl implements ImageInputStream {
-
-    private final TileReader tileReader;
-
-    private final int tileDataLength;
-
-    private byte[] currTileData;
-
-    private int currTileDataIndex;
-
-    private int currTileIndex = -1;
-
-    private final int length;
-
-    public ArcSDETiledImageInputStream(final TileReader tileReader) {
-        super();
-        this.tileReader = tileReader;
-        final int bytesPerTile = tileReader.getBytesPerTile();
-        this.tileDataLength = bytesPerTile;
-        this.currTileData = new byte[bytesPerTile];
-        // force load at the first read invocation
-        this.currTileDataIndex = tileDataLength;
-
-        final int tilesWide = tileReader.getTilesWide();
-        final int tilesHigh = tileReader.getTilesHigh();
-        final int numberOfBands = tileReader.getNumberOfBands();
-
-        length = bytesPerTile * tilesWide * tilesHigh * numberOfBands;
-    }
-
-    /**
-     * Returns the computed lenght of the stream based on the tile dimensions, number of tiles,
-     * number of bands, and bits per sample
-     */
-    @Override
-    public long length() {
-        return length;
-    }
-
-    @Override
-    public int read() throws IOException {
-        final byte[] data = getTileData();
-        if (data == null) {
-            close();
-            return -1;
-        }
-        byte b = data[currTileDataIndex];
-        ++currTileDataIndex;
-        ++streamPos;
-        return b;
-    }
-
-    @Override
-    public int read(byte[] buff, int off, int len) throws IOException {
-        final byte[] data = getTileData();
-        if (data == null) {
-            close();
-            return -1;
-        }
-        final int available = data.length - currTileDataIndex;
-        final int count = Math.min(available, len);
-        System.arraycopy(data, currTileDataIndex, buff, off, count);
-        currTileDataIndex += count;
-        streamPos += count;
-        return count;
-    }
-
-    /**
-     * Fetches a tile from the {@code tileReader} if necessary and returns the current tile data.
-     * <p>
-     * It is needed to fetch a new tile if {@link #currTileDataIndex} indicates all the current tile
-     * data has been already read. If so, {@code currTileDataIndex} is reset to 0. The {@code read}
-     * operations are responsible of incrementing {@code currTileDataIndex} depending on how many
-     * bytes have been consumed from the tile data returned by this method.
-     * </p>
-     *
-     * @return {@code null} if there's no more tiles to fetch, the current tile data otherwise
-     * @throws IOException
-     */
-    private byte[] getTileData() throws IOException {
-//        if (currTileDataIndex == tileDataLength) {
-//            if (!tileReader.hasNext()) {
-//                return null;
-//            }
-//
-//            currTileDataIndex = 0;
-//            ++currTileIndex;
-//            TileInfo tile = tileReader.next();
-//            currTileData = tile.getTileData();
-//
-//            if (!tileReader.hasNext()) {
-//                tileReader.dispose();
-//            }
-//        }
-        return currTileData;
-    }
-
-    @Override
-    public void close() throws IOException {
-        tileReader.dispose();
-        super.close();
-    }
-}
\ No newline at end of file

Modified: trunk/modules/plugin/arcsde/datastore/src/main/java/org/geotools/arcsde/raster/jai/ArcSDETiledRenderedImage.java
===================================================================
--- trunk/modules/plugin/arcsde/datastore/src/main/java/org/geotools/arcsde/raster/jai/ArcSDETiledRenderedImage.java 2009-11-06 19:42:43 UTC (rev 34338)
+++ trunk/modules/plugin/arcsde/datastore/src/main/java/org/geotools/arcsde/raster/jai/ArcSDETiledRenderedImage.java 2009-11-06 19:44:57 UTC (rev 34339)
@@ -5,6 +5,11 @@
 
 import java.awt.Point;
 import java.awt.image.DataBuffer;
+import java.awt.image.DataBufferByte;
+import java.awt.image.DataBufferFloat;
+import java.awt.image.DataBufferInt;
+import java.awt.image.DataBufferShort;
+import java.awt.image.DataBufferUShort;
 import java.awt.image.Raster;
 import java.awt.image.SampleModel;
 import java.awt.image.WritableRaster;
@@ -13,10 +18,10 @@
 import javax.imageio.ImageTypeSpecifier;
 
 import org.apache.commons.collections.map.LRUMap;
-import org.geotools.arcsde.raster.io.TileInfo;
 import org.geotools.arcsde.raster.io.TileReader;
 
 import com.sun.media.imageioimpl.common.SimpleRenderedImage;
+import com.sun.media.jai.codecimpl.util.DataBufferDouble;
 
 @SuppressWarnings("unchecked")
 class ArcSDETiledRenderedImage extends SimpleRenderedImage {
@@ -56,70 +61,96 @@
         final int xOrigin = tileXToX(tileX);
         final int yOrigin = tileYToY(tileY);
 
-        final int numBands = tileSampleModel.getNumBands();
+        // final int numBands = tileSampleModel.getNumBands();
 
-        DataBuffer dataBuffer = tileSampleModel.createDataBuffer();
-        TileInfo[] tileInfo;
+        currentTile = Raster.createWritableRaster(tileSampleModel, new Point(xOrigin, yOrigin));
+        final DataBuffer dataBuffer = currentTile.getDataBuffer();
         try {
-            tileInfo = tileReader.getTile(tileX, tileY);
+            switch (tileSampleModel.getDataType()) {
+            case DataBuffer.TYPE_BYTE: {
+                byte[][] data = ((DataBufferByte) dataBuffer).getBankData();
+                tileReader.getTile(tileX, tileY, data);
+            }
+                break;
+            case DataBuffer.TYPE_USHORT: {
+                short[][] data = ((DataBufferUShort) dataBuffer).getBankData();
+                tileReader.getTile(tileX, tileY, data);
+            }
+                break;
+            case DataBuffer.TYPE_SHORT: {
+                short[][] data = ((DataBufferShort) dataBuffer).getBankData();
+                tileReader.getTile(tileX, tileY, data);
+            }
+                break;
+            case DataBuffer.TYPE_INT: {
+                int[][] data = ((DataBufferInt) dataBuffer).getBankData();
+                tileReader.getTile(tileX, tileY, data);
+            }
+                break;
+            case DataBuffer.TYPE_FLOAT: {
+                float[][] data = ((DataBufferFloat) dataBuffer).getBankData();
+                tileReader.getTile(tileX, tileY, data);
+            }
+                break;
+            case DataBuffer.TYPE_DOUBLE: {
+                double[][] data = ((DataBufferDouble) dataBuffer).getBankData();
+                tileReader.getTile(tileX, tileY, data);
+            }
+                break;
+            default:
+                throw new IllegalStateException("Unrecognized DataBuffer type: "
+                        + dataBuffer.getDataType());
+            }
         } catch (IOException e) {
             e.printStackTrace();
             throw new RuntimeException(e);
         }
 
-        for (int bandN = 0; bandN < numBands; bandN++) {
-            TileInfo bandData = tileInfo[bandN];
-            bandData.fill(dataBuffer, bandN);
-        }
+        // TileInfo[] tileInfo;
+        // try {
+        // tileInfo = tileReader.getTile(tileX, tileY);
+        // } catch (IOException e) {
+        // e.printStackTrace();
+        // throw new RuntimeException(e);
+        // }
 
-        currentTile = Raster.createWritableRaster(tileSampleModel, dataBuffer, new Point(xOrigin,
-                yOrigin));
+        // for (int bandN = 0; bandN < numBands; bandN++) {
+        // TileInfo bandData = tileInfo[bandN];
+        // bandData.fill(dataBuffer, bandN);
+        // }
+
         cache(key, currentTile);
 
         return currentTile;
     }
 
     private TileKey newKey(final int tileX, final int tileY) {
-        final long rasterId = tileReader.getRasterId();
-        final int pyramidLevel = tileReader.getPyramidLevel();
-        final int rasterTileX = tileReader.getMinTileX() + tileX;
-        final int rasterTileY = tileReader.getMinTileY() + tileY;
-
-        TileKey tileKey = new TileKey(rasterId, pyramidLevel, tileX, tileY, rasterTileX,
-                rasterTileY);
+        TileKey tileKey = new TileKey(tileX, tileY);
         return tileKey;
     }
 
-    private final LRUMap cache = new LRUMap(5);
+    private LRUMap cache;
 
     private void cache(TileKey key, WritableRaster tile) {
+        if (cache == null) {
+            // int tilesWide = tileReader.getTilesWide();
+            // int maxCacheSize = Math.min(10, tilesWide);
+            cache = new LRUMap(5);
+        }
         cache.put(key, tile);
     }
 
     private WritableRaster getCached(TileKey key) {
-        WritableRaster tile = (WritableRaster) cache.get(key);
+        WritableRaster tile = cache == null ? null : (WritableRaster) cache.get(key);
         return tile;
     }
 
     private static class TileKey {
         private int tileX, tileY;
 
-        private long rasterId;
-
-        private int pyramidLevel;
-
-        private int rasterTileX;
-
-        private int rasterTileY;
-
-        public TileKey(long rasterId, int pyramidLevel, int tileX, int tileY, int rasterTileX,
-                int rasterTileY) {
-            this.rasterId = rasterId;
-            this.pyramidLevel = pyramidLevel;
+        public TileKey(int tileX, int tileY) {
             this.tileX = tileX;
             this.tileY = tileY;
-            this.rasterTileX = rasterTileX;
-            this.rasterTileY = rasterTileY;
         }
 
         @Override
@@ -128,13 +159,12 @@
                 return false;
             }
             TileKey t = (TileKey) o;
-            return rasterId == t.rasterId && pyramidLevel == t.pyramidLevel
-                    && rasterTileX == t.rasterTileX && rasterTileY == t.rasterTileY;
+            return tileX == t.tileX && tileY == t.tileY;
         }
 
         @Override
         public int hashCode() {
-            return (17 ^ pyramidLevel) + rasterTileX * rasterTileY;
+            return 17 ^ tileX * tileY;
         }
 
         public int getTileX() {

Modified: trunk/modules/plugin/arcsde/datastore/src/test/java/org/geotools/arcsde/raster/gce/ArcSDEGridCoverage2DReaderJAILegacyOnlineTest.java
===================================================================
--- trunk/modules/plugin/arcsde/datastore/src/test/java/org/geotools/arcsde/raster/gce/ArcSDEGridCoverage2DReaderJAILegacyOnlineTest.java 2009-11-06 19:42:43 UTC (rev 34338)
+++ trunk/modules/plugin/arcsde/datastore/src/test/java/org/geotools/arcsde/raster/gce/ArcSDEGridCoverage2DReaderJAILegacyOnlineTest.java 2009-11-06 19:44:57 UTC (rev 34339)
@@ -120,7 +120,7 @@
         final AbstractGridCoverage2DReader reader = getReader();
         assertNotNull("Couldn't obtain a reader for " + tableName, reader);
 
-        final int count = 0;
+        final int count = 10;
         long time = 0;
         // warm up
         _testIMG_USGSQUAD_SGBASE(reader);
@@ -205,13 +205,14 @@
     @Test
     public void testReadIMG_USGSQUADM_Buggy() throws Exception {
         // http://localhost:8080/geoserver/wms?HEIGHT=500&WIDTH=1200&LAYERS=sde:IMG_USGSQUADM&STYLES=&SRS=EPSG%3A26986&FORMAT=image%2Fjpeg&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&EXCEPTIONS=application%2Fvnd.ogc.se_inimage&BBOX=253178.45971681,872419.13604732,253521.78247071,872562.18719478
-        //http://arcy.opengeo.org:8080/geoserver/wms?SRS=EPSG%3A26986&WIDTH=950&STYLES=&HEIGHT=400&LAYERS=massgis%3ASDE.IMG_USGSQUADM&FORMAT=image%2Fpng&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&EXCEPTIONS=application%2Fvnd.ogc.se_inimage&BBOX=290557.15234375,932233.3984375,325347.19140625,946881.8359375
+        // http://arcy.opengeo.org:8080/geoserver/wms?SRS=EPSG%3A26986&WIDTH=950&STYLES=&HEIGHT=400&LAYERS=massgis%3ASDE.IMG_USGSQUADM&FORMAT=image%2Fpng&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&EXCEPTIONS=application%2Fvnd.ogc.se_inimage&BBOX=290557.15234375,932233.3984375,325347.19140625,946881.8359375
         tableName = "SDE.RASTER.IMG_USGSQUADM";
         final AbstractGridCoverage2DReader reader = getReader();
         assertNotNull("Couldn't obtain a reader for " + tableName, reader);
 
         final GeneralEnvelope requestEnvelope = new GeneralEnvelope(reader.getOriginalEnvelope());
-        requestEnvelope.setEnvelope(290557.15234375,932233.3984375,325347.19140625,946881.8359375);
+        requestEnvelope.setEnvelope(290557.15234375, 932233.3984375, 325347.19140625,
+                946881.8359375);
 
         final int reqWidth = 950;
         final int reqHeight = 400;

Modified: trunk/modules/plugin/arcsde/datastore/src/test/java/org/geotools/arcsde/raster/gce/ArcSDEGridCoverage2DReaderJAIOnlineTest.java
===================================================================
--- trunk/modules/plugin/arcsde/datastore/src/test/java/org/geotools/arcsde/raster/gce/ArcSDEGridCoverage2DReaderJAIOnlineTest.java 2009-11-06 19:42:43 UTC (rev 34338)
+++ trunk/modules/plugin/arcsde/datastore/src/test/java/org/geotools/arcsde/raster/gce/ArcSDEGridCoverage2DReaderJAIOnlineTest.java 2009-11-06 19:44:57 UTC (rev 34339)
@@ -34,7 +34,6 @@
 import java.util.logging.Logger;
 
 import javax.imageio.ImageIO;
-import javax.media.jai.operator.FormatDescriptor;
 
 import org.geotools.arcsde.ArcSDERasterFormatFactory;
 import org.geotools.arcsde.raster.info.RasterCellType;
@@ -88,6 +87,7 @@
 
     @BeforeClass
     public static void setUpBeforeClass() throws Exception {
+        LOGGER.setLevel(Level.FINEST);
         // rasterTestData = new RasterTestData();
         // rasterTestData.setUp();
         // DEBUG = Boolean
@@ -148,7 +148,7 @@
     @Test
     @Ignore
     public void testRead_04bit_1Band() throws Exception {
-        testReadFullLevel0(TYPE_4BIT, 1);
+        testReadFullLevel0(TYPE_4BIT, 1, TYPE_8BIT_U);
     }
 
     @Test
@@ -196,7 +196,8 @@
 
     @Test
     public void testRead_08bit_U_7Band() throws Exception {
-        testReadFullLevel0(TYPE_8BIT_U, 7);
+        // type promotion caused becuase test data has no statistics...
+        testReadFullLevel0(TYPE_8BIT_U, 7, TYPE_16BIT_U);
     }
 
     @Test
@@ -207,32 +208,32 @@
 
     @Test
     public void testRead_08bit_S_1Band() throws Exception {
-        testReadFullLevel0(TYPE_8BIT_S, 1);
+        testReadFullLevel0(TYPE_8BIT_S, 1, TYPE_16BIT_S);
     }
 
     @Test
     public void testRead_08bit_S_7Band() throws Exception {
-        testReadFullLevel0(TYPE_8BIT_S, 7);
+        testReadFullLevel0(TYPE_8BIT_S, 7, TYPE_16BIT_S);
     }
 
     @Test
     public void testRead_16bit_S_1Band() throws Exception {
-        testReadFullLevel0(TYPE_16BIT_S, 1);
+        testReadFullLevel0(TYPE_16BIT_S, 1, TYPE_32BIT_S);
     }
 
     @Test
     public void testRead_16bit_S_7Band() throws Exception {
-        testReadFullLevel0(TYPE_16BIT_S, 7);
+        testReadFullLevel0(TYPE_16BIT_S, 7, TYPE_32BIT_S);
     }
 
     @Test
     public void testRead_16bit_U_1Band() throws Exception {
-        testReadFullLevel0(TYPE_16BIT_U, 1);
+        testReadFullLevel0(TYPE_16BIT_U, 1, TYPE_32BIT_U);
     }
 
     @Test
     public void testRead_16bit_U_7Band() throws Exception {
-        testReadFullLevel0(TYPE_16BIT_U, 7);
+        testReadFullLevel0(TYPE_16BIT_U, 7, TYPE_32BIT_U);
     }
 
     @Test
@@ -432,21 +433,16 @@
         // ///////////////////////////////////////////////////////////assertEquals(originalGridRange,
         // gridGeometry.getGridRange());
 
-        final RenderedImage geophysics = coverage.view(ViewType.NATIVE).getRenderedImage();
-        assertNotNull(geophysics);
-
         final String fileName = "testReadFullLevel0_" + fileNamePostFix;
 
-        if (!(geophysics.getColorModel() instanceof IndexColorModel)) {
-            // not sure why, but the geotiff writer goes OOM if it's an indexed image
-            writeToDisk(coverage, fileName);
-        }
-        writeToDisk(geophysics, fileName);
+        writeToDisk(coverage, fileName);
 
         // ////assertEquals(cellType.getDataBufferType(), image.getSampleModel().getDataType());
-        final int[] sampleSize = geophysics.getSampleModel().getSampleSize();
-        final ColorModel colorModel = geophysics.getColorModel();
 
+        RenderedImage nativeImage = coverage.view(ViewType.NATIVE).getRenderedImage();
+        final int[] sampleSize = nativeImage.getSampleModel().getSampleSize();
+        final ColorModel colorModel = nativeImage.getColorModel();
+
         if (colorModel instanceof IndexColorModel) {
             switch (cellType) {
             case TYPE_1BIT:
@@ -640,23 +636,34 @@
     private void writeToDisk(GridCoverage2D coverage, String fileName) throws Exception {
         Object destination;
         {
-            String file = System.getProperty("user.home");
-            file += File.separator + "arcsde_test" + File.separator + fileName + ".tiff";
-            File path = new File(file);
+            String directory = System.getProperty("user.home");
+            directory += File.separator + "arcsde_test" + File.separator + fileName
+                    + "_native.tiff";
+            File path = new File(directory);
             path.getParentFile().mkdirs();
             destination = path;
         }
-        GeoTiffWriter writer = new GeoTiffWriter(destination);
-
-        System.out.println("\n --- Writing to " + destination);
-        try {
-            long t = System.currentTimeMillis();
-            writer.write(coverage, null);
-            System.out.println(" - wrote in " + t + "ms" + destination);
-        } catch (Exception e) {
-            e.printStackTrace();
-            throw e;
+        if (coverage.getRenderedImage().getColorModel() instanceof IndexColorModel) {
+            LOGGER.info("not writing GeoTiff for " + fileName
+                    + " because it fails with IndexColorModel. Don't know why");
+        } else {
+            GeoTiffWriter writer = new GeoTiffWriter(destination);
+            System.out.println("\n --- Writing to " + destination);
+            try {
+                long t = System.currentTimeMillis();
+                writer.write(coverage, null);
+                System.out.println(" - wrote in " + t + "ms" + destination);
+            } catch (Exception e) {
+                e.printStackTrace();
+                throw e;
+            }
         }
+        RenderedImage rendered = coverage.view(ViewType.RENDERED).getRenderedImage();
+        writeToDisk(rendered, fileName + "_rendered");
+        RenderedImage geophysics = coverage.view(ViewType.GEOPHYSICS).getRenderedImage();
+        writeToDisk(geophysics, fileName + "_geophysics");
+        RenderedImage photographic = coverage.view(ViewType.PHOTOGRAPHIC).getRenderedImage();
+        writeToDisk(photographic, fileName + "_photographic");
     }
 
     private void writeToDisk(final RenderedImage image, String fileName) throws Exception {
@@ -666,16 +673,12 @@
         }
         String file = System.getProperty("user.home");
         file += File.separator + "arcsde_test" + File.separator + fileName;
-        File geophysics = new File(file + "_geophysics.tiff");
-        File rendered = new File(file + "_rendered.tiff");
-        geophysics.getParentFile().mkdirs();
+        File targetFile = new File(file + ".tiff");
+        targetFile.getParentFile().mkdirs();
         System.out.println("\n --- Writing to " + file);
 
         try {
-            ImageIO.write(image, "TIFF", geophysics);
-
-            ImageIO.write(FormatDescriptor.create(image, Integer.valueOf(DataBuffer.TYPE_BYTE),
-                    null), "TIFF", rendered);
+            ImageIO.write(image, "TIFF", targetFile);
         } catch (Exception e) {
             e.printStackTrace();
             throw e;

Modified: trunk/modules/plugin/arcsde/datastore/src/test/java/org/geotools/arcsde/raster/gce/RasterTestData.java
===================================================================
--- trunk/modules/plugin/arcsde/datastore/src/test/java/org/geotools/arcsde/raster/gce/RasterTestData.java 2009-11-06 19:42:43 UTC (rev 34338)
+++ trunk/modules/plugin/arcsde/datastore/src/test/java/org/geotools/arcsde/raster/gce/RasterTestData.java 2009-11-06 19:44:57 UTC (rev 34339)
@@ -71,7 +71,6 @@
 import org.geotools.arcsde.session.Command;
 import org.geotools.arcsde.session.ISession;
 import org.geotools.arcsde.session.ISessionPool;
-import org.geotools.arcsde.session.UnavailableConnectionException;
 import org.geotools.util.logging.Logging;
 
 import com.esri.sde.sdk.client.SDEPoint;
@@ -426,7 +425,7 @@
 
                 // if there's a colormap to insert, let's add that too
                 if (indexCM != null) {
-                    attr = getRasterAttributes(tableName, new Rectangle(0, 0, 0, 0), 0,
+                    attr = getRasterAttributes(connection, tableName, new Rectangle(0, 0, 0, 0), 0,
                             new int[] { 1 });
                     final int numEntries = indexCM.getMapSize();
                     // number of colors, including alpha, if any
@@ -1031,48 +1030,35 @@
         return true;
     }
 
-    public SeRasterAttr getRasterAttributes(final String rasterName, final Rectangle tiles,
-            final int level, final int[] bands) throws IOException {
+    public SeRasterAttr getRasterAttributes(SeConnection conn, final String rasterName,
+            final Rectangle tiles, final int level, final int[] bands) throws IOException {
 
-        ISession conn;
         try {
-            conn = getConnectionPool().getSession();
-        } catch (UnavailableConnectionException e) {
-            throw new RuntimeException(e);
-        }
+            final SeQuery query = new SeQuery(conn, new String[] { "RASTER" }, new SeSqlConstruct(
+                    rasterName));
+            query.prepareQuery();
+            query.execute();
+            final SeRow r = query.fetch();
 
-        try {
-            final SeQuery query = conn.createAndExecuteQuery(new String[] { conn.getRasterColumn(
-                    rasterName).getName() }, new SeSqlConstruct(rasterName));
+            // Now build a SeRasterConstraint object which queries the db for
+            // the right tiles/bands/pyramid level
+            SeRasterConstraint rConstraint = new SeRasterConstraint();
+            rConstraint.setEnvelope((int) tiles.getMinX(), (int) tiles.getMinY(), (int) tiles
+                    .getMaxX(), (int) tiles.getMaxY());
+            rConstraint.setLevel(level);
+            rConstraint.setBands(bands);
 
-            return conn.issue(new Command<SeRasterAttr>() {
+            // Finally, execute the raster query aganist the already-opened
+            // SeQuery object which already has an SeRow fetched against it.
 
-                @Override
-                public SeRasterAttr execute(ISession session, SeConnection connection)
-                        throws SeException, IOException {
-                    final SeRow r = query.fetch();
+            query.queryRasterTile(rConstraint);
+            final SeRasterAttr rattr = r.getRaster(0);
 
-                    // Now build a SeRasterConstraint object which queries the db for
-                    // the right tiles/bands/pyramid level
-                    SeRasterConstraint rConstraint = new SeRasterConstraint();
-                    rConstraint.setEnvelope((int) tiles.getMinX(), (int) tiles.getMinY(),
-                            (int) tiles.getMaxX(), (int) tiles.getMaxY());
-                    rConstraint.setLevel(level);
-                    rConstraint.setBands(bands);
+            query.close();
 
-                    // Finally, execute the raster query aganist the already-opened
-                    // SeQuery object which already has an SeRow fetched against it.
-
-                    query.queryRasterTile(rConstraint);
-                    final SeRasterAttr rattr = r.getRaster(0);
-
-                    query.close();
-
-                    return rattr;
-                }
-            });
-        } finally {
-            conn.dispose();
+            return rattr;
+        } catch (SeException e) {
+            throw new ArcSdeException(e);
         }
     }
 

Modified: trunk/modules/plugin/arcsde/datastore/src/test/java/org/geotools/arcsde/raster/io/BitmaskToNoDataConverterTest.java
===================================================================
--- trunk/modules/plugin/arcsde/datastore/src/test/java/org/geotools/arcsde/raster/io/BitmaskToNoDataConverterTest.java 2009-11-06 19:42:43 UTC (rev 34338)
+++ trunk/modules/plugin/arcsde/datastore/src/test/java/org/geotools/arcsde/raster/io/BitmaskToNoDataConverterTest.java 2009-11-06 19:44:57 UTC (rev 34339)
@@ -1,276 +1,249 @@
 package org.geotools.arcsde.raster.io;
 
-import static org.geotools.arcsde.raster.info.RasterCellType.TYPE_16BIT_U;
-import static org.geotools.arcsde.raster.info.RasterCellType.TYPE_1BIT;
-import static org.geotools.arcsde.raster.info.RasterCellType.TYPE_4BIT;
-import static org.geotools.arcsde.raster.info.RasterCellType.TYPE_8BIT_U;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
 
-import java.awt.Dimension;
-import java.awt.Point;
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.DataInputStream;
-import java.io.DataOutputStream;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-import org.geotools.arcsde.raster.info.RasterBandInfo;
-import org.geotools.arcsde.raster.info.RasterCellType;
-import org.geotools.arcsde.raster.info.RasterDatasetInfo;
-import org.geotools.arcsde.raster.info.RasterInfo;
-import org.geotools.arcsde.raster.io.BitmaskToNoDataConverter.Unsigned8bitConverter;
-import org.geotools.geometry.jts.ReferencedEnvelope;
-import org.junit.Test;
-
 public class BitmaskToNoDataConverterTest {
 
-//    @Test
-//    public void testGetInstance8BitU() throws IOException {
-//        RasterDatasetInfo rasterInfo;
-//        BitmaskToNoDataConverter noData;
-//
-//        int noDataValue;
-//        double statsMin;
-//        double statsMax;
-//
-//        noDataValue = 0;
-//        statsMin = 1;
-//        statsMax = 255;
-//        rasterInfo = createRasterInfo(TYPE_8BIT_U, noDataValue, statsMin, statsMax);
-//        noData = BitmaskToNoDataConverter.getInstance(rasterInfo, 1L);
-//        assertNotNull(noData);
-//
-//        noDataValue = 255;
-//        statsMin = 0;
-//        statsMax = 254;
-//        rasterInfo = createRasterInfo(TYPE_8BIT_U, noDataValue, statsMin, statsMax);
-//        noData = BitmaskToNoDataConverter.getInstance(rasterInfo, 1L);
-//        assertNotNull(noData);
-//        assertTrue(noData instanceof BitmaskToNoDataConverter.Unsigned8bitConverter);
-//
-//        final int samplesPerTile = rasterInfo.getTileDimension(0).width
-//                * rasterInfo.getTileDimension(0).height;
-//
-//        /*
-//         * bulk set, a whole no-data tile
-//         */
-//        byte[] tileData = new byte[samplesPerTile];
-//        noData.setAll(1L, tileData);
-//        DataInputStream in = new DataInputStream(new ByteArrayInputStream(tileData));
-//        for (int sampleN = 0; sampleN < samplesPerTile; sampleN++) {
-//            assertEquals(255, in.readByte() & 0xFF);
-//        }
-//
-//        /*
-//         * bitmask data states the first 8 and last 8 samples are no-data
-//         */
-//        byte[] bitmaskData = new byte[(int) Math.ceil(samplesPerTile / 8D)];
-//        Arrays.fill(bitmaskData, (byte) 0xFF);
-//        // set the first 8 and last 8 samples to no-data
-//        bitmaskData[0] = 0x00;
-//        bitmaskData[bitmaskData.length - 1] = 0x00;
-//
-//        final byte dataValue = 5;
-//        byte[] expected = new byte[samplesPerTile];
-//        Arrays.fill(expected, dataValue);
-//        Arrays.fill(expected, 0, 8, (byte) noDataValue);
-//        Arrays.fill(expected, expected.length - 8, expected.length, (byte) noDataValue);
-//
-//        tileData = new byte[samplesPerTile];
-//        Arrays.fill(tileData, dataValue);
-//        noData.setNoData(1L, tileData, bitmaskData);
-//        assertTrue("Arrays differ, expected:" + Arrays.toString(expected) + ", actual:"
-//                + Arrays.toString(tileData), Arrays.equals(expected, tileData));
-//
-//        /*
-//         * set individual sample
-//         */
-//        tileData = new byte[samplesPerTile];
-//        noData.setNoData(1L, 0, tileData);
-//        assertEquals(noDataValue, tileData[0] & 0xFF);
-//        noData.setNoData(1L, 5, tileData);
-//        assertEquals(noDataValue, tileData[5] & 0xFF);
-//        noData.setNoData(1L, tileData.length - 1, tileData);
-//        assertEquals(noDataValue, tileData[tileData.length - 1] & 0xFF);
-//    }
-//
-//    @Test
-//    public void testGetInstance1Bit() {
-//        RasterDatasetInfo rasterInfo;
-//        BitmaskToNoDataConverter noData;
-//
-//        int noDataValue;
-//        double statsMin;
-//        double statsMax;
-//
-//        noDataValue = 0;
-//        statsMin = 0;
-//        statsMax = 1;
-//        rasterInfo = createRasterInfo(TYPE_1BIT, noDataValue, statsMin, statsMax);
-//        try {
-//            noData = BitmaskToNoDataConverter.getInstance(rasterInfo, 1L);
-//            fail("Expected UOE, noDataValue == 0 is non valid");
-//        } catch (UnsupportedOperationException e) {
-//            assertTrue(true);
-//        }
-//
-//        noDataValue = 2;
-//        statsMin = 0;
-//        statsMax = 1;
-//        rasterInfo = createRasterInfo(TYPE_1BIT, noDataValue, statsMin, statsMax);
-//        noData = BitmaskToNoDataConverter.getInstance(rasterInfo, 1L);
-//        assertNotNull(noData);
-//        // make sure promotion from 1 to 8 bit is being taking place here and hence we got a 8-bit-u
-//        // no-data setter
-//        assertTrue(noData instanceof Unsigned8bitConverter);
-//    }
-//
-//    @Test
-//    public void testGetInstance4Bit() {
-//        RasterDatasetInfo rasterInfo;
-//        BitmaskToNoDataConverter noData;
-//
-//        int noDataValue;
-//        double statsMin;
-//        double statsMax;
-//
-//        statsMin = TYPE_4BIT.getSampleValueRange().getMinimum();
-//        statsMax = TYPE_4BIT.getSampleValueRange().getMaximum();
-//        noDataValue = 0;
-//
-//        rasterInfo = createRasterInfo(TYPE_4BIT, noDataValue, statsMin, statsMax);
-//        try {
-//            noData = BitmaskToNoDataConverter.getInstance(rasterInfo, 1L);
-//            fail("Expected UOE, noDataValue == 0 is non valid");
-//        } catch (UnsupportedOperationException e) {
-//            assertTrue(true);
-//        }
-//
-//        noDataValue = (int) (statsMax + 1);
-//
-//        rasterInfo = createRasterInfo(TYPE_4BIT, noDataValue, statsMin, statsMax);
-//        noData = BitmaskToNoDataConverter.getInstance(rasterInfo, 1L);
-//        assertNotNull(noData);
-//        // make sure promotion from 4 to 8 bit is being taking place here and hence we got a 8-bit-u
-//        // no-data setter
-//        assertTrue(noData instanceof Unsigned8bitConverter);
-//    }
-//
-//    @Test
-//    public void testGetInstance16BitU() throws IOException {
-//        RasterDatasetInfo rasterInfo;
-//        BitmaskToNoDataConverter noData;
-//
-//        final int noDataValue = (int) TYPE_16BIT_U.getSampleValueRange().getMaximum();
-//        double statsMin;
-//        double statsMax;
-//
-//        statsMin = TYPE_16BIT_U.getSampleValueRange().getMinimum();
-//        statsMax = TYPE_16BIT_U.getSampleValueRange().getMaximum() - 1;
-//        rasterInfo = createRasterInfo(TYPE_16BIT_U, noDataValue, statsMin, statsMax);
-//        noData = BitmaskToNoDataConverter.getInstance(rasterInfo, 1L);
-//        assertNotNull(noData);
-//
-//        final int samplesPerTile = rasterInfo.getTileDimension(0).width
-//                * rasterInfo.getTileDimension(0).height;
-//
-//        final int dataValue = 5;
-//
-//        byte[] tileData = new byte[TYPE_16BIT_U.getBitsPerSample() * samplesPerTile];
-//        noData.setAll(1L, tileData);
-//        DataInputStream in = new DataInputStream(new ByteArrayInputStream(tileData));
-//        for (int sampleN = 0; sampleN < samplesPerTile; sampleN++) {
-//            assertEquals(noDataValue, in.readUnsignedShort());
-//        }
-//
-//        byte[] bitmaskData = new byte[(int) Math.ceil(samplesPerTile / 8D)];
-//        Arrays.fill(bitmaskData, (byte) 0xFF);
-//        // set the first 8 and last 8 samples to no-data
-//        bitmaskData[0] = 0x00;
-//        bitmaskData[bitmaskData.length - 1] = 0x00;
-//
-//        byte[] expected;
-//        {
-//            ByteArrayOutputStream actualOut = new ByteArrayOutputStream();
-//            DataOutputStream actualWriter = new DataOutputStream(actualOut);
-//
-//            ByteArrayOutputStream expectedOut = new ByteArrayOutputStream();
-//            DataOutputStream expectedWriter = new DataOutputStream(expectedOut);
-//            for (int i = 0; i < samplesPerTile; i++) {
-//                actualWriter.writeShort(dataValue);
-//
-//                if (i < 8 || i >= samplesPerTile - 8) {
-//                    expectedWriter.writeShort(noDataValue);
-//                } else {
-//                    expectedWriter.writeShort(dataValue);
-//                }
-//            }
-//            tileData = actualOut.toByteArray();
-//            expected = expectedOut.toByteArray();
-//        }
-//
-//        noData.setNoData(1L, tileData, bitmaskData);
-//        assertTrue("Arrays differ, expected:" + Arrays.toString(expected) + ", actual:"
-//                + Arrays.toString(tileData), Arrays.equals(expected, tileData));
-//
-//        /*
-//         * set individual sample
-//         */
-//        final int bitsPerSample = TYPE_16BIT_U.getBitsPerSample();
-//        tileData = new byte[bitsPerSample * samplesPerTile];
-//
-//        in = new DataInputStream(new ByteArrayInputStream(tileData));
-//        noData.setNoData(1L, 0, tileData);
-//        assertEquals(noDataValue, in.readUnsignedShort());
-//
-//        in = new DataInputStream(new ByteArrayInputStream(tileData, 5 * (bitsPerSample / 8), 2));
-//        noData.setNoData(1L, 5, tileData);
-//        assertEquals(noDataValue, in.readUnsignedShort());
-//
-//        in = new DataInputStream(new ByteArrayInputStream(tileData, (samplesPerTile - 1)
-//                * (bitsPerSample / 8), 2));
-//        noData.setNoData(1L, samplesPerTile - 1, tileData);
-//        assertEquals(noDataValue, in.readUnsignedShort());
-//    }
-//
-//    private RasterDatasetInfo createRasterInfo(RasterCellType nativeType, Number noDataValue,
-//            double statsMin, double statsMax) {
-//
-//        RasterDatasetInfo datasetInfo = new RasterDatasetInfo();
-//
-//        List<RasterInfo> datasetRasters = new ArrayList<RasterInfo>();
-//        // fake a 3x8 pixel raster so it's a matrix of 24 elements and it matches a full bitmask
-//        // array (no unused bitmask bits)
-//        RasterInfo rasterInfo = new RasterInfo(1L, 3, 8);
-//        datasetRasters.add(rasterInfo);
-//
-//        rasterInfo.addPyramidLevel(0, new ReferencedEnvelope(), new Point(), new Point(), 10, 10,
-//                new Dimension(100, 100));
-//        List<RasterBandInfo> bands = new ArrayList<RasterBandInfo>();
-//        RasterBandInfo bandInfo = new RasterBandInfo(1L, nativeType, noDataValue, statsMin,
-//                statsMax);
-//        bands.add(bandInfo);
-//
-//        // bandInfo.bandId = 1L;
-//        // // the native type
-//        // bandInfo.cellType = nativeType;
-//        // // the target type will be determined based on the native type bounds and the band's
-//        // // statistics
-//        // bandInfo.noDataValue = noDataValue;
-//        // bandInfo.statsMin = statsMin;
-//        // bandInfo.statsMax = statsMax;
-//
-//        rasterInfo.setBands(bands);
-//
-//        datasetInfo.setPyramidInfo(datasetRasters);
-//
-//        return datasetInfo;
-//    }
+    // @Test
+    // public void testGetInstance8BitU() throws IOException {
+    // RasterDatasetInfo rasterInfo;
+    // BitmaskToNoDataConverter noData;
+    //
+    // int noDataValue;
+    // double statsMin;
+    // double statsMax;
+    //
+    // noDataValue = 0;
+    // statsMin = 1;
+    // statsMax = 255;
+    // rasterInfo = createRasterInfo(TYPE_8BIT_U, noDataValue, statsMin, statsMax);
+    // noData = BitmaskToNoDataConverter.getInstance(rasterInfo, 1L);
+    // assertNotNull(noData);
+    //
+    // noDataValue = 255;
+    // statsMin = 0;
+    // statsMax = 254;
+    // rasterInfo = createRasterInfo(TYPE_8BIT_U, noDataValue, statsMin, statsMax);
+    // noData = BitmaskToNoDataConverter.getInstance(rasterInfo, 1L);
+    // assertNotNull(noData);
+    // assertTrue(noData instanceof BitmaskToNoDataConverter.Unsigned8bitConverter);
+    //
+    // final int samplesPerTile = rasterInfo.getTileDimension(0).width
+    // * rasterInfo.getTileDimension(0).height;
+    //
+    // /*
+    // * bulk set, a whole no-data tile
+    // */
+    // byte[] tileData = new byte[samplesPerTile];
+    // noData.setAll(1L, tileData);
+    // DataInputStream in = new DataInputStream(new ByteArrayInputStream(tileData));
+    // for (int sampleN = 0; sampleN < samplesPerTile; sampleN++) {
+    // assertEquals(255, in.readByte() & 0xFF);
+    // }
+    //
+    // /*
+    // * bitmask data states the first 8 and last 8 samples are no-data
+    // */
+    // byte[] bitmaskData = new byte[(int) Math.ceil(samplesPerTile / 8D)];
+    // Arrays.fill(bitmaskData, (byte) 0xFF);
+    // // set the first 8 and last 8 samples to no-data
+    // bitmaskData[0] = 0x00;
+    // bitmaskData[bitmaskData.length - 1] = 0x00;
+    //
+    // final byte dataValue = 5;
+    // byte[] expected = new byte[samplesPerTile];
+    // Arrays.fill(expected, dataValue);
+    // Arrays.fill(expected, 0, 8, (byte) noDataValue);
+    // Arrays.fill(expected, expected.length - 8, expected.length, (byte) noDataValue);
+    //
+    // tileData = new byte[samplesPerTile];
+    // Arrays.fill(tileData, dataValue);
+    // noData.setNoData(1L, tileData, bitmaskData);
+    // assertTrue("Arrays differ, expected:" + Arrays.toString(expected) + ", actual:"
+    // + Arrays.toString(tileData), Arrays.equals(expected, tileData));
+    //
+    // /*
+    // * set individual sample
+    // */
+    // tileData = new byte[samplesPerTile];
+    // noData.setNoData(1L, 0, tileData);
+    // assertEquals(noDataValue, tileData[0] & 0xFF);
+    // noData.setNoData(1L, 5, tileData);
+    // assertEquals(noDataValue, tileData[5] & 0xFF);
+    // noData.setNoData(1L, tileData.length - 1, tileData);
+    // assertEquals(noDataValue, tileData[tileData.length - 1] & 0xFF);
+    // }
+    //
+    // @Test
+    // public void testGetInstance1Bit() {
+    // RasterDatasetInfo rasterInfo;
+    // BitmaskToNoDataConverter noData;
+    //
+    // int noDataValue;
+    // double statsMin;
+    // double statsMax;
+    //
+    // noDataValue = 0;
+    // statsMin = 0;
+    // statsMax = 1;
+    // rasterInfo = createRasterInfo(TYPE_1BIT, noDataValue, statsMin, statsMax);
+    // try {
+    // noData = BitmaskToNoDataConverter.getInstance(rasterInfo, 1L);
+    // fail("Expected UOE, noDataValue == 0 is non valid");
+    // } catch (UnsupportedOperationException e) {
+    // assertTrue(true);
+    // }
+    //
+    // noDataValue = 2;
+    // statsMin = 0;
+    // statsMax = 1;
+    // rasterInfo = createRasterInfo(TYPE_1BIT, noDataValue, statsMin, statsMax);
+    // noData = BitmaskToNoDataConverter.getInstance(rasterInfo, 1L);
+    // assertNotNull(noData);
+    // // make sure promotion from 1 to 8 bit is being taking place here and hence we got a 8-bit-u
+    // // no-data setter
+    // assertTrue(noData instanceof Unsigned8bitConverter);
+    // }
+    //
+    // @Test
+    // public void testGetInstance4Bit() {
+    // RasterDatasetInfo rasterInfo;
+    // BitmaskToNoDataConverter noData;
+    //
+    // int noDataValue;
+    // double statsMin;
+    // double statsMax;
+    //
+    // statsMin = TYPE_4BIT.getSampleValueRange().getMinimum();
+    // statsMax = TYPE_4BIT.getSampleValueRange().getMaximum();
+    // noDataValue = 0;
+    //
+    // rasterInfo = createRasterInfo(TYPE_4BIT, noDataValue, statsMin, statsMax);
+    // try {
+    // noData = BitmaskToNoDataConverter.getInstance(rasterInfo, 1L);
+    // fail("Expected UOE, noDataValue == 0 is non valid");
+    // } catch (UnsupportedOperationException e) {
+    // assertTrue(true);
+    // }
+    //
+    // noDataValue = (int) (statsMax + 1);
+    //
+    // rasterInfo = createRasterInfo(TYPE_4BIT, noDataValue, statsMin, statsMax);
+    // noData = BitmaskToNoDataConverter.getInstance(rasterInfo, 1L);
+    // assertNotNull(noData);
+    // // make sure promotion from 4 to 8 bit is being taking place here and hence we got a 8-bit-u
+    // // no-data setter
+    // assertTrue(noData instanceof Unsigned8bitConverter);
+    // }
+    //
+    // @Test
+    // public void testGetInstance16BitU() throws IOException {
+    // RasterDatasetInfo rasterInfo;
+    // BitmaskToNoDataConverter noData;
+    //
+    // final int noDataValue = (int) TYPE_16BIT_U.getSampleValueRange().getMaximum();
+    // double statsMin;
+    // double statsMax;
+    //
+    // statsMin = TYPE_16BIT_U.getSampleValueRange().getMinimum();
+    // statsMax = TYPE_16BIT_U.getSampleValueRange().getMaximum() - 1;
+    // rasterInfo = createRasterInfo(TYPE_16BIT_U, noDataValue, statsMin, statsMax);
+    // noData = BitmaskToNoDataConverter.getInstance(rasterInfo, 1L);
+    // assertNotNull(noData);
+    //
+    // final int samplesPerTile = rasterInfo.getTileDimension(0).width
+    // * rasterInfo.getTileDimension(0).height;
+    //
+    // final int dataValue = 5;
+    //
+    // byte[] tileData = new byte[TYPE_16BIT_U.getBitsPerSample() * samplesPerTile];
+    // noData.setAll(1L, tileData);
+    // DataInputStream in = new DataInputStream(new ByteArrayInputStream(tileData));
+    // for (int sampleN = 0; sampleN < samplesPerTile; sampleN++) {
+    // assertEquals(noDataValue, in.readUnsignedShort());
+    // }
+    //
+    // byte[] bitmaskData = new byte[(int) Math.ceil(samplesPerTile / 8D)];
+    // Arrays.fill(bitmaskData, (byte) 0xFF);
+    // // set the first 8 and last 8 samples to no-data
+    // bitmaskData[0] = 0x00;
+    // bitmaskData[bitmaskData.length - 1] = 0x00;
+    //
+    // byte[] expected;
+    // {
+    // ByteArrayOutputStream actualOut = new ByteArrayOutputStream();
+    // DataOutputStream actualWriter = new DataOutputStream(actualOut);
+    //
+    // ByteArrayOutputStream expectedOut = new ByteArrayOutputStream();
+    // DataOutputStream expectedWriter = new DataOutputStream(expectedOut);
+    // for (int i = 0; i < samplesPerTile; i++) {
+    // actualWriter.writeShort(dataValue);
+    //
+    // if (i < 8 || i >= samplesPerTile - 8) {
+    // expectedWriter.writeShort(noDataValue);
+    // } else {
+    // expectedWriter.writeShort(dataValue);
+    // }
+    // }
+    // tileData = actualOut.toByteArray();
+    // expected = expectedOut.toByteArray();
+    // }
+    //
+    // noData.setNoData(1L, tileData, bitmaskData);
+    // assertTrue("Arrays differ, expected:" + Arrays.toString(expected) + ", actual:"
+    // + Arrays.toString(tileData), Arrays.equals(expected, tileData));
+    //
+    // /*
+    // * set individual sample
+    // */
+    // final int bitsPerSample = TYPE_16BIT_U.getBitsPerSample();
+    // tileData = new byte[bitsPerSample * samplesPerTile];
+    //
+    // in = new DataInputStream(new ByteArrayInputStream(tileData));
+    // noData.setNoData(1L, 0, tileData);
+    // assertEquals(noDataValue, in.readUnsignedShort());
+    //
+    // in = new DataInputStream(new ByteArrayInputStream(tileData, 5 * (bitsPerSample / 8), 2));
+    // noData.setNoData(1L, 5, tileData);
+    // assertEquals(noDataValue, in.readUnsignedShort());
+    //
+    // in = new DataInputStream(new ByteArrayInputStream(tileData, (samplesPerTile - 1)
+    // * (bitsPerSample / 8), 2));
+    // noData.setNoData(1L, samplesPerTile - 1, tileData);
+    // assertEquals(noDataValue, in.readUnsignedShort());
+    // }
+    //
+    // private RasterDatasetInfo createRasterInfo(RasterCellType nativeType, Number noDataValue,
+    // double statsMin, double statsMax) {
+    //
+    // RasterDatasetInfo datasetInfo = new RasterDatasetInfo();
+    //
+    // List<RasterInfo> datasetRasters = new ArrayList<RasterInfo>();
+    // // fake a 3x8 pixel raster so it's a matrix of 24 elements and it matches a full bitmask
+    // // array (no unused bitmask bits)
+    // RasterInfo rasterInfo = new RasterInfo(1L, 3, 8);
+    // datasetRasters.add(rasterInfo);
+    //
+    // rasterInfo.addPyramidLevel(0, new ReferencedEnvelope(), new Point(), new Point(), 10, 10,
+    // new Dimension(100, 100));
+    // List<RasterBandInfo> bands = new ArrayList<RasterBandInfo>();
+    // RasterBandInfo bandInfo = new RasterBandInfo(1L, nativeType, noDataValue, statsMin,
+    // statsMax);
+    // bands.add(bandInfo);
+    //
+    // // bandInfo.bandId = 1L;
+    // // // the native type
+    // // bandInfo.cellType = nativeType;
+    // // // the target type will be determined based on the native type bounds and the band's
+    // // // statistics
+    // // bandInfo.noDataValue = noDataValue;
+    // // bandInfo.statsMin = statsMin;
+    // // bandInfo.statsMax = statsMax;
+    //
+    // rasterInfo.setBands(bands);
+    //
+    // datasetInfo.setPyramidInfo(datasetRasters);
+    //
+    // return datasetInfo;
+    // }
 
 }


------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
GeoTools-commits mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/geotools-commits