org.deegree.coverage.raster.data
Class TiledRasterData

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

public class TiledRasterData
extends Object
implements RasterData

The TiledRasterData is a grid of raster data, wrapping all pixel operations on the tiles.

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

Field Summary
 
Fields inherited from interface org.deegree.coverage.raster.data.RasterData
TYPE_BYTE_RGB, TYPE_BYTE_RGBA
 
Constructor Summary
protected TiledRasterData(GridReader reader, RasterIOOptions options)
           
 
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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TiledRasterData

protected TiledRasterData(GridReader reader,
                          RasterIOOptions options)
Parameters:
reader - to be used for the tiles.
options -
Method Detail

asReadOnly

public RasterData asReadOnly()
Description copied from interface: RasterData
Return a read-only version of this RasterData. The result shares the same data as the original.

Specified by:
asReadOnly in interface RasterData
Returns:
a read-only RasterData

createCompatibleRasterData

public RasterData createCompatibleRasterData(RasterRect sampleDomain,
                                             BandType[] bands)
Description copied from interface: RasterData
Returns a new RasterData with the same DataType and InterleaveType

Specified by:
createCompatibleRasterData in interface RasterData
Parameters:
sampleDomain - the raster rectangle defining the sample domain of this raster data.
bands - indices to the requested bands
Returns:
new empty raster

createCompatibleRasterData

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

Specified by:
createCompatibleRasterData in interface RasterData
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

public RasterData createCompatibleRasterData(int width,
                                             int height)
Description copied from interface: RasterData
Returns a new RasterData with the same DataType and InterleaveType and all bands

Specified by:
createCompatibleRasterData in interface RasterData
Parameters:
width - width of the new raster
height - height of the new raster
Returns:
new empty raster

createCompatibleRasterData

public RasterData createCompatibleRasterData(BandType[] bands)
Description copied from interface: RasterData
Returns a new RasterData with the same size, DataType and InterleaveType

Specified by:
createCompatibleRasterData in interface RasterData
Parameters:
bands - definitions of the new rasterdata.
Returns:
new empty raster

createCompatibleRasterData

public RasterData createCompatibleRasterData()
Description copied from interface: RasterData
Returns a new RasterData with the same size, bands, DataType and InterleaveType

Specified by:
createCompatibleRasterData in interface RasterData
Returns:
new empty raster

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.

Specified by:
createCompatibleWritableRasterData in interface RasterData
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

getBands

public int getBands()
Description copied from interface: RasterData
Returns the number of bands of the raster

Specified by:
getBands in interface RasterData
Returns:
the bands

getBytePixel

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

Specified by:
getBytePixel in interface RasterData
result - an array to put the values into or null
Returns:
the result array or a new array, if the result array is null

getByteSample

public byte getByteSample(int x,
                          int y,
                          int band)
Description copied from interface: RasterData
Returns a byte sample from coordinate x/y and selected band.

Specified by:
getByteSample in interface RasterData
band - band number for sample
Returns:
sample from selected coordinate and band

getBytes

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

Specified by:
getBytes in interface RasterData
result - an array to put the values into or null
Returns:
the result array or a new array, if the result array is null

getDataInfo

public RasterDataInfo getDataInfo()
Description copied from interface: RasterData
Returns an encapsulation of all available information of this raster data.

Specified by:
getDataInfo in interface RasterData
Returns:
available information of this raster data.

getDataType

public DataType getDataType()
Description copied from interface: RasterData
Returns the data type of the raster.

Specified by:
getDataType in interface RasterData
Returns:
data type of the raster

getDoublePixel

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

Specified by:
getDoublePixel in interface RasterData
result - an array to put the values into or null
Returns:
the result array or a new array, if the result array is null

getDoubleSample

public double getDoubleSample(int x,
                              int y,
                              int band)
Description copied from interface: RasterData
Returns a double sample from coordinate x/y and selected band.

Specified by:
getDoubleSample in interface RasterData
band - band number for sample
Returns:
sample from selected coordinate and band

getDoubles

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

Specified by:
getDoubles in interface RasterData
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

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

Specified by:
getFloatPixel in interface RasterData
result - an array to put the values into or null
Returns:
the result array or a new array, if the result array is null

getFloatSample

public float getFloatSample(int x,
                            int y,
                            int band)
Description copied from interface: RasterData
Returns a float sample from coordinate x/y and selected band.

Specified by:
getFloatSample in interface RasterData
band - band number for sample
Returns:
sample from selected coordinate and band

getFloats

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

Specified by:
getFloats in interface RasterData
result - an array to put the values into or null
Returns:
the result array or a new array, if the result array is null

getRows

public int getRows()
Description copied from interface: RasterData
Returns the height of the raster

Specified by:
getRows in interface RasterData
Returns:
the height

getIntPixel

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

Specified by:
getIntPixel in interface RasterData
result - an array to put the values into or null
Returns:
the result array or a new array, if the result array is null

getIntSample

public int getIntSample(int x,
                        int y,
                        int band)
Description copied from interface: RasterData
Returns an integer sample from coordinate x/y and selected band.

Specified by:
getIntSample in interface RasterData
band - band number for sample
Returns:
sample from selected coordinate and band

getInts

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

Specified by:
getInts in interface RasterData
result - an array to put the values into or null
Returns:
the result array or a new array, if the result array is null

getNullPixel

public byte[] getNullPixel(byte[] result)
Description copied from interface: RasterData
Returns the no data values for this raster, or the view of this rasters bands.

Specified by:
getNullPixel in interface RasterData
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

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

getSample

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

Specified by:
getSample in interface RasterData
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

getShortPixel

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

Specified by:
getShortPixel in interface RasterData
result - an array to put the values into or null
Returns:
the result array or a new array, if the result array is null

getShortSample

public short getShortSample(int x,
                            int y,
                            int band)
Description copied from interface: RasterData
Returns a short sample from coordinate x/y and selected band.

Specified by:
getShortSample in interface RasterData
band - band number for sample
Returns:
sample from selected coordinate and band

getShorts

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

Specified by:
getShorts in interface RasterData
result - an array to put the values into or null
Returns:
the result array or a new array, if the result array is null

getColumns

public int getColumns()
Description copied from interface: RasterData
Returns the width of the raster

Specified by:
getColumns in interface RasterData
Returns:
the width

setBytePixel

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

Specified by:
setBytePixel in interface RasterData
pixel - array with one sample per band

setByteSample

public void setByteSample(int x,
                          int y,
                          int band,
                          byte value)
Description copied from interface: RasterData
Sets a single byte sample on coordinate x/y and selected band.

Specified by:
setByteSample in interface RasterData
band - band number for sample
value - new value for sample

setBytes

public void setBytes(int x,
                     int y,
                     int width,
                     int height,
                     int band,
                     byte[] values)
Description copied from interface: RasterData
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...})

Specified by:
setBytes in interface RasterData
values - the samples to put into the raster

setDoublePixel

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

Specified by:
setDoublePixel in interface RasterData
pixel - array with one sample per band

setDoubleSample

public void setDoubleSample(int x,
                            int y,
                            int band,
                            double value)
Description copied from interface: RasterData
Sets a single double sample on coordinate x/y and selected band.

Specified by:
setDoubleSample in interface RasterData
band - band number for sample
value - new value for sample

setDoubles

public void setDoubles(int x,
                       int y,
                       int width,
                       int height,
                       int band,
                       double[] values)
Description copied from interface: RasterData
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...})

Specified by:
setDoubles in interface RasterData
values - the samples to put into the raster

setFloatPixel

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

Specified by:
setFloatPixel in interface RasterData
pixel - array with one sample per band

setFloatSample

public void setFloatSample(int x,
                           int y,
                           int band,
                           float value)
Description copied from interface: RasterData
Sets a single float sample on coordinate x/y and selected band.

Specified by:
setFloatSample in interface RasterData
band - band number for sample
value - new value for sample

setFloats

public void setFloats(int x,
                      int y,
                      int width,
                      int height,
                      int band,
                      float[] values)
Description copied from interface: RasterData
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...})

Specified by:
setFloats in interface RasterData
values - the samples to put into the raster

setIntPixel

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

Specified by:
setIntPixel in interface RasterData
pixel - array with one sample per band

setIntSample

public void setIntSample(int x,
                         int y,
                         int band,
                         int value)
Description copied from interface: RasterData
Sets a single integer sample on coordinate x/y and selected band.

Specified by:
setIntSample in interface RasterData
band - band number for sample
value - new value for sample

setInts

public void setInts(int x,
                    int y,
                    int width,
                    int height,
                    int band,
                    int[] values)
Description copied from interface: RasterData
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...})

Specified by:
setInts in interface RasterData
values - the samples to put into the raster

setNoDataValue

public void setNoDataValue(byte[] values)
Description copied from interface: RasterData
Sets the no data values for this raster

Specified by:
setNoDataValue in interface RasterData
Parameters:
values - an array with the null values

setPixel

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

setSample

public void setSample(int x,
                      int y,
                      int band,
                      byte[] values)
Description copied from interface: RasterData
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

Specified by:
setSample in interface RasterData
band - selected band
values - array with the sample value

setShortPixel

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

Specified by:
setShortPixel in interface RasterData
pixel - array with one sample per band

setShortSample

public void setShortSample(int x,
                           int y,
                           int band,
                           short value)
Description copied from interface: RasterData
Sets a single short sample on coordinate x/y and selected band.

Specified by:
setShortSample in interface RasterData
band - band number for sample
value - new value for sample

setShorts

public void setShorts(int x,
                      int y,
                      int width,
                      int height,
                      int band,
                      short[] values)
Description copied from interface: RasterData
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...})

Specified by:
setShorts in interface RasterData
values - the samples to put into the raster

getSubset

public RasterData getSubset(RasterRect rasterRect)
Description copied from interface: RasterData
Returns new RasterData object for the specified rectangle.

Specified by:
getSubset in interface RasterData
Parameters:
rasterRect - rectangle for subset
Returns:
selected subset

getSubset

public RasterData getSubset(RasterRect rasterRect,
                            BandType[] bands)
Description copied from interface: RasterData
Returns new single-band RasterData object for the specified rectangle.

Specified by:
getSubset in interface RasterData
Parameters:
rasterRect - rectangle for subset
bands - selected band
Returns:
selected rectangle

setSubset

public void setSubset(int x,
                      int y,
                      int width,
                      int height,
                      RasterData sourceRaster)
Description copied from interface: RasterData
Sets the raster with values from sourceRaster.

Specified by:
setSubset in interface RasterData
Parameters:
x - insert position
y - insert position
width - width of the subset
height - height of the subset
sourceRaster - data source to copy

setSubset

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

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

setSubset

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

Specified by:
setSubset in interface RasterData
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

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

Specified by:
setSubset in interface RasterData
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

public void dispose()
Description copied from interface: RasterData
Try to dispose all allocated memory of this data object.

Specified by:
dispose in interface RasterData


Copyright © 2011. All Rights Reserved.