Package com.luciad.format.raster
Class TLcdBILModelDecoder
java.lang.Object
com.luciad.format.raster.TLcdBILModelDecoder
- All Implemented Interfaces:
ILcdInputStreamFactoryCapable
,ILcdModelDecoder
@LcdService(service=ILcdModelDecoder.class,
priority=20000)
public class TLcdBILModelDecoder
extends Object
implements ILcdModelDecoder, ILcdInputStreamFactoryCapable
This model decoder decodes Band Interleaved by Line (BIL) raster files.
Input files
File | Required | Entry point | Description | *.BIL | x | x | BIL file containing the band-interleaved image data |
---|---|---|---|
*.HDR | x | x | header file containing image metadata |
*.BLW | x | BIL World file specifying raster bounds |
Model reference
The model reference is obtained from anILcdModelReferenceDecoder
. The default reference decoder set on this
model decoder is based on all model reference decoders annotated with the LcdService
annotation, and can handle
- EPSG references (
<filename>.epsg
): seeTLcdEPSGModelReferenceDecoder
for more info. - WKT references (
<filename>.prj
): seeTLcdWKTModelReferenceDecoder
for more info. - Luciad encoded model references (
<filename>.ref
): seeTLcdModelReferenceDecoder
for more info.
If the HDR or BLW files don't specify raster bounds, they are retrieved from
the bounds
property of this decoder.
The decoder parses the following keywords for determining the BIL file structure:
ncols
intnrows
intnbands
intnbits
intbyteorder [IM]
skipbytes
intbandrowbytes
intlayout bil
xulcorner
double (orulxmap
double)yulcorner
double (orulymap
double)xllcorner
double (orllxmap
double)yllcorner
double (orllymap
double)cellsize
doublexdim
doubleydim
double
Supported file transfer protocols
- This model decoder supports all transfer protocols that are supported by
the
inputStreamFactory
of this decoder.
Model structure
- This model decoder creates a model per BIL file.
- All models returned by this model decoder implement
ILcd2DBoundsIndexedModel
.
Model descriptor
- All models returned by this model decoder have a
TLcdBILModelDescriptor
. - The type name of the model descriptor is the display name of this decoder.
Model elements
- Each decoded model contains one
ILcdRaster
instance.
Useful settings
- The properties
colorModel
,defaultValue
, andforcedTransparentColorIndex
provide some control over the color models that are attached to the decoded rasters.
Sample code
ILcdModelDecoder decoder = new TLcdBILModelDecoder();
ILcdModel model = decoder.decode("image.bil");
Performance tips
- BIL rasters can be large. Precomputing and storing multiple levels
of detail may speed up visualization and some computations. The
TLcdGeoTIFFModelEncoder
can create compressed multilevel GeoTIFF files that can replace the original BIL files.
Thread safety
- The decoding of models is not thread-safe.
- The decoded models are thread-safe for read access.
Known limitations
- The current implementation truncates 3x16-bits RGB data to 3x8-bits.
-
Field Summary
-
Constructor Summary
ConstructorDescriptionCreates a newTLcdBILModelDecoder
, with a globally shared buffer for caching tiles.TLcdBILModelDecoder
(ILcdBuffer aBuffer) Creates a newTLcdBILModelDecoder
.TLcdBILModelDecoder
(ILcdBuffer aBuffer, ILcdModelReference aDefaultModelReference) Creates a newTLcdBILModelDecoder
.TLcdBILModelDecoder
(ILcdBuffer aBuffer, ILcdModelReferenceDecoder aModelReferenceDecoder) Creates a newTLcdBILModelDecoder
.TLcdBILModelDecoder
(ILcdBuffer aBuffer, ILcdModelReference aDefaultModelReference, ILcdBounds aDefaultBounds) Creates a newTLcdBILModelDecoder
.TLcdBILModelDecoder
(ILcdBuffer aBuffer, ILcdModelReference aDefaultModelReference, ILcdBounds aDefaultBounds, ColorModel aColorModel, int aDefaultValue) Creates a newTLcdBILModelDecoder
.TLcdBILModelDecoder
(ILcdBuffer aBuffer, ILcdModelReference aDefaultModelReference, ColorModel aColorModel, int aDefaultValue) Creates a newTLcdBILModelDecoder
. -
Method Summary
Modifier and TypeMethodDescriptionboolean
canDecodeSource
(String aSourceName) Checks whether this decoder can decode the given data.Creates a new model from the given data source.Returns the default bounds for decoded rasters.Returns the default color model for decoded rasters.Returns the default model reference for decoded models.int
Returns the default color or color index that is assigned to decoded rasters.Returns a short, displayable name for the format that is decoded by thisILcdModelDecoder
.int
Returns the index of a color that is made transparent in the gray scale rasters that are decoded.Returns the input stream factory that is used for creating input streams given source names.Deprecated.Returns the model reference decoder that is used for creating model references for decoded models.void
setBounds
(ILcdBounds aBounds) Sets the default bounds for decoded rasters, in case an input data set doesn't provide any.void
setColorModel
(ColorModel aColorModel) Sets the default color model for decoded rasters.void
setDefaultModelReference
(ILcdModelReference aDefaultModelReference) Sets the default model reference for decoded models, in case the model reference decoder doesn't provide one.void
setDefaultValue
(int aDefaultValue) Sets the default color or color index to be assigned to decoded rasters.void
setForcedTransparentColorIndex
(int aForcedTransparentColorIndex) Sets the index of a color that should be made transparent in the gray scale rasters that will be decoded next.void
setInputStreamFactory
(ILcdInputStreamFactory aInputStreamFactory) Sets the input stream factory that will be used for creating input streams given source names.void
setModelReference
(ILcdModelReference aDefaultModelReference) Deprecated.void
setModelReferenceDecoder
(ILcdModelReferenceDecoder aModelReferenceDecoder) Sets the model reference decoder that will be used for creating model references for decoded models.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.luciad.model.ILcdModelDecoder
canDecodeSource, decodeModelMetadata, decodeModelMetadata, decodeSource, discoverDataSources
-
Field Details
-
DEFAULT_DISPLAY_NAME
- See Also:
-
-
Constructor Details
-
TLcdBILModelDecoder
public TLcdBILModelDecoder()Creates a newTLcdBILModelDecoder
, with a globally shared buffer for caching tiles.- See Also:
-
TLcdBILModelDecoder
Creates a newTLcdBILModelDecoder
.- Parameters:
aBuffer
- the buffer in which decoded raster tiles will be cached.
-
TLcdBILModelDecoder
Creates a newTLcdBILModelDecoder
.- Parameters:
aBuffer
- the shared buffer that decoded models will use.aModelReferenceDecoder
- the model reference decoder.
-
TLcdBILModelDecoder
Creates a newTLcdBILModelDecoder
.- Parameters:
aBuffer
- the shared buffer that decoded models will use.aDefaultModelReference
- the default model reference.
-
TLcdBILModelDecoder
public TLcdBILModelDecoder(ILcdBuffer aBuffer, ILcdModelReference aDefaultModelReference, ILcdBounds aDefaultBounds) Creates a newTLcdBILModelDecoder
.- Parameters:
aBuffer
- the shared buffer that decoded models will use.aDefaultModelReference
- the default model reference.aDefaultBounds
- the default raster bounds.
-
TLcdBILModelDecoder
public TLcdBILModelDecoder(ILcdBuffer aBuffer, ILcdModelReference aDefaultModelReference, ColorModel aColorModel, int aDefaultValue) Creates a newTLcdBILModelDecoder
.- Parameters:
aBuffer
- the shared buffer that decoded models will use.aDefaultModelReference
- the default model reference.aColorModel
- the color model for decoded rasters.aDefaultValue
- the default pixel value for decoded rasters.
-
TLcdBILModelDecoder
public TLcdBILModelDecoder(ILcdBuffer aBuffer, ILcdModelReference aDefaultModelReference, ILcdBounds aDefaultBounds, ColorModel aColorModel, int aDefaultValue) Creates a newTLcdBILModelDecoder
.- Parameters:
aBuffer
- the shared buffer that decoded models will use.aDefaultModelReference
- the default model reference.aDefaultBounds
- the default raster bounds.aColorModel
- the color model for decoded rasters.aDefaultValue
- the default pixel value for decoded rasters.
-
-
Method Details
-
setInputStreamFactory
Sets the input stream factory that will be used for creating input streams given source names.- Specified by:
setInputStreamFactory
in interfaceILcdInputStreamFactoryCapable
- Parameters:
aInputStreamFactory
- the input stream factory to be used.
-
getInputStreamFactory
Returns the input stream factory that is used for creating input streams given source names.- Specified by:
getInputStreamFactory
in interfaceILcdInputStreamFactoryCapable
- Returns:
- the input stream factory that is used.
-
setModelReferenceDecoder
Sets the model reference decoder that will be used for creating model references for decoded models. -
getModelReferenceDecoder
Returns the model reference decoder that is used for creating model references for decoded models. The default value supports WKT (*.prj), REF (*.ref), and EPSG (*.epsg).- Returns:
- the model reference decoder used by this decoder
- See Also:
-
setDefaultModelReference
Sets the default model reference for decoded models, in case the model reference decoder doesn't provide one. -
getDefaultModelReference
Returns the default model reference for decoded models. -
setModelReference
Deprecated. -
getModelReference
Deprecated. -
setBounds
Sets the default bounds for decoded rasters, in case an input data set doesn't provide any. -
getBounds
Returns the default bounds for decoded rasters. -
setColorModel
Sets the default color model for decoded rasters. -
getColorModel
Returns the default color model for decoded rasters. -
setDefaultValue
public void setDefaultValue(int aDefaultValue) Sets the default color or color index to be assigned to decoded rasters. -
getDefaultValue
public int getDefaultValue()Returns the default color or color index that is assigned to decoded rasters. -
setForcedTransparentColorIndex
public void setForcedTransparentColorIndex(int aForcedTransparentColorIndex) Sets the index of a color that should be made transparent in the gray scale rasters that will be decoded next. The default is 0. -
getForcedTransparentColorIndex
public int getForcedTransparentColorIndex()Returns the index of a color that is made transparent in the gray scale rasters that are decoded. -
getDisplayName
Description copied from interface:ILcdModelDecoder
Returns a short, displayable name for the format that is decoded by thisILcdModelDecoder
.- Specified by:
getDisplayName
in interfaceILcdModelDecoder
- Returns:
- the displayable name of this
ILcdModelDecoder
.
-
canDecodeSource
Checks whether this decoder can decode the given data. The extension of the file name should be "bil", "hdr", or "blw".- Specified by:
canDecodeSource
in interfaceILcdModelDecoder
- Parameters:
aSourceName
- the name of the file that is to be decoded.- Returns:
true
ifTLcdBILModelDecoder
can decode the data specified by the source name,false
otherwise.- See Also:
-
decode
Description copied from interface:ILcdModelDecoder
Creates a new model from the given data source.- Specified by:
decode
in interfaceILcdModelDecoder
- Parameters:
aSourceName
- the data source to be decoded; typically a file name or a URL.- Returns:
- A model containing the decoded data. While
null
is allowed, implementors are advised to throw an error instead. - Throws:
IOException
- for any exceptions caused by IO problems or invalid data. Since decoding invalid data almost always results in RunTimeExceptions (NullPointerException, IndexOutOfBoundsException, IllegalArgumentException, ...) on unexpected places, implementations are advised to catch RuntimeExceptions in their decode() method, and wrap them into an IOException, as illustrated in the code snippet below.public ILcdModel decode( String aSourceName ) throws IOException { try (InputStream input = fInputStreamFactory.createInputStream(aSourceName)) { // Perform decoding ... } catch (RuntimeException e) { throw new IOException(e); } }
- See Also:
-
.getDefaultModelReference()