Class TLcdGDALModelDecoder
- All Implemented Interfaces:
ILcdMetadataDecoder
,ILcdModelDecoder
,ILcdStatusSource
- ACE2 (*.ace2)
- Arc/Info Binary Grid (*.adf)
- Azavea Raster Grid (*.arg, *.json)
- Magellan BLX Topo (*.blx, *.xlb)
- BSB Nautical Chart (*.kap)
- VTP Binary Terrain Format (*.bt)
- First Generation USGS DOQ (*.doq)
- ERDAS Imagine (*.img)
- ENVI .hdr Labelled Raster (*.dat)
- EOSAT FAST Format (*.fst)
- Golden Software ASCII Grid (*.grd)
- Golden Software Binary Grid (*.grd)
- Golden Software Surfer 7 Binary Grid (*.grd)
- New Labelled USGS DOQ (*.doq, *.nws)
- GXF - Grid eXchange File (*.gxf)
- NOAA .gtx vertical datum shift (*.gtx)
- HF2/HFZ heightfield raster (*.hf2)
- SGI Image Format (*.bw, *.rgb, *.rgba, *.sgi)
- Snow Data Assimilation System (*.hdr)
- SRTM HGT Format (*.hgt)
- GDAL Virtual (*.vrt)
- GeospatialPDF (*.pdf)
setAllowUnverifiedFormats(boolean)
. Since this behaviour is unverified the decoder might not succeed in decoding the source.
A raster data file is typically a satellite image which can represent either a measurement (e.g. elevation) or true color (e.g. RGB).
It can also be a multi or hyper spectral image as well.
Input Files
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
- 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.
Supported file transfer protocols
- This model decoder decodes data from a file system.
Model structure
- If the data does not contain subdatasets, this model decoder creates an
ILcd2DBoundsIndexedModel
with a single domain object for an input file. - If the data contains subdatasets, a
ILcdModelTreeNode
containing multipleILcd2DBoundsIndexedModel
s will be decoded.
Model descriptor
- The returned model has a model descriptor with "
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". - The model descriptor of the model is a
ILcdImageModelDescriptor
. - The decoded source name is the display name of the model descriptor.
Model reference
- The returned model has a reference which implements either
ILcdGeodeticReference
orILcdGridReference
. When the image is rotated relative to the axes of the model reference, a fitted (also called "derived") projectedILcdGridReference
is returned.
Model elements
- The returned model is a
ILcd2DBoundsIndexedModel
. - The returned model has only one element and it is an
ALcdImage
.
Thread safety
- The decoding of models is thread-safe, as long as no properties are changed during the decoding.
- The decoded models are thread-safe for read access.
Sample code
// 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.
- Since:
- 2016.0
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.luciad.format.metadata.model.ILcdMetadataDecoder
ILcdMetadataDecoder.MetadataWithSource
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
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
(ILcdDataSource aDataSource) Checks whether this model decoder can decode the data source(s), identified by the passedILcdDataSource
.boolean
canDecodeSource
(String aSourceName) Checks whether this model decoder can decode the specified data source.Creates a new model from the given data source.decodeMetadata
(String aSourceName) Decodes the metadata from a gdal source and returns aTLcdISO19115Metadata
instance.decodeSource
(ILcdDataSource aDataSource) Creates a new model from the given data source.List
<? extends ILcdDataSource> discoverDataSources
(String aPath) Retrieves a set of model-specificILcdDataSource
instances.Returns "GDAL".void
removeStatusListener
(ILcdStatusListener aListener) Removes the specified listener so it is no longer notified.void
setAllowUnverifiedFormats
(boolean aAllow) Allow decoding of formats that have not been verified by Luciad, including formats for which a proper model decoder exists.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.luciad.format.metadata.model.ILcdMetadataDecoder
findAndDecodeMetadata
Methods inherited from interface com.luciad.model.ILcdModelDecoder
decodeModelMetadata, decodeModelMetadata
-
Field Details
-
TYPE_NAME
The first part of the type name of the model descriptor; its value is "GDAL". The actual type name isGDAL/<type>
, where thetype
is obtained from the GDAL library driver and depends on the format.- See Also:
-
-
Constructor Details
-
TLcdGDALModelDecoder
public TLcdGDALModelDecoder()
-
-
Method Details
-
setAllowUnverifiedFormats
public void setAllowUnverifiedFormats(boolean aAllow) Allow decoding of formats that have not been verified by Luciad, including formats for which a proper model decoder exists. The default is off, unless the default itself has been overridden using the system property "com.luciad.format.gdal.allowUnverifiedFormats".- Parameters:
aAllow
- whether or not to allow decoding of unverified formats- Since:
- 2024.0
-
getDisplayName
Returns "GDAL".- Specified by:
getDisplayName
in interfaceILcdModelDecoder
- Returns:
- "GDAL"
-
canDecodeSource
Description copied from interface:ILcdModelDecoder
Checks whether this model decoder can decode the specified data source. It is acceptable for this method to returntrue
for a source name whiledecode
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.
- Specified by:
canDecodeSource
in interfaceILcdModelDecoder
- 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
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:
-
canDecodeMetadata
Description copied from interface:ILcdMetadataDecoder
Tells whether this metadata decoder can likely decode metadata for a given source name.-
If
true
, it is likely thatILcdMetadataDecoder.decodeMetadata(String)
will return a non-nullTLcdISO19115Metadata
object, but it is not a guarantee. The result is optimistic. -
If
false
, it is guaranteed thatILcdMetadataDecoder.decodeMetadata(String)
will throw an exception or returnnull
.
- Specified by:
canDecodeMetadata
in interfaceILcdMetadataDecoder
- Parameters:
aSourceName
- the source name to decode metadata for- Returns:
true
if this metadata decoder can decode metadata for the given source name,false
otherwise
-
If
-
decodeMetadata
Decodes the metadata from a gdal source and returns aTLcdISO19115Metadata
instance.- Specified by:
decodeMetadata
in interfaceILcdMetadataDecoder
- Parameters:
aSourceName
- a gdal source- Returns:
- a
TLcdISO19115Metadata
instance which contains paths of all files which are needed to decode the gdal source, null if the metadata can not be decoded. - Throws:
IOException
- if the source can not be found
-
discoverDataSources
Description copied from interface:ILcdModelDecoder
Retrieves a set of model-specific
ILcdDataSource
instances.By default, this method:
- returns a list containing at least a single
TLcdDataSource
that contains a reference to the supplied path, whenILcdModelDecoder.canDecodeSource(String)
returnstrue
for the supplied path. - throws an
IOException
whenILcdModelDecoder.canDecodeSource(String)
returnsfalse
for the supplied path.
ILcdDataSource
, for instance, if the path references a collection of data sources.An example where this is useful is for container formats, such as NetCDF. A NetCDF file can contain multiple measurement layers. This
ILcdModelDecoder.discoverDataSources(String)
method allows you to distinguish between them usingILcdDataSource
s, where each measurement layer can be referenced to and decoded separately usingILcdModelDecoder.decodeSource(ILcdDataSource)
- Specified by:
discoverDataSources
in interfaceILcdModelDecoder
- Parameters:
aPath
- A path to the data source to be decoded; typically a file path or a URL.- Returns:
- If this model decoder returns
true
forILcdModelDecoder.canDecodeSource(String)
, it will return a list containing at least a singleILcdDataSource
. - Throws:
IOException
- If this model decoder returnsfalse
forILcdModelDecoder.canDecodeSource(String)
or if any exceptions caused by IO problems or invalid data occur.
- returns a list containing at least a single
-
canDecodeSource
Description copied from interface:ILcdModelDecoder
Checks whether this model decoder can decode the data source(s), identified by the passed
ILcdDataSource
.For performance reasons, we strongly recommend that this will only be a simple test. For example: check the instance class of
aDataSource
, or check the file extension if it is aTLcdDataSource
.The default implementation of this method will check if the given
ILcdDataSource
is aTLcdDataSource
. If not, this method returns false. Otherwise, it delegates the source to theILcdModelDecoder.canDecodeSource(String)
method.- Specified by:
canDecodeSource
in interfaceILcdModelDecoder
- Parameters:
aDataSource
- theILcdModelSource
to be verified.- Returns:
true
if this decoder can likely decode the data specified byaDataSource
,false
otherwise.- See Also:
-
decodeSource
Description copied from interface:ILcdModelDecoder
Creates a new model from the given data source.
By default, this method:
- Throws a
NullPointerException
when anull
data source is passed. - Delegates to the
ILcdModelDecoder.decode(String)
method when aTLcdDataSource
is passed. - Throws an IOException in other case.
- Specified by:
decodeSource
in interfaceILcdModelDecoder
- Parameters:
aDataSource
- theILcdDataSource
to be decoded.- 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 decodeSource(ILcdDataSource aDataSource) throws IOException { try { // Perform decoding ... } catch (RuntimeException e) { throw new IOException(e); } }
- See Also:
- Throws a
-
addStatusListener
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 interfaceILcdStatusSource
- Parameters:
aListener
- The listener to be notified when the status has changed.
-
removeStatusListener
Description copied from interface:ILcdStatusSource
Removes the specified listener so it is no longer notified.- Specified by:
removeStatusListener
in interfaceILcdStatusSource
- Parameters:
aListener
- The listener to remove.
-