Class TLcdWMMModelDecoder

java.lang.Object
com.luciad.format.magneticnorth.TLcdWMMModelDecoder
All Implemented Interfaces:
ILcdInputStreamFactoryCapable, ILcdModelDecoder, ILcdStatusSource

public class TLcdWMMModelDecoder extends Object implements ILcdInputStreamFactoryCapable
This class produces a TLcdMagneticNorthModel from a data file containing the parameters for the WMM magnetic model. Such a file can be found in samples/resources/Data/magneticnorth

Input files

File Required Entry point Description
*.cof x x file containing the magnetic model coefficients
The decode(java.lang.String) method can decode a single filename or a "," or ";" separated list of filenames. For instance, when you pass the argument "/../WMM2005.COF, /../WMM2010.COF", both the WMM2005 and the WMM2010 file will be available to calculate magnetic north declination data from.

Model reference

The model reference of the decoded models is geodetic (WGS 84).

Supported file transfer protocols

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

Model structure

All models returned by this model decoder implement ILcd2DBoundsIndexedModel.

Model descriptor

Model elements

The model elements are lines of constant declination of the magnetic field with respect to the true North, according to the set date. The model elements implement ILcdDataObject, on top of implementing their respective shape.

Sample code

    TLcdWMMModelDecoder modelDecoder = new TLcdWMMModelDecoder();

    //Specify the date on the model decoder
    Calendar calendar = Calendar.getInstance();
    calendar.set(2020, Calendar.AUGUST, 26, 16, 52);
    modelDecoder.setDate(calendar);

    //Decode the model
    ILcdModel model = modelDecoder.decode("Data/magneticnorth/WMM2020.COF");

Thread safety

  • The decoded models are thread-safe for read access when taking a read lock.

