@LcdService(service=ILcdModelDecoder.class, priority=20000) public class TLcdGDALModelDecoder extends Object implements ILcdModelDecoder, ILcdMetadataDecoder, ILcdStatusSource
setUnlockAllFormats(boolean)
.
This unlocks the formats:
File | Required | Entry point | Description |
---|---|---|---|
*.img | X | X | The ERDAS Imagine file |
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.ILcd2DBoundsIndexedModel
.GDAL
/<type>" as type name.
The type is obtained from the GDAL library driver, and depends on the format.
For example for ERDAS Imagine data the type is "HFA".ILcdImageModelDescriptor
.ILcdGeodeticReference
or ILcdGridReference
.ILcd2DBoundsIndexedModel
.ALcdImage
.
// decode the model TLcdGDALModelDecoder decoder = new TLcdGDALModelDecoder(); ILcdModel model = decoder.decode(aSource); // retrieve the measurements Object domainObject = model.elements().nextElement(); ALcdImage image = ALcdImage.fromDomainObject(domainObject);For more information on how to integrate GDAL decoded raster data into your application, refer to the GDAL developer's guide.
ILcdMetadataDecoder.MetadataWithSource
Modifier and Type | Field and Description |
---|---|
static String |
TYPE_NAME
The first part of the type name of the model descriptor; its value is "GDAL".
|
Constructor and Description |
---|
TLcdGDALModelDecoder() |
Modifier and Type | Method and Description |
---|---|
void |
addStatusListener(ILcdStatusListener aListener)
Registers the given listener so it will receive status events from this source.
|
boolean |
canDecodeMetadata(String aSourceName)
Tells whether this metadata decoder can likely decode metadata for a given source name.
|
boolean |
canDecodeSource(String aSourceName)
Checks whether this model decoder can decode the specified data source.
|
ILcdModel |
decode(String aSourceName)
Creates a new model from the given data source.
|
TLcdISO19115Metadata |
decodeMetadata(String aSourceName)
Decodes the metadata from a gdal source and returns a
TLcdISO19115Metadata instance. |
String |
getDisplayName()
Returns "GDAL".
|
void |
removeStatusListener(ILcdStatusListener aListener)
Removes the specified listener so it is no longer notified.
|
void |
setUnlockAllFormats(boolean aUnlock)
Unlocks decoding of all formats, including the ones for which Luciad has a proper model decoder.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
canDecodeSource, decodeModelMetadata, decodeModelMetadata, decodeSource, discoverDataSources
findAndDecodeMetadata
public static final String TYPE_NAME
GDAL/<type>
, where the type
is obtained from the GDAL library driver and depends on the format.public void setUnlockAllFormats(boolean aUnlock)
aUnlock
- whether or not to unlock decoding of all formatspublic String getDisplayName()
getDisplayName
in interface ILcdModelDecoder
public boolean canDecodeSource(String aSourceName)
ILcdModelDecoder
true
for a source name while decode
throws an exception for that same source name.
For performance reasons, we strongly recommend that this will only be a simple test. For example: check the file extension of a file, but not that the file exists or contains expected content.
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)
public boolean canDecodeMetadata(String aSourceName)
ILcdMetadataDecoder
true
, it is likely that ILcdMetadataDecoder.decodeMetadata(String)
will return a non-null TLcdISO19115Metadata
object,
but it is not a guarantee. The result is optimistic.
false
, it is guaranteed that ILcdMetadataDecoder.decodeMetadata(String)
will throw an exception or return null
.
canDecodeMetadata
in interface ILcdMetadataDecoder
aSourceName
- the source name to decode metadata fortrue
if this metadata decoder can decode metadata for the given source name, false
otherwisepublic TLcdISO19115Metadata decodeMetadata(String aSourceName) throws IOException
TLcdISO19115Metadata
instance.decodeMetadata
in interface ILcdMetadataDecoder
aSourceName
- a gdal sourceTLcdISO19115Metadata
instance which contains paths of all files which are needed to decode the gdal source, null if the metadata can not be decoded.IOException
- if the source can not be foundpublic 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.