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

1 message Options
Embed this post
Permalink
svn_geotools

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

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

Modified:
   trunk/modules/plugin/arcsde/datastore/src/main/java/org/geotools/arcsde/raster/io/BitmaskToNoDataConverter.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/test/java/org/geotools/arcsde/raster/gce/ArcSDEGridCoverage2DReaderJAILegacyOnlineTest.java
Log:
GEOT-2616, fix setting no data values

Modified: trunk/modules/plugin/arcsde/datastore/src/main/java/org/geotools/arcsde/raster/io/BitmaskToNoDataConverter.java
===================================================================
--- trunk/modules/plugin/arcsde/datastore/src/main/java/org/geotools/arcsde/raster/io/BitmaskToNoDataConverter.java 2009-11-04 21:59:17 UTC (rev 34331)
+++ trunk/modules/plugin/arcsde/datastore/src/main/java/org/geotools/arcsde/raster/io/BitmaskToNoDataConverter.java 2009-11-04 22:32:45 UTC (rev 34332)
@@ -168,7 +168,7 @@
     /**
      * Returns whether the sample N in the bitmask byte array is marked as a no-data pixel
      */
-    public final boolean isNoData(int sampleN, byte[] bitmaskData) {
+    protected final boolean isNoData(int sampleN, byte[] bitmaskData) {
         boolean isNoData = ((bitmaskData[sampleN / 8] >> (7 - (sampleN % 8))) & 0x01) == 0x00;
         return isNoData;
     }
@@ -177,11 +177,21 @@
      * Sets all the samples of {@code tileData} marked as no-data pixel in {@code bitmaskData} to
      * the no-data value for band {@code bandId}
      */
-    public void setNoData(final TileInfo tileData) {
-        final byte[] bitmaskData = tileData.getBitmaskData();
-        for (int sampleN = 0; sampleN < pixelsPerTile; sampleN++) {
-            if (isNoData(sampleN, bitmaskData)) {
-                setNoData(sampleN, tileData);
+    public void setNoData(final TileInfo tileInfo) {
+        final byte[] bitmaskData = tileInfo.getBitmaskData();
+        final int numPixelsRead = tileInfo.getNumPixelsRead();
+        final boolean hasNoDataPixels = bitmaskData.length > 0;
+
+        if (numPixelsRead == 0) {
+            setAll(tileInfo);
+        } else if (hasNoDataPixels) {
+            final int numSamples = tileInfo.getNumPixels();
+            assert numPixelsRead == numSamples;
+
+            for (int sampleN = 0; sampleN < numSamples; sampleN++) {
+                if (isNoData(sampleN, bitmaskData)) {
+                    setNoData(sampleN, tileInfo);
+                }
             }
         }
     }
@@ -193,7 +203,7 @@
      * number of samples in a tile. Subclasses may override to optimize.
      * </p>
      */
-    public void setAll(final TileInfo tile) {
+    protected void setAll(final TileInfo tile) {
         for (int sampleN = 0; sampleN < pixelsPerTile; sampleN++) {
             setNoData(sampleN, tile);
         }
@@ -202,7 +212,7 @@
     /**
      * Sets the sample N for the band {@code bandId} on {@code tileData} to the no-data value
      */
-    public void setNoData(final int sampleN, final TileInfo tileData) {
+    protected void setNoData(final int sampleN, final TileInfo tileData) {
         final Long bandId = tileData.getBandId();
         // byte[] noData = byBandIdNoDataValues.get(bandId);
         Number noData = byBandIdNoDataValues.get(bandId);

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:59:17 UTC (rev 34331)
+++ trunk/modules/plugin/arcsde/datastore/src/main/java/org/geotools/arcsde/raster/io/NativeTileReader.java 2009-11-04 22:32:45 UTC (rev 34332)
@@ -360,36 +360,7 @@
             final int numberOfBands = getNumberOfBands();
             for (int bandN = 0; bandN < numberOfBands; bandN++) {
                 final TileInfo tile = bandTiles[bandN];
-                final byte[] bitMaskData = tile.getBitmaskData();
-
-                if (LOGGER.isLoggable(Level.FINEST)) {
-                    LOGGER.finest(" >> Fetching " + tile + " - bitmask: " + bitMaskData.length);
-                }
-
-                assert bitMaskData.length == 0 ? true : bitmaskDataLength == bitMaskData.length;
-
-                final int numPixels = tile.getNumPixelsRead();
-
-                if (0 == numPixels) {
-                    if (LOGGER.isLoggable(Level.FINER)) {
-                        LOGGER.finer("tile contains no pixel data, skipping: " + tile);
-                    }
-                    noData.setAll(tile);
-                } else if (pixelsPerTile == numPixels) {
-
-                    if (bitMaskData.length > 0) {
-                        noData.setNoData(tile);
-                    }
-
-                    if (LOGGER.isLoggable(Level.FINEST)) {
-                        LOGGER.finest("returning " + numPixels + " pixels data packaged into "
-                                + tileDataLength + " bytes for tile [" + tile.getColumnIndex()
-                                + "," + tile.getRowIndex() + "]");
-                    }
-                } else {
-                    throw new IllegalStateException("Expected pixels per tile == " + pixelsPerTile
-                            + " but got " + numPixels + ": " + tile);
-                }
+                noData.setNoData(tile);
             }
 
         } catch (RuntimeException e) {

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-04 21:59:17 UTC (rev 34331)
+++ trunk/modules/plugin/arcsde/datastore/src/main/java/org/geotools/arcsde/raster/io/PromotingTileReader.java 2009-11-04 22:32:45 UTC (rev 34332)
@@ -107,8 +107,12 @@
 
             for (int bandN = 0; bandN < numberOfBands; bandN++) {
                 TileInfo nativeData = nativeBandInfo[bandN];
+
                 TileInfo promotedData = promoter.promote(nativeData);
-                setNoData(promotedData);
+
+                nativeBandInfo[bandN] = null;// release early release often...
+
+                noData.setNoData(promotedData);
                 promotedBandInfo[bandN] = promotedData;
             }
         } catch (IOException e) {
@@ -154,27 +158,6 @@
         // return promotedTileInfo;
     }
 
-    private void setNoData(TileInfo tileInfo) {
-        final byte[] bitmaskData = tileInfo.getBitmaskData();
-        final boolean hasNoDataPixels = bitmaskData.length > 0;
-
-        if (hasNoDataPixels) {
-            final int numPixelsRead = tileInfo.getNumPixelsRead();
-            if (numPixelsRead == 0) {
-                noData.setAll(tileInfo);
-            } else {
-                final int numSamples = getPixelsPerTile();
-                assert numPixelsRead == numSamples;
-
-                for (int sampleN = 0; sampleN < numSamples; sampleN++) {
-                    if (noData.isNoData(sampleN, bitmaskData)) {
-                        noData.setNoData(sampleN, tileInfo);
-                    }
-                }
-            }
-        }
-    }
-
     /**
      *
      * @author Gabriel Roldan
@@ -216,8 +199,8 @@
             short[] promotedPixels = nativeData.getTileDataAsUnsignedShorts();
 
             TileInfo promotedTileInfo = new TileInfo(nativeData.getBandId(), nativeData
-                    .getColumnIndex(), nativeData.getRowIndex(), nativeData.getNumPixelsRead(),
-                    nativeData.getBitmaskData());
+                    .getColumnIndex(), nativeData.getRowIndex(), nativeData.getNumPixels(),
+                    nativeData.getNumPixelsRead(), nativeData.getBitmaskData());
 
             promotedTileInfo.setTileData(promotedPixels);
 
@@ -261,8 +244,8 @@
             int[] promotedPixels = nativeData.getTileDataAsIntegers();
 
             TileInfo promotedTileInfo = new TileInfo(nativeData.getBandId(), nativeData
-                    .getColumnIndex(), nativeData.getRowIndex(), nativeData.getNumPixelsRead(),
-                    nativeData.getBitmaskData());
+                    .getColumnIndex(), nativeData.getRowIndex(), nativeData.getNumPixels(),
+                    nativeData.getNumPixelsRead(), nativeData.getBitmaskData());
 
             promotedTileInfo.setTileData(promotedPixels);
 

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:59:17 UTC (rev 34331)
+++ trunk/modules/plugin/arcsde/datastore/src/main/java/org/geotools/arcsde/raster/io/TileFetchCommand.java 2009-11-04 22:32:45 UTC (rev 34332)
@@ -75,7 +75,8 @@
             int colIndex = tile.getColumnIndex();
             int rowIndex = tile.getRowIndex();
 
-            TileInfo tileInfo = new TileInfo(bandId, colIndex, rowIndex, numPixelsRead, bitMaskData);
+            TileInfo tileInfo = new TileInfo(bandId, colIndex, rowIndex, pixelsPerTile,
+                    numPixelsRead, bitMaskData);
 
             dataFetcher.setTileData(pixelsPerTile, tile, tileInfo);
 

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-04 21:59:17 UTC (rev 34331)
+++ trunk/modules/plugin/arcsde/datastore/src/main/java/org/geotools/arcsde/raster/io/TileInfo.java 2009-11-04 22:32:45 UTC (rev 34332)
@@ -26,10 +26,14 @@
 
     private double[] tileDataDoubles;
 
-    public TileInfo(long bandId, int colIndex, int rowIndex, int numPixelsRead, byte[] bitMaskData) {
+    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;
     }
@@ -42,6 +46,17 @@
         return bitmaskData;
     }
 
+    /**
+     * @return number of pixels in the tile data
+     */
+    public int getNumPixels() {
+        return numPixels;
+    }
+
+    /**
+     * @return number of pixels actually read. It shall be either {@code 0} or equal to
+     *         {@link #getNumPixels()}
+     */
     public int getNumPixelsRead() {
         return numPixelsRead;
     }

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-04 21:59:17 UTC (rev 34331)
+++ trunk/modules/plugin/arcsde/datastore/src/test/java/org/geotools/arcsde/raster/gce/ArcSDEGridCoverage2DReaderJAILegacyOnlineTest.java 2009-11-04 22:32:45 UTC (rev 34332)
@@ -120,7 +120,7 @@
         final AbstractGridCoverage2DReader reader = getReader();
         assertNotNull("Couldn't obtain a reader for " + tableName, reader);
 
-        final int count = 10;
+        final int count = 0;
         long time = 0;
         // warm up
         _testIMG_USGSQUAD_SGBASE(reader);
@@ -205,16 +205,16 @@
     @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
         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(253178.45971681, 872419.13604732, 253521.78247071,
-                872562.18719478);
+        requestEnvelope.setEnvelope(290557.15234375,932233.3984375,325347.19140625,946881.8359375);
 
-        final int reqWidth = 1200;
-        final int reqHeight = 500;
+        final int reqWidth = 950;
+        final int reqHeight = 400;
 
         final GridCoverage2D coverage = readCoverage(reader, reqWidth, reqHeight, requestEnvelope);
         assertNotNull("read coverage returned null", coverage);


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