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): seeTLcdEPSGModelReferenceDecoderfor more info. - WKT references (
<filename>.prj): seeTLcdWKTModelReferenceDecoderfor more info. - Luciad encoded model references (
<filename>.ref): seeTLcdModelReferenceDecoderfor 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
ILcd2DBoundsIndexedModelwith a single domain object for an input file. - If the data contains subdatasets, a
ILcdModelTreeNodecontaining multipleILcd2DBoundsIndexedModels 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
ILcdGeodeticReferenceorILcdGridReference. When the image is rotated relative to the axes of the model reference, a fitted (also called "derived") projectedILcdGridReferenceis 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
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddStatusListener(ILcdStatusListener aListener) Registers the given listener so it will receive status events from this source.booleancanDecodeMetadata(String aSourceName) Tells whether this metadata decoder can likely decode metadata for a given source name.booleancanDecodeSource(ILcdDataSource aDataSource) Checks whether this model decoder can decode the data source(s), identified by the passedILcdDataSource.booleancanDecodeSource(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 aTLcdISO19115Metadatainstance.decodeSource(ILcdDataSource aDataSource) Creates a new model from the given data source.List<? extends ILcdDataSource> discoverDataSources(String aPath) Retrieves a set of model-specificILcdDataSourceinstances.Returns the default model reference for decoded models.Returns "GDAL".Returns the model reference decoder that is used for creating model references for decoded models.voidremoveStatusListener(ILcdStatusListener aListener) Removes the specified listener so it is no longer notified.voidsetAllowUnverifiedFormats(boolean aAllow) Allow decoding of formats that have not been verified by Luciad, including formats for which a proper model decoder exists.voidsetDefaultModelReference(ILcdModelReference aDefaultModelReference) Sets the default model reference for decoded models, in case the model reference decoder doesn't provide one.voidsetModelReferenceDecoder(ILcdModelReferenceDecoder aModelReferenceDecoder) Sets the model reference decoder that will be used for creating model references for decoded models.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.luciad.format.metadata.model.ILcdMetadataDecoder
findAndDecodeMetadataMethods 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 thetypeis 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
-
setModelReferenceDecoder
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 referencewill be used.- Parameters:
aModelReferenceDecoder- the new model reference decoder- Since:
- 2025.0
-
getModelReferenceDecoder
Returns the model reference decoder that is used for creating model references for decoded models.- Returns:
- the model reference decoder
- Since:
- 2025.0
-
setDefaultModelReference
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- Since:
- 2025.0
-
getDefaultModelReference
Returns the default model reference for decoded models.- Returns:
- the default model reference
- Since:
- 2025.0
-
getDisplayName
Returns "GDAL".- Specified by:
getDisplayNamein interfaceILcdModelDecoder- Returns:
- "GDAL"
-
canDecodeSource
Description copied from interface:ILcdModelDecoderChecks whether this model decoder can decode the specified data source. It is acceptable for this method to returntruefor a source name whiledecodethrows 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:
canDecodeSourcein interfaceILcdModelDecoder- Parameters:
aSourceName- the data source to be verified; typically a file name or a URL.- Returns:
trueif this decoder can likely decode the data specified by the source name,falseotherwise.- See Also:
-
decode
Description copied from interface:ILcdModelDecoderCreates a new model from the given data source.- Specified by:
decodein interfaceILcdModelDecoder- Parameters:
aSourceName- the data source to be decoded; typically a file name or a URL.- Returns:
- A model containing the decoded data. While
nullis 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:ILcdMetadataDecoderTells 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-nullTLcdISO19115Metadataobject, 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:
canDecodeMetadatain interfaceILcdMetadataDecoder- Parameters:
aSourceName- the source name to decode metadata for- Returns:
trueif this metadata decoder can decode metadata for the given source name,falseotherwise
-
If
-
decodeMetadata
Decodes the metadata from a gdal source and returns aTLcdISO19115Metadatainstance.- Specified by:
decodeMetadatain interfaceILcdMetadataDecoder- Parameters:
aSourceName- a gdal source- Returns:
- a
TLcdISO19115Metadatainstance 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:ILcdModelDecoderRetrieves a set of model-specific
ILcdDataSourceinstances.By default, this method:
- returns a list containing at least a single
TLcdDataSourcethat contains a reference to the supplied path, whenILcdModelDecoder.canDecodeSource(String)returnstruefor the supplied path. - throws an
IOExceptionwhenILcdModelDecoder.canDecodeSource(String)returnsfalsefor 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 usingILcdDataSources, where each measurement layer can be referenced to and decoded separately usingILcdModelDecoder.decodeSource(ILcdDataSource)- Specified by:
discoverDataSourcesin 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
trueforILcdModelDecoder.canDecodeSource(String), it will return a list containing at least a singleILcdDataSource. - Throws:
IOException- If this model decoder returnsfalseforILcdModelDecoder.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:ILcdModelDecoderChecks 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
ILcdDataSourceis aTLcdDataSource. If not, this method returns false. Otherwise, it delegates the source to theILcdModelDecoder.canDecodeSource(String)method.- Specified by:
canDecodeSourcein interfaceILcdModelDecoder- Parameters:
aDataSource- theILcdModelSourceto be verified.- Returns:
trueif this decoder can likely decode the data specified byaDataSource,falseotherwise.- See Also:
-
decodeSource
Description copied from interface:ILcdModelDecoderCreates a new model from the given data source.
By default, this method:
- Throws a
NullPointerExceptionwhen anulldata source is passed. - Delegates to the
ILcdModelDecoder.decode(String)method when aTLcdDataSourceis passed. - Throws an IOException in other case.
- Specified by:
decodeSourcein interfaceILcdModelDecoder- Parameters:
aDataSource- theILcdDataSourceto be decoded.- Returns:
- a model containing the decoded data. While
nullis 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:ILcdStatusSourceRegisters 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
ALcdWeakStatusListenerinstance as status listener.- Specified by:
addStatusListenerin interfaceILcdStatusSource- Parameters:
aListener- The listener to be notified when the status has changed.
-
removeStatusListener
Description copied from interface:ILcdStatusSourceRemoves the specified listener so it is no longer notified.- Specified by:
removeStatusListenerin interfaceILcdStatusSource- Parameters:
aListener- The listener to remove.
-