@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.
File | Required | Entry point | Description |
---|---|---|---|
*.asc or *.grd | x | x | ESRI ASCII grid format file containing the raster data and meta data |
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
<filename>.epsg
): see TLcdEPSGModelReferenceDecoder
for more info.<filename>.prj
): see TLcdWKTModelReferenceDecoder
for more info.<filename>.ref
): see TLcdModelReferenceDecoder
for more info.inputStreamFactory
of this decoder.ILcd2DBoundsIndexedModel
.TLcdRasterModelDescriptor
.TYPE_NAME
.ALcdImage
(and ILcdRaster
) instance.colorModel
provides some control over the color models that
are attached to the decoded rasters.
ILcdModelDecoder decoder = new TLcdArcInfoASCIIGridModelDecoder();
ILcdModel model = decoder.decode("my_raster.asc");
Modifier and Type | Field and Description |
---|---|
static String |
TYPE_NAME
The
type name which will be used for the decoded models. |
Constructor and Description |
---|
TLcdArcInfoASCIIGridModelDecoder()
Creates a new
TLcdArcInfoASCIIGridModelDecoder , with a globally shared buffer for
caching tiles. |
TLcdArcInfoASCIIGridModelDecoder(ILcdBuffer aBuffer)
Creates a new
TLcdArcInfoASCIIGridModelDecoder . |
Modifier and Type | Method and Description |
---|---|
void |
addStatusListener(ILcdStatusListener aListener)
Registers the given listener so it will receive status events from this source.
|
boolean |
canDecodeSource(String aSourceName)
Checks whether this decoder can decode the given data, based on the extension of the file.
|
ILcdModel |
decode(String aSourceName)
Creates a new model from the given data source.
|
ColorModel |
getColorModel()
Returns the default color model for decoded rasters.
|
ILcdModelReference |
getDefaultModelReference()
Returns the default model reference for decoded models.
|
String |
getDisplayName()
Returns a short, displayable name for the format that is decoded by this
ILcdModelDecoder . |
ILcdInputStreamFactory |
getInputStreamFactory()
Returns the input stream factory that is used.
|
ILcdModelReferenceDecoder |
getModelReferenceDecoder()
Returns the model reference decoder that is used for creating model references for decoded
models.
|
void |
removeStatusListener(ILcdStatusListener aListener)
Removes the specified listener so it is no longer notified.
|
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 |
setInputStreamFactory(ILcdInputStreamFactory aInputStreamFactory)
Sets the input stream factory to be used.
|
void |
setModelReferenceDecoder(ILcdModelReferenceDecoder aModelReferenceDecoder)
Sets the model reference decoder that will be used for creating model references for decoded
models.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
canDecodeSource, decodeModelMetadata, decodeModelMetadata, decodeSource, discoverDataSources
public static final String TYPE_NAME
type name
which will be used for the decoded models.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.
TLcdSharedBuffer.getBufferInstance()
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.
aBuffer
- the buffer in which decoded raster tiles will be cached.public void addStatusListener(ILcdStatusListener aListener)
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.
addStatusListener
in interface ILcdStatusSource
aListener
- The listener to be notified when the status has changed.public void removeStatusListener(ILcdStatusListener aListener)
ILcdStatusSource
removeStatusListener
in interface ILcdStatusSource
aListener
- The listener to remove.public void setInputStreamFactory(ILcdInputStreamFactory aInputStreamFactory)
setInputStreamFactory
in interface ILcdInputStreamFactoryCapable
aInputStreamFactory
- the input stream factory to be used.NullPointerException
- if the specified input stream factory is null
public ILcdInputStreamFactory getInputStreamFactory()
ILcdInputStreamFactoryCapable
getInputStreamFactory
in interface ILcdInputStreamFactoryCapable
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.
aModelReferenceDecoder
- the new model reference decodergetModelReferenceDecoder()
public ILcdModelReferenceDecoder getModelReferenceDecoder()
setModelReferenceDecoder(com.luciad.model.ILcdModelReferenceDecoder)
public void setDefaultModelReference(ILcdModelReference aDefaultModelReference)
aDefaultModelReference
- the new default model referencegetDefaultModelReference()
public ILcdModelReference getDefaultModelReference()
setDefaultModelReference(com.luciad.model.ILcdModelReference)
public void setColorModel(ColorModel aColorModel)
aColorModel
- the new default color modelgetColorModel()
public ColorModel getColorModel()
Returns the default color model for decoded rasters.
By default, the ColorModel
is null
.
setColorModel(java.awt.image.ColorModel)
public String getDisplayName()
ILcdModelDecoder
ILcdModelDecoder
.getDisplayName
in interface ILcdModelDecoder
ILcdModelDecoder
.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".
canDecodeSource
in interface ILcdModelDecoder
aSourceName
- the data source to be verified; typically a file name or a URL.true
if this decoder can likely decode the data specified by the source name, false
otherwise.ILcdModelDecoder.decode(String)
,
ILcdModelDecoder.decodeModelMetadata(String)
public ILcdModel decode(String aSourceName) throws IOException
ILcdModelDecoder
decode
in interface ILcdModelDecoder
aSourceName
- the data source to be decoded; typically a file name or a URL.null
is allowed, implementors are advised to throw an error instead.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);
}
}
InterruptedIOException
- When the thread on which this method is called is interrupted: it is recommended to stop the decoding
and throw an InterruptedIOException
.
This same exception can also be used if the decoder shows UI to the user, and the user cancels the decoding
through the UI.ILcdModelDecoder.canDecodeSource(String)