public class TLcdIGRFModelDecoder extends Object implements ILcdInputStreamFactoryCapable
TLcdMagneticNorthModel
from a data file containing
the parameters for the IGRF magnetic model. Such a file can be found in
samples/resources/Data/magneticnorth
File | Required | Entry point | Description |
---|---|---|---|
* | x | x | file containing the magnetic model coefficients |
ILcdInputStreamFactory
of this decoder.
ILcd2DBoundsIndexedModel
.
TLcdIGRFModelDescriptor
data model
contains the data types found in
TLcdMagneticNorthDataTypes
set date
.
The model elements implement ILcdDataObject
, on top of implementing their respective shape.
TLcdIGRFModelDecoder decoder = new TLcdIGRFModelDecoder();
decoder.setDate(new GregorianCalendar(2019, 1, 1));
ILcdModel model = decoder.decode("Data/magneticnorth/igrf");
read lock
.Constructor and Description |
---|
TLcdIGRFModelDecoder() |
Modifier and Type | Method and Description |
---|---|
void |
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 |
createMagneticNorthModelDescriptor()
Create a model descriptor specific for magnetic north models.
|
protected TLcdMagneticNorthModel |
createModel(ILcdMagneticNorthMap aMap) |
protected ILcdModelDescriptor |
createModelDescriptor(ILcdMagneticNorthMap aMap)
Creates a model descriptor for the model by creating a magnetic north model descriptor
(
createMagneticNorthModelDescriptor() ) and then configuring it. |
ILcdModel |
decode(String aSourceName)
Creates a new model from the given data source.
|
ILcdBounds |
getBounds() |
Calendar |
getDate() |
int |
getDegreesBetweenLines()
Deprecated.
Use
getStep() instead. |
String |
getDisplayName()
Returns a short, displayable name for the format that is decoded by this
ILcdModelDecoder . |
ILcdInputStreamFactory |
getInputStreamFactory()
Returns the input stream factory to load the data.
|
double |
getPrecision()
Returns the precision.
|
double |
getStep()
Returns the step in degrees between the iso lines of equal declination.
|
boolean |
isCreateValuedPolygons() |
boolean |
isTraceOn()
Deprecated.
This method has been deprecated. It is recommended to use the
standard Java logging framework directly.
|
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 for
|
static void |
setClassTraceOn(boolean aClassTraceOn)
Deprecated.
This method has been deprecated. It is recommended to use the
standard Java logging framework directly.
|
void |
setCreateValuedPolygons(boolean aCreateClosedContours)
Set this ALcdMagneticNorthModelDecoder to always create closed contours.
|
void |
setDate(Calendar aDate)
Sets the date to decode the model for.
|
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 ) |
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. It is recommended to use the
standard Java logging framework directly.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
canDecodeSource, decodeModelMetadata, decodeModelMetadata, decodeSource, discoverDataSources
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 String getDisplayName()
ILcdModelDecoder
ILcdModelDecoder
.getDisplayName
in interface ILcdModelDecoder
ILcdModelDecoder
.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)
protected ILcdModelDescriptor createModelDescriptor(ILcdMagneticNorthMap aMap)
createMagneticNorthModelDescriptor()
) and then configuring it.aMap
- the map to create a model descriptor forprotected ALcdMagneticNorthModelDescriptor createMagneticNorthModelDescriptor()
createModelDescriptor(ILcdMagneticNorthMap)
.public ILcdInputStreamFactory getInputStreamFactory()
getInputStreamFactory
in interface ILcdInputStreamFactoryCapable
setInputStreamFactory(com.luciad.io.ILcdInputStreamFactory)
public void setInputStreamFactory(ILcdInputStreamFactory aInputStreamFactory)
setInputStreamFactory
in interface ILcdInputStreamFactoryCapable
aInputStreamFactory
- an InputStream factory that creates input streams to load the
magnetic north data.getInputStreamFactory()
public static void setClassTraceOn(boolean aClassTraceOn)
true
then all log messages are recorded, otherwise only
the informative, warning and error messages are recorded.aClassTraceOn
- if true then all log messages are recorded,
otherwise only the informative, warning and error messages are recorded.public void setTraceOn(boolean aTraceOn)
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.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.public boolean isTraceOn()
true
if tracing is enabled for this class.public double getPrecision()
public void setPrecision(double aPrecision)
aPrecision
- the precision to be usedpublic int getDegreesBetweenLines()
getStep()
instead.public void setDegreesBetweenLines(int aDegreesBetweenLines)
setStep(double)
instead.
Sets the number of degrees between the iso lines. ( f.e. a line every 2 degrees )aDegreesBetweenLines
- the number of degrees between two lines. The lower this number, the higher the number
of lines that will be created.public double getStep()
public void setStep(double aStep)
aStep
- The step in degrees between the iso lines of equal declination.public Calendar getDate()
public void setDate(Calendar aDate)
aDate
- The new datepublic ILcdBounds getBounds()
public void setBounds(ILcdBounds aBounds)
aBounds
- the new boundsprotected TLcdMagneticNorthModel createModel(ILcdMagneticNorthMap aMap)
public void addStatusListener(ILcdStatusListener aStatusListener)
addStatusListener
in interface ILcdStatusSource
aStatusListener
- the listener to inform of progress when processing the data that was loaded.removeStatusListener(com.luciad.util.ILcdStatusListener)
public void removeStatusListener(ILcdStatusListener aStatusListener)
removeStatusListener
in interface ILcdStatusSource
aStatusListener
- a listener that should no longer be informed of progress when processing the data that was loaded.addStatusListener(com.luciad.util.ILcdStatusListener)
public void setCreateValuedPolygons(boolean aCreateClosedContours)
aCreateClosedContours
- The behaviour to setpublic boolean isCreateValuedPolygons()
setCreateValuedPolygons(boolean)