Supported versions and specifications

  • Constructor Details

    • TLcdWMMModelDecoder

      public TLcdWMMModelDecoder()
  • Method Details

    • 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:
    • 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.
    • decode

      public ILcdModel decode(String aSourceName) throws IOException
      This method can decode a single filename or a "," or ";" separated list of filenames. For instance, when you pass the argument "/../WMM2005.COF, /../WMM2010.COF", both the WMM2005 and the WMM2010 file will be available to calculate magnetic north declination data from.
      Specified by:
      decode in interface ILcdModelDecoder
      Parameters:
      aSourceName - A WMM configuration filename of a list of such names, separated by a "," or a ";".
      Returns:
      a magnetic north declination model.
      Throws:
      IOException - when the list contains no valid filenames or when one of the files can't be opened.
      See Also:
    • createMagneticNorthModelDescriptor

      protected ALcdMagneticNorthModelDescriptor createMagneticNorthModelDescriptor()
      Create a model descriptor specific for magnetic north models. This method is called from createModelDescriptor(ILcdMagneticNorthMap).
      Returns:
      a magnetic north model descriptor that can be configured.
    • createModelDescriptor

      protected ILcdModelDescriptor createModelDescriptor(ILcdMagneticNorthMap aMap)
      Creates a model descriptor for the model by creating a magnetic north model descriptor (createMagneticNorthModelDescriptor()) and then configuring it.
      Parameters:
      aMap - the map to create a model descriptor for
      Returns:
      a magnetic north model descriptor for the given map.
    • getInputStreamFactory

      public ILcdInputStreamFactory getInputStreamFactory()
      Returns the input stream factory to load the data.
      Specified by:
      getInputStreamFactory in interface ILcdInputStreamFactoryCapable
      Returns:
      the input stream factory to load the data.
      See Also:
    • setInputStreamFactory

      public void setInputStreamFactory(ILcdInputStreamFactory aInputStreamFactory)
      Sets the input stream factory to load the data.
      Specified by:
      setInputStreamFactory in interface ILcdInputStreamFactoryCapable
      Parameters:
      aInputStreamFactory - an InputStream factory that creates input streams to load the magnetic north data.
      See Also:
    • setClassTraceOn

      public static void setClassTraceOn(boolean aClassTraceOn)
      Deprecated.
      This method has been deprecated. It is recommended to use the standard Java logging framework directly.
      Enables tracing for all instances of this class. If the argument is true then all log messages are recorded, otherwise only the informative, warning and error messages are recorded.
      Parameters:
      aClassTraceOn - if true then all log messages are recorded, otherwise only the informative, warning and error messages are recorded.
    • setTraceOn

      public void setTraceOn(boolean aTraceOn)
      Deprecated.
      This method has been deprecated. It is recommended to use the standard Java logging framework directly.
      Enables tracing for this class instance. Calling this method with either 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.
      Parameters:
      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.
    • isTraceOn

      public boolean isTraceOn()
      Deprecated.
      This method has been deprecated. It is recommended to use the standard Java logging framework directly.
      Returns true if tracing is enabled for this class.
      Returns:
      true if tracing is enabled for this class, false otherwise.
    • getPrecision

      public double getPrecision()
      Returns the precision. Higher value is better precision, usable values between 0.1 and 1
      Returns:
      a value indicating the precision
    • setPrecision

      public void setPrecision(double aPrecision)
      Sets the precision. Higher value is better precision (but slower) and vice-versa. Usable values between 0.1 and 1. Must be strictly greater than zero.
      Parameters:
      aPrecision - the precision to be used
    • getDegreesBetweenLines

      public int getDegreesBetweenLines()
      Deprecated.
      Use getStep() instead.
      Returns:
      the degrees between the lines.
    • setDegreesBetweenLines

      public void setDegreesBetweenLines(int aDegreesBetweenLines)
      Deprecated.
      Use setStep(double) instead. Sets the number of degrees between the iso lines. ( f.e. a line every 2 degrees )
      Parameters:
      aDegreesBetweenLines - the number of degrees between two lines. The lower this number, the higher the number of lines that will be created.
    • getStep

      public double getStep()
      Returns the step in degrees between the iso lines of equal declination.
      Returns:
      the step in degrees between the iso lines of equal declination.
    • setStep

      public void setStep(double aStep)
      Sets the step in degrees between the iso lines of equal declination.
      Parameters:
      aStep - The step in degrees between the iso lines of equal declination.
    • getDate

      public Calendar getDate()
      Returns:
      the date this model is valid
    • setDate

      public void setDate(Calendar aDate)
      Sets the date to decode the model for. By default, the current date is used.
      Parameters:
      aDate - The new date
    • getBounds

      public ILcdBounds getBounds()
      Returns:
      The bounds the magnetic north was calculated for.
    • setBounds

      public void setBounds(ILcdBounds aBounds)
      Sets the bounds the magnetic will be retrieved for
      Parameters:
      aBounds - the new bounds
    • createModel

      protected TLcdMagneticNorthModel createModel(ILcdMagneticNorthMap aMap)
    • addStatusListener

      public void addStatusListener(ILcdStatusListener aStatusListener)
      Adds a listener that will be informed of progress when processing the data that was loaded. Note that this listener is not informed of progress when loading the data.
      Specified by:
      addStatusListener in interface ILcdStatusSource
      Parameters:
      aStatusListener - the listener to inform of progress when processing the data that was loaded.
      See Also:
    • removeStatusListener

      public void removeStatusListener(ILcdStatusListener aStatusListener)
      Removes a listener that should no longer be informed of progress when processing the data that was loaded.
      Specified by:
      removeStatusListener in interface ILcdStatusSource
      Parameters:
      aStatusListener - a listener that should no longer be informed of progress when processing the data that was loaded.
      See Also:
    • setCreateValuedPolygons

      public void setCreateValuedPolygons(boolean aCreateClosedContours)
      Set this ALcdMagneticNorthModelDecoder to always create closed contours. If true, the model decoder adds ILcdValuedPolygon objects to the model. If false, the model decoder adds TLcdValuedContour objects containing an open or closed ILcdPolyline to the model
      Parameters:
      aCreateClosedContours - The behaviour to set
    • isCreateValuedPolygons

      public boolean isCreateValuedPolygons()
      Returns:
      Whether it always creates closed contour lines, or can create both open and closed polylines.
      See Also: