Class TLcdNITFModelDecoder
- All Implemented Interfaces:
ILcdInputStreamFactoryCapable,ILcdModelDecoder
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.
setAllowOrthographicReferencing(boolean)setMaximumResidualTiePointError(double)setRasterReferencer(com.luciad.format.raster.reference.ILcdRasterReferencer)
null).
The decoder supports the following optional Tagged Record Extensions:- BLOCKA, which contains the image corner locations at a higher precision than the one in the standard NITF header.
- RPC00B, which specifies rational function polynomial coefficients and normalization parameters that define the physical relationship between image coordinates and ground coordinates.
- SENSRB, providing information about the imaging sensor and its installation (geographical location, position relative to the aircraft, yaw, pitch and roll angles, etc).
Input files
The decoder supports decoding of NITF (*.ntf), NSF (*.nsf) and NSIF (*.nsif)
files, as well as any supported CADRG frame file. Extensions for these files are a concatenation
of a data series code and a zone code. See TLcdCADRGModelDecoder for more info.
Supported file transfer protocols
- This model decoder supports all transfer protocols that are supported by
the
inputStreamFactoryof this decoder.
Model structure
- This model decoder creates a model per raster data set.
- All models returned by this model decoder implement
ILcd2DBoundsIndexedModel. - If the
separateGraphicsproperty is set totrue, models that contain vector graphic segments also implementILcdModelTreeNode. The vector data are then returned in model tree nodes, one per graphic segment. The model tree nodes also implementILcd2DBoundsIndexedModel.
Model descriptor
- All models returned by this model decoder have a
TLcdNITFModelDescriptor. - The type name of the model descriptor is the display name of this decoder.
Model reference
- If the NITF file has an RPC00B (Rapid Positioning Capability) tagged record extension,
the returned reference is an
ILcdGridReferenceconstructed from the RPC parameters (see the RPC00B specifications). The datum of the reference is WGS84. - If the NITF file has a SENSRB tagged record extension, the returned reference is an
ILcdGridReferenceconstructed from the SENSRB parameters. The datum of the reference is WGS84. - If the NITF
ICORDSelement is set, the returned model reference can be anILcdGeodeticReferenceor aTLcdUTMGrid. constructed from theICORDSelement. - If none of the above is available, the user-defined model reference decoder and the default model reference are tried (in this order).
Model elements
- Raster data are decoded as implementation of
ALcdImageand (ILcdRaster) elements. - Vector data in graphic segments are decoded as
ILcdShapeelements, as specified byTLcdCGMModelDecoder. By default, the vector data are decoded as elements of the main model. If theseparateGraphicsproperty is set totrue, they are decoded as elements of model tree nodes of the main model, with one model tree node per graphic segment.
Useful settings
- If vector data from graphic segments are not required, they can be
skipped with the
ignoreGraphicsproperty.
Sample code
ILcdModelDecoder decoder = new TLcdNITFModelDecoder();
ILcdModel model = decoder.decode("raster.ntf");
Performance tips
- NITF rasters can be large. Precomputing and storing multiple levels
of detail may speed up visualization and some computations. The
TLcdGeoTIFFModelEncodercan create compressed and tiled multilevel GeoTIFF files that can replace the original NITF files.
Thread safety
- The decoding of models is not thread-safe.
- The decoded models and elements are thread-safe for read access, on the condition that a thread-safe buffer is used.
Supported versions and specifications
- National Imagery Transmission Format Version 2.1 (NITF, MIL-STD-2500C, 01 May 2006)
- NATO Secondary Imagery Format (NSIF, STANAG No. 4545, 27 September 1998)
- Registered Data Values for Raster Product Format (MIL-STD-2411-1, 30 August 1994)
- Integration of Raster Product Format Files into the National Imagery Transmission Format (MIL-STD-2411-2, 26 August 1994)
- Vector Quantization Decompression for the National Imagery Transmission Format (MIL-STD-188-199, 27 June 1994)
- Compressed ARC Digitized Raster Graphics (CADRG, MIL-C-89038, 6 October 1994)
- Compressed ARC Digitized Raster Graphics (CADRG, MIL-PRF-89038, 6 October 1994)
- Controlled Image Base (CIB, MIL-C-89041, 15 May 1995)
- Controlled Image Base (CIB, MIL-PRF-89041, 15 May 1995)
- Joint Photographic Experts Group (JPEG) Image Compression for the National Imagery Transmission Format (MIL-STD-188-198A, 15 December 1993)
- The Compendium of Controlled Extensions (CE) for the National Imagery Transmission Format (NITFS), Appendix E, Airborne Support Data Extensions (ASDE, Version 1.1, 16 November 2000)
- Raster Product Format (MIL-STD-2411, 6 October 1994)
Known limitations
- The raster path only supports 1 (M/LU) or 3 (RGB) bands
(see
ELcdNITFBandRepresentation). - Signed data is not supported for JPEG2000
- Non-byte-aligned data is not supported for uncompressed images
- The current implementation does not support 12-bits grayscale JPEG images.
- The current implementation ignores data extension segments.
- Since:
- 3.0
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a newTLcdNITFModelDecoder, with a globally shared buffer for caching tiles.TLcdNITFModelDecoder(ILcdBuffer aBuffer) Creates a newTLcdNITFModelDecoder.TLcdNITFModelDecoder(ILcdBuffer aBuffer, ILcdModelReferenceDecoder aModelReferenceDecoder) Creates a newTLcdNITFModelDecoder.TLcdNITFModelDecoder(ILcdBuffer aBuffer, ILcdModelReferenceDecoder aModelReferenceDecoder, ILcdModelReference aDefaultModelReference, ILcdBounds aDefaultBounds) Creates a newTLcdNITFModelDecoder.TLcdNITFModelDecoder(ILcdBuffer aBuffer, ILcdModelReference aDefaultModelReference, ILcdBounds aDefaultBounds) Creates a newTLcdNITFModelDecoder. -
Method Summary
Modifier and TypeMethodDescriptionbooleancanDecodeSource(ILcdDataSource aDataSource) Checks whether this model decoder can decode the data source(s), identified by the passedILcdDataSource.booleancanDecodeSource(String aSourceName) Checks whether this decoder can decode the given data.Creates a new model from the given data source.decodeSource(ILcdDataSource aDataSource) Creates a new model from the given data source.List<? extends ILcdDataSource> discoverDataSources(String aSourceName) Retrieves a set of model-specificILcdDataSourceinstances.Returns the default bounds for decoded rasters, in case an input NITF file doesn't provide any.Returns the default model reference for decoded models, in case an input NITF file and the model reference decoder don't provide one.Returns a short, displayable name for the format that is decoded by thisILcdModelDecoder.Returns the input stream factory that is used for creating input streams given source names.doubleReturns the maximum acceptable residual error for the four corner points.Returns the model reference decoder that is used for creating model references for decoded models, in case an input NITF file doesn't provide one.Returns the raster referencer that is used when positioning image files based on tie points.booleanReturns whether images that are rotated in a geodetic reference may be put in an orthographic grid reference that is centered around the image.booleanReturns whether the decoder may return multilevel rasters (when possible) instead of single-level rasters.booleanReturns whether CGM vector graphics segments are ignored.booleanReturns whether CGM vector graphics segments are separated into individual submodels.voidsetAllowOrthographicReferencing(boolean aAllowOrthographicReferencing) Specifies whether images that are rotated in a geodetic reference may be put in an approximating orthographic grid reference that is centered around the image.voidsetDecodeMultilevelRasters(boolean aDecodeMultilevelRasters) Specifies whether the decoder is allowed to create multilevel rasters if the input data permits (for instance, for rasters with JPEG-2000 compression).voidsetDefaultBounds(ILcdBounds aDefaultBounds) Sets the default bounds for decoded rasters, in case an input NITF file doesn't provide any.voidsetDefaultModelReference(ILcdModelReference aDefaultModelReference) Sets the default model reference for decoded models, in case an input NITF file and the model reference decoder don't provide one.voidsetIgnoreGraphics(boolean aIgnoreGraphics) Specifies whether to ignore CGM vector graphics segments.voidsetInputStreamFactory(ILcdInputStreamFactory aInputStreamFactory) Sets the input stream factory that will be used for creating input streams given source names.voidsetMaximumResidualTiePointError(double aMaximumResidualTiePointError) Sets the maximum acceptable residual error for the four corner points, when positioning image files in an approximating orthographic grid reference.voidsetModelReferenceDecoder(ILcdModelReferenceDecoder aModelReferenceDecoder) Sets the model reference decoder that will be used for creating model references for decoded models, in case an input NITF file doesn't provide one.voidsetRasterReferencer(ILcdRasterReferencer aRasterReferencer) Sets the raster referencer that will be used when positioning image files based on tie points.voidsetSeparateGraphics(boolean aSeparateGraphics) Specifies whether to separate CGM vector graphics segments into individual submodels.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.luciad.model.ILcdModelDecoder
decodeModelMetadata, decodeModelMetadata
-
Constructor Details
-
TLcdNITFModelDecoder
public TLcdNITFModelDecoder()Creates a newTLcdNITFModelDecoder, with a globally shared buffer for caching tiles.- See Also:
-
TLcdNITFModelDecoder
Creates a newTLcdNITFModelDecoder.- Parameters:
aBuffer- the shared buffer that decoded models will use.
-
TLcdNITFModelDecoder
Creates a newTLcdNITFModelDecoder.- Parameters:
aBuffer- the shared buffer that decoded models will use.aModelReferenceDecoder- the model reference decoder for NITF files that don't specify model references.
-
TLcdNITFModelDecoder
public TLcdNITFModelDecoder(ILcdBuffer aBuffer, ILcdModelReference aDefaultModelReference, ILcdBounds aDefaultBounds) Creates a newTLcdNITFModelDecoder.- Parameters:
aBuffer- the shared buffer that decoded models will use.aDefaultModelReference- the default model reference for NITF files that don't specify model references.aDefaultBounds- the default raster bounds for NITF images that don't have bounds.
-
TLcdNITFModelDecoder
public TLcdNITFModelDecoder(ILcdBuffer aBuffer, ILcdModelReferenceDecoder aModelReferenceDecoder, ILcdModelReference aDefaultModelReference, ILcdBounds aDefaultBounds) Creates a newTLcdNITFModelDecoder.- Parameters:
aBuffer- the shared buffer that decoded models will use.aModelReferenceDecoder- the model reference decoder for NITF files that don't specify model references.aDefaultModelReference- the default model reference for NITF files that don't specify model references.aDefaultBounds- the default raster bounds for NITF images that don't have bounds.
-
-
Method Details
-
setInputStreamFactory
Sets the input stream factory that will be used for creating input streams given source names.- Specified by:
setInputStreamFactoryin interfaceILcdInputStreamFactoryCapable- Parameters:
aInputStreamFactory- the input stream factory to be used.
-
getInputStreamFactory
Returns the input stream factory that is used for creating input streams given source names.- Specified by:
getInputStreamFactoryin interfaceILcdInputStreamFactoryCapable- Returns:
- the input stream factory that is used.
-
setModelReferenceDecoder
Sets the model reference decoder that will be used for creating model references for decoded models, in case an input NITF file doesn't provide one. -
getModelReferenceDecoder
Returns the model reference decoder that is used for creating model references for decoded models, in case an input NITF file doesn't provide one. The default value supports WKT (*.prj), REF (*.ref), and EPSG (*.epsg).- Returns:
- the model reference decoder used by this decoder
- See Also:
-
setDefaultModelReference
Sets the default model reference for decoded models, in case an input NITF file and the model reference decoder don't provide one. -
getDefaultModelReference
Returns the default model reference for decoded models, in case an input NITF file and the model reference decoder don't provide one. -
setDefaultBounds
Sets the default bounds for decoded rasters, in case an input NITF file doesn't provide any. -
getDefaultBounds
Returns the default bounds for decoded rasters, in case an input NITF file doesn't provide any. -
setAllowOrthographicReferencing
public void setAllowOrthographicReferencing(boolean aAllowOrthographicReferencing) Specifies whether images that are rotated in a geodetic reference may be put in an approximating orthographic grid reference that is centered around the image. -
isAllowOrthographicReferencing
public boolean isAllowOrthographicReferencing()Returns whether images that are rotated in a geodetic reference may be put in an orthographic grid reference that is centered around the image. -
setMaximumResidualTiePointError
public void setMaximumResidualTiePointError(double aMaximumResidualTiePointError) Sets the maximum acceptable residual error for the four corner points, when positioning image files in an approximating orthographic grid reference. The residual error is computed in image coordinates and expressed in pixels. The default is 3.- Parameters:
aMaximumResidualTiePointError- the maximum residual error, expressed in pixels.- See Also:
-
getMaximumResidualTiePointError
public double getMaximumResidualTiePointError()Returns the maximum acceptable residual error for the four corner points. -
setRasterReferencer
Sets the raster referencer that will be used when positioning image files based on tie points. If it is set, it replaces the more basic settingsallowOrthographicReferencingandmaximumResidualTiePointError, which are used by default.- Parameters:
aRasterReferencer- the raster referencer, which will create model references and raster bounds based on tie points.
-
getRasterReferencer
Returns the raster referencer that is used when positioning image files based on tie points. -
setIgnoreGraphics
public void setIgnoreGraphics(boolean aIgnoreGraphics) Specifies whether to ignore CGM vector graphics segments. -
isIgnoreGraphics
public boolean isIgnoreGraphics()Returns whether CGM vector graphics segments are ignored. -
setSeparateGraphics
public void setSeparateGraphics(boolean aSeparateGraphics) Specifies whether to separate CGM vector graphics segments into individual submodels. The main model is then a model tree node that contains the raster as its sole element, and the CGM vector graphics in distinct submodels. When this option is enabled the display level between graphic segments and other types of segments is not enforced, which may result in incorrect paint order. -
isSeparateGraphics
public boolean isSeparateGraphics()Returns whether CGM vector graphics segments are separated into individual submodels. When this option is enabled the display level between graphic segments and other types of segments is not enforced, which may result in incorrect paint order. -
getDefaultExtension
- Returns:
- "ntf".
-
getDisplayName
Description copied from interface:ILcdModelDecoderReturns a short, displayable name for the format that is decoded by thisILcdModelDecoder.- Specified by:
getDisplayNamein interfaceILcdModelDecoder- Returns:
- "ntf".
-
isDecodeMultilevelRasters
public boolean isDecodeMultilevelRasters()Returns whether the decoder may return multilevel rasters (when possible) instead of single-level rasters. The default value isfalse.- Returns:
- true if the decoder may return multilevel rasters.
-
setDecodeMultilevelRasters
public void setDecodeMultilevelRasters(boolean aDecodeMultilevelRasters) Specifies whether the decoder is allowed to create multilevel rasters if the input data permits (for instance, for rasters with JPEG-2000 compression).- Parameters:
aDecodeMultilevelRasters- specifies whether the decoder should create multilevel rasters when possible.
-
canDecodeSource
Checks whether this decoder can decode the given data. The extension of the file name should be "ntf", "nsf" or "nsif". CADRG frame files are also supported. SeeTLcdCADRGModelDecoderfor more information on which CADRG frame types are supported.- Specified by:
canDecodeSourcein interfaceILcdModelDecoder- Parameters:
aSourceName- the name of the file or URL that is to be decoded.- Returns:
trueif this decoder can 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:
-
discoverDataSources
Retrieves 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
Provides two data sources for an NITF file. One can be used to decode the NITF file into a georeferenced model, while the other can be used to create a non-georeferenced model. When decoding the data source into a non-georeferenced model, the result is anILcdModelDecoder.discoverDataSources(String)method allows you to distinguish between them usingILcdDataSources, where each measurement layer can be referenced to and decoded separately usingILcdModelDecoder.decodeSource(ILcdDataSource)ILcdModelTreeNodewith a sub model for each segment in the NITF file.- Specified by:
discoverDataSourcesin interfaceILcdModelDecoder- Parameters:
aSourceName- 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
-