Class TLcdASTERIXModelDecoder

java.lang.Object
com.luciad.format.asterix.ALcdASTERIXDecoder
com.luciad.format.asterix.TLcdASTERIXModelDecoder
All Implemented Interfaces:
ILcdInputStreamFactoryCapable, ILcdDataSourceModelDecoder, ILcdModelDecoder

This decoder reads ASTERIX data and represents it in a TLcdModelList. For each encountered category/ UAP/datatype combination, a new sub ILcdModel is added to the TLcdModelList. The datatype can either be trajectories, plots, weather pictures or service messages.

The current implementation of TLcdASTERIXLiveDecoder will add trajectories, plots, weather pictures or service messages 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 or service messages.

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.

Input files

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)

Supported file transfer protocols

  • This model decoder supports all transfer protocols that are supported by the ILcdInputStreamFactory of this decoder.

Model structure

Model descriptor

Model reference

Model elements

  • All domain objects decoded with this decoder implement the ILcdDataObject interface. This interface allows you to retrieve information on each of the domain models of ASTERIX in a uniform way. The data models and types can be obtained from either the domain objects or from the TLcdASTERIXDataTypes class.
  • The domain objects decoded with this model decoder also implement the ILcdFeatured interface. While this interface will also provide information about the attributes of the domain model, it is recommended to use the newer ILcdDataObject interface to query a domain object on its properties. The ILcdFeatured does not provide information about the metadata of the features it represents. For this, an ILcdFeaturedDescriptor can be used. The use of the ILcdFeaturedDescriptor interface in ASTERIX is described in ALcdASTERIXModelDescriptor

Sample code


 ILcdModelDecoder decoder = new TLcdASTERIXModelDecoder();
 ILcdModel model = decoder.decode( "asterix_data.ast" );
 

Performance tips

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.

Supported versions

Limitations

  • Field Details

    • UNKNOWN_FORMAT

      public static final int UNKNOWN_FORMAT
      Constant describing an unknown format.

      See Also:
    • ASTERIX_FORMAT

      public static final int ASTERIX_FORMAT
      Constant describing the standard ASTERIX file format: regular ASTERIX data blocks concatenated one after the other, without any headers or footers.
      See Also:
    • ASTERIX_FINAL_FORMAT

      public static final int ASTERIX_FINAL_FORMAT
      Constant describing the ASTERIX final file format. ASTERIX final is a simple extension of the ASTERIX standard, where every ASTERIX final record is composed like this:
      HEADER NormalAsterixBlock1 NormalAsterixBlock2 ... FOOTER
      These ASTERIX final records are concatenated in a file, one after the other.

      The header of 8 bytes is composed like this:

      byte 0length (msb)
      byte 1length (lsb)
      byte 2board number
      byte 3line number
      byte 4recording day
      byte 5time (msb)
      byte 6time
      byte 7time (lsb)
      The length is a two byte integer, starting with the most significant byte. It includes the length of the header and the footer itself. The fields board number, line number and recording day are in general not used and set to 0. The time is provided in 1/100th seconds since midnight as a three bytes integer, starting with the most significant byte.

      The footer of 4 bytes is composed of 4 times 0xa5 (decimal 165).

      See Also:
    • PCAP_FORMAT

      public static final int PCAP_FORMAT
      Constant describing the PCAP file format. Files in this format should be in the PCAP file format. Currently the decoder can only extract ASTERIX data from the following protocols:
      • Data link layer
        • Only Ethernet (version II, LLC, LLC+SNAP) is supported
      • Network layer
        • Only IPv4 is supported.
      • Transport layer
        • Only UDP is supported. UDP datagrams sent across IP fragments are supported.
      Packets sent using any other protocol and captured in the PCAP file are ignored by the decoder.
      See Also:
  • Constructor Details

    • TLcdASTERIXModelDecoder

      public TLcdASTERIXModelDecoder()
  • Method Details

    • setInputStreamFactory

      public void setInputStreamFactory(ILcdInputStreamFactory aInputStreamFactory)
      Sets the input stream factory that will be used for creating input streams given source names.
      Specified by:
      setInputStreamFactory in interface ILcdInputStreamFactoryCapable
      Parameters:
      aInputStreamFactory - the input stream factory to be used.
    • getInputStreamFactory

      public ILcdInputStreamFactory getInputStreamFactory()
      Returns the input stream factory that is currently used for creating input streams given source names.
      Specified by:
      getInputStreamFactory in interface ILcdInputStreamFactoryCapable
      Returns:
      the input stream factory that is currently used.
    • getTimeOffset

      public long getTimeOffset()
      Returns the time offset. See setTimeOffset(long) for details.
      Returns:
      The offset date that is used to get absolute dates from the relative dates of ASTERIX data.
    • setTimeOffset

      public 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. With this method, it is possible to set an offset date of choice. To calculate absolute dates, this offset date is added together with the time-since-midnight found in ASTERIX data. Note that the time part of the offset date is ignored, so only the year, month and day are used.

      Parameters:
      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.
    • getDisplayName

      public String getDisplayName()
      Description copied from interface: ILcdModelDecoder
      Returns a short, displayable name for the format that is decoded by this ILcdModelDecoder.
      Specified by:
      getDisplayName in interface ILcdModelDecoder
      Returns:
      the displayable name of this ILcdModelDecoder.
    • retrieveFormat

      protected int retrieveFormat(String aSourceName)
      Retrieves the format for the given source name.

      By default, this method calls determineFormat(String). Override if your source names don't follow the conventions used by that method.

      Parameters:
      aSourceName - The source name, similar as the source given to the decode method.
      Returns:
      One of 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.
      See Also:
    • determineFormat

      public static int determineFormat(String aSourceName)
      Derives the format from the given source name. This method maps file names as described below: This list can be expanded in the future, when support for new file formats is added.
      Parameters:
      aSourceName - The source name from which to derive the format.
      Returns:
      One of 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.
      Since:
      2018.0
    • canDecodeSource

      public boolean canDecodeSource(String aSourceName)
      Description copied from interface: ILcdModelDecoder
      Checks whether this model decoder can decode the specified data source. It is acceptable for this method to return 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.

      Specified by:
      canDecodeSource in interface ILcdModelDecoder
      Parameters:
      aSourceName - the data source to be verified; typically a file name or a URL.
      Returns:
      true if this decoder can likely decode the data specified by the source name, false otherwise.
      See Also:
    • canDecodeSource

      public boolean canDecodeSource(ILcdDataSource aDataSource)
      Checks whether the data source is a 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.

      Specified by:
      canDecodeSource in interface ILcdModelDecoder
      Parameters:
      aDataSource - The data source to check.
      Returns:
      true if the data source is a TLcdASTERIXDataSource, false otherwise.
      See Also:
    • decodeSource

      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 the TLcdASTERIXDataSource
      • should be consecutive files, i.e. the end of one file should correspond to the beginning of the next file.
      • should all be in the same file format, for instance, PCAP_FORMAT

      Creates a new model from the given data source.

      By default, this method:

      Specified by:
      decodeSource in interface ILcdModelDecoder
      Parameters:
      aDataSource - The ILcdDataSource to decode. This must be an instance of TLcdASTERIXDataSource. This must not be null.
      Returns:
      The decoded model list.
      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:
    • decode

      public ILcdModel decode(String aSourceName) throws IOException
      Description copied from interface: ILcdModelDecoder
      Creates a new model from the given data source.
      Specified by:
      decode in interface ILcdModelDecoder
      Parameters:
      aSourceName - the data source to be decoded; typically a file name or a URL.
      Returns:
      A model containing the decoded data. While null is 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: