faa.tg.units
Class MagneticHeading

java.lang.Object
  extended by faa.tg.units.AMeasure
      extended by faa.tg.units.Angle
          extended by faa.tg.units.MagneticHeading
All Implemented Interfaces:
HasText, java.io.Serializable, java.lang.Cloneable, java.lang.Comparable<AMeasure>
Direct Known Subclasses:
Radial

public class MagneticHeading
extends Angle

 MagneticHeading represents a measurement of the heading of an aircraft
 with respect to Magnetic North.

 See section 5.6 of the Detailed Design Document for a discussion
    of design issues.
 
See the source: MagneticHeading.java

Version:
$Id: MagneticHeading.java,v 3.4 2008/12/15 19:39:31 lykensj Exp $
Author:
Tim Kimmet (modeled after Robert G. Oliver's Units Classes)
See Also:
AUnits, AMeasure, MagneticHeading, Units.radians, Serialized Form

Field Summary
static java.lang.String CVS_VERSION_ID
          The CVS Version ID
static MagneticHeading DEG_360
           
(package private) static long serialVersionUID
           
 
Fields inherited from class faa.tg.units.Angle
D180_DIV_PI, DEG_1, DEG_180, DEG_270, DEG_30, DEG_330, DEG_5, DEG_60, DEG_90, DEG_NEG180, DEG_NEG270, DEG_NEG30, DEG_NEG5, DEG_NEG90, DEG_PER_RAD, NEG_NINETY_DEG, NEG_ONEEIGHTY_DEG, NINETY_DEG, ONEEIGHTY_DEG, PI, PI_DIV_180, PI_DIV_2, PI_DIV_4, PI_MUL_2, PI_MUL_4, RAD_PER_DEG, THIRTY_DEG, THREETHIRTY_DEG, TWOSEVENTY_DEG, ZERO
 
Fields inherited from class faa.tg.units.AMeasure
DEC0, DEC0_, DEC00, DEC000, DEC1, DEC1_, DEC12, DEC12_, DEC1L, DEC1L_, DEC2, DEC2_, DEC3, DEC3_, DEC4, DEC4_, DEC5, DEC5_, DEC6, DEC6_, DEC7, DEC7_, DEC9, DEC9_, itsValue, TIME_FRACTION
 
Constructor Summary
MagneticHeading(double theValue, AngleUnits theUnits)
          Constructor for the MagneticHeading class
MagneticHeading(java.lang.String dmsStr)
          Constructor for MagneticHeading that parses an input String to determine the value.
 
Method Summary
 boolean eq(MagneticHeading theMeasure)
          This method provides a test for equality.
 TurnDirection findTurnDirectionTo(MagneticHeading desiredHeading)
          Determines the TurnDirection to a given desired magnetic heading.
 boolean ge(MagneticHeading theMeasure)
          This method provides a test for greater than / equal to.
 TrueHeading getTrueHeading(MagneticDeclination magdec)
          Returns the TrueHeading of the magnetic declination of a Position.
 boolean gt(MagneticHeading theMeasure)
          This method provides a test for greater than.
 boolean le(MagneticHeading theMeasure)
          This method provides a test for less than / equal to.
 boolean lt(MagneticHeading theMeasure)
          This method provides a test for less than.
private static double normalizeRange(double degrees, AUnits units)
          Normalizes the MagneticHeading value to be greater than 0 and <= 360.
 double ratio(MagneticHeading val)
          This division method produces a dimensionless ratio of like measures.
 java.lang.String toString()
          returns the String representation of this object in the units used to create it.
 
Methods inherited from class faa.tg.units.Angle
abs, add, aeq, as, average, cos, diff, eq, ge, gt, isBetween, le, lt, main, parseDmsString, ratio, reciprocalAngle, removeDelimiters, sin, sub, tan, toDmsString, toRadialString, toText
 
Methods inherited from class faa.tg.units.AMeasure
absoluteValue, add, as, as, clone, compareTo, debug, div, eq, equals, ge, getAUnit, getCanonicalUnit, getCanonicalValue, getInitialUnit, getUnitClass, gt, hashCode, isBetween, le, lt, mul, ratio, sub, toAMeasure, toString, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

serialVersionUID

static final long serialVersionUID
See Also:
Constant Field Values

CVS_VERSION_ID

public static final java.lang.String CVS_VERSION_ID
The CVS Version ID

See Also:
Constant Field Values

DEG_360

public static final MagneticHeading DEG_360
Constructor Detail

MagneticHeading

public MagneticHeading(double theValue,
                       AngleUnits theUnits)
                throws java.lang.NumberFormatException
Constructor for the MagneticHeading class

Parameters:
theValue - The magnitude of MagneticHeading as a double.
theUnits - The units of the value that will be stored (ex: deg).
Throws:
java.lang.NumberFormatException

MagneticHeading

public MagneticHeading(java.lang.String dmsStr)
                throws java.lang.NumberFormatException
Constructor for MagneticHeading that parses an input String to determine the value. The String may be in any of the following formats:
   ddd-mm-ss.sss     ddd-mm-ss     ddd-mm.mmm     ddd-mm     ddd.ddd
   dd-mm-ss.sss      dd-mm-ss      dd-mm.mmm      dd-mm      dd.ddd

   ddd:mm:ss.sss     ddd:mm:ss     ddd:mm.mmm     ddd:mm     ddd
   dd:mm:ss.sss      dd:mm:ss      dd:mm.mmm      dd:mm      dd

   dddmmss.sss       dddmmss       dddmm.mmm      dddmm
   ddmmss.sss        ddmmss        ddmm.mmm       ddmm
 
In addition, the string may start or end with one of the following hemisphere designation characters:
     N      S      E      W      +      -
 
Note: the degrees field must have either 2 or 3 digits; minutes and seconds fields (not including decimal fraction) must be 2 digits.

Parameters:
dmsStr - A String in degrees:minutes:seconds format. If in [D]DD:MM:SS, the string should start or end with a N-S, E-W or +/- direction designator.
Throws:
java.lang.NumberFormatException - If the string could not be parsed.
Method Detail

findTurnDirectionTo

public TurnDirection findTurnDirectionTo(MagneticHeading desiredHeading)
Determines the TurnDirection to a given desired magnetic heading.

Parameters:
desiredHeading - the end heading
Returns:
the appropriate TurnDirection
See Also:
TurnDirection

getTrueHeading

public TrueHeading getTrueHeading(MagneticDeclination magdec)
Returns the TrueHeading of the magnetic declination of a Position.

Parameters:
magdec - The MagneticDeclination to get the TrueHeading of.

normalizeRange

private static double normalizeRange(double degrees,
                                     AUnits units)
Normalizes the MagneticHeading value to be greater than 0 and <= 360. This must be static to be used in the super call.


ratio

public double ratio(MagneticHeading val)
This division method produces a dimensionless ratio of like measures.

Returns:
the ratio of the two measures

eq

public boolean eq(MagneticHeading theMeasure)
This method provides a test for equality. It overrides the method in the superclass and checks for like AMeasures as well as doing the cast for you.

Returns:
Returns boolean indicating whether values are equal.

lt

public boolean lt(MagneticHeading theMeasure)
This method provides a test for less than. It overrides the method in the superclass and checks for like AMeasures as well as doing the cast for you.

Returns:
Returns whether this value is less than the given value.

gt

public boolean gt(MagneticHeading theMeasure)
This method provides a test for greater than. It overrides the method in the superclass and checks for like AMeasures as well as doing the cast for you.

Returns:
Returns whether this value is greater than the given value.

ge

public boolean ge(MagneticHeading theMeasure)
This method provides a test for greater than / equal to. It overrides the method in the superclass and checks for like AMeasures as well as doing the cast for you.

Returns:
Returns result of test for greater than or equal to.

le

public boolean le(MagneticHeading theMeasure)
This method provides a test for less than / equal to. It overrides the method in the superclass and checks for like AMeasures as well as doing the cast for you.

Returns:
Returns result of test for less than or equal to.

toString

public java.lang.String toString()
returns the String representation of this object in the units used to create it.

Overrides:
toString in class Angle
Returns:
A String representing the measure in the canonical unit.
See Also:
Units