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 an ILcdModelReferenceDecoder. The default reference decoder set on this model decoder is based on all model reference decoders annotated with the LcdService annotation, and can handle If this fails, the decoder's default model reference is returned. Unless set by the user, the default model reference is null.

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 int
  • nrows int
  • nbands int
  • nbits int
  • byteorder [IM]
  • skipbytes int
  • bandrowbytes int
  • layout bil
The decoder parses the following optional keywords for determining the georeference bounds:
  • xulcorner double (or ulxmap double)
  • yulcorner double (or ulymap double)
  • xllcorner double (or llxmap double)
  • yllcorner double (or llymap double)
  • cellsize double
  • xdim double
  • ydim double
The keywords are case-insensitive. Other keywords are ignored.

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, and forcedTransparentColorIndex 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 Details

  • Constructor Details

    • TLcdBILModelDecoder

      public TLcdBILModelDecoder()
      Creates a new TLcdBILModelDecoder, with a globally shared buffer for caching tiles.
      See Also:
    • TLcdBILModelDecoder

      public TLcdBILModelDecoder(ILcdBuffer aBuffer)
      Creates a new TLcdBILModelDecoder.
      Parameters:
      aBuffer - the buffer in which decoded raster tiles will be cached.
    • TLcdBILModelDecoder

      public TLcdBILModelDecoder(ILcdBuffer aBuffer, ILcdModelReferenceDecoder aModelReferenceDecoder)
      Creates a new TLcdBILModelDecoder.
      Parameters:
      aBuffer - the shared buffer that decoded models will use.
      aModelReferenceDecoder - the model reference decoder.
    • TLcdBILModelDecoder

      public TLcdBILModelDecoder(ILcdBuffer aBuffer, ILcdModelReference aDefaultModelReference)
      Creates a new TLcdBILModelDecoder.
      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 new TLcdBILModelDecoder.
      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 new TLcdBILModelDecoder.
      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 new TLcdBILModelDecoder.
      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

      public void setInputStreamFactory(ILcdInputStreamFactory aInputStreamFactory)
      Sets the input stream factory that will be used for creating input streams given source names.
      Specified by:
      setInputStreamFactory in interface ILcdInputStreamFactoryCapable
      Parameters:
      aInputStreamFactory - the input stream factory to be used.
    • getInputStreamFactory

      public ILcdInputStreamFactory getInputStreamFactory()
      Returns the input stream factory that is used for creating input streams given source names.
      Specified by:
      getInputStreamFactory in interface ILcdInputStreamFactoryCapable
      Returns:
      the input stream factory that is used.
    • setModelReferenceDecoder

      public void setModelReferenceDecoder(ILcdModelReferenceDecoder aModelReferenceDecoder)
      Sets the model reference decoder that will be used for creating model references for decoded models.
    • getModelReferenceDecoder

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

      public void setDefaultModelReference(ILcdModelReference aDefaultModelReference)
      Sets the default model reference for decoded models, in case the model reference decoder doesn't provide one.
    • getDefaultModelReference

      public ILcdModelReference getDefaultModelReference()
      Returns the default model reference for decoded models.
    • setModelReference

      public void setModelReference(ILcdModelReference aDefaultModelReference)
    • getModelReference

      public ILcdModelReference getModelReference()
      Deprecated.
    • setBounds

      public void setBounds(ILcdBounds aBounds)
      Sets the default bounds for decoded rasters, in case an input data set doesn't provide any.
    • getBounds

      public ILcdBounds getBounds()
      Returns the default bounds for decoded rasters.
    • setColorModel

      public void setColorModel(ColorModel aColorModel)
      Sets the default color model for decoded rasters.
    • getColorModel

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

      public String getDisplayName()
      Description copied from interface: ILcdModelDecoder
      Returns a short, displayable name for the format that is decoded by this ILcdModelDecoder.
      Specified by:
      getDisplayName in interface ILcdModelDecoder
      Returns:
      the displayable name of this ILcdModelDecoder.
    • canDecodeSource

      public boolean canDecodeSource(String aSourceName)
      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 interface ILcdModelDecoder
      Parameters:
      aSourceName - the name of the file that is to be decoded.
      Returns:
      true if TLcdBILModelDecoder can decode the data specified by the source name, false otherwise.
      See Also:
    • decode

      public ILcdModel decode(String aSourceName) throws IOException
      Description copied from interface: ILcdModelDecoder
      Creates a new model from the given data source.
      Specified by:
      decode in interface ILcdModelDecoder
      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: