@Deprecated public class TLcdGRIB2ModelDecoder extends Object implements ILcdModelDecoder, ILcdInputStreamFactoryCapable
File | Required | Entry point | Description |
---|---|---|---|
*.grib2 *.grb2 |
x | x | GRIB file containing one or more meteorological rasters |
inputStreamFactory
of this decoder.ILcd2DBoundsIndexedModel
if only
one dataset was included.ILcdModelContainer
containing implementations for each included dataset.TLcdGRIB2ModelDescriptor
. ILcdModelContainer
, the number of rasters equals its model countcolorModel
allows to override the default
16-bits index color that is attached to the decoded rasters, since
GRIB files don't contain any color information. Note that the indexing
must be based on the internal GRIB values, not on the actual values.CreateModelTreeNodes
allows to choose the ILcdModelContainer implementation for
GRIB2 formats containing multiple datatsets. If this property is true, the model decoder generates an
ILcdModelTreeNode
implementationThe actual value of a parameter can be calculated with the formula:
Y * 10D = R + (X*2E)
where
Each GRIB2 format can contain one or multiple rasters. If a file contains only one raster, the model decoder
generates one instance of a TLcdBoundsIndexedModel. When a GRIB2 file contains multiple rasters, the decoder
generates a model list or a model tree, depending on the property createModelTreeNodes
Note that this decoder will only decode the first message of a GRIB2 file
that contains multiple messages (called a bulletin).
To decode all messages in a bulletin, use TLcdGRIBBulletinModelDecoder
.
The structure of the model and the model descriptor depend on the number of datasets included in the format.
The decoded model is very similar to a decoded GRIB1 file, except for some additional meta data. The decimal scale factor, the reference value and the binary scale factor, and other raster specific properties are configured. The model descriptor contains one product definition.
The decoded model contains multiple rasters and therefore it is
not possible to assign values to the raster properties in the TLcdGRIBModelDescriptor
. In this case the
model
decoder generates for each raster a model and a TLcdGRIB2ModelDescriptor
. This model descriptor
contains the raster specific properties.
This type of file is typically used for wind information.
One of the rasters typically contains the wind direction and the other raster contains the wind speed. In
order to display this information in one layer you can define an instance of a TLcdMultivaluedRaster
.
ILcdModelContainer model_container = ((ILcdModelContainer)model); ILcdModel u_model = model_container.getModel( 0 );
ILcdModel v_model = model_container.getModel( 1 );
ILcdRaster[] rasters =
{ ( ILcdRaster ) u_model.elements().nextElement(), ( ILcdRaster )v_model.elements().nextElement() };
// Create a multi-valued raster that contains both rasters.
TLcdMultivaluedRaster uv_raster = new TLcdMultivaluedRaster( rasters );
// Create a new model.
TLcd2DBoundsIndexedModel uv_model = new TLcd2DBoundsIndexedModel();
// Create an array containing the model descriptors.
TLcdRasterModelDescriptor[] descriptors =
{ ( TLcdRasterModelDescriptor ) u_model.getModelDescriptor(),
( TLcdRasterModelDescriptor ) v_model.getModelDescriptor()};
TLcdMultivaluedRasterModelDescriptor uv_descriptor =
new TLcdMultivaluedRasterModelDescriptor(u_model.getModelDescriptor().getSourceName(),
u_model.getModelDescriptor().getDisplayName(),
u_model.getModelDescriptor().getTypeName(),
descriptors );
uv_model.setModelDescriptor( uv_descriptor );
uv_model.setModelReference( u_model.getModelReference() );
uv_model.addElement( uv_raster, ILcdFireEventMode.NO_EVENT );
addParameterTable(TLcdGRIB2ParameterTable, boolean)
and addCategoryTable(TLcdGRIB2CategoryTable)
before decoding the GRIB2 file with the customized category and/or parameter.Constructor and Description |
---|
TLcdGRIB2ModelDecoder()
Deprecated.
Creates a new
TLcdGRIB2ModelDecoder , with a globally shared
buffer for caching tiles. |
TLcdGRIB2ModelDecoder(ILcdBuffer aBuffer)
Deprecated.
Creates a new
TLcdGRIB2ModelDecoder . |
Modifier and Type | Method and Description |
---|---|
void |
addCategoryTable(TLcdGRIB2CategoryTable aCategoryTable)
Deprecated.
Adds a category table.
|
void |
addCategoryTable(TLcdGRIB2CategoryTable aCategoryTable,
boolean aMatchCenter)
Deprecated.
Adds a category table.
|
void |
addParameterTable(TLcdGRIB2ParameterTable aParameterTable)
Deprecated.
Adds a parameter table.
|
void |
addParameterTable(TLcdGRIB2ParameterTable aParameterTable,
boolean aMatchCenter)
Deprecated.
Adds a parameter table.
|
boolean |
canDecodeSource(String aSourceName)
Deprecated.
Checks whether this model decoder can decode the specified data source.
|
ILcdModel |
decode(String aSourceName)
Deprecated.
Creates a new model from the given data source.
|
ColorModel |
getColorModel()
Deprecated.
Returns the color model that is attached by default to the decoded rasters.
|
String |
getDefaultExtension()
Deprecated.
Gets the default file extension of GRIB messages.
|
TLcdGRIB2DisciplineTable |
getDisciplineTable()
Deprecated.
Returns the discipline table.
|
String |
getDisplayName()
Deprecated.
Returns a short, displayable name for the format that is decoded by this
ILcdModelDecoder . |
ILcdInputStreamFactory |
getInputStreamFactory()
Deprecated.
Returns the input stream factory that is used for creating input streams given source names.
|
int |
getSampleStrategy()
Deprecated.
Returns the sampling strategy that is used for displaying raster data.
|
boolean |
isCreateModelTreeNodes()
Deprecated.
Returns
true if the decoder creates model tree nodes for GRIB files with multiple datasets,
false if the decoder creates model lists for GRIB files with multiple datasets. |
void |
removeCategoryTable(TLcdGRIB2CategoryTable aCategoryTable)
Deprecated.
Removes a category table.
|
void |
removeParameterTable(TLcdGRIB2ParameterTable aParameterTable)
Deprecated.
Removes a parameter table.
|
void |
setColorModel(ColorModel aColorModel)
Deprecated.
Sets the color model that is attached by default to the decoded rasters.
|
void |
setCreateModelTreeNodes(boolean aCreateModelTreeNodes)
Deprecated.
Sets the behavior of the decoder when GRIB files contain multiple datasets.
|
void |
setDisciplineTable(TLcdGRIB2DisciplineTable aDisciplineTable)
Deprecated.
Sets the discipline table.
|
void |
setInputStreamFactory(ILcdInputStreamFactory aInputStreamFactory)
Deprecated.
Sets the input stream factory that is used for creating input streams given source names.
|
void |
setSampleStrategy(int aSampleStrategy)
Deprecated.
Sets the sampling strategy that is used for displaying raster data.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
canDecodeSource, decodeModelMetadata, decodeModelMetadata, decodeSource, discoverDataSources
public TLcdGRIB2ModelDecoder()
TLcdGRIB2ModelDecoder
, with a globally shared
buffer for caching tiles.TLcdSharedBuffer.getBufferInstance()
public TLcdGRIB2ModelDecoder(ILcdBuffer aBuffer)
TLcdGRIB2ModelDecoder
.aBuffer
- the shared buffer that decoded models use.public void setInputStreamFactory(ILcdInputStreamFactory aInputStreamFactory)
setInputStreamFactory
in interface ILcdInputStreamFactoryCapable
aInputStreamFactory
- The input stream factory to be used.getInputStreamFactory()
public ILcdInputStreamFactory getInputStreamFactory()
getInputStreamFactory
in interface ILcdInputStreamFactoryCapable
setInputStreamFactory(com.luciad.io.ILcdInputStreamFactory)
public void addCategoryTable(TLcdGRIB2CategoryTable aCategoryTable)
aCategoryTable
- the parameter table to add.addCategoryTable(TLcdGRIB2CategoryTable, boolean)
public void addParameterTable(TLcdGRIB2ParameterTable aParameterTable)
aParameterTable
- the parameter table to add.addCategoryTable(TLcdGRIB2CategoryTable, boolean)
public void addCategoryTable(TLcdGRIB2CategoryTable aCategoryTable, boolean aMatchCenter)
aCategoryTable
- the parameter table to add.aMatchCenter
- a boolean flag that indicates if the table version, center ID and subcenter ID have to match
in order for
this table to be used.public void addParameterTable(TLcdGRIB2ParameterTable aParameterTable, boolean aMatchCenter)
aParameterTable
- the parameter table to add.aMatchCenter
- a boolean flag that indicates if the table version, center ID and subcenter ID have to
match
in order
for this table to be used.public void setDisciplineTable(TLcdGRIB2DisciplineTable aDisciplineTable)
aDisciplineTable
- The discipline table to be used.getDisciplineTable()
public TLcdGRIB2DisciplineTable getDisciplineTable()
setDisciplineTable(TLcdGRIB2DisciplineTable)
public void removeCategoryTable(TLcdGRIB2CategoryTable aCategoryTable)
aCategoryTable
- the parameter table to remove.public void removeParameterTable(TLcdGRIB2ParameterTable aParameterTable)
aParameterTable
- the parameter table to remove.public void setColorModel(ColorModel aColorModel)
null
.aColorModel
- an 8-bit or 16-bit IndexColorModel that is compatible with the GRIB data to be decoded.getColorModel()
public ColorModel getColorModel()
setColorModel(java.awt.image.ColorModel)
public void setSampleStrategy(int aSampleStrategy)
aSampleStrategy
- one of getSampleStrategy()
public int getSampleStrategy()
setSampleStrategy(int)
public String getDefaultExtension()
public String getDisplayName()
ILcdModelDecoder
ILcdModelDecoder
.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 the given file name has extension "grb2" or "grib2"
(possibly extended with ".gz" or ".zip").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 isCreateModelTreeNodes()
true
if the decoder creates model tree nodes for GRIB files with multiple datasets,
false
if the decoder creates model lists for GRIB files with multiple datasets.true
if decoder creates model tree nodes for GRIB files with multiple datasets.setCreateModelTreeNodes(boolean)
public void setCreateModelTreeNodes(boolean aCreateModelTreeNodes)
aCreateModelTreeNodes
- true
if the decoder should create model tree nodes,
false
if it should create model lists.isCreateModelTreeNodes()