public class TLcdWMMMagneticNorthMap extends Object implements ILcdInputStreamFactoryCapable
Be sure to use the same TLcdWMMMagneticNorthMap
for successive calculations since it performs caching.
The model used for the calculations has a limited life span. If you try to perform
calculations outside this lifespan, an exception will be thrown. You can set this class
to ignore the limited lifespan with the method setIgnoreModelLifeSpan
. In
this case, no exception will be thrown when you perform calculations outside the
lifespan.
Multiple data file names, for multiple life spans can be used for this map. The map will always
switch to the correct data file when setDate(java.util.Calendar)
is called. Note that the user of this class is
responsible for setting the data file names.
Check out http://www.ngdc.noaa.gov/geomag/geomag.shtml for more info about the used terms.
Check out http://www.ngdc.noaa.gov/geomag/WMM/DoDWMM.shtml for more information about the used model.
This implementation is not thread-safe
Modifier and Type | Field and Description |
---|---|
protected static int |
DECLINATION |
protected static int |
INCLINATION |
protected static int |
TOTAL_INTENSITY |
Constructor and Description |
---|
TLcdWMMMagneticNorthMap()
Constructs a new
TLcdWMMMagneticNorthMap . |
TLcdWMMMagneticNorthMap(String aDataFileName)
Constructs a new
TLcdWMMMagneticNorthMap ready to use, for a single data file. |
TLcdWMMMagneticNorthMap(String[] aDataFileNames)
Constructor for a
TLcdWMMMagneticNorthMap , initialized with a number of
consecutive data files. |
Modifier and Type | Method and Description |
---|---|
Object |
clone() |
static float |
convertCalendarToDecimalTime(Calendar aTime)
Converts a
Calendar to a decimal year format. |
static Calendar |
convertDecimalTimeToCalendar(float aDecimalTime)
Converts a decimal year format to a
Calendar . |
Calendar |
getBeginValidDate()
Return the first date value for which this map can retrieve magnetic north.
|
String |
getDataFileName()
Returns the file name of the data file currently used to base the calculations on.
|
String[] |
getDataFileNames()
Returns the uses data file names.
|
Calendar |
getDate()
Returns the current date set to this map.
|
Calendar |
getEndValidDate()
Return the last date value for which this map can retrieve magnetic north.
|
ILcdInputStreamFactory |
getInputStreamFactory()
Returns the currently used input stream factory.
|
String |
getModelName()
Returns the name of the model.
|
String |
getShortModelName()
Returns the abbreviated model name.
|
Calendar |
getValidDateClosestToToday() |
boolean |
isIgnoreModelLifeSpan()
Returns true if the model lifespan is ignored, false otherwise.
|
boolean |
isValidDate(Calendar aDate)
Checks whether the given date is a valid date for this map.
|
float |
retrieveDeclinationAt(ILcdPoint aPoint)
Given a point (and implicitly a time value via setDate()), this method calculates
the declination of the magnetic north vector.
|
float |
retrieveInclinationAt(ILcdPoint aPoint)
Given a point (and implicitly a time value via setDate()), this method calculates
the inclination of the magnetic north vector.
|
float |
retrieveTotalIntensityAt(ILcdPoint aPoint)
Given a point (and implicitly a time value via setDate()), this method calculates
the total intensity of the magnetic north vector.
|
void |
setDataFileName(String aDataFileName)
Sets the file name of the data file to be used.
|
void |
setDataFileNames(String[] aDataFileNames)
Sets the list of data files to use.
|
void |
setDate(Calendar aDate)
Sets the date to retrieve the magnetic north at.
|
void |
setIgnoreModelLifeSpan(boolean aIgnoreModelLifeSpan)
With this method one set to ignore or to not ignore the model life span.
|
void |
setInputStreamFactory(ILcdInputStreamFactory aInputStreamFactory)
Sets the input stream factory to load the data.
|
protected static final int DECLINATION
protected static final int INCLINATION
protected static final int TOTAL_INTENSITY
public TLcdWMMMagneticNorthMap()
TLcdWMMMagneticNorthMap
. The data file(s) should be
set before all functionality of this object is available. Call setDataFileName
or
setDataFileNames
before attempting to retrieve magnetic north parameters.public TLcdWMMMagneticNorthMap(String aDataFileName)
TLcdWMMMagneticNorthMap
ready to use, for a single data file.aDataFileName
- The data file name for this object.IllegalArgumentException
- when the file can't be found.public TLcdWMMMagneticNorthMap(String[] aDataFileNames) throws IllegalArgumentException
TLcdWMMMagneticNorthMap
, initialized with a number of
consecutive data files.aDataFileNames
- a list of filenames for the different WMM data files to be taken
into account.IllegalArgumentException
- When the valid date ranges for the passed data files aren't
consecutive, or when one of the files can't be found.public String getDataFileName()
setDataFileName(java.lang.String)
,
setDataFileNames(java.lang.String[])
public void setDataFileName(String aDataFileName) throws IllegalArgumentException
setDataFileNames(java.lang.String[])
when using multiple data files.aDataFileName
- The file name relative to the classpathIllegalArgumentException
- when the file can't be found.getDataFileName()
,
setDataFileNames(java.lang.String[])
public String[] getDataFileNames()
public void setDataFileNames(String[] aDataFileNames) throws IllegalArgumentException
getBeginValidDate()
and getEndValidDate()
, there will be a
range of dates that will cause exceptions when used with this map.aDataFileNames
- A list of data file names relative to the classpath.IllegalArgumentException
- When the valid date ranges for the passed data files aren't
consecutive, or when one of the files can't be found.public float retrieveDeclinationAt(ILcdPoint aPoint)
ILcdMagneticNorthMap
retrieveDeclinationAt
in interface ILcdMagneticNorthMap
aPoint
- The point on the globe, the reference is World Geodetic System
1984 (WGS 84)public float retrieveInclinationAt(ILcdPoint aPoint)
ILcdMagneticNorthMap
retrieveInclinationAt
in interface ILcdMagneticNorthMap
aPoint
- The point on the globe, the reference is World Geodetic System
1984 (WGS 84)public float retrieveTotalIntensityAt(ILcdPoint aPoint)
ILcdMagneticNorthMap
retrieveTotalIntensityAt
in interface ILcdMagneticNorthMap
aPoint
- The point on the globe, the reference is World Geodetic System
1984 (WGS 84)public Object clone() throws CloneNotSupportedException
clone
in interface ILcdMagneticNorthMap
CloneNotSupportedException
ILcdMagneticNorthMap
public boolean isIgnoreModelLifeSpan()
public void setIgnoreModelLifeSpan(boolean aIgnoreModelLifeSpan)
aIgnoreModelLifeSpan
- true if the model life span should be ignored, false otherwise.public String getModelName()
ILcdMagneticNorthMap
getModelName
in interface ILcdMagneticNorthMap
public String getShortModelName()
ILcdMagneticNorthMap
getShortModelName
in interface ILcdMagneticNorthMap
public void setDate(Calendar aDate) throws IllegalArgumentException
setDate
in interface ILcdMagneticNorthMap
aDate
- The date, isValidDate(aDate) must be true.IllegalArgumentException
- when isIgnoreModelLifeSpan()
returns false and the
date passed falls outside the life span for all available data files.ILcdMagneticNorthMap.getDate()
public Calendar getBeginValidDate()
getBeginValidDate
in interface ILcdMagneticNorthMap
public Calendar getEndValidDate()
getEndValidDate
in interface ILcdMagneticNorthMap
public Calendar getDate()
getDate
in interface ILcdMagneticNorthMap
ILcdMagneticNorthMap.setDate(java.util.Calendar)
public boolean isValidDate(Calendar aDate)
isValidDate
in interface ILcdMagneticNorthMap
aDate
- the date to check the validity for.getBeginValidDate() <= aDate <= getEndValidDate()
, false otherwise.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 ILcdInputStreamFactory getInputStreamFactory()
getInputStreamFactory
in interface ILcdInputStreamFactoryCapable
public Calendar getValidDateClosestToToday()
public static float convertCalendarToDecimalTime(Calendar aTime)
Calendar
to a decimal year format.
Only uses year, month and day. Hours and seconds are ignored.public static Calendar convertDecimalTimeToCalendar(float aDecimalTime)
Calendar
.
Only uses year. Month, day, hours and seconds are ignored.