org.deegree.coverage.raster.data.nio
Class PixelInterleavedRasterData

java.lang.Object
  extended by org.deegree.coverage.raster.data.nio.ByteBufferRasterData
      extended by org.deegree.coverage.raster.data.nio.PixelInterleavedRasterData
All Implemented Interfaces:
RasterData

public class PixelInterleavedRasterData
extends ByteBufferRasterData

This class implements a pixel-interleaved, ByteBuffer-based RasterData.

Version:
$Revision: 31644 $, $Date: 2011-08-24 22:27:43 +0200 (Wed, 24 Aug 2011) $
Author:
Oliver Tonnhofer, last edited by: $Author: mschneider $

Field Summary
 
Fields inherited from class org.deegree.coverage.raster.data.nio.ByteBufferRasterData
dataAccess, dataInfo, info, rasterHeight, rasterWidth
 
Fields inherited from interface org.deegree.coverage.raster.data.RasterData
TYPE_BYTE_RGB, TYPE_BYTE_RGBA
 
Constructor Summary
protected PixelInterleavedRasterData(DataView view, int rasterWidth, int rasterHeight, RasterReader reader, RasterDataInfo dataInfo, boolean init)
           
  PixelInterleavedRasterData(RasterRect sampleDomain, int rasterWidth, int rasterHeight, RasterDataInfo dataInfo)
          Creates a new PixelInterleavedRasterData with given size, number of bands and data type, backed with no data.
  PixelInterleavedRasterData(RasterRect sampleDomain, int rasterWidth, int rasterHeight, RasterReader reader, RasterDataInfo dataInfo)
          Creates a new PixelInterleavedRasterData with given size, number of bands and data type
 
Method Summary
protected  ByteBufferRasterData createCompatibleEmptyRasterData()
           
 PixelInterleavedRasterData createCompatibleRasterData(DataView view)
          Implementation should create a view of this raster data.
 RasterData createCompatibleWritableRasterData(RasterRect sampleDomain, BandType[] bands)
          Create a writable compatible raster with the height and width of the given sample domain.
 int getBandStride()
          Returns the byte offset to the next sample of the same pixel.
 Pair<ByteBuffer,RasterRect> getDataRect()
           
 int getLineStride()
          Returns the byte offset to the next row (same column, same sample)
 byte[] getPixel(int x, int y, byte[] result)
          Returns a pixel as byte array, regardless of the DataType. i.e. a FLOAT DataType results in a four byte array.
 int getPixelStride()
          Retruns the byte offset to the next pixel.
 boolean isOutside()
           
 boolean isWithinDataArea()
           
 void setPixel(int x, int y, byte[] result)
          Sets a pixel with data from a byte array, regardless of the DataType. i.e. a float sample must be packed as a four byte array.
 void setSubset(int dstX, int dstY, int width, int height, RasterData srcRaster, int srcX, int srcY)
          Sets the raster with values from sourceRaster.
 
Methods inherited from class org.deegree.coverage.raster.data.nio.ByteBufferRasterData
asReadOnly, calculatePos, calculatePos, calculateViewPos, calculateViewPos, checkBounds, checkBoundsEx, clampSize, createCompatibleRasterData, createCompatibleRasterData, createCompatibleRasterData, createCompatibleRasterData, createCompatibleRasterData, createRasterDataInfo, dispose, fillWithNoData, getBands, getByteBuffer, getBytebufferDomain, getBytePixel, getBytes, getByteSample, getColumns, getDataInfo, getDataType, getDoublePixel, getDoubles, getDoubleSample, getFloatPixel, getFloats, getFloatSample, getIntPixel, getInts, getIntSample, getNullPixel, getOriginalDataInfo, getOriginalHeight, getOriginalWidth, getReader, getRequiredBufferSize, getRows, getSample, getShortPixel, getShorts, getShortSample, getSubset, getSubset, getView, initByteBuffer, min, setByteBuffer, setBytePixel, setBytes, setByteSample, setDoublePixel, setDoubles, setDoubleSample, setFloatPixel, setFloats, setFloatSample, setIntPixel, setInts, setIntSample, setNoDataValue, setSample, setShortPixel, setShorts, setShortSample, setSubset, setSubset, setSubset, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PixelInterleavedRasterData

public PixelInterleavedRasterData(RasterRect sampleDomain,
                                  int rasterWidth,
                                  int rasterHeight,
                                  RasterDataInfo dataInfo)
Creates a new PixelInterleavedRasterData with given size, number of bands and data type, backed with no data.

Parameters:
sampleDomain - the raster rectangle defining the sample domain of this raster data.
rasterWidth - width of the underlying raster data.
rasterHeight - height of the underlying raster data.
dataInfo - containing information about the underlying raster.

PixelInterleavedRasterData

public PixelInterleavedRasterData(RasterRect sampleDomain,
                                  int rasterWidth,
                                  int rasterHeight,
                                  RasterReader reader,
                                  RasterDataInfo dataInfo)
Creates a new PixelInterleavedRasterData with given size, number of bands and data type

Parameters:
sampleDomain - the raster rectangle defining the sample domain of this raster data.
rasterWidth - width of the underlying raster data.
rasterHeight - height of the underlying raster data.
reader - to be used for reading the data, may be null
dataInfo - containing information about the underlying raster.

PixelInterleavedRasterData

protected PixelInterleavedRasterData(DataView view,
                                     int rasterWidth,
                                     int rasterHeight,
                                     RasterReader reader,
                                     RasterDataInfo dataInfo,
                                     boolean init)
Parameters:
view - the raster rectangle defining the sample domain of this raster data as well as the data info of the view.
rasterWidth - width of the underlying raster data.
rasterHeight - height of the underlying raster data.
reader - to be used for reading the data, may be null
dataInfo - containing information about the underlying raster.
init - true if a new buffer should be initialized
Method Detail

createCompatibleRasterData

public PixelInterleavedRasterData createCompatibleRasterData(DataView view)
Description copied from class: ByteBufferRasterData
Implementation should create a view of this raster data.

Specified by:
createCompatibleRasterData in class ByteBufferRasterData
Parameters:
view - the new view on this data
Returns:
a view or new raster data object, backed by a ByteBuffer

createCompatibleWritableRasterData

public RasterData createCompatibleWritableRasterData(RasterRect sampleDomain,
                                                     BandType[] bands)
Description copied from interface: RasterData
Create a writable compatible raster with the height and width of the given sample domain.

Parameters:
sampleDomain - the raster rectangle defining the sample domain of this raster data.
bands - indices to the requested bands if null all bands will be available.
Returns:
new empty raster

createCompatibleEmptyRasterData

protected ByteBufferRasterData createCompatibleEmptyRasterData()
Specified by:
createCompatibleEmptyRasterData in class ByteBufferRasterData
Returns:
ByteBufferRasterData with unset data

getBandStride

public final int getBandStride()
Description copied from class: ByteBufferRasterData
Returns the byte offset to the next sample of the same pixel.

Specified by:
getBandStride in class ByteBufferRasterData
Returns:
byte offset to sample in the next band (same pixel)

getLineStride

public final int getLineStride()
Description copied from class: ByteBufferRasterData
Returns the byte offset to the next row (same column, same sample)

Specified by:
getLineStride in class ByteBufferRasterData
Returns:
byte offset to next row (same column, same sample)

getPixelStride

public final int getPixelStride()
Description copied from class: ByteBufferRasterData
Retruns the byte offset to the next pixel.

Specified by:
getPixelStride in class ByteBufferRasterData
Returns:
byte offset to next pixel

getPixel

public byte[] getPixel(int x,
                       int y,
                       byte[] result)
Description copied from interface: RasterData
Returns a pixel as byte array, regardless of the DataType. i.e. a FLOAT DataType results in a four byte array.

Specified by:
getPixel in interface RasterData
Overrides:
getPixel in class ByteBufferRasterData
result - a byte array to put the values into or null
Returns:
the result array or a new array, if the result array is null

setPixel

public void setPixel(int x,
                     int y,
                     byte[] result)
Description copied from interface: RasterData
Sets a pixel with data from a byte array, regardless of the DataType. i.e. a float sample must be packed as a four byte array.

Specified by:
setPixel in interface RasterData
Overrides:
setPixel in class ByteBufferRasterData

setSubset

public void setSubset(int dstX,
                      int dstY,
                      int width,
                      int height,
                      RasterData srcRaster,
                      int srcX,
                      int srcY)
Description copied from interface: RasterData
Sets the raster with values from sourceRaster.

Specified by:
setSubset in interface RasterData
Overrides:
setSubset in class ByteBufferRasterData
Parameters:
dstX - insert position
dstY - insert position
width - width of the subset
height - height of the subset
srcRaster - data source to copy
srcX - x offset in the source raster
srcY - y offset in the source raster

isWithinDataArea

public boolean isWithinDataArea()
Returns:
true if the view lies totally within data range.

isOutside

public boolean isOutside()
Returns:
true if the view lies totally outside data range.

getDataRect

public Pair<ByteBuffer,RasterRect> getDataRect()
Returns:
the loaded buffer and the rectangle for which the buffer has data.


Copyright © 2011. All Rights Reserved.