@LcdService(service=ILcdModelDecoder.class, priority=20000) public class TLcdASTERIXModelDecoder extends ALcdASTERIXDecoder implementsILcdDataSourceModelDecoder, ILcdInputStreamFactoryCapable
trajectories
, plots
or
weather pictures
.
The current implementation of TLcdASTERIXLiveDecoder will
add trajectories
, plots
or
weather pictures
to the sub models.
The domain object depends on the incoming messages. Messages without ID's will
be generated as plots, other messages will be generated as trajectories except if there are weather pictures.
Timing information of ASTERIX data is relative to midnight, but for replay purposes it is
convenient to have absolute time values. An offset date can be specified using
setTimeOffset(long)
to convert time-since-midnight to an absolute time value.
You can decode single files using the decode(String)
method. If you have recorded ASTERIX data
that is split in separate files, you can use the decodeSource(com.luciad.model.ILcdDataSource)
method to decode several files in one
go, keeping trajectories split over multiple files together.
File | Required | Entry point | Description |
---|---|---|---|
*.ast | x | x | AST file containing a simple sequence of ASTERIX blocks (see ASTERIX_FORMAT ) |
*.asterix | x | x | ASTERIX file containing a simple sequence of ASTERIX blocks (see ASTERIX_FORMAT ) |
*.astfin | x | x | ASTERIX Final file containing a sequence of ASTERIX blocks within a header and footer (see ASTERIX_FINAL_FORMAT ) |
*.pcap | x | x | ASTERIX blocks captured from the network in a PCAP file (see PCAP_FORMAT ) |
ILcdInputStreamFactory
of this decoder.model list
with a model
for each data type in the input.ILcd2DBoundsIndexedModel
.track model descriptor
plot model descriptor
weather model descriptor
TLcdASTERIXRadarVideoModelDescriptor
ILcdGridReference
.ALcdASTERIXModelDescriptor
ILcdModelDecoder decoder = new TLcdASTERIXModelDecoder();
ILcdModel model = decoder.decode( "asterix_data.ast" );
Modifier and Type | Field and Description |
---|---|
static int |
ASTERIX_FINAL_FORMAT
Constant describing the ASTERIX final file format.
|
static int |
ASTERIX_FORMAT
Constant describing the standard ASTERIX file format: regular ASTERIX data blocks concatenated
one after the other, without any headers or footers.
|
static int |
PCAP_FORMAT
Constant describing the PCAP file format.
|
static int |
UNKNOWN_FORMAT
Constant describing an unknown format.
|
Constructor and Description |
---|
TLcdASTERIXModelDecoder() |
Modifier and Type | Method and Description |
---|---|
boolean |
canDecodeSource(ILcdDataSource aDataSource)
Checks whether the data source is a
TLcdASTERIXDataSource . |
boolean |
canDecodeSource(String aSourceName)
Checks whether this model decoder can decode the specified data source.
|
ILcdModel |
decode(String aSourceName)
Creates a new model from the given data source.
|
ILcdModel |
decodeSource(ILcdDataSource aDataSource)
Decodes instances of
TLcdASTERIXDataSource , allowing you to decode multiple sources in one go. |
static int |
determineFormat(String aSourceName)
Derives the format from the given source name.
|
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 currently used for creating input streams
given source names.
|
long |
getTimeOffset()
Returns the time offset.
|
protected int |
retrieveFormat(String aSourceName)
Retrieves the format for the given source name.
By default, this method calls
determineFormat(String) . |
void |
setInputStreamFactory(ILcdInputStreamFactory aInputStreamFactory)
Sets the input stream factory that will be used for creating input streams
given source names.
|
void |
setTimeOffset(long aTimeOffset)
Sets the time offset used to convert time-since-midnight values to an
absolute date and time.
ASTERIX data only contains dates relative to midnight.
|
getCategories, getRecordFilter, getReferenceProvider, getScalingFactorProvider, getTransformationProvider, isClassTraceOn, setCategories, setClassTraceOn, setRecordFilter, setReferenceProvider, setScalingFactorProvider, setTransformationProvider
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
decodeModelMetadata, decodeModelMetadata, discoverDataSources
public static final int UNKNOWN_FORMAT
retrieveFormat(String)
,
Constant Field Valuespublic static final int ASTERIX_FORMAT
retrieveFormat(String)
,
Constant Field Valuespublic static final int ASTERIX_FINAL_FORMAT
HEADER NormalAsterixBlock1 NormalAsterixBlock2 ... FOOTERThese ASTERIX final records are concatenated in a file, one after the other. The header of 8 bytes is composed like this:
byte 0 | length (msb) |
byte 1 | length (lsb) |
byte 2 | board number |
byte 3 | line number |
byte 4 | recording day |
byte 5 | time (msb) |
byte 6 | time |
byte 7 | time (lsb) |
retrieveFormat(String)
,
Constant Field Valuespublic static final int PCAP_FORMAT
retrieveFormat(String)
,
Constant Field Valuespublic void setInputStreamFactory(ILcdInputStreamFactory aInputStreamFactory)
setInputStreamFactory
in interface ILcdInputStreamFactoryCapable
aInputStreamFactory
- the input stream factory to be used.public ILcdInputStreamFactory getInputStreamFactory()
getInputStreamFactory
in interface ILcdInputStreamFactoryCapable
public long getTimeOffset()
setTimeOffset(long)
for details.public void setTimeOffset(long aTimeOffset)
aTimeOffset
- Date used as offset for the relative ASTERIX dates, it is
specified as a value in milliseconds since 1970, similar to Date.getTime()
. Set -1 to use the start of today as the offset.public String getDisplayName()
ILcdModelDecoder
ILcdModelDecoder
.getDisplayName
in interface ILcdModelDecoder
ILcdModelDecoder
.protected int retrieveFormat(String aSourceName)
determineFormat(String)
. Override if your source names don't
follow the conventions used by that method.aSourceName
- The source name, similar as the source given to the
decode
method.ASTERIX_FORMAT
, ASTERIX_FINAL_FORMAT
, PCAP_FORMAT
or
UNKNOWN_FORMAT
. This list can be expanded in the future, when support for new file formats is added.determineFormat(String)
public static int determineFormat(String aSourceName)
ASTERIX_FORMAT
,ASTERIX_FINAL_FORMAT
,PCAP_FORMAT
,UNKNOWN_FORMAT
.aSourceName
- The source name from which to derive the format.ASTERIX_FORMAT
, ASTERIX_FINAL_FORMAT
, PCAP_FORMAT
or
UNKNOWN_FORMAT
. This list can be expanded in the future, when support for new file formats is added.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 this decoder can likely decode the data specified by the source name, false
otherwise.ILcdModelDecoder.decode(String)
,
ILcdModelDecoder.decodeModelMetadata(String)
public boolean canDecodeSource(ILcdDataSource aDataSource)
TLcdASTERIXDataSource
.
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 a TLcdDataSource
.
The default implementation of this method will check if the given ILcdDataSource
is a
TLcdDataSource
. If not, this method returns false. Otherwise, it delegates
the source to the ILcdModelDecoder.canDecodeSource(String)
method.
canDecodeSource
in interface ILcdModelDecoder
aDataSource
- The data source to check.true
if the data source is a TLcdASTERIXDataSource
, false
otherwise.ILcdModelDecoder.decodeSource(ILcdDataSource)
,
ILcdModelDecoder.decodeModelMetadata(ILcdDataSource)
public ILcdModel decodeSource(ILcdDataSource aDataSource) throws IOException
Decodes instances of TLcdASTERIXDataSource
, allowing you to decode multiple sources in one go.
The sources are decoded in the order they are listed in the TLcdASTERIXDataSource.getSourceNames
.
By using this method, a trajectory that spans two files can still be decoded as a single trajectory. In
contrast, if you decode the two files separately using the decode(String)
method, the trajectory will
be cut at the boundaries of the files, and be split over the two resulting models.
Use this method if you have recorded your ASTERIX data in several files, for instance, when you record your ASTERIX data in chunks of one hour each.
Note: the sources described by theTLcdASTERIXDataSource
PCAP_FORMAT
Creates a new model from the given data source.
By default, this method:
NullPointerException
when a null
data source is passed.ILcdModelDecoder.decode(String)
method when a TLcdDataSource
is passed.decodeSource
in interface ILcdModelDecoder
aDataSource
- The ILcdDataSource
to decode. This must be an instance of TLcdASTERIXDataSource
. This must not be null
.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);
}
}
TLcdASTERIXDataSource
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)