|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
ObjectIIOParam
ImageReadParam
SpatialImageReadParam
public class SpatialImageReadParam
Default parameters for SpatialImageReader. This class extends the standard
ImageReadParam class with the following additional capabilities:
Specify the plane to read in datasets having more than 2 dimensions, as for example in NetCDF files.
Specify the name of a color palette. This is useful when reading an image from a file that doesn't contain such information, for example ASCII grid.
For images having more than one band where the bands are not color components, specify which band to use with the Index Color Model. For example an image may contain Sea Surface Temperature (SST) measurements in the first band, and an estimation of the measurement errors in the second band. Users may want to read both bands for computation purpose, while applying a color palette using only the values in the first band.
Handling more than two dimensions
Some file formats like NetCDF can store dataset having more than two dimensions.
Geotk handles the supplemental dimensions with the following policies by default:
The two first dimensions - typically named (x, y) - are assigned to the (columns, rows) pixel indices.
An additional dimension can optionally be assigned to band indices. This is typically the
altitude (z) in a dataset having the (x, y, z,
t) dimensions, but can be customized. The actual dimension assigned to band
indices is returned by DimensionIdentification.findDimensionIndex(Iterable). See
MultidimensionalImageStore for more information.
An additional dimension can optionally be assigned to image index. This is typically
the time (t) in a dataset having the (x, y, z,
t) dimensions, but can be customized. See
MultidimensionalImageStore for more information.
Only one slice of every supplemental dimensions can be read. By default the data at index
0 are loaded, but different indices can be selected (see DimensionSlice). The actual
index used is the value returned by getSliceIndex(Object[]).
| coverage/geotk-coverageio (download) | View source code for this class |
| Field Summary | |
|---|---|
static String |
DEFAULT_PALETTE_NAME
The name of the default color palette to apply when none was explicitly specified. |
protected ImageReader |
reader
The image reader for which this SpatialImageReadParam instance
has been created, or null if unknown. |
| Fields inherited from class ImageReadParam |
|---|
canSetSourceRenderSize, destination, destinationBands, minProgressivePass, numProgressivePasses, sourceRenderSize |
| Fields inherited from class IIOParam |
|---|
controller, defaultController, destinationOffset, destinationType, sourceBands, sourceRegion, sourceXSubsampling, sourceYSubsampling, subsamplingXOffset, subsamplingYOffset |
| Fields inherited from interface WarningProducer |
|---|
LOGGER |
| Constructor Summary | |
|---|---|
SpatialImageReadParam(ImageReader reader)
Creates a new, initially empty, set of parameters. |
|
| Method Summary | |
|---|---|
DimensionSlice |
getDimensionSlice(Object... dimensionIds)
Returns the dimension slice identified by at least one of the given identifiers. |
Set<DimensionSlice> |
getDimensionSlices()
Returns all DimensionSlice instances known to this parameters block. |
Locale |
getLocale()
Returns the locale used for formatting error messages, or null if none. |
PaletteFactory |
getPaletteFactory()
Returns the palette factory to use for creating a color model from the palette name. |
String |
getPaletteName()
Returns the name of the color palette to apply when creating an index color model. |
List<SampleDomain> |
getSampleDomains()
Returns the range of valid values together with the fill values, or null if
unspecified. |
int |
getSliceIndex(Object... dimensionIds)
Returns the index of the slice in the dimension identified by at least one of the given identifiers. |
int |
getVisibleBand()
Returns the band to display in the target image. |
boolean |
hasDimensionSlices()
Returns true if the parameters contain at least one DimensionSlice. |
boolean |
isSampleConversionAllowed(SampleConversionType type)
Returns true if the given kind of sample conversions is allowed. |
DimensionSlice |
newDimensionSlice()
Creates a new handler for selecting a slice of the (x, y) plane to read. |
void |
setPaletteFactory(PaletteFactory factory)
Sets the palette factory to use for creating a color model from the palette name. |
void |
setPaletteName(String palette)
Sets the color palette as one of the available names provided by the default palette factory. |
void |
setSampleConversionAllowed(SampleConversionType type,
boolean allowed)
Sets whatever the given kind of sample conversions is allowed. |
void |
setSampleDomains(List<SampleDomain> domains)
Sets the range of valid values and fill values to use for creating a color model. |
void |
setVisibleBand(int visibleBand)
Sets the band to make visible in the destination image. |
String |
toString()
Returns a string representation of this block of parameters. |
boolean |
warningOccurred(LogRecord record)
Invoked when a warning occurred. |
| Methods inherited from class Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final String DEFAULT_PALETTE_NAME
getPaletteName(),
setPaletteName(String),
Constant Field Valuesprotected final ImageReader reader
SpatialImageReadParam instance
has been created, or null if unknown.
| Constructor Detail |
|---|
public SpatialImageReadParam(ImageReader reader)
reader - The reader for which this parameter block is created, or null.| Method Detail |
|---|
public boolean hasDimensionSlices()
true if the parameters contain at least one DimensionSlice.
Invoking this method is equivalent to testing
!getDimensionSlices().isEmpty().
public DimensionSlice newDimensionSlice()
addDimensionId(...) methods for specifying the dimension, and invoke
DimensionSlice.setSliceIndex(int) for specifying the index of the
slice point (WMS 2.0 terminology).
A new handler can be created for each supplemental dimension above the two (x, y) dimensions and the bands handled by Java2D. If no slice is specified for a supplemental dimension, then the default is the slice at index 0.
public Set<DimensionSlice> getDimensionSlices()
DimensionSlice instances known to this parameters block. They are
the instances created by newDimensionSlice() and for which at least one
identifier has been added.
The returned collection is live: if new dimension slices are created, they will appear dynamically in the returned set.
public DimensionSlice getDimensionSlice(Object... dimensionIds)
Integer, a dimension name as a
String, or an axis direction as an AxisDirection. More than one identifier
can be specified in order to increase the chance to get the index, for example:
DimensionSlice slice = getDimensionSlice("time", AxisDirection.FUTURE);
If different slices are found for the given identifiers, then a
warning is emitted
and this method returns the first slice matching the given identifiers.
If no slice is found, null is returned.
dimensionIds - Integer, String or AxisDirection
that identify the dimension for which the slice is desired.
null if none.public int getSliceIndex(Object... dimensionIds)
This method is relevant mostly for n-dimensional dataset where n>2. The dimension can be identified by a zero-based index as anDimensionSlice slice = getDimensionSlice(dimensionIds); return (slice != null) ? slice.getSliceIndex() : 0;
Integer, a dimension
name as a String, or an axis direction as an AxisDirection. More than one
identifier can be specified in order to increase the chance to get the index, for example:
int index = getSliceIndex("time", AxisDirection.FUTURE);
If different indices are found for the given identifiers, then a
warning is emitted
and this method returns the index for the first slice matching the given identifiers.
If no index is found, 0 (which is the default index value) is returned.
dimensionIds - Integer, String or AxisDirection
that identify the dimension for which the index is desired.
DimensionSlice.getSliceIndex()public int getVisibleBand()
public void setVisibleBand(int visibleBand)
throws IllegalArgumentException
visibleBand - The band to make visible.
IllegalArgumentException - if the specified band index is invalid.public String getPaletteName()
setPaletteName(String).
For a table of available palette names in the default Geotk installation,
see the PaletteFactory class javadoc.
null if none.SpatialImageReader.hasColors(int)public void setPaletteName(String palette)
SpatialImageReader default implementation to the
default palette factory for creating a
image type specifier.
Note: This method is useful with image formats that don't store any color information
in the file. If the image format provides its own color palette (as in PNG of JPEG formats),
then the palette name given to this method may be ignored. The
SpatialImageReader.hasColors(int) method can be invoked in order to check if the
image file provides its own color palette.
For a table of available palette names in the default Geotk installation,
see the PaletteFactory class javadoc.
palette - The name of the color palette to apply.SpatialImageReader.hasColors(int),
PaletteFactory.getAvailableNames()public PaletteFactory getPaletteFactory()
SpatialImageReader.getImageType method after it has determined the range of sample
values from the image metadata.
The returned factory may be used in various way, but the following pseudo-code can be
considered typical:
public ImageTypeSpecifier getImageType(int imageIndex, ImageReadParam param, ...) {
SpatialMetadata md = getImageMetadata(imageIndex);
// ... process metadata
return param.getPaletteFactory().getPalette(param.getPaletteName(),
lower, upper, size, numBands, visibleBand);
}
SpatialImageReader.getImageType method
shall use for creating a color model from the palette name, or null for the default factory.public void setPaletteFactory(PaletteFactory factory)
factory - The new factory, or null for the
default factory.public List<SampleDomain> getSampleDomains()
null if
unspecified. If non-null, then SpatialImageReader will use this information
for creating the image color model as documented in the getPaletteFactory()
method.
This property is typically null, either because the color model is specified
by the image format, or because the range of valid values is extracted from the
image metadata.
If non-null, then the size of this list shall be equals to the number of
source bands. The SampleDomain at
index i is for the band at index sourceBands[i] in the
stream.
null if unspecified.public void setSampleDomains(List<SampleDomain> domains)
If this method is invoked with a non-null value, then the size of the given list
shall be equals to the number of source bands. The
SampleDomain at index i is for the band at index sourceBands[i]
in the stream. The range and fill values in the given SampleDomains while have
precedence over any value declared in the image metadata.
domains - The range of valid values and the fill values for each band to be read,
or null for letting the reader infers them from the image metadata.public boolean isSampleConversionAllowed(SampleConversionType type)
true if the given kind of sample conversions is allowed. By default, newly
constructed SpatialImageReadParam instances return false for any given type
(i.e. SpatialImageReader will make its best effort for storing the sample values
with no change). However more efficient storage can be achieved if some changes are allowed
on the sample values. See setSampleConversionAllowed for examples.
type - The kind of conversion.
public void setSampleConversionAllowed(SampleConversionType type,
boolean allowed)
false
value is assigned to all conversion types (i.e. SpatialImageReader will make its best
effort for storing the sample values with no change). However more efficient storage can be
achieved if some changes are allowed on the sample values, for example
adding an offset to signed integers
in order to ensure that all values are positive.
type - The kind of conversion.allowed - Whatever the given kind of conversion is allowed.public Locale getLocale()
null if none.
The default implementation returns the locale used by the ImageReader
given at construction time, or null if none.
getLocale in interface Localizednull if not explicitly defined.public boolean warningOccurred(LogRecord record)
warningOccurred in interface WarningProducerrecord - The warning that occurred.
true if the message has been sent to at least one warning listener,
or false if it has been sent to the logging system as a fallback.public String toString()
toString in class Object
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||