Package com.luciad.format.magneticnorth
Class TLcdIGRFModelDecoder
java.lang.Object
com.luciad.format.magneticnorth.TLcdIGRFModelDecoder
- All Implemented Interfaces:
ILcdInputStreamFactoryCapable
,ILcdModelDecoder
,ILcdStatusSource
This class produces a
Should you want to download such a file from the IGRF website, beware that the file format is that of the Geomag software, not the spreadsheet
format.
The current implementation supports the coefficient files up to IGRF-13. Because the coefficients file format is subject to change, this decoder is not guaranteed to work with future coefficient files.
TLcdMagneticNorthModel
from a data file containing
the parameters for the IGRF magnetic model. Such a file can be found in
samples/resources/Data/magneticnorth
Input files
File | Required | Entry point | Description |
---|---|---|---|
* | x | x | file containing the magnetic model coefficients |
The current implementation supports the coefficient files up to IGRF-13. Because the coefficients file format is subject to change, this decoder is not guaranteed to work with future coefficient files.
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
TLcdIGRFModelDescriptor
- The
data model
contains 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
TLcdIGRFModelDecoder decoder = new TLcdIGRFModelDecoder();
decoder.setDate(new GregorianCalendar(2019, 1, 1));
ILcdModel model = decoder.decode("Data/magneticnorth/igrf");
Thread safety
- The decoded models are thread-safe for read access when taking a
read lock
.
Supported versions and specifications
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addStatusListener
(ILcdStatusListener aStatusListener) Adds a listener that will be informed of progress when processing the data that was loaded.boolean
canDecodeSource
(String aSourceName) Checks whether this model decoder can decode the specified data source.protected ALcdMagneticNorthModelDescriptor
Create a model descriptor specific for magnetic north models.protected TLcdMagneticNorthModel
protected ILcdModelDescriptor
Creates a model descriptor for the model by creating a magnetic north model descriptor (createMagneticNorthModelDescriptor()
) and then configuring it.Creates a new model from the given data source.getDate()
int
Deprecated.Returns a short, displayable name for the format that is decoded by thisILcdModelDecoder
.Returns the input stream factory to load the data.double
Returns the precision.double
getStep()
Returns the step in degrees between the iso lines of equal declination.boolean
boolean
Deprecated.This method has been deprecated.void
removeStatusListener
(ILcdStatusListener aStatusListener) Removes a listener that should no longer be informed of progress when processing the data that was loaded.void
setBounds
(ILcdBounds aBounds) Sets the bounds the magnetic will be retrieved forstatic void
setClassTraceOn
(boolean aClassTraceOn) Deprecated.This method has been deprecated.void
setCreateValuedPolygons
(boolean aCreateClosedContours) Set this ALcdMagneticNorthModelDecoder to always create closed contours.void
Sets the date to decode the model for.void
setDegreesBetweenLines
(int aDegreesBetweenLines) Deprecated.UsesetStep(double)
instead.void
setInputStreamFactory
(ILcdInputStreamFactory aInputStreamFactory) Sets the input stream factory to load the data.void
setPrecision
(double aPrecision) Sets the precision.void
setStep
(double aStep) Sets the step in degrees between the iso lines of equal declination.void
setTraceOn
(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, wait
Methods inherited from interface com.luciad.model.ILcdModelDecoder
canDecodeSource, decodeModelMetadata, decodeModelMetadata, decodeSource, discoverDataSources
-
Constructor Details
-
TLcdIGRFModelDecoder
public TLcdIGRFModelDecoder()
-
-
Method Details
-
canDecodeSource
Description copied from interface:ILcdModelDecoder
Checks whether this model decoder can decode the specified data source. It is acceptable for this method to returntrue
for a source name whiledecode
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 interfaceILcdModelDecoder
- 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
Description copied from interface:ILcdModelDecoder
Returns a short, displayable name for the format that is decoded by thisILcdModelDecoder
.- Specified by:
getDisplayName
in interfaceILcdModelDecoder
- Returns:
- the displayable name of this
ILcdModelDecoder
.
-
decode
Description copied from interface:ILcdModelDecoder
Creates a new model from the given data source.- Specified by:
decode
in interfaceILcdModelDecoder
- 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:
-
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.
-
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.
-
getInputStreamFactory
Returns the input stream factory to load the data.- Specified by:
getInputStreamFactory
in interfaceILcdInputStreamFactoryCapable
- Returns:
- the input stream factory to load the data.
- See Also:
-
setInputStreamFactory
Sets the input stream factory to load the data.- Specified by:
setInputStreamFactory
in 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 istrue
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 eithertrue
orfalse
as argument automatically turns off tracing for all other class instances for whichsetTraceOn
has not been called. If the argument isfalse
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.Returnstrue
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.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:
addStatusListener
in 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:
removeStatusListener
in 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.