@LcdService(service=ILcdModelDecoder.class, priority=20000) public class TLcdCADRGModelDecoder extends Object implements ILcdModelDecoder, ILcdInputStreamFactoryCapable
File | Required | Entry point | Description |
---|---|---|---|
A.TOC |
x | Table of contents, referring to individual frame files | |
*.<ds><z> |
x | x | Individual frame file.<ds> refers the the data series code as listed in the data series
table below.<z> refers to the ARC zone number. This is a character in the range
[1-9] for the northern hemisphere or [A-HJ] for the southern hemisphere. Please refer to section 3.4
of the ADRG specification (MIL-A-89007) for more details on the ARC system. |
A1, A2, A3, A4, AT, C1, C2, C3, C4, C5, C6, C7, C8, C9, CA, CB, CC, CD, CE, CF, CH, CJ, CK, CL, CN, CP, CQ, CR, CS, CT, D1, D2, EG, ES, ET, F1, F2, F3, F4, F5, GN, I1, I2, I3, I4, JA, JG, JN, JO, JR, K1, K2, K3, K7, K8, KB, KE, KM, KR, KS, KU, L1, L2, L3, L4, L5, LF, LN, MH, MI, MJ, OH, ON, OW, P1, P2, P3, P4, P5, P6, P7, P8, P9, PA, PB, PC, PD, PE, PF, PG, PH, PI, PJ, PK, PL, PM, PN, PO, PP, PQ, PR, PS, PT, PU, PV, R1, R2, R3, R4, R5, RC, RL, RR, RV, TC, TF, TL, TN, TP, TQ, TR, TT, UL, V1, V2, V3, V4, VH, VN, VT, WA, WB, WC, WD, WE, WF, WG, WH, WI, WK, XD, XE, XF, XG, XH, XI, XJ, XK, Y9, YA, YB, YC, YD, YE, YF, YI, YJ, YZ, Z8, ZA, ZB, ZC, ZD, ZE, ZF, ZG, ZH, ZI, ZJ, ZK, ZT, ZV, ZZ
The following codes are recognized, but can't be decoded:CG, CM, CO, HA, I5, IV, M1, M2, MM, OA
We refer to the specification for a more detailed overview of these codes.inputStreamFactory
of this decoder.ILcd2DBoundsIndexedModel
.TLcdCADRGModelDescriptor
or a
TLcdCADRGMultilevelRasterModelDescriptor
, depending on the
property createMultilevelRasters
.ILcdGeodeticReference
as model references.TLcdCADRGRaster
elements,
or ILcdMultilevelRaster
elements containing TLcdCADRGRaster
instances, depending on the property createMultilevelRasters
.
TLcdCADRGRaster
instances correspond to
the CADRG/CIB boundary rectangles. They contain additional information
about the rectangles.TLcdCADRGRaster
instances in turn contain
TLcdCADRGTile
instances that correspond to the
individual CADRG/CIB frames. They contain additional information about
the frames.DirectColorModel
instances instead of IndexColorModel
instances.
This avoids problems with clashing color maps from different CADRG tiles (cfr. MIL-C-89038, Section 3.10.3 "Color reduction").
This behavior can be disabled by setting the property expandColorMap
to false
.
createMultilevelRasters
allows to decode
ILcdMultilevelRaster
elements instead of simple
ILcdRaster
elements.
ILcdModelDecoder decoder =
new TLcdCADRGModelDecoder(TLcdSharedBuffer.getBufferInstance(), true, true);
ILcdModel model = decoder.decode("A.TOC");
Creating multilevel rasters
can help avoiding picking the right level of detail when painting them.
Rasters that are defined at different levels of detail will not be
painted at the same time, which is generally unnecessary for overlapping
rasters. Usually this should be combined with
expanding color maps
since all levels
must use the same kind of pixel.Modifier and Type | Field and Description |
---|---|
static String |
DEFAULT_EXTENSION |
static String |
DISPLAY_NAME |
static String |
LEGEND_EXTENSION |
static String |
OVERVIEW_EXTENSION |
static String |
TOC_NAME |
Constructor and Description |
---|
TLcdCADRGModelDecoder()
Creates a new
TLcdCADRGModelDecoder , with a globally shared
buffer for caching tiles. |
TLcdCADRGModelDecoder(ILcdBuffer aBuffer)
Creates a new
TLcdCADRGModelDecoder . |
TLcdCADRGModelDecoder(ILcdBuffer aBuffer,
boolean aExpandColorMap)
Creates a new
TLcdCADRGModelDecoder . |
TLcdCADRGModelDecoder(ILcdBuffer aBuffer,
boolean aExpandColorMap,
boolean aCreateMultilevelRasters)
Creates a new
TLcdCADRGModelDecoder . |
Modifier and Type | Method and Description |
---|---|
boolean |
canDecodeSource(String aSourceName)
Checks whether
TLcdCADRGModelDecoder can decode the given
data. |
ILcdModel |
decode(String aSourceName)
Creates a new model from the given data source.
|
TLcdModelMetadata |
decodeModelMetadata(String aSourceName)
Decodes metadata for the specified data source.
|
String |
getDisplayName()
Returns a short, displayable name for the format that is decoded by this
ILcdModelDecoder . |
ILcdInputStreamFactory |
getInputStreamFactory()
Returns the input stream factory that is used for creating input streams
given source names.
|
boolean |
isCreateMultilevelRasters()
Returns whether decoded models contain multilevel rasters, one for each
CADRG zone, or just regular rasters.
|
boolean |
isExpandColorMap()
Returns whether the color maps of decoded tiles are expanded.
|
boolean |
isTraceOn()
Deprecated.
This method has been deprecated. It is recommended to use the
standard Java logging framework directly.
|
static void |
setClassTraceOn(boolean aClassTraceOn)
Deprecated.
This method has been deprecated. It is recommended to use the
standard Java logging framework directly.
|
void |
setCreateMultilevelRasters(boolean aCreateMultilevelRasters)
Specifies whether decoded models should contain multilevel rasters, one
for each CADRG zone, or just regular rasters.
|
void |
setExpandColorMap(boolean aExpandColorMap)
Sets whether the color maps of decoded tiles should be expanded.
|
void |
setInputStreamFactory(ILcdInputStreamFactory aInputStreamFactory)
Sets the input stream factory that will be used for creating input streams
given source names.
|
void |
setTraceOn(boolean aTraceOn)
Deprecated.
This method has been deprecated. It is recommended to use the
standard Java logging framework directly.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
canDecodeSource, decodeModelMetadata, decodeSource, discoverDataSources
public static final String DISPLAY_NAME
public static final String TOC_NAME
public static final String DEFAULT_EXTENSION
public static final String OVERVIEW_EXTENSION
public static final String LEGEND_EXTENSION
public TLcdCADRGModelDecoder()
TLcdCADRGModelDecoder
, with a globally shared
buffer for caching tiles.TLcdSharedBuffer.getBufferInstance()
public TLcdCADRGModelDecoder(ILcdBuffer aBuffer)
TLcdCADRGModelDecoder
.aBuffer
- the buffer in which pixel data can be decoded and cached.public TLcdCADRGModelDecoder(ILcdBuffer aBuffer, boolean aExpandColorMap)
TLcdCADRGModelDecoder
.aBuffer
- the buffer in which pixel data can be decoded and cached.aExpandColorMap
- specifies whether the color maps of decoded
tiles should be expanded.public TLcdCADRGModelDecoder(ILcdBuffer aBuffer, boolean aExpandColorMap, boolean aCreateMultilevelRasters)
TLcdCADRGModelDecoder
.aBuffer
- the buffer in which pixel data can be decoded and cached.aExpandColorMap
- specifies whether the color maps of decoded
tiles should be expanded.aCreateMultilevelRasters
- specifies whether the decoder should
create multilevel rasters instead of ordinary
rasterspublic static void setClassTraceOn(boolean aClassTraceOn)
true
then all log messages are recorded, otherwise only
the informative, warning and error messages are recorded.aClassTraceOn
- if true then all log messages are recorded,
otherwise only the informative, warning and error messages are recorded.public void setTraceOn(boolean aTraceOn)
true
or false
as argument automatically turns
off tracing for all other class instances for which
setTraceOn
has not been called.
If the argument is false
then only the informative, warning
and error log messages are recorded.aTraceOn
- if true then all log messages are recorded for this
instance. If false, then only the informative, warning and
error log messages are recorded.public boolean isTraceOn()
true
if tracing is enabled for this class.public void setInputStreamFactory(ILcdInputStreamFactory aInputStreamFactory)
setInputStreamFactory
in interface ILcdInputStreamFactoryCapable
aInputStreamFactory
- the input stream factory to be used.public ILcdInputStreamFactory getInputStreamFactory()
getInputStreamFactory
in interface ILcdInputStreamFactoryCapable
public void setExpandColorMap(boolean aExpandColorMap)
public boolean isExpandColorMap()
public void setCreateMultilevelRasters(boolean aCreateMultilevelRasters)
expanding of color maps
since all
levels must have the same pixel type.setExpandColorMap(boolean)
public boolean isCreateMultilevelRasters()
public String getDisplayName()
ILcdModelDecoder
ILcdModelDecoder
.getDisplayName
in interface ILcdModelDecoder
ILcdModelDecoder
.public TLcdModelMetadata decodeModelMetadata(String aSourceName) throws IOException
If the given data source is a .TOC
file, the resulting TLcdModelMetadata
will also
contain a metadata instance for each of the referenced frame files. These frame files' metadata are stored as data
series children and can be retrieved with TLcdModelMetadata.discoverDataSeries()
. All
information in the metadata is obtained from the .TOC
file itself, which means that none of the frame
files will be decoded (or even accessed) and a call to TLcdModelMetadata.discoverDataSeries()
will not
trigger any additional I/O.
If the given data source is a single frame file, the file is simply decoded and the resulting metadata is extracted
from that decoded model with ILcdModel.getModelMetadata()
.
decodeModelMetadata
in interface ILcdModelDecoder
aSourceName
- the data source for which the model metadata will be decoded.IOException
- if the metadata cannot be decoded for some reason.ILcdModelDecoder.canDecodeSource(String)
public boolean canDecodeSource(String aSourceName)
TLcdCADRGModelDecoder
can decode the given
data. The result is true
if the source name has one of
the supported extensions.canDecodeSource
in interface ILcdModelDecoder
aSourceName
- the name of the file or URL that is to be decoded.true
if TLcdCADRGModelDecoder
can 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)