svn - r34331 - in trunk/modules/plugin/arcsde/datastore/src/main/java/org/geotools/arcsde/raster: io jai

1 message Options
Embed this post
Permalink
svn_geotools

svn - r34331 - in trunk/modules/plugin/arcsde/datastore/src/main/java/org/geotools/arcsde/raster: io jai

Reply Threaded More More options
Print post
Permalink
Author: groldan
Date: 2009-11-04 16:59:17 -0500 (Wed, 04 Nov 2009)
New Revision: 34331

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/TileFetchCommand.java
   trunk/modules/plugin/arcsde/datastore/src/main/java/org/geotools/arcsde/raster/jai/ArcSDETiledRenderedImage.java
Log:
GEOT-2616, if SeRasterTile contains no pixels then pixelType == 0, so use a safe pixel type parameter

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-04 21:25:42 UTC (rev 34330)
+++ trunk/modules/plugin/arcsde/datastore/src/main/java/org/geotools/arcsde/raster/io/NativeTileReader.java 2009-11-04 21:59:17 UTC (rev 34331)
@@ -81,6 +81,8 @@
 
     private int bitsPerSample;
 
+    private final RasterCellType nativeCellType;
+
     /**
      * @see DefaultTiledRasterReader#nextRaster()
      */
@@ -187,7 +189,7 @@
 
         this.pixelsPerTile = tileSize.width * tileSize.height;
 
-        final RasterCellType nativeCellType = rasterInfo.getNativeCellType();
+        this.nativeCellType = rasterInfo.getNativeCellType();
         this.bitsPerSample = nativeCellType.getBitsPerSample();
         this.tileDataLength = (int) Math
                 .ceil(((double) pixelsPerTile * (double) bitsPerSample) / 8D);
@@ -343,7 +345,7 @@
         final int numberOfBands = getNumberOfBands();
         final SeQuery preparedQuery = queryCommand.getPreparedQuery();
         TileFetchCommand fetchCommand = new TileFetchCommand(preparedQuery, row, pixelsPerTile,
-                numberOfBands);
+                numberOfBands, nativeCellType);
         return fetchCommand;
     }
 

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-04 21:25:42 UTC (rev 34330)
+++ trunk/modules/plugin/arcsde/datastore/src/main/java/org/geotools/arcsde/raster/io/TileFetchCommand.java 2009-11-04 21:59:17 UTC (rev 34331)
@@ -1,16 +1,21 @@
 package org.geotools.arcsde.raster.io;
 
+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_S;
+import static org.geotools.arcsde.raster.info.RasterCellType.TYPE_8BIT_U;
+
 import java.io.IOException;
 import java.util.HashMap;
 import java.util.Map;
 
+import org.geotools.arcsde.raster.info.RasterCellType;
 import org.geotools.arcsde.session.Command;
 import org.geotools.arcsde.session.ISession;
 
 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.SeRaster;
 import com.esri.sde.sdk.client.SeRasterTile;
 import com.esri.sde.sdk.client.SeRow;
 
@@ -33,14 +38,18 @@
 
     private final int numberOfBands;
 
-    private TileDataFetcher dataFetcher;
+    private final TileDataFetcher dataFetcher;
 
+    private final RasterCellType nativeType;
+
     public TileFetchCommand(final SeQuery preparedQuery, final SeRow row, final int pixelsPerTile,
-            final int numberOfBands) {
+            final int numberOfBands, final RasterCellType nativeType) {
         this.preparedQuery = preparedQuery;
         this.row = row;
         this.pixelsPerTile = pixelsPerTile;
         this.numberOfBands = numberOfBands;
+        this.nativeType = nativeType;
+        this.dataFetcher = getTileDataFetcher(nativeType);
     }
 
     public SeQuery getQuery() {
@@ -68,11 +77,6 @@
 
             TileInfo tileInfo = new TileInfo(bandId, colIndex, rowIndex, numPixelsRead, bitMaskData);
 
-            if (dataFetcher == null) {
-                final int sePixelType = tile.getPixelType();
-                dataFetcher = getTileDataFetcher(sePixelType);
-            }
-
             dataFetcher.setTileData(pixelsPerTile, tile, tileInfo);
 
             tilesPerBand[bandN] = tileInfo;
@@ -80,22 +84,22 @@
         return tilesPerBand;
     }
 
-    private static Map<Integer, TileDataFetcher> tileDataSetters = new HashMap<Integer, TileDataFetcher>();
+    private static Map<RasterCellType, TileDataFetcher> tileDataSetters = new HashMap<RasterCellType, TileDataFetcher>();
     static {
         {
             ByteTileSetter byteTileSetter = new ByteTileSetter();
-            tileDataSetters.put(SeRaster.SE_PIXEL_TYPE_1BIT, byteTileSetter);
-            tileDataSetters.put(SeRaster.SE_PIXEL_TYPE_4BIT, byteTileSetter);
-            tileDataSetters.put(SeRaster.SE_PIXEL_TYPE_8BIT_S, byteTileSetter);
-            tileDataSetters.put(SeRaster.SE_PIXEL_TYPE_8BIT_U, byteTileSetter);
+            tileDataSetters.put(TYPE_1BIT, byteTileSetter);
+            tileDataSetters.put(TYPE_4BIT, byteTileSetter);
+            tileDataSetters.put(TYPE_8BIT_S, byteTileSetter);
+            tileDataSetters.put(TYPE_8BIT_U, byteTileSetter);
         }
     }
 
-    private TileDataFetcher getTileDataFetcher(final int sePixelType) {
-        TileDataFetcher tileDataFetcher = tileDataSetters.get(Integer.valueOf(sePixelType));
+    private TileDataFetcher getTileDataFetcher(final RasterCellType pixelType) {
+        TileDataFetcher tileDataFetcher = tileDataSetters.get(pixelType);
         if (tileDataFetcher == null) {
             throw new IllegalArgumentException("No registered TileDataFetcher for pixel type "
-                    + sePixelType);
+                    + pixelType);
         }
         return tileDataFetcher;
     }

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-04 21:25:42 UTC (rev 34330)
+++ trunk/modules/plugin/arcsde/datastore/src/main/java/org/geotools/arcsde/raster/jai/ArcSDETiledRenderedImage.java 2009-11-04 21:59:17 UTC (rev 34331)
@@ -63,6 +63,7 @@
         try {
             tileInfo = tileReader.getTile(tileX, tileY);
         } catch (IOException e) {
+            e.printStackTrace();
             throw new RuntimeException(e);
         }
 


------------------------------------------------------------------------------
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