Package com.luciad.format.magneticnorth
Class TLcdWMMModelDecoder
java.lang.Object
com.luciad.format.magneticnorth.TLcdWMMModelDecoder
- All Implemented Interfaces:
ILcdInputStreamFactoryCapable,ILcdModelDecoder,ILcdStatusSource
This class produces a
The
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 |
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 theILcdInputStreamFactory of this decoder.
Model structure
All models returned by this model decoder implementILcd2DBoundsIndexedModel.
Model descriptor
- Models created by this model decoder have a
TLcdWMMModelDescriptor - The
data modelcontains the data types found inTLcdMagneticNorthDataTypes.
Model elements
The model elements are lines of constant declination of the magnetic field with respect to the true North, according to theset 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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddStatusListener(ILcdStatusListener aStatusListener) Adds a listener that will be informed of progress when processing the data that was loaded.booleancanDecodeSource(String aSourceName) Checks whether this model decoder can decode the specified data source.protected ALcdMagneticNorthModelDescriptorCreate a model descriptor specific for magnetic north models.protected TLcdMagneticNorthModelprotected ILcdModelDescriptorCreates a model descriptor for the model by creating a magnetic north model descriptor (createMagneticNorthModelDescriptor()) and then configuring it.This method can decode a single filename or a "," or ";" separated list of filenames.getDate()intDeprecated.Returns a short, displayable name for the format that is decoded by thisILcdModelDecoder.Returns the input stream factory to load the data.doubleReturns the precision.doublegetStep()Returns the step in degrees between the iso lines of equal declination.booleanbooleanDeprecated.This method has been deprecated.voidremoveStatusListener(ILcdStatusListener aStatusListener) Removes a listener that should no longer be informed of progress when processing the data that was loaded.voidsetBounds(ILcdBounds aBounds) Sets the bounds the magnetic will be retrieved forstatic voidsetClassTraceOn(boolean aClassTraceOn) Deprecated.This method has been deprecated.voidsetCreateValuedPolygons(boolean aCreateClosedContours) Set this ALcdMagneticNorthModelDecoder to always create closed contours.voidSets the date to decode the model for.voidsetDegreesBetweenLines(int aDegreesBetweenLines) Deprecated.UsesetStep(double)instead.voidsetInputStreamFactory(ILcdInputStreamFactory aInputStreamFactory) Sets the input stream factory to load the data.voidsetPrecision(double aPrecision) Sets the precision.voidsetStep(double aStep) Sets the step in degrees between the iso lines of equal declination.voidsetTraceOn(boolean aTraceOn) Deprecated.This method has been deprecated.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
canDecodeSource, decodeModelMetadata, decodeModelMetadata, decodeSource, discoverDataSources
-
Constructor Details
-
TLcdWMMModelDecoder
public TLcdWMMModelDecoder()
-
-
Method Details
-
canDecodeSource
Description copied from interface:ILcdModelDecoderChecks whether this model decoder can decode the specified data source. It is acceptable for this method to returntruefor a source name whiledecodethrows 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:
canDecodeSourcein interfaceILcdModelDecoder- Parameters:
aSourceName- the data source to be verified; typically a file name or a URL.- Returns:
trueif this decoder can likely decode the data specified by the source name,falseotherwise.- See Also:
-
getDisplayName
Description copied from interface:ILcdModelDecoderReturns a short, displayable name for the format that is decoded by thisILcdModelDecoder.- Specified by:
getDisplayNamein interfaceILcdModelDecoder- Returns:
- the displayable name of this
ILcdModelDecoder.
-
decode
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:
decodein interfaceILcdModelDecoder- 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
Create a model descriptor specific for magnetic north models. This method is called fromcreateModelDescriptor(ILcdMagneticNorthMap).- Returns:
- a magnetic north model descriptor that can be configured.
-
createModelDescriptor
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
Returns the input stream factory to load the data.- Specified by:
getInputStreamFactoryin interfaceILcdInputStreamFactoryCapable- Returns:
- the input stream factory to load the data.
- See Also:
-
setInputStreamFactory
Sets the input stream factory to load the data.- Specified by:
setInputStreamFactoryin interfaceILcdInputStreamFactoryCapable- 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 istruethen 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 eithertrueorfalseas argument automatically turns off tracing for all other class instances for whichsetTraceOnhas not been called. If the argument isfalsethen 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.Returnstrueif 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.UsegetStep()instead.- Returns:
- the degrees between the lines.
-
setDegreesBetweenLines
public void setDegreesBetweenLines(int aDegreesBetweenLines) Deprecated.UsesetStep(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
- Returns:
- the date this model is valid
-
setDate
Sets the date to decode the model for. By default, the current date is used.- Parameters:
aDate- The new date
-
getBounds
- Returns:
- The bounds the magnetic north was calculated for.
-
setBounds
Sets the bounds the magnetic will be retrieved for- Parameters:
aBounds- the new bounds
-
createModel
-
addStatusListener
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:
addStatusListenerin interfaceILcdStatusSource- Parameters:
aStatusListener- the listener to inform of progress when processing the data that was loaded.- See Also:
-
removeStatusListener
Removes a listener that should no longer be informed of progress when processing the data that was loaded.- Specified by:
removeStatusListenerin interfaceILcdStatusSource- 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:
-
getStep()instead.