|
|
|
svn_geotools
|
Author: groldan
Date: 2009-11-02 00:59:38 -0500 (Mon, 02 Nov 2009) New Revision: 34302 Added: trunk/modules/plugin/arcsde/datastore/src/main/java/org/geotools/arcsde/gce/RasterInputStream.java Modified: trunk/modules/plugin/arcsde/datastore/src/main/java/org/geotools/arcsde/gce/ArcSDEGridCoverage2DReaderJAI.java trunk/modules/plugin/arcsde/datastore/src/main/java/org/geotools/arcsde/gce/ArcSDETiledImageInputStream.java trunk/modules/plugin/arcsde/datastore/src/main/java/org/geotools/arcsde/gce/DefaultTiledRasterReader.java trunk/modules/plugin/arcsde/datastore/src/main/java/org/geotools/arcsde/gce/NativeTileReader.java trunk/modules/plugin/arcsde/datastore/src/main/java/org/geotools/arcsde/gce/PromotingTileReader.java trunk/modules/plugin/arcsde/datastore/src/main/java/org/geotools/arcsde/gce/TileReader.java trunk/modules/plugin/arcsde/datastore/src/test/java/org/geotools/arcsde/gce/ArcSDEGridCoverage2DReaderJAILegacyOnlineTest.java Log: GEOS-3619, Tile data is fetch as a byte[] by SeRasterTile so no really need for copying to an intermediate buffer Modified: trunk/modules/plugin/arcsde/datastore/src/main/java/org/geotools/arcsde/gce/ArcSDEGridCoverage2DReaderJAI.java =================================================================== --- trunk/modules/plugin/arcsde/datastore/src/main/java/org/geotools/arcsde/gce/ArcSDEGridCoverage2DReaderJAI.java 2009-11-02 05:17:00 UTC (rev 34301) +++ trunk/modules/plugin/arcsde/datastore/src/main/java/org/geotools/arcsde/gce/ArcSDEGridCoverage2DReaderJAI.java 2009-11-02 05:59:38 UTC (rev 34302) @@ -19,7 +19,6 @@ import java.awt.Rectangle; import java.awt.RenderingHints; -import java.awt.geom.AffineTransform; import java.awt.image.BufferedImage; import java.awt.image.ColorModel; import java.awt.image.DataBuffer; @@ -45,8 +44,6 @@ import javax.media.jai.InterpolationNearest; import javax.media.jai.JAI; import javax.media.jai.ParameterBlockJAI; -import javax.media.jai.RenderedOp; -import javax.media.jai.operator.AffineDescriptor; import javax.media.jai.operator.FormatDescriptor; import javax.media.jai.operator.MosaicDescriptor; @@ -412,20 +409,6 @@ .getResultDimensionInsideTiledImage()); log.log(image, query.getRasterId(), "02_crop"); - // final Rectangle mosaicLocation = query.getMosaicLocation(); - // double sx = (float)mosaicLocation.getWidth() / image.getWidth(); - // double sy = (float)mosaicLocation.getHeight() / image.getHeight(); - // double tx = mosaicLocation.x - image.getMinX(); - // double ty = mosaicLocation.y - image.getMinY(); - // - // AffineTransform sc = AffineTransform.getScaleInstance(sx, sy); - // AffineTransform tr = AffineTransform.getTranslateInstance(tx, ty); - // sc.concatenate(tr); - // - // double[] bgvalues = null;//{255,255,255,255}; - // image = AffineDescriptor.create(image, sc, new InterpolationNearest(), bgvalues, - // hints); - final Rectangle mosaicLocation = query.getMosaicLocation(); // scale Float scaleX = Float.valueOf((float) (mosaicLocation.getWidth() / image.getWidth())); @@ -444,7 +427,7 @@ try { LOGGER.info("Forcing loading data for mosaic as per GEOT-"); - image.getData(); + image.getData(); } catch (RuntimeException e) { throw new DataSourceException("Error fetching arcsde raster", e); } @@ -517,13 +500,9 @@ final ImageLayout layout = new ImageLayout(mosaicGeometry.x, mosaicGeometry.y, mosaicGeometry.width, mosaicGeometry.height); - // tiling - // final Dimension tileDimensions = request.getTileDimensions(); - // if (tileDimensions != null) { - // layout.setTileHeight(tileDimensions.width).setTileWidth(tileDimensions.height); - // } + final RenderingHints hints = new RenderingHints(JAI.KEY_IMAGE_LAYOUT, layout); - hints.put(JAI.KEY_SERIALIZE_DEEP_COPY, Boolean.TRUE); + //hints.put(JAI.KEY_SERIALIZE_DEEP_COPY, Boolean.TRUE); for (RenderedImage img : transformed) { mosaicParams.addSource(img); @@ -539,6 +518,15 @@ return mosaic; } + /** + * Crops the image representing a full tile set to the required dimension and returns it, but + * keeps minx and miny being zero. + * + * @param fullTilesRaster + * @param tiledImageGridRagne + * @param cropTo + * @return + */ private RenderedImage cropToRequiredDimension(final RenderedImage fullTilesRaster, final Rectangle tiledImageGridRagne, final Rectangle cropTo) { Modified: trunk/modules/plugin/arcsde/datastore/src/main/java/org/geotools/arcsde/gce/ArcSDETiledImageInputStream.java =================================================================== --- trunk/modules/plugin/arcsde/datastore/src/main/java/org/geotools/arcsde/gce/ArcSDETiledImageInputStream.java 2009-11-02 05:17:00 UTC (rev 34301) +++ trunk/modules/plugin/arcsde/datastore/src/main/java/org/geotools/arcsde/gce/ArcSDETiledImageInputStream.java 2009-11-02 05:59:38 UTC (rev 34302) @@ -22,6 +22,8 @@ import javax.imageio.stream.ImageInputStream; import javax.imageio.stream.ImageInputStreamImpl; +import org.geotools.arcsde.gce.TileReader.TileInfo; + /** * An {@link ImageInputStream} that reads ArcSDE raster tiles in a band interleaved order. * @@ -38,7 +40,7 @@ private final int tileDataLength; - private final byte[] currTileData; + private byte[] currTileData; private int currTileDataIndex; @@ -117,7 +119,8 @@ currTileDataIndex = 0; ++currTileIndex; - tileReader.next(currTileData); + TileInfo tile = tileReader.next(); + currTileData = tile.getTileData(); } return currTileData; } @@ -128,49 +131,4 @@ super.close(); } - // @Override - public void _seek(final long newPos) throws IOException { - if (newPos == streamPos) { - //System.err.println("seek to currPos " + newPos + ". currPos = " + streamPos); - return; - } -// if (newPos < streamPos) { -// System.err.println("back seek to " + newPos + ". currPos = " + streamPos); -// }else{ -// System.err.println("Forward seek to " + newPos + ". currPos = " + streamPos); -// } - super.seek(newPos); -// if (newPos >= length) { -// //System.err.println("---> seek to " + newPos + " > length: " + length); -// return; -// } -// -// // force tile for newPos to be loaded -// //this.currTileDataIndex = tileDataLength; -// -// -// final long actualPos = ((long)tileDataLength * currTileIndex) + currTileDataIndex; -// if(newPos > actualPos){ -// System.err.println("---> seek to " + newPos + " > actualPos: " + actualPos); -// int delta = (int) (newPos - actualPos); -// int newDataIndex = currTileDataIndex + delta; -// while(newDataIndex > tileDataLength){ -// // force tile for newPos to be loaded -// this.currTileDataIndex = tileDataLength; -// getTileData(); -// newDataIndex -= tileDataLength; -// } -// this.currTileDataIndex = newDataIndex; -// } - } - - @Override - public boolean isCached() { - return true; - } - - @Override - public boolean isCachedMemory() { - return true; - } } \ No newline at end of file Modified: trunk/modules/plugin/arcsde/datastore/src/main/java/org/geotools/arcsde/gce/DefaultTiledRasterReader.java =================================================================== --- trunk/modules/plugin/arcsde/datastore/src/main/java/org/geotools/arcsde/gce/DefaultTiledRasterReader.java 2009-11-02 05:17:00 UTC (rev 34301) +++ trunk/modules/plugin/arcsde/datastore/src/main/java/org/geotools/arcsde/gce/DefaultTiledRasterReader.java 2009-11-02 05:59:38 UTC (rev 34302) @@ -29,12 +29,12 @@ import javax.imageio.ImageReadParam; import javax.imageio.ImageReader; import javax.imageio.ImageTypeSpecifier; +import javax.imageio.spi.ImageReaderSpi; import javax.imageio.stream.ImageInputStream; import javax.media.jai.ImageLayout; import javax.media.jai.JAI; import org.geotools.arcsde.session.ISessionPool; -import org.geotools.data.DataSourceException; import org.geotools.util.logging.Logging; import com.esri.sde.sdk.client.SeQuery; @@ -104,7 +104,7 @@ */ fullTilesRaster = createTiledRaster(tileReader, matchingTiles, rasterId); - + return fullTilesRaster; } @@ -132,20 +132,6 @@ sampleModel = fullImageSpec.getSampleModel(tiledImageWidth, tiledImageHeight); } - // Finally, build the image input stream - final ImageInputStream raw; - { - final long[] imageOffsets = new long[] { 0 }; - final Dimension[] imageDimensions = new Dimension[] { tiledImageSize }; - - final ImageTypeSpecifier its = new ImageTypeSpecifier(colorModel, sampleModel); - - final ImageInputStream tiledImageInputStream; - tiledImageInputStream = new ArcSDETiledImageInputStream(tileReader); - - raw = new RawImageInputStream(tiledImageInputStream, its, imageOffsets, imageDimensions); - } - final int tileWidth = tileReader.getTileWidth(); final int tileHeight = tileReader.getTileHeight(); @@ -169,10 +155,33 @@ sampleModel, colorModel); } + // Finally, build the image input stream + final ImageInputStream raw; + final ImageReader readerInstance; + { + final long[] imageOffsets = new long[] { 0 }; + final Dimension[] imageDimensions = new Dimension[] { tiledImageSize }; + + final ImageTypeSpecifier its = new ImageTypeSpecifier(colorModel, sampleModel); + + final ImageInputStream tiledImageInputStream; + tiledImageInputStream = new ArcSDETiledImageInputStream(tileReader); + raw = new RawImageInputStream(tiledImageInputStream, its, imageOffsets, imageDimensions); + ImageReaderSpi imageIOSPI = new RawImageReaderSpi(); + readerInstance = imageIOSPI.createReaderInstance(); + + // final ImageInputStream tiledImageInputStream; + // tiledImageInputStream = new MemoryCacheImageInputStream(new RasterInputStream( + // tileReader)); + // raw = new RawImageInputStream(tiledImageInputStream, its, imageOffsets, + // imageDimensions); + // ImageReaderSpi imageIOSPI = new RawImageReaderSpi(); + // readerInstance = imageIOSPI.createReaderInstance(); + } + // First operator: read the image final RenderingHints hints = new RenderingHints(JAI.KEY_IMAGE_LAYOUT, imageLayout); - hints.put(JAI.KEY_SERIALIZE_DEEP_COPY, Boolean.TRUE); - + ParameterBlock pb = new ParameterBlock(); pb.add(raw);// Input /* @@ -186,23 +195,20 @@ pb.add(null);// Locale final ImageReadParam rParam = new ImageReadParam(); pb.add(rParam);// ReadParam - RawImageReaderSpi imageIOSPI = new RawImageReaderSpi(); - ImageReader readerInstance = imageIOSPI.createReaderInstance(); - //readerInstance = new ArcSDEImageReader(imageIOSPI); pb.add(readerInstance);// Reader RenderedImage image = JAI.create("ImageRead", pb, hints); -// // translate -// int minX = (matchingTiles.x * tileWidth); -// int minY = (matchingTiles.y * tileHeight); -// pb = new ParameterBlock(); -// pb.addSource(image); -// pb.add(Float.valueOf(minX)); -// pb.add(Float.valueOf(minY)); -// pb.add(null); -// -// image = JAI.create("translate", pb); + // // translate + // int minX = (matchingTiles.x * tileWidth); + // int minY = (matchingTiles.y * tileHeight); + // pb = new ParameterBlock(); + // pb.addSource(image); + // pb.add(Float.valueOf(minX)); + // pb.add(Float.valueOf(minY)); + // pb.add(null); + // + // image = JAI.create("translate", pb); return image; } Modified: trunk/modules/plugin/arcsde/datastore/src/main/java/org/geotools/arcsde/gce/NativeTileReader.java =================================================================== --- trunk/modules/plugin/arcsde/datastore/src/main/java/org/geotools/arcsde/gce/NativeTileReader.java 2009-11-02 05:17:00 UTC (rev 34301) +++ trunk/modules/plugin/arcsde/datastore/src/main/java/org/geotools/arcsde/gce/NativeTileReader.java 2009-11-02 05:59:38 UTC (rev 34302) @@ -77,7 +77,7 @@ */ private SeQuery preparedQuery; - private SeRasterTile nextTile; + private TileInfo nextTile; private boolean started; @@ -94,20 +94,41 @@ /** * Command to fetch an {@link SeRasterTile tile} */ - private static class TileFetchCommand extends Command<SeRasterTile> { + private static class TileFetchCommand extends Command<TileInfo> { private final SeRow row; - public TileFetchCommand(final SeRow row) { + private final int tileDataLength; + + public TileFetchCommand(final SeRow row, final int tileDataLength) { this.row = row; + this.tileDataLength = tileDataLength; } @Override - public SeRasterTile execute(ISession session, SeConnection connection) throws SeException, + public TileInfo execute(ISession session, SeConnection connection) throws SeException, IOException { - return row.getRasterTile(); + SeRasterTile tile = row.getRasterTile(); + final TileInfo tileInfo; + if (tile == null) { + tileInfo = null; + } else { + byte[] bitMaskData = tile.getBitMaskData(); + int numPixelsRead = tile.getNumPixels(); + byte[] tileData; + if (numPixelsRead == 0) { + tileData = new byte[tileDataLength]; + } else { + tileData = tile.getPixelData(); + } + long bandId = tile.getBandId().longValue(); + int colIndex = tile.getColumnIndex(); + int rowIndex = tile.getRowIndex(); + tileInfo = new TileInfo(bandId, colIndex, rowIndex, numPixelsRead, tileData, + bitMaskData); + } + return tileInfo; } - } /** @@ -388,20 +409,15 @@ final SeRow row = queryCommand.getSeRow(); - this.tileFetchCommand = new TileFetchCommand(row); + this.tileFetchCommand = new TileFetchCommand(row, tileDataLength); this.preparedQuery = queryCommand.getPreparedQuery(); } /** - * @see org.geotools.arcsde.gce.TileReader#next(byte[]) + * @see org.geotools.arcsde.gce.TileReader#next() */ - public TileInfo next(byte[] tileData) throws IOException { - if (tileData == null) { - dispose(); - throw new IllegalArgumentException("tileData is null"); - } - - final SeRasterTile tile; + public TileInfo next() throws IOException { + final TileInfo tile; final boolean hasNext = hasNext(); if (hasNext) { tile = nextTile(); @@ -410,7 +426,7 @@ } try { - final byte[] bitMaskData = tile.getBitMaskData(); + final byte[] bitMaskData = tile.getBitmaskData(); if (LOGGER.isLoggable(Level.FINEST)) { LOGGER.finest(" >> Fetching " + tile + " - bitmask: " + bitMaskData.length); @@ -418,30 +434,20 @@ assert bitMaskData.length == 0 ? true : bitmaskDataLength == bitMaskData.length; - final int numPixels = tile.getNumPixels(); + final int numPixels = tile.getNumPixelsRead(); + final byte[] rawTileData = tile.getTileData(); - final Long bandId = Long.valueOf(tile.getBandId().longValue()); + final Long bandId = tile.getBandId(); if (0 == numPixels) { if (LOGGER.isLoggable(Level.FINER)) { LOGGER.finer("tile contains no pixel data, skipping: " + tile); } - noData.setAll(bandId, tileData); + noData.setAll(bandId, rawTileData); } else if (pixelsPerTile == numPixels) { - // try { - // tile.getPixels(tileData); - // } catch (Exception e) { - // e.printStackTrace(); - // throw new RuntimeException(e); - // } - - final byte[] rawTileData = tile.getPixelData(); - - System.arraycopy(rawTileData, 0, tileData, 0, tileDataLength); - if (bitMaskData.length > 0) { - noData.setNoData(bandId, tileData, bitMaskData); + noData.setNoData(bandId, rawTileData, bitMaskData); } if (LOGGER.isLoggable(Level.FINEST)) { @@ -454,7 +460,8 @@ + " but got " + numPixels + ": " + tile); } - return new TileInfo(bandId, bitMaskData, numPixels); + // return new TileInfo(bandId, bitMaskData, numPixels); + return tile; } catch (RuntimeException e) { dispose(); @@ -462,12 +469,12 @@ } } - private SeRasterTile nextTile() throws IOException { + private TileInfo nextTile() throws IOException { if (nextTile == null) { dispose(); throw new EOFException("No more tiles to read"); } - SeRasterTile curr = nextTile; + TileInfo curr = nextTile; try { nextTile = session.issue(tileFetchCommand); Modified: trunk/modules/plugin/arcsde/datastore/src/main/java/org/geotools/arcsde/gce/PromotingTileReader.java =================================================================== --- trunk/modules/plugin/arcsde/datastore/src/main/java/org/geotools/arcsde/gce/PromotingTileReader.java 2009-11-02 05:17:00 UTC (rev 34301) +++ trunk/modules/plugin/arcsde/datastore/src/main/java/org/geotools/arcsde/gce/PromotingTileReader.java 2009-11-02 05:59:38 UTC (rev 34302) @@ -48,15 +48,12 @@ private final BitmaskToNoDataConverter noData; - private final byte[] nativeTileData; - public PromotingTileReader(final TileReader nativeTileReader, final RasterCellType sourceType, final RasterCellType targetType, final BitmaskToNoDataConverter noData) { this.nativeReader = nativeTileReader; this.targetType = targetType; this.noData = noData; - this.nativeTileData = new byte[nativeTileReader.getBytesPerTile()]; this.promoter = SampleDepthPromoter.createFor(sourceType, targetType); LOGGER.fine("Using sample depth promoting tile reader, from " + sourceType + " to " + targetType); @@ -101,8 +98,10 @@ return nativeReader.hasNext(); } - public TileInfo next(byte[] tileData) throws IOException { - final TileInfo tileInfo = nativeReader.next(nativeTileData); + public TileInfo next() throws IOException { + final TileInfo tileInfo = nativeReader.next(); + final byte[] nativeTileData = tileInfo.getTileData(); + final byte[] tileData = new byte[getBytesPerTile()]; try { final byte[] bitmaskData = tileInfo.getBitmaskData(); final boolean hasNoDataPixels = bitmaskData.length > 0; @@ -128,7 +127,11 @@ dispose(); throw e; } - return tileInfo; + + TileInfo promotedTileInfo = new TileInfo(tileInfo.getBandId(), tileInfo.getColumnIndex(), + tileInfo.getRowIndex(), tileInfo.getNumPixelsRead(), tileData, tileInfo + .getBitmaskData()); + return promotedTileInfo; } /** @@ -157,7 +160,7 @@ } } - private static class UcharToUshort extends SampleDepthPromoter { + private static final class UcharToUshort extends SampleDepthPromoter { @Override public void promote(int sampleN, byte[] nativeTileData, byte[] tileData) { @@ -167,7 +170,7 @@ } } - private static class OneBitToUchar extends SampleDepthPromoter { + private static final class OneBitToUchar extends SampleDepthPromoter { @Override public void promote(int sampleN, byte[] nativeTileData, byte[] tileData) { @@ -179,7 +182,7 @@ } } - private static class ShortToInt extends SampleDepthPromoter { + private static final class ShortToInt extends SampleDepthPromoter { @Override public void promote(int sampleN, byte[] nativeTileData, byte[] tileData) { Added: trunk/modules/plugin/arcsde/datastore/src/main/java/org/geotools/arcsde/gce/RasterInputStream.java =================================================================== --- trunk/modules/plugin/arcsde/datastore/src/main/java/org/geotools/arcsde/gce/RasterInputStream.java (rev 0) +++ trunk/modules/plugin/arcsde/datastore/src/main/java/org/geotools/arcsde/gce/RasterInputStream.java 2009-11-02 05:59:38 UTC (rev 34302) @@ -0,0 +1,138 @@ +/* + * 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.gce; + +import java.io.IOException; +import java.io.InputStream; + +import javax.imageio.stream.ImageInputStream; + +import org.geotools.arcsde.gce.TileReader.TileInfo; + +/** + * 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 $ + */ +final class RasterInputStream extends InputStream { + + private final TileReader tileReader; + + private final int tileDataLength; + + private byte[] currTileData; + + private int currTileDataIndex; + + private final int length; + + public RasterInputStream(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; + } + + @Override + public int read() throws IOException { + final byte[] data = getTileData(); + if (data == null) { + return -1; + } + byte b = data[currTileDataIndex]; + ++currTileDataIndex; + return b; + } + + @Override + public int read(byte[] buff, int off, int len) throws IOException { + final byte[] data = getTileData(); + if (data == null) { + return -1; + } + final int available = data.length - currTileDataIndex; + final int count = Math.min(available, len); + System.arraycopy(data, currTileDataIndex, buff, off, count); + currTileDataIndex += 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; + TileInfo tileInfo = tileReader.next(); + currTileData = tileInfo.getTileData(); + } + return currTileData; + } + + @Override + public void close() throws IOException { + tileReader.dispose(); + } + + @Override + public int available() throws IOException { + return tileDataLength - currTileDataIndex; + } + + @Override + public synchronized void mark(int readlimit) { + System.err.println("mark at " + readlimit); + } + + @Override + public boolean markSupported() { + return false; + } + + @Override + public long skip(long n) throws IOException { + return super.skip(n); + } +} \ No newline at end of file Property changes on: trunk/modules/plugin/arcsde/datastore/src/main/java/org/geotools/arcsde/gce/RasterInputStream.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Id URL Added: svn:eol-style + native Modified: trunk/modules/plugin/arcsde/datastore/src/main/java/org/geotools/arcsde/gce/TileReader.java =================================================================== --- trunk/modules/plugin/arcsde/datastore/src/main/java/org/geotools/arcsde/gce/TileReader.java 2009-11-02 05:17:00 UTC (rev 34301) +++ trunk/modules/plugin/arcsde/datastore/src/main/java/org/geotools/arcsde/gce/TileReader.java 2009-11-02 05:59:38 UTC (rev 34302) @@ -32,16 +32,26 @@ interface TileReader { public class TileInfo { - private Long bandId; + private final long bandId; - private byte[] bitmaskData; + private final byte[] bitmaskData; - private int numPixelsRead; + private final int numPixelsRead; - public TileInfo(Long bandId, byte[] bitMaskData, int numPixelsRead) { + private final byte[] tileDta; + + private final int columnIndex; + + private final int rowIndex; + + public TileInfo(long bandId, int colIndex, int rowIndex, int numPixelsRead, + byte[] tileData, byte[] bitMaskData) { this.bandId = bandId; + this.columnIndex = colIndex; + this.rowIndex = rowIndex; + this.numPixelsRead = numPixelsRead; + this.tileDta = tileData; this.bitmaskData = bitMaskData; - this.numPixelsRead = numPixelsRead; } public Long getBandId() { @@ -55,6 +65,18 @@ public int getNumPixelsRead() { return numPixelsRead; } + + public byte[] getTileData() { + return tileDta; + } + + public int getColumnIndex() { + return columnIndex; + } + + public int getRowIndex() { + return rowIndex; + } } /** @@ -117,11 +139,11 @@ * @throws {@link IllegalArgumentException} if tileData is not null and its size is less than * {@link #getBytesPerTile()} */ - public abstract TileInfo next(byte[] tileData) throws IOException; + public abstract TileInfo next() throws IOException; /** * Disposes any resource being held by this TileReader, making the TileReader unusable and the - * behaviour of {@link #hasNext()} and {@link #next(byte[])} unpredictable + * behaviour of {@link #hasNext()} and {@link #next} unpredictable */ public abstract void dispose(); Modified: trunk/modules/plugin/arcsde/datastore/src/test/java/org/geotools/arcsde/gce/ArcSDEGridCoverage2DReaderJAILegacyOnlineTest.java =================================================================== --- trunk/modules/plugin/arcsde/datastore/src/test/java/org/geotools/arcsde/gce/ArcSDEGridCoverage2DReaderJAILegacyOnlineTest.java 2009-11-02 05:17:00 UTC (rev 34301) +++ trunk/modules/plugin/arcsde/datastore/src/test/java/org/geotools/arcsde/gce/ArcSDEGridCoverage2DReaderJAILegacyOnlineTest.java 2009-11-02 05:59:38 UTC (rev 34302) @@ -7,11 +7,7 @@ import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; -import java.awt.Graphics; -import java.awt.Graphics2D; import java.awt.Rectangle; -import java.awt.geom.AffineTransform; -import java.awt.image.BufferedImage; import java.awt.image.ColorModel; import java.awt.image.IndexColorModel; import java.awt.image.RenderedImage; @@ -50,6 +46,8 @@ import org.opengis.parameter.GeneralParameterValue; import org.opengis.referencing.crs.CoordinateReferenceSystem; +import com.vividsolutions.jts.util.Stopwatch; + /** * Tests over legacy data that should not be deleted * @@ -121,6 +119,18 @@ final AbstractGridCoverage2DReader reader = getReader(); assertNotNull("Couldn't obtain a reader for " + tableName, reader); + final int count = 10; + long time = 0; + //warm up + _testIMG_USGSQUAD_SGBASE(reader); + for (int i = 0; i < count; i++) { + time += _testIMG_USGSQUAD_SGBASE(reader); + } + System.err.println(count + " reads in " + time + "ms"); + } + + public long _testIMG_USGSQUAD_SGBASE(AbstractGridCoverage2DReader reader) throws Exception { + // http://localhost:8080/geoserver/wms?WIDTH=256&LAYERS=sde%3AIMG_USGSQUAD_SGBASE&STYLES=&SRS=EPSG%3A26986&HEIGHT=256&FORMAT=image%2Fjpeg&TILED=true&TILESORIGIN=169118.35%2C874964.388&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&EXCEPTIONS=application%2Fvnd.ogc.se_inimage&BBOX=239038.74625,916916.62575,253022.8255,930900.705 final GeneralEnvelope originalEnvelope = reader.getOriginalEnvelope(); @@ -131,20 +141,16 @@ GeneralEnvelope reqEnvelope = new GeneralEnvelope(originalEnvelope); reqEnvelope.setEnvelope(239038.74625, 916916.62575, 253022.8255, 930900.705); + Stopwatch sw = new Stopwatch(); + sw.start(); + final GridCoverage2D coverage = readCoverage(reader, reqWidth, reqHeight, reqEnvelope); assertNotNull("read coverage returned null", coverage); RenderedImage image = coverage.getRenderedImage(); writeToDisk(image, "testRead_" + tableName); - - BufferedImage bi = new BufferedImage(256, 256, BufferedImage.TYPE_4BYTE_ABGR); - Graphics2D g = bi.createGraphics(); - double sx = image.getWidth() / bi.getWidth(); - double sy = image.getHeight() / bi.getHeight(); - AffineTransform xform = AffineTransform.getScaleInstance(sx, sy); - g.drawRenderedImage(image, xform); - - writeToDisk(bi, "testRead_" + tableName + "_renderedToBI"); + sw.stop(); + return sw.getTime(); } @Test ------------------------------------------------------------------------------ Come build with us! The BlackBerry(R) Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9 - 12, 2009. Register now! http://p.sf.net/sfu/devconference _______________________________________________ GeoTools-commits mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/geotools-commits |
||||||||||||||||
| Free Embeddable Forum Powered by Nabble | Help |