Class TLcdArcInfoASCIIGridModelDecoder

java.lang.Object
com.luciad.format.raster.TLcdArcInfoASCIIGridModelDecoder
All Implemented Interfaces:
ILcdInputStreamFactoryCapable, ILcdModelDecoder, ILcdStatusSource

@LcdService(service=ILcdModelDecoder.class, priority=20000) public class TLcdArcInfoASCIIGridModelDecoder extends Object implements ILcdModelDecoder, ILcdInputStreamFactoryCapable, ILcdStatusSource

This model decoder decodes ESRI ArcInfo ASCII Grid format (*.asc, *.grd) raster files.

Input files

File Required Entry point Description
*.asc or *.grd x x ESRI ASCII grid format file containing the raster data and meta data

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.

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 ASCII grid format file.
  • All models returned by this model decoder implement ILcd2DBoundsIndexedModel.

Model descriptor

Model elements

  • Each decoded model contains one object: an ALcdImage (and ILcdRaster) instance.

Useful settings

  • The property colorModel provides some control over the color models that are attached to the decoded rasters.

Sample code


 ILcdModelDecoder decoder = new TLcdArcInfoASCIIGridModelDecoder();

 ILcdModel model = decoder.decode("my_raster.asc");
 

Thread safety

  • The decoding of models is not thread-safe.
  • The decoded models are thread-safe for read access.
Since:
2013.1
  • Field Details

  • Constructor Details

    • TLcdArcInfoASCIIGridModelDecoder

      public TLcdArcInfoASCIIGridModelDecoder()

      Creates a new TLcdArcInfoASCIIGridModelDecoder, with a globally shared buffer for caching tiles.

      By default, the model decoder will use a default ILcdInputStreamFactory and ILcdModelReferenceDecoder. Use the corresponding setters if you want to change this.

      See Also:
    • TLcdArcInfoASCIIGridModelDecoder

      public TLcdArcInfoASCIIGridModelDecoder(ILcdBuffer aBuffer)

      Creates a new TLcdArcInfoASCIIGridModelDecoder.

      By default, the model decoder will use a default ILcdInputStreamFactory and ILcdModelReferenceDecoder. Use the corresponding setters if you want to change this.

      Parameters:
      aBuffer - the buffer in which decoded raster tiles will be cached.
  • Method Details

    • addStatusListener

      public void addStatusListener(ILcdStatusListener aListener)
      Description copied from interface: ILcdStatusSource

      Registers the given listener so it will receive status events from this source.

      In case you need to register a listener which keeps a reference to an object with a shorter life-time than this status source, you can use a ALcdWeakStatusListener instance as status listener.

      Specified by:
      addStatusListener in interface ILcdStatusSource
      Parameters:
      aListener - The listener to be notified when the status has changed.
    • removeStatusListener

      public void removeStatusListener(ILcdStatusListener aListener)
      Description copied from interface: ILcdStatusSource
      Removes the specified listener so it is no longer notified.
      Specified by:
      removeStatusListener in interface ILcdStatusSource
      Parameters:
      aListener - The listener to remove.
    • setInputStreamFactory

      public void setInputStreamFactory(ILcdInputStreamFactory aInputStreamFactory)
      Sets the input stream factory to be used.
      Specified by:
      setInputStreamFactory in interface ILcdInputStreamFactoryCapable
      Parameters:
      aInputStreamFactory - the input stream factory to be used.
      Throws:
      NullPointerException - if the specified input stream factory is null
    • getInputStreamFactory

      public ILcdInputStreamFactory getInputStreamFactory()
      Description copied from interface: ILcdInputStreamFactoryCapable
      Returns the input stream factory that is used.
      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. When the model reference decoder is not set, or when it cannot create a model reference for a certain source, the default model reference will be used.

      Parameters:
      aModelReferenceDecoder - the new model reference decoder
      See Also:
    • getModelReferenceDecoder

      public ILcdModelReferenceDecoder getModelReferenceDecoder()
      Returns the model reference decoder that is used for creating model references for decoded models.
      Returns:
      the model reference 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.
      Parameters:
      aDefaultModelReference - the new default model reference
      See Also:
    • getDefaultModelReference

      public ILcdModelReference getDefaultModelReference()
      Returns the default model reference for decoded models.
      Returns:
      the default model reference
      See Also:
    • setColorModel

      public void setColorModel(ColorModel aColorModel)
      Sets the default color model for decoded rasters.
      Parameters:
      aColorModel - the new default color model
      See Also:
    • getColorModel

      public ColorModel getColorModel()

      Returns the default color model for decoded rasters.

      By default, the ColorModel is null.

      Returns:
      the default color model
      See Also:
    • 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, based on the extension of the file. The extension of the file name should be "asc" or "grd".

      Specified by:
      canDecodeSource in interface ILcdModelDecoder
      Parameters:
      aSourceName - the data source to be verified; typically a file name or a URL.
      Returns:
      true if this decoder can likely 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: