Class TLcdWMMMagneticNorthMap
- All Implemented Interfaces:
ILcdMagneticNorthMap,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
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final intprotected static final intprotected static final int -
Constructor Summary
ConstructorsConstructorDescriptionConstructs a newTLcdWMMMagneticNorthMap.TLcdWMMMagneticNorthMap(String aDataFileName) Constructs a newTLcdWMMMagneticNorthMapready to use, for a single data file.TLcdWMMMagneticNorthMap(String[] aDataFileNames) Constructor for aTLcdWMMMagneticNorthMap, initialized with a number of consecutive data files. -
Method Summary
Modifier and TypeMethodDescriptionclone()static floatConverts aCalendarto a decimal year format.static CalendarconvertDecimalTimeToCalendar(float aDecimalTime) Converts a decimal year format to aCalendar.Return the first date value for which this map can retrieve magnetic north.Returns the file name of the data file currently used to base the calculations on.String[]Returns the uses data file names.getDate()Returns the current date set to this map.Return the last date value for which this map can retrieve magnetic north.Returns the currently used input stream factory.Returns the name of the model.Returns the abbreviated model name.booleanReturns true if the model lifespan is ignored, false otherwise.booleanisValidDate(Calendar aDate) Checks whether the given date is a valid date for this map.floatretrieveDeclinationAt(ILcdPoint aPoint) Given a point (and implicitly a time value via setDate()), this method calculates the declination of the magnetic north vector.floatretrieveInclinationAt(ILcdPoint aPoint) Given a point (and implicitly a time value via setDate()), this method calculates the inclination of the magnetic north vector.floatretrieveTotalIntensityAt(ILcdPoint aPoint) Given a point (and implicitly a time value via setDate()), this method calculates the total intensity of the magnetic north vector.voidsetDataFileName(String aDataFileName) Sets the file name of the data file to be used.voidsetDataFileNames(String[] aDataFileNames) Sets the list of data files to use.voidSets the date to retrieve the magnetic north at.voidsetIgnoreModelLifeSpan(boolean aIgnoreModelLifeSpan) With this method one set to ignore or to not ignore the model life span.voidsetInputStreamFactory(ILcdInputStreamFactory aInputStreamFactory) Sets the input stream factory to load the data.
-
Field Details
-
DECLINATION
protected static final int DECLINATION- See Also:
-
INCLINATION
protected static final int INCLINATION- See Also:
-
TOTAL_INTENSITY
protected static final int TOTAL_INTENSITY- See Also:
-
-
Constructor Details
-
TLcdWMMMagneticNorthMap
public TLcdWMMMagneticNorthMap()Constructs a newTLcdWMMMagneticNorthMap. The data file(s) should be set before all functionality of this object is available. CallsetDataFileNameorsetDataFileNamesbefore attempting to retrieve magnetic north parameters. -
TLcdWMMMagneticNorthMap
Constructs a newTLcdWMMMagneticNorthMapready to use, for a single data file.- Parameters:
aDataFileName- The data file name for this object.- Throws:
IllegalArgumentException- when the file can't be found.
-
TLcdWMMMagneticNorthMap
Constructor for aTLcdWMMMagneticNorthMap, initialized with a number of consecutive data files.- Parameters:
aDataFileNames- a list of filenames for the different WMM data files to be taken into account.- Throws:
IllegalArgumentException- When the valid date ranges for the passed data files aren't consecutive, or when one of the files can't be found.
-
-
Method Details
-
getDataFileName
Returns the file name of the data file currently used to base the calculations on.- Returns:
- The file name of the data file currently used to base the calculations on
- See Also:
-
setDataFileName
Sets the file name of the data file to be used. Refer tosetDataFileNames(java.lang.String[])when using multiple data files.- Parameters:
aDataFileName- The file name relative to the classpath- Throws:
IllegalArgumentException- when the file can't be found.- See Also:
-
getDataFileNames
Returns the uses data file names.- Returns:
- the list of available data file names.
-
setDataFileNames
Sets the list of data files to use. Warning: Make sure there are no holes in the total range of valid dates for the separate data files. Do not, for instance, pass a WMM file for 2000-2005 and one for 2010-2015 and omit the file for 2005-2010. The map will still work for the available life spans, but betweengetBeginValidDate()andgetEndValidDate(), there will be a range of dates that will cause exceptions when used with this map.- Parameters:
aDataFileNames- A list of data file names relative to the classpath.- Throws:
IllegalArgumentException- When the valid date ranges for the passed data files aren't consecutive, or when one of the files can't be found.
-
retrieveDeclinationAt
Description copied from interface:ILcdMagneticNorthMapGiven a point (and implicitly a time value via setDate()), this method calculates the declination of the magnetic north vector.- Specified by:
retrieveDeclinationAtin interfaceILcdMagneticNorthMap- Parameters:
aPoint- The point on the globe, the reference is World Geodetic System 1984 (WGS 84)- Returns:
- the declination in degrees at the given point
-
retrieveInclinationAt
Description copied from interface:ILcdMagneticNorthMapGiven a point (and implicitly a time value via setDate()), this method calculates the inclination of the magnetic north vector.- Specified by:
retrieveInclinationAtin interfaceILcdMagneticNorthMap- Parameters:
aPoint- The point on the globe, the reference is World Geodetic System 1984 (WGS 84)- Returns:
- the inclination in degrees at the given point
-
retrieveTotalIntensityAt
Description copied from interface:ILcdMagneticNorthMapGiven a point (and implicitly a time value via setDate()), this method calculates the total intensity of the magnetic north vector.- Specified by:
retrieveTotalIntensityAtin interfaceILcdMagneticNorthMap- Parameters:
aPoint- The point on the globe, the reference is World Geodetic System 1984 (WGS 84)- Returns:
- the total intensity in nanoTesla (nT) at the given point
-
clone
- Specified by:
clonein interfaceILcdMagneticNorthMap- Throws:
CloneNotSupportedException- See Also:
-
isIgnoreModelLifeSpan
public boolean isIgnoreModelLifeSpan()Returns true if the model lifespan is ignored, false otherwise.- Returns:
- true if the model lifespan is ignored, false otherwise.
-
setIgnoreModelLifeSpan
public void setIgnoreModelLifeSpan(boolean aIgnoreModelLifeSpan) With this method one set to ignore or to not ignore the model life span. See above for more info.- Parameters:
aIgnoreModelLifeSpan- true if the model life span should be ignored, false otherwise.
-
getModelName
Description copied from interface:ILcdMagneticNorthMapReturns the name of the model.- Specified by:
getModelNamein interfaceILcdMagneticNorthMap- Returns:
- the name of the model
-
getShortModelName
Description copied from interface:ILcdMagneticNorthMapReturns the abbreviated model name.- Specified by:
getShortModelNamein interfaceILcdMagneticNorthMap- Returns:
- the abbreviated model name
-
setDate
Sets the date to retrieve the magnetic north at.- Specified by:
setDatein interfaceILcdMagneticNorthMap- Parameters:
aDate- The date, isValidDate(aDate) must be true.- Throws:
IllegalArgumentException- whenisIgnoreModelLifeSpan()returns false and the date passed falls outside the life span for all available data files.- See Also:
-
getBeginValidDate
Return the first date value for which this map can retrieve magnetic north.- Specified by:
getBeginValidDatein interfaceILcdMagneticNorthMap- Returns:
- the first date value for which this map can retrieve magnetic north
-
getEndValidDate
Return the last date value for which this map can retrieve magnetic north.- Specified by:
getEndValidDatein interfaceILcdMagneticNorthMap- Returns:
- the last date value for which this map can retrieve magnetic north
-
getDate
Returns the current date set to this map.- Specified by:
getDatein interfaceILcdMagneticNorthMap- Returns:
- The current date set to this map.
- See Also:
-
isValidDate
Checks whether the given date is a valid date for this map.- Specified by:
isValidDatein interfaceILcdMagneticNorthMap- Parameters:
aDate- the date to check the validity for.- Returns:
- true if
getBeginValidDate() <= aDate <= getEndValidDate(), false otherwise.
-
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:
-
getInputStreamFactory
Returns the currently used input stream factory.- Specified by:
getInputStreamFactoryin interfaceILcdInputStreamFactoryCapable- Returns:
- the currently used input stream factory.
-
getValidDateClosestToToday
-
convertCalendarToDecimalTime
Converts aCalendarto a decimal year format. Only uses year, month and day. Hours and seconds are ignored. -
convertDecimalTimeToCalendar
Converts a decimal year format to aCalendar. Only uses year. Month, day, hours and seconds are ignored.
-