Constructor and Description |
---|
TileImpl(RasterDataNode rasterDataNode,
Raster raster) |
TileImpl(RasterDataNode rasterDataNode,
Raster raster,
Rectangle rectangle,
boolean target) |
TileImpl(RasterDataNode rasterDataNode,
WritableRaster raster,
Rectangle rectangle) |
Modifier and Type | Method and Description |
---|---|
ProductData |
getDataBuffer()
Obtains access to the underlying raw sample buffer.
|
byte[] |
getDataBufferByte()
Gets the underlying raw sample array of type
byte (signed or unsigned). |
double[] |
getDataBufferDouble()
Gets the underlying raw sample array of type
double . |
float[] |
getDataBufferFloat()
Gets the underlying raw sample array of type
float . |
int |
getDataBufferIndex(int x,
int y)
Gets the index into the underlying raw sample buffer for the given pixel coordinates.
|
int[] |
getDataBufferInt()
Gets the underlying raw sample array of type
int . |
short[] |
getDataBufferShort()
Gets the underlying raw sample array of type
short (signed or unsigned). |
int |
getHeight()
Gets the height in pixels within the scene covered by the tile's
RasterDataNode . |
int |
getMaxX()
Gets the maximum pixel x-coordinate within the scene covered by the tile's
RasterDataNode . |
int |
getMaxY()
Gets the maximum pixel y-coordinate within the scene covered by the tile's
RasterDataNode . |
int |
getMinX()
Gets the minimum pixel x-coordinate within the scene covered by the tile's
RasterDataNode . |
int |
getMinY()
Gets the minimum pixel y-coordinate within the scene covered by the tile's
RasterDataNode . |
RasterDataNode |
getRasterDataNode()
Gets the
RasterDataNode associated with this tile,
e.g. a Band for source and target tiles or
TiePointGrid for a source tile. |
ProductData |
getRawSamples()
Gets the raw (unscaled, uncalibrated) samples, e.g. detector counts, copied from or wrapping the underlying
data buffer.
|
Rectangle |
getRectangle()
Gets the tile rectangle in pixel coordinates within the scene covered by the tile's
RasterDataNode . |
boolean |
getSampleBit(int x,
int y,
int bitIndex)
Gets the bit-coded sample value for the given pixel coordinate and the specified bit index as a
boolean . |
boolean |
getSampleBoolean(int x,
int y)
Gets the (geo-)physically scaled sample at the given pixel coordinate as
boolean value. |
double |
getSampleDouble(int x,
int y)
Gets the (geo-)physically scaled sample value for the given pixel coordinate as
double . |
float |
getSampleFloat(int x,
int y)
Gets the (geo-)physically scaled sample at the given pixel coordinate as
float value. |
int |
getSampleInt(int x,
int y)
Gets the (geo-)physically scaled sample at the given pixel coordinate as
int value. |
byte[] |
getSamplesByte()
Gets the scaled, (geo-)physical array of
int samples, copied from or directly returning the underlying
data buffer. |
double[] |
getSamplesDouble()
Gets the scaled, (geo-)physical array of
double samples, copied from or directly returning the underlying
data buffer. |
float[] |
getSamplesFloat()
Gets the scaled, (geo-)physical array of
double samples, copied from or directly returning the underlying
data buffer. |
int[] |
getSamplesInt()
Gets the scaled, (geo-)physical array of
int samples, copied from or directly returning the underlying
data buffer. |
short[] |
getSamplesShort()
Gets the scaled, (geo-)physical array of
int samples, copied from or directly returning the underlying
data buffer. |
int |
getScanlineOffset()
Gets the scanline offset.
|
int |
getScanlineStride()
Gets the raster scanline stride for addressing the internal data buffer.
|
int |
getWidth()
Gets the width in pixels within the scene covered by the tile's
RasterDataNode . |
boolean |
isSampleValid(int x,
int y)
Checks whether or not the sample value exists and is valid at a given image pixel position.
|
boolean |
isTarget()
Checks if this is a target tile.
|
Iterator<Tile.Pos> |
iterator()
Gets an iterator which can be used to visit all pixels in the tile.
|
void |
setRawSamples(ProductData rawSamples)
Sets this tile's raw (unscaled, uncalibrated) samples.
|
void |
setSample(int x,
int y,
boolean sample)
Sets the (geo-)physically scaled sample at the given pixel coordinate from a
boolean value. |
void |
setSample(int x,
int y,
double sample)
Sets the (geo-)physically scaled sample at the given pixel coordinate from a
double value. |
void |
setSample(int x,
int y,
float sample)
Sets the (geo-)physically scaled sample at the given pixel coordinate from a
float value. |
void |
setSample(int x,
int y,
int sample)
Sets the (geo-)physically scaled sample at the given pixel coordinate from a
int value. |
void |
setSample(int x,
int y,
int bitIndex,
boolean sample)
Sets the bit-coded sample at the given pixel coordinate and the specified bit index from a
boolean value. |
void |
setSamples(byte[] samples)
Sets this tile's scaled, (geo-)physical samples as array of
floats s. |
void |
setSamples(double[] samples)
Sets this tile's scaled, (geo-)physical samples as array of
double s. |
void |
setSamples(float[] samples)
Sets this tile's scaled, (geo-)physical samples as array of
floats s. |
void |
setSamples(int[] samples)
Sets this tile's scaled, (geo-)physical samples as array of
floats s. |
void |
setSamples(short[] samples)
Sets this tile's scaled, (geo-)physical samples as array of
floats s. |
double |
toGeoPhysical(double sample)
Converts a raw sample value (e.g. digital counts) to a (geo-)physically scaled sample value
of type
double . |
float |
toGeoPhysical(float sample)
Converts a raw sample value (e.g. digital counts) to a (geo-)physically scaled sample value
of type
float . |
double |
toRaw(double sample)
Converts a (geo-)physically scaled sample value of type
double to a
its corresponding raw sample value (e.g. digital counts). |
float |
toRaw(float sample)
Converts a (geo-)physically scaled sample value of type
float to a
its corresponding raw sample value (e.g. digital counts). |
public TileImpl(RasterDataNode rasterDataNode, Raster raster)
public TileImpl(RasterDataNode rasterDataNode, WritableRaster raster, Rectangle rectangle)
public TileImpl(RasterDataNode rasterDataNode, Raster raster, Rectangle rectangle, boolean target)
public float toGeoPhysical(float sample)
Tile
float
.toGeoPhysical
in interface Tile
sample
- The raw sample value.public double toGeoPhysical(double sample)
Tile
double
.toGeoPhysical
in interface Tile
sample
- The raw sample value.public float toRaw(float sample)
Tile
float
to a
its corresponding raw sample value (e.g. digital counts).public double toRaw(double sample)
Tile
double
to a
its corresponding raw sample value (e.g. digital counts).public final boolean isTarget()
Tile
public boolean isSampleValid(int x, int y)
Tile
isSampleValid
in interface Tile
x
- the image pixel x-coordinatey
- the image pixel y-coordinatepublic final Rectangle getRectangle()
Tile
RasterDataNode
.
Simply returns new Rectangle(
minX
,
minY
,
width
,
height
)
.getRectangle
in interface Tile
public final int getMinX()
Tile
RasterDataNode
.public final int getMaxX()
Tile
RasterDataNode
.public final int getMinY()
Tile
RasterDataNode
.public final int getMaxY()
Tile
RasterDataNode
.public final int getWidth()
Tile
RasterDataNode
.public final int getHeight()
Tile
RasterDataNode
.public final RasterDataNode getRasterDataNode()
Tile
RasterDataNode
associated with this tile,
e.g. a Band
for source and target tiles or
TiePointGrid
for a source tile.getRasterDataNode
in interface Tile
RasterDataNode
associated with this tile.public int getDataBufferIndex(int x, int y)
Tile
The pixel coordinates are absolute; meaning they are defined in the scene raster coordinate system
of this tile's RasterDataNode
.
The returned index is computed as follows:
int dx = x -Tile.getMinX()
; int dy = y -Tile.getMinY()
; int index =Tile.getScanlineOffset()
+ dy *Tile.getScanlineStride()
+ dx;
getDataBufferIndex
in interface Tile
x
- The absolute pixel x-coordinate, must be greater or equal Tile.getMinX()
and less or equal Tile.getMaxX()
.y
- The absolute pixel y-coordinate, must be greater or equal Tile.getMinY()
and less or equal Tile.getMaxY()
.public ProductData getDataBuffer()
Tile
Obtains access to the underlying raw sample buffer. The data buffer holds the raw (unscaled, uncalibrated) sample data (e.g. detector counts).
Elements in this array must be addressed by an index computed via thescanlineStride
and
scanlineOffset
properties.
The index can also be directly computed using the Tile.getDataBufferIndex(int, int)
method.
The most efficient way to access and/or modify the samples in the raw data buffer is using the following nested loops:
int lineStride = tile.Tile.getScanlineStride()
; int lineOffset = tile.Tile.getScanlineOffset()
; for (int y = tile.Tile.getMinY()
; y <= tile.Tile.getMaxY()
; y++) { int index = lineOffset; for (int x = tile.Tile.getMinX()
; x <= tile.Tile.getMaxX()
; x++) { // use index here to access raw data buffer... index++; } lineOffset += lineStride; }
If the absolute x,y pixel coordinates are not required, the following construct maybe more readable:
int lineStride = tile.Tile.getScanlineStride()
; int lineOffset = tile.Tile.getScanlineOffset()
; for (int y = 0; y < tile.Tile.getHeight()
; y++) { int index = lineOffset; for (int x = 0; x < tile.Tile.getWidth()
; x++) { // use index here to access raw data buffer... index++; } lineOffset += lineStride; }
getDataBuffer
in interface Tile
public final byte[] getDataBufferByte()
Tile
byte
(signed or unsigned).
If the underlying data buffer is not of type byte
, null
is returned.
Refer to Tile.getDataBuffer()
for using the primitive array.
getDataBufferByte
in interface Tile
null
(see above).Tile.getDataBufferIndex(int, int)
,
Tile.getDataBuffer()
public final short[] getDataBufferShort()
Tile
short
(signed or unsigned).
If the underlying data buffer is not of type short
, null
is returned.
Refer to Tile.getDataBuffer()
for using the primitive array.
getDataBufferShort
in interface Tile
null
(see above).Tile.getDataBufferIndex(int, int)
,
Tile.getDataBuffer()
public final int[] getDataBufferInt()
Tile
int
.
If the underlying data buffer is not of type int
, null
is returned.
Refer to Tile.getDataBuffer()
for using the primitive array.
getDataBufferInt
in interface Tile
null
(see above).Tile.getDataBufferIndex(int, int)
,
Tile.getDataBuffer()
public final float[] getDataBufferFloat()
Tile
float
.
If the underlying data buffer is not of type float
, null
is returned.
Refer to Tile.getDataBuffer()
for using the primitive array.
getDataBufferFloat
in interface Tile
null
(see above).Tile.getDataBufferIndex(int, int)
,
Tile.getDataBuffer()
public final double[] getDataBufferDouble()
Tile
double
.
If the underlying data buffer is not of type double
, null
is returned.
Refer to Tile.getDataBuffer()
for using the primitive array.
getDataBufferDouble
in interface Tile
null
(see above).Tile.getDataBufferIndex(int, int)
,
Tile.getDataBuffer()
public final int getScanlineOffset()
Tile
getScanlineOffset
in interface Tile
Tile.getScanlineStride()
public final int getScanlineStride()
Tile
getScanlineStride
in interface Tile
Tile.getScanlineOffset()
public ProductData getRawSamples()
Tile
Tile.getDataBuffer()
method, the returned samples
will cover exactly the region Tile.getRectangle()
rectangle} of this tile. Thus, the number
of returned samples will always equal width
*
height
.
In order to apply changes of the samples values to this tile, it is mandatory to call
Tile.setRawSamples(org.esa.beam.framework.datamodel.ProductData)
with the modified
ProductData
instance.
getRawSamples
in interface Tile
public void setRawSamples(ProductData rawSamples)
Tile
width
*
height
of this tile.
This method must be used
in order to apply changes made to the samples returned by the Tile.getRawSamples()
method.
setRawSamples
in interface Tile
rawSamples
- The raw samples to be set.public byte[] getSamplesByte()
Tile
int
samples, copied from or directly returning the underlying
data buffer. In contradiction to the Tile.getDataBuffer()
method, the returned samples
will cover exactly the region Tile.getRectangle()
rectangle} of this tile. Thus, the number
of returned samples will always equal width
*
height
.
Sample values that are masked out (see Tile.isSampleValid(int, int)
) are set to zero.getSamplesByte
in interface Tile
Tile.setSamples(byte[])
public short[] getSamplesShort()
Tile
int
samples, copied from or directly returning the underlying
data buffer. In contradiction to the Tile.getDataBuffer()
method, the returned samples
will cover exactly the region Tile.getRectangle()
rectangle} of this tile. Thus, the number
of returned samples will always equal width
*
height
.
Sample values that are masked out (see Tile.isSampleValid(int, int)
) are set to zero.getSamplesShort
in interface Tile
Tile.setSamples(short[])
public int[] getSamplesInt()
Tile
int
samples, copied from or directly returning the underlying
data buffer. In contradiction to the Tile.getDataBuffer()
method, the returned samples
will cover exactly the region Tile.getRectangle()
rectangle} of this tile. Thus, the number
of returned samples will always equal width
*
height
.
Sample values that are masked out (see Tile.isSampleValid(int, int)
) are set to zero.getSamplesInt
in interface Tile
Tile.setSamples(int[])
public float[] getSamplesFloat()
Tile
double
samples, copied from or directly returning the underlying
data buffer. In contradiction to the Tile.getDataBuffer()
method, the returned samples
will cover exactly the region Tile.getRectangle()
rectangle} of this tile. Thus, the number
of returned samples will always equal width
*
height
.
Sample values that are masked out (see Tile.isSampleValid(int, int)
) are set to Float.NaN
.getSamplesFloat
in interface Tile
Tile.setSamples(float[])
public double[] getSamplesDouble()
Tile
double
samples, copied from or directly returning the underlying
data buffer. In contradiction to the Tile.getDataBuffer()
method, the returned samples
will cover exactly the region Tile.getRectangle()
rectangle} of this tile. Thus, the number
of returned samples will always equal width
*
height
.
Sample values that are masked out (see Tile.isSampleValid(int, int)
) are set to Double.NaN
.getSamplesDouble
in interface Tile
Tile.setSamples(double[])
public void setSamples(byte[] samples)
Tile
floats
s.
The number of given samples must be equal width
*
height
of this tile.setSamples
in interface Tile
samples
- The (geo-)physical samples to be set.Tile.getSamplesByte()
public void setSamples(short[] samples)
Tile
floats
s.
The number of given samples must be equal width
*
height
of this tile.setSamples
in interface Tile
samples
- The (geo-)physical samples to be set.Tile.getSamplesShort()
public void setSamples(int[] samples)
Tile
floats
s.
The number of given samples must be equal width
*
height
of this tile.setSamples
in interface Tile
samples
- The (geo-)physical samples to be set.Tile.getSamplesInt()
public void setSamples(float[] samples)
Tile
floats
s.
The number of given samples must be equal width
*
height
of this tile.setSamples
in interface Tile
samples
- The (geo-)physical samples to be set.Tile.getSamplesFloat()
public void setSamples(double[] samples)
Tile
double
s.
The number of given samples must be equal width
*
height
of this tile.
This method must be used
in order to apply changes made to the samples returned by the Tile.getRawSamples()
method.
setSamples
in interface Tile
samples
- The (geo-)physical samples to be set.Tile.getSamplesDouble()
public boolean getSampleBoolean(int x, int y)
Tile
boolean
value.
If the underlying data buffer is of a different sample data type, an appropriate type conversion is performed.
Note that in most cases, accessing the tile's dataBuffer
directly in conjunction
with the scanlineOffset
and scanlineStride
properties
gives a better performance.
getSampleBoolean
in interface Tile
x
- The absolute pixel x-coordinate, must be greater or equal Tile.getMinX()
and less or equal Tile.getMaxX()
.y
- The absolute pixel y-coordinate, must be greater or equal Tile.getMinY()
and less or equal Tile.getMaxY()
.boolean
value.public void setSample(int x, int y, boolean sample)
Tile
boolean
value.
If the underlying data buffer is of a different sample data type, an appropriate type conversion is performed.
Note that in most cases, accessing the tile's dataBuffer
directly in conjunction
with the scanlineOffset
and scanlineStride
properties
gives a better performance.
setSample
in interface Tile
x
- The absolute pixel x-coordinate, must be greater or equal Tile.getMinX()
and less or equal Tile.getMaxX()
.y
- The absolute pixel y-coordinate, must be greater or equal Tile.getMinY()
and less or equal Tile.getMaxY()
.sample
- The (geo-)physically scaled sample as boolean
value.public int getSampleInt(int x, int y)
Tile
int
value.
If the underlying data buffer is of a different sample data type, an appropriate type conversion is performed.
Note that in most cases, accessing the tile's dataBuffer
directly in conjunction
with the scanlineOffset
and scanlineStride
properties
gives a better performance.
getSampleInt
in interface Tile
x
- The absolute pixel x-coordinate, must be greater or equal Tile.getMinX()
and less or equal Tile.getMaxX()
.y
- The absolute pixel y-coordinate, must be greater or equal Tile.getMinY()
and less or equal Tile.getMaxY()
.int
value.public void setSample(int x, int y, int sample)
Tile
int
value.
If the underlying data buffer is of a different sample data type, an appropriate type conversion is performed. The conversion ensures that no overflow happens. If necessary the value is cropped to the value range.
Note that in most cases, accessing the tile's dataBuffer
directly in conjunction
with the scanlineOffset
and scanlineStride
properties
gives a better performance.
setSample
in interface Tile
x
- The absolute pixel x-coordinate, must be greater or equal Tile.getMinX()
and less or equal Tile.getMaxX()
.y
- The absolute pixel y-coordinate, must be greater or equal Tile.getMinY()
and less or equal Tile.getMaxY()
.sample
- The (geo-)physically scaled sample as int
value.public float getSampleFloat(int x, int y)
Tile
float
value.
If the underlying data buffer is of a different sample data type, an appropriate type conversion is performed.
Note that in most cases it is more performant to directly access the tile's dataBuffer
in conjunction
with the scanlineOffset
and scanlineStride
properties.
getSampleFloat
in interface Tile
x
- The absolute pixel x-coordinate, must be greater or equal Tile.getMinX()
and less or equal Tile.getMaxX()
.y
- The absolute pixel y-coordinate, must be greater or equal Tile.getMinY()
and less or equal Tile.getMaxY()
.float
value.public void setSample(int x, int y, float sample)
Tile
float
value.
If the underlying data buffer is of a different sample data type, an appropriate type conversion is performed. The conversion ensures that no overflow happens. If necessary the value is cropped to the value range.
Note that in most cases, accessing the tile's dataBuffer
directly in conjunction
with the scanlineOffset
and scanlineStride
properties
gives a better performance.
setSample
in interface Tile
x
- The absolute pixel x-coordinate, must be greater or equal Tile.getMinX()
and less or equal Tile.getMaxX()
.y
- The absolute pixel y-coordinate, must be greater or equal Tile.getMinY()
and less or equal Tile.getMaxY()
.sample
- The (geo-)physically scaled sample as float
value.public double getSampleDouble(int x, int y)
Tile
double
.
If the underlying data buffer is of a different sample data type, an appropriate type conversion is performed.
Note that in most cases, accessing the tile's dataBuffer
directly in conjunction
with the scanlineOffset
and scanlineStride
properties
gives a better performance.
getSampleDouble
in interface Tile
x
- The absolute pixel x-coordinate, must be greater or equal Tile.getMinX()
and less or equal Tile.getMaxX()
.y
- The absolute pixel y-coordinate, must be greater or equal Tile.getMinY()
and less or equal Tile.getMaxY()
.double
value.public void setSample(int x, int y, double sample)
Tile
double
value.
If the underlying data buffer is of a different sample data type, an appropriate type conversion is performed. The conversion ensures that no overflow happens. If necessary the value is cropped to the value range.
Note that in most cases, accessing the tile's dataBuffer
directly in conjunction
with the scanlineOffset
and scanlineStride
properties
gives a better performance.
setSample
in interface Tile
x
- The absolute pixel x-coordinate, must be greater or equal Tile.getMinX()
and less or equal Tile.getMaxX()
.y
- The absolute pixel y-coordinate, must be greater or equal Tile.getMinY()
and less or equal Tile.getMaxY()
.sample
- The (geo-)physically scaled sample as double
value.public boolean getSampleBit(int x, int y, int bitIndex)
Tile
boolean
.
If the underlying data buffer is of a different sample data type, an appropriate type conversion is performed.
Note that in most cases it is more performant to directly access the tile's dataBuffer
in conjunction
with the scanlineOffset
and scanlineStride
properties.
getSampleBit
in interface Tile
x
- The absolute pixel x-coordinate, must be greater or equal Tile.getMinX()
and less or equal Tile.getMaxX()
.y
- The absolute pixel y-coordinate, must be greater or equal Tile.getMinY()
and less or equal Tile.getMaxY()
.bitIndex
- The bit index.boolean
value.public void setSample(int x, int y, int bitIndex, boolean sample)
Tile
boolean
value.
If the underlying data buffer is of a different sample data type, an appropriate type conversion is performed.
Note that in most cases it is more performant to directly access the tile's dataBuffer
in conjunction
with the scanlineOffset
and scanlineStride
properties.
setSample
in interface Tile
x
- The absolute pixel x-coordinate, must be greater or equal Tile.getMinX()
and less or equal Tile.getMaxX()
.y
- The absolute pixel y-coordinate, must be greater or equal Tile.getMinY()
and less or equal Tile.getMaxY()
.bitIndex
- The bit index.sample
- The sample as boolean
value.public Iterator<Tile.Pos> iterator()
Tile
for (Tile.Pos pos: tile) { int x = pos.x; int y = pos.y; // ... }is equivalent to iterating over all pixels using two nested loops
for (int y = tile.getMinY(); y <= tile.getMaxY(); y++) { for (int x = tile.getMinX(); x <= tile.getMaxX(); x++) { // ... } }
Copyright © 2002–2014 Brockmann Consult GmbH. All rights reserved.