org.deegree.coverage.raster.data
Interface RasterData

All Known Implementing Classes:
BandInterleavedRasterData, ByteBufferRasterData, LineInterleavedRasterData, PixelInterleavedRasterData, TiledRasterData

public interface RasterData

Interface for a 2 dimensional raster.

A raster is a rectangular grid of pixels with coordinates from the uppler left corner (0, 0) to the lower right corner (width-1, height-1). A raster can contain multiple bands. A pixel stores one sample for every band. The sample arrangement is determined by the interleaving type (InterleaveType). The size of each sample is dertermined by the data type (DataType).

Most get-methods accept an array as a parameter for performance reasons. This parameter is used to store the result. The same array will be returned by the method, filled with requested values. A new array will be created, filled and returned if this parameter is null.

TODO: Only defines interface to byte, short and float data at the moment. Copy float methods for other data types.

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

Field Summary
static int TYPE_BYTE_RGB
          Integer defining the RGB byte bands
static int TYPE_BYTE_RGBA
          Integer defining the RGBA byte bands with.
 
Method Summary
 RasterData asReadOnly()
          Return a read-only version of this RasterData.
 RasterData createCompatibleRasterData()
          Returns a new RasterData with the same size, bands, DataType and InterleaveType
 RasterData createCompatibleRasterData(BandType[] bands)
          Returns a new RasterData with the same size, DataType and InterleaveType
 RasterData createCompatibleRasterData(int width, int height)
          Returns a new RasterData with the same DataType and InterleaveType and all bands
 ByteBufferRasterData createCompatibleRasterData(RasterRect sampleDomain)
          Returns a view as a new RasterData with the same DataType and InterleaveType but valid only for the given rect.
 RasterData createCompatibleRasterData(RasterRect sampleDomain, BandType[] bands)
          Returns a new RasterData with the same DataType and InterleaveType
 RasterData createCompatibleWritableRasterData(RasterRect sampleDomain, BandType[] bands)
          Create a writable compatible raster with the height and width of the given sample domain.
 void dispose()
          Try to dispose all allocated memory of this data object.
 int getBands()
          Returns the number of bands of the raster
 byte[] getBytePixel(int x, int y, byte[] result)
          Returns a byte array with all sample values from coordinate x/y.
 byte[] getBytes(int x, int y, int width, int height, int band, byte[] result)
          Gets values from the specified rectangle and band.
 byte getByteSample(int x, int y, int band)
          Returns a byte sample from coordinate x/y and selected band.
 int getColumns()
          Returns the width of the raster
 RasterDataInfo getDataInfo()
          Returns an encapsulation of all available information of this raster data.
 DataType getDataType()
          Returns the data type of the raster.
 double[] getDoublePixel(int x, int y, double[] result)
          Returns a double array with all sample values from coordinate x/y.
 double[] getDoubles(int x, int y, int width, int height, int band, double[] result)
          Gets values from the specified rectangle and band.
 double getDoubleSample(int x, int y, int band)
          Returns a double sample from coordinate x/y and selected band.
 float[] getFloatPixel(int x, int y, float[] result)
          Returns a float array with all sample values from coordinate x/y.
 float[] getFloats(int x, int y, int width, int height, int band, float[] result)
          Gets values from the specified rectangle and band.
 float getFloatSample(int x, int y, int band)
          Returns a float sample from coordinate x/y and selected band.
 int[] getIntPixel(int x, int y, int[] result)
          Returns an integer array with all sample values from coordinate x/y.
 int[] getInts(int x, int y, int width, int height, int band, int[] result)
          Gets values from the specified rectangle and band.
 int getIntSample(int x, int y, int band)
          Returns an integer sample from coordinate x/y and selected band.
 byte[] getNullPixel(byte[] result)
          Returns the no data values for this raster, or the view of this rasters bands.
 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 getRows()
          Returns the height of the raster
 byte[] getSample(int x, int y, int band, byte[] result)
          Returns a sample as byte array, regardless of the DataType. i.e. a FLOAT DataType results in a four byte array
 short[] getShortPixel(int x, int y, short[] result)
          Returns a short array with all sample values from coordinate x/y.
 short[] getShorts(int x, int y, int width, int height, int band, short[] result)
          Gets values from the specified rectangle and band.
 short getShortSample(int x, int y, int band)
          Returns a short sample from coordinate x/y and selected band.
 RasterData getSubset(RasterRect rasterRect)
          Returns new RasterData object for the specified rectangle.
 RasterData getSubset(RasterRect rasterRect, BandType[] bands)
          Returns new single-band RasterData object for the specified rectangle.
 void setBytePixel(int x, int y, byte[] pixel)
          Sets a single pixel with byte values for each sample.
 void setBytes(int x, int y, int width, int height, int band, byte[] values)
          Sets values from the array to the specified rectangle and band.
 void setByteSample(int x, int y, int band, byte value)
          Sets a single byte sample on coordinate x/y and selected band.
 void setDoublePixel(int x, int y, double[] pixel)
          Sets a single pixel with double values for each sample.
 void setDoubles(int x, int y, int width, int height, int band, double[] values)
          Sets values from the array to the specified rectangle and band.
 void setDoubleSample(int x, int y, int band, double value)
          Sets a single double sample on coordinate x/y and selected band.
 void setFloatPixel(int x, int y, float[] pixel)
          Sets a single pixel with float values for each sample.
 void setFloats(int x, int y, int width, int height, int band, float[] values)
          Sets values from the array to the specified rectangle and band.
 void setFloatSample(int x, int y, int band, float value)
          Sets a single float sample on coordinate x/y and selected band.
 void setIntPixel(int x, int y, int[] pixel)
          Sets a single pixel with integer values for each sample.
 void setInts(int x, int y, int width, int height, int band, int[] values)
          Sets values from the array to the specified rectangle and band.
 void setIntSample(int x, int y, int band, int value)
          Sets a single integer sample on coordinate x/y and selected band.
 void setNoDataValue(byte[] values)
          Sets the no data values for this raster
 void setPixel(int x, int y, byte[] pixel)
          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 setSample(int x, int y, int band, byte[] values)
          Sets a sample with data from a byte array, regardless of the DataType. i.e. a float must be packed as a four byte array
 void setShortPixel(int x, int y, short[] pixel)
          Sets a single pixel with short values for each sample.
 void setShorts(int x, int y, int width, int height, int band, short[] values)
          Sets values from the array to the specified rectangle and band.
 void setShortSample(int x, int y, int band, short value)
          Sets a single short sample on coordinate x/y and selected band.
 void setSubset(int x, int y, int width, int height, int dstBand, RasterData sourceRaster, int srcBand)
          Sets a single band of the raster with values from one band of the sourceRaster.
 void setSubset(int x, int y, int width, int height, int dstBand, RasterData sourceRaster, int srcBand, int xOffset, int yOffset)
          Sets a single band of the raster with values from one band of the sourceRaster.
 void setSubset(int x, int y, int width, int height, RasterData sourceRaster)
          Sets the raster with values from sourceRaster.
 void setSubset(int x, int y, int width, int height, RasterData sourceRaster, int xOffset, int yOffset)
          Sets the raster with values from sourceRaster.
 

Field Detail

TYPE_BYTE_RGB

static final int TYPE_BYTE_RGB
Integer defining the RGB byte bands

See Also:
Constant Field Values

TYPE_BYTE_RGBA

static final int TYPE_BYTE_RGBA
Integer defining the RGBA byte bands with.

See Also:
Constant Field Values
Method Detail

getDataType

DataType getDataType()
Returns the data type of the raster.

Returns:
data type of the raster

getBands

int getBands()
Returns the number of bands of the raster

Returns:
the bands

getDataInfo

RasterDataInfo getDataInfo()
Returns an encapsulation of all available information of this raster data.

Returns:
available information of this raster data.

getRows

int getRows()
Returns the height of the raster

Returns:
the height

getColumns

int getColumns()
Returns the width of the raster

Returns:
the width

getNullPixel

byte[] getNullPixel(byte[] result)
Returns the no data values for this raster, or the view of this rasters bands.

Parameters:
result - an array to put the values into or null
Returns:
the result array or a new array, if the result array is null

setNoDataValue

void setNoDataValue(byte[] values)
Sets the no data values for this raster

Parameters:
values - an array with the null values

createCompatibleRasterData

RasterData createCompatibleRasterData(RasterRect sampleDomain,
                                      BandType[] bands)
Returns a new RasterData with the same DataType and InterleaveType

Parameters:
sampleDomain - the raster rectangle defining the sample domain of this raster data.
bands - indices to the requested bands
Returns:
new empty raster

createCompatibleWritableRasterData

RasterData createCompatibleWritableRasterData(RasterRect sampleDomain,
                                              BandType[] bands)
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

createCompatibleRasterData

ByteBufferRasterData createCompatibleRasterData(RasterRect sampleDomain)
Returns a view as a new RasterData with the same DataType and InterleaveType but valid only for the given rect.

Parameters:
sampleDomain - the raster rectangle defining the sample domain of this raster data.
Returns:
new raster backed by the readonly data of original raster.

createCompatibleRasterData

RasterData createCompatibleRasterData(int width,
                                      int height)
Returns a new RasterData with the same DataType and InterleaveType and all bands

Parameters:
width - width of the new raster
height - height of the new raster
Returns:
new empty raster

createCompatibleRasterData

RasterData createCompatibleRasterData(BandType[] bands)
Returns a new RasterData with the same size, DataType and InterleaveType

Parameters:
bands - definitions of the new rasterdata.
Returns:
new empty raster

createCompatibleRasterData

RasterData createCompatibleRasterData()
Returns a new RasterData with the same size, bands, DataType and InterleaveType

Returns:
new empty raster

asReadOnly

RasterData asReadOnly()
Return a read-only version of this RasterData. The result shares the same data as the original.

Returns:
a read-only RasterData

getSample

byte[] getSample(int x,
                 int y,
                 int band,
                 byte[] result)
Returns a sample as byte array, regardless of the DataType. i.e. a FLOAT DataType results in a four byte array

Parameters:
x -
y -
band - selected band
result - an array to put the values into or null
Returns:
the result array or a new array, if the result array is null

setSample

void setSample(int x,
               int y,
               int band,
               byte[] values)
Sets a sample with data from a byte array, regardless of the DataType. i.e. a float must be packed as a four byte array

Parameters:
x -
y -
band - selected band
values - array with the sample value

getPixel

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.

Parameters:
x -
y -
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

void setPixel(int x,
              int y,
              byte[] pixel)
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.

Parameters:
x -
y -
pixel -

getBytePixel

byte[] getBytePixel(int x,
                    int y,
                    byte[] result)
Returns a byte array with all sample values from coordinate x/y. The length of the array is equal to the number of bands.

Parameters:
x -
y -
result - an array to put the values into or null
Returns:
the result array or a new array, if the result array is null

getDoublePixel

double[] getDoublePixel(int x,
                        int y,
                        double[] result)
Returns a double array with all sample values from coordinate x/y. The length of the array is equal to the number of bands.

Parameters:
x -
y -
result - an array to put the values into or null
Returns:
the result array or a new array, if the result array is null

getFloatPixel

float[] getFloatPixel(int x,
                      int y,
                      float[] result)
Returns a float array with all sample values from coordinate x/y. The length of the array is equal to the number of bands.

Parameters:
x -
y -
result - an array to put the values into or null
Returns:
the result array or a new array, if the result array is null

getIntPixel

int[] getIntPixel(int x,
                  int y,
                  int[] result)
Returns an integer array with all sample values from coordinate x/y. The length of the array is equal to the number of bands.

Parameters:
x -
y -
result - an array to put the values into or null
Returns:
the result array or a new array, if the result array is null

getShortPixel

short[] getShortPixel(int x,
                      int y,
                      short[] result)
Returns a short array with all sample values from coordinate x/y. The length of the array is equal to the number of bands.

Parameters:
x -
y -
result - an array to put the values into or null
Returns:
the result array or a new array, if the result array is null

setBytePixel

void setBytePixel(int x,
                  int y,
                  byte[] pixel)
Sets a single pixel with byte values for each sample. The length of pixel array must be equal to the number of bands.

Parameters:
x -
y -
pixel - array with one sample per band

setDoublePixel

void setDoublePixel(int x,
                    int y,
                    double[] pixel)
Sets a single pixel with double values for each sample. The length of pixel array must be equal to the number of bands.

Parameters:
x -
y -
pixel - array with one sample per band

setFloatPixel

void setFloatPixel(int x,
                   int y,
                   float[] pixel)
Sets a single pixel with float values for each sample. The length of pixel array must be equal to the number of bands.

Parameters:
x -
y -
pixel - array with one sample per band

setIntPixel

void setIntPixel(int x,
                 int y,
                 int[] pixel)
Sets a single pixel with integer values for each sample. The length of pixel array must be equal to the number of bands.

Parameters:
x -
y -
pixel - array with one sample per band

setShortPixel

void setShortPixel(int x,
                   int y,
                   short[] pixel)
Sets a single pixel with short values for each sample. The length of pixel array must be equal to the number of bands.

Parameters:
x -
y -
pixel - array with one sample per band

getByteSample

byte getByteSample(int x,
                   int y,
                   int band)
Returns a byte sample from coordinate x/y and selected band.

Parameters:
x -
y -
band - band number for sample
Returns:
sample from selected coordinate and band

getDoubleSample

double getDoubleSample(int x,
                       int y,
                       int band)
Returns a double sample from coordinate x/y and selected band.

Parameters:
x -
y -
band - band number for sample
Returns:
sample from selected coordinate and band

getFloatSample

float getFloatSample(int x,
                     int y,
                     int band)
Returns a float sample from coordinate x/y and selected band.

Parameters:
x -
y -
band - band number for sample
Returns:
sample from selected coordinate and band

getIntSample

int getIntSample(int x,
                 int y,
                 int band)
Returns an integer sample from coordinate x/y and selected band.

Parameters:
x -
y -
band - band number for sample
Returns:
sample from selected coordinate and band

getShortSample

short getShortSample(int x,
                     int y,
                     int band)
Returns a short sample from coordinate x/y and selected band.

Parameters:
x -
y -
band - band number for sample
Returns:
sample from selected coordinate and band

setByteSample

void setByteSample(int x,
                   int y,
                   int band,
                   byte value)
Sets a single byte sample on coordinate x/y and selected band.

Parameters:
x -
y -
band - band number for sample
value - new value for sample

setDoubleSample

void setDoubleSample(int x,
                     int y,
                     int band,
                     double value)
Sets a single double sample on coordinate x/y and selected band.

Parameters:
x -
y -
band - band number for sample
value - new value for sample

setFloatSample

void setFloatSample(int x,
                    int y,
                    int band,
                    float value)
Sets a single float sample on coordinate x/y and selected band.

Parameters:
x -
y -
band - band number for sample
value - new value for sample

setIntSample

void setIntSample(int x,
                  int y,
                  int band,
                  int value)
Sets a single integer sample on coordinate x/y and selected band.

Parameters:
x -
y -
band - band number for sample
value - new value for sample

setShortSample

void setShortSample(int x,
                    int y,
                    int band,
                    short value)
Sets a single short sample on coordinate x/y and selected band.

Parameters:
x -
y -
band - band number for sample
value - new value for sample

getBytes

byte[] getBytes(int x,
                int y,
                int width,
                int height,
                int band,
                byte[] result)
Gets values from the specified rectangle and band. The result is stored row-ordered in a single array (e.g. {x0y0, x1y0, x2y0,...,x0y1...})

Parameters:
x -
y -
width -
height -
band -
result - an array to put the values into or null
Returns:
the result array or a new array, if the result array is null

getDoubles

double[] getDoubles(int x,
                    int y,
                    int width,
                    int height,
                    int band,
                    double[] result)
Gets values from the specified rectangle and band. The result is stored row-ordered in a single array (e.g. {x0y0, x1y0, x2y0,...,x0y1...})

Parameters:
x -
y -
width -
height -
band -
result - an array to put the values into or null
Returns:
the result array or a new array, if the result array is null

getFloats

float[] getFloats(int x,
                  int y,
                  int width,
                  int height,
                  int band,
                  float[] result)
Gets values from the specified rectangle and band. The result is stored row-ordered in a single array (e.g. {x0y0, x1y0, x2y0,...,x0y1...})

Parameters:
x -
y -
width -
height -
band -
result - an array to put the values into or null
Returns:
the result array or a new array, if the result array is null

getInts

int[] getInts(int x,
              int y,
              int width,
              int height,
              int band,
              int[] result)
Gets values from the specified rectangle and band. The result is stored row-ordered in a single array (e.g. {x0y0, x1y0, x2y0,...,x0y1...})

Parameters:
x -
y -
width -
height -
band -
result - an array to put the values into or null
Returns:
the result array or a new array, if the result array is null

getShorts

short[] getShorts(int x,
                  int y,
                  int width,
                  int height,
                  int band,
                  short[] result)
Gets values from the specified rectangle and band. The result is stored row-ordered in a single array (e.g. {x0y0, x1y0, x2y0,...,x0y1...})

Parameters:
x -
y -
width -
height -
band -
result - an array to put the values into or null
Returns:
the result array or a new array, if the result array is null

setBytes

void setBytes(int x,
              int y,
              int width,
              int height,
              int band,
              byte[] values)
Sets values from the array to the specified rectangle and band. The values must be stored row-ordered in a single array (e.g. {x0y0, x1y0, x2y0,...,x0y1...})

Parameters:
x -
y -
width -
height -
band -
values - the samples to put into the raster

setDoubles

void setDoubles(int x,
                int y,
                int width,
                int height,
                int band,
                double[] values)
Sets values from the array to the specified rectangle and band. The values must be stored row-ordered in a single array (e.g. {x0y0, x1y0, x2y0,...,x0y1...})

Parameters:
x -
y -
width -
height -
band -
values - the samples to put into the raster

setFloats

void setFloats(int x,
               int y,
               int width,
               int height,
               int band,
               float[] values)
Sets values from the array to the specified rectangle and band. The values must be stored row-ordered in a single array (e.g. {x0y0, x1y0, x2y0,...,x0y1...})

Parameters:
x -
y -
width -
height -
band -
values - the samples to put into the raster

setInts

void setInts(int x,
             int y,
             int width,
             int height,
             int band,
             int[] values)
Sets values from the array to the specified rectangle and band. The values must be stored row-ordered in a single array (e.g. {x0y0, x1y0, x2y0,...,x0y1...})

Parameters:
x -
y -
width -
height -
band -
values - the samples to put into the raster

setShorts

void setShorts(int x,
               int y,
               int width,
               int height,
               int band,
               short[] values)
Sets values from the array to the specified rectangle and band. The values must be stored row-ordered in a single array (e.g. {x0y0, x1y0, x2y0,...,x0y1...})

Parameters:
x -
y -
width -
height -
band -
values - the samples to put into the raster

getSubset

RasterData getSubset(RasterRect rasterRect)
Returns new RasterData object for the specified rectangle.

Parameters:
rasterRect - rectangle for subset
Returns:
selected subset

getSubset

RasterData getSubset(RasterRect rasterRect,
                     BandType[] bands)
Returns new single-band RasterData object for the specified rectangle.

Parameters:
rasterRect - rectangle for subset
bands - selected band
Returns:
selected rectangle

setSubset

void setSubset(int x,
               int y,
               int width,
               int height,
               RasterData sourceRaster)
Sets the raster with values from sourceRaster.

Parameters:
x - insert position
y - insert position
width - width of the subset
height - height of the subset
sourceRaster - data source to copy

setSubset

void setSubset(int x,
               int y,
               int width,
               int height,
               RasterData sourceRaster,
               int xOffset,
               int yOffset)
Sets the raster with values from sourceRaster.

Parameters:
x - insert position
y - insert position
width - width of the subset
height - height of the subset
xOffset - x offset in the source raster
yOffset - y offset in the source raster
sourceRaster - data source to copy

setSubset

void setSubset(int x,
               int y,
               int width,
               int height,
               int dstBand,
               RasterData sourceRaster,
               int srcBand)
Sets a single band of the raster with values from one band of the sourceRaster.

Parameters:
x - insert position
y - insert position
width - width of the subset
height - height of the subset
dstBand - the index of the destination band
sourceRaster - data source to copy
srcBand - the index of the source band of sourceRaster

setSubset

void setSubset(int x,
               int y,
               int width,
               int height,
               int dstBand,
               RasterData sourceRaster,
               int srcBand,
               int xOffset,
               int yOffset)
Sets a single band of the raster with values from one band of the sourceRaster.

Parameters:
x - insert position
y - insert position
width - width of the subset
height - height of the subset
dstBand - the index of the destination band
sourceRaster - data source to copy
srcBand - the index of the source band of sourceRaster
xOffset - x offset in the source raster
yOffset - y offset in the source raster

dispose

void dispose()
Try to dispose all allocated memory of this data object.



Copyright © 2011. All Rights Reserved.