faa.tg.units
Class Altitude

java.lang.Object
  extended by faa.tg.units.AMeasure
      extended by faa.tg.units.Distance
          extended by faa.tg.units.Altitude
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, java.lang.Comparable<AMeasure>

public class Altitude
extends Distance

 Altitude represents the object for measuring units of Altitude:
 generally the distance above Mean Sea Level (MSL).

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

Version:
$Id: Altitude.java,v 3.12 2008/08/21 16:21:27 jimh Exp $
Author:
Tim Kimmet (modeled after Robert G. Oliver's Units Classes)
See Also:
Units.m, AUnits, AMeasure, Serialized Form

Field Summary
static Altitude ALT_TOLERANCE
          Fifty feet for almost equal aeq().
static java.lang.String CVS_VERSION_ID
          The CVS Version ID
static Altitude FT_1
           
static Altitude FT_10
           
static Altitude FT_100
           
static Altitude FT_1000
           
static Altitude FT_10000
           
static Altitude FT_1500
           
static Altitude FT_200
           
static Altitude FT_2000
           
static Altitude FT_24000
           
static Altitude FT_250
           
static Altitude FT_3000
           
static Altitude FT_400
           
static Altitude FT_450
           
static Altitude FT_50
           
static Altitude FT_500
           
static Altitude FT_50000
           
static Altitude FT_65000
           
static Altitude FT_800
           
static Altitude FT_8000
           
static Altitude KM_11
           
static Altitude KM_20
           
static Altitude MAX_ALT
          Maximum altitude currently defined in our atmospheric models.
static Altitude MIN_ALT
           
static Altitude ONE_THOUSAND_FT
           
(package private) static long serialVersionUID
           
static Altitude TEN_THOUSAND_FT
           
static Altitude ZERO
          Zero altitude.
 
Fields inherited from class faa.tg.units.Distance
FIVE_NM, FT_5, NM_1, NM_10, NM_100, NM_1000, NM_20, NM_3, NM_4, NM_5, NM_50, NM_HALF, ONE_FT
 
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
Altitude(Altitude origAlt, AltitudeRate rate, Time timeToTravel)
          Constructor for the Altitude class that uses a reference altitude, a altitude rate and a time interval to travel at the specified rate.
Altitude(double value, DistanceUnits units)
          Constructor for the Altitude class.
Altitude(java.lang.String str)
          This contructor parses a string with an altitude in flight level units (hundreds of feet: flight level 55 equals 5500 feet of altitude).
 
Method Summary
 Altitude add(Altitude theMeasure)
          This summation method adds a value with like units.
 boolean aeq(Altitude theAltitude)
          Almost equal defaults to within the ALT_TOLERANCE (50 ft).
 boolean aeq(Altitude altitude, Altitude acceptableMargin)
          Return whether the specified value is almost equal to this value (is within the acceptable margin).
 int asFL()
          This method returns the flight level (FL) value as an integer, which is the altitude unit and precision used by the Mode C altitude report.
 boolean eq(Altitude theMeasure)
          This method provides a test for equality.
 boolean ge(Altitude theMeasure)
          This method provides a test for greater than / equal to.
 boolean gt(Altitude theMeasure)
          This method provides a test for greater than.
 boolean le(Altitude theMeasure)
          This method provides a test for less than / equal to.
 boolean lt(Altitude theMeasure)
          This method provides a test for less than.
static Altitude parseAlt(java.lang.String alt)
          Parses a String containing a number and a unit name to create an Altitude: if a unit field is not successfully parsed from the text, then the unit of the numeric value is assumed to be a flight level.
static Altitude parseAltitude(java.lang.String alt)
          Parses a String containing a number and a unit name to create an Altitude: if a unit field is not successfully parsed from the text, then the unit of the numeric value is assumed to be in feet.
 Altitude sub(Altitude theMeasure)
          This subtraction method subtracts a value with like units.
static Altitude toAltitude(org.w3c.dom.Element altElem)
          Creates an Altitude from an XML element containing AttributeNodes for an altitude's value and units.
 java.lang.String toDraText()
           
 java.lang.String toFL()
          Returns the flight level (FL) value as a three character String.
 java.lang.String toString()
          This method returns the String representation of this object in the units with which it was constructed.
 
Methods inherited from class faa.tg.units.Distance
abs, add, as, eq, ge, gt, le, lt, main, parseDistance, ratio, sub
 
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

ZERO

public static final Altitude ZERO
Zero altitude.


MIN_ALT

public static final Altitude MIN_ALT

ONE_THOUSAND_FT

public static final Altitude ONE_THOUSAND_FT

TEN_THOUSAND_FT

public static final Altitude TEN_THOUSAND_FT

FT_1

public static final Altitude FT_1

FT_10

public static final Altitude FT_10

FT_50

public static final Altitude FT_50

FT_100

public static final Altitude FT_100

FT_200

public static final Altitude FT_200

FT_250

public static final Altitude FT_250

FT_400

public static final Altitude FT_400

FT_450

public static final Altitude FT_450

FT_500

public static final Altitude FT_500

FT_800

public static final Altitude FT_800

FT_1000

public static final Altitude FT_1000

FT_1500

public static final Altitude FT_1500

FT_2000

public static final Altitude FT_2000

FT_3000

public static final Altitude FT_3000

FT_8000

public static final Altitude FT_8000

FT_10000

public static final Altitude FT_10000

FT_24000

public static final Altitude FT_24000

FT_50000

public static final Altitude FT_50000

FT_65000

public static final Altitude FT_65000

KM_11

public static final Altitude KM_11

KM_20

public static final Altitude KM_20

MAX_ALT

public static final Altitude MAX_ALT
Maximum altitude currently defined in our atmospheric models.


ALT_TOLERANCE

public static Altitude ALT_TOLERANCE
Fifty feet for almost equal aeq(). Changed from 10 -> 50 because of SimPilot display accuracy (controllers thought 500 ft was aeq)

Constructor Detail

Altitude

public Altitude(double value,
                DistanceUnits units)
Constructor for the Altitude class.

Parameters:
value - The magnitude of the Altitude as a double.
units - Units of the value to be stored (ex: km).

Altitude

public Altitude(java.lang.String str)
         throws java.lang.NumberFormatException
This contructor parses a string with an altitude in flight level units (hundreds of feet: flight level 55 equals 5500 feet of altitude).

Parameters:
str - The String to make into a valid altitude.
Throws:
java.lang.NumberFormatException

Altitude

public Altitude(Altitude origAlt,
                AltitudeRate rate,
                Time timeToTravel)
Constructor for the Altitude class that uses a reference altitude, a altitude rate and a time interval to travel at the specified rate.

Parameters:
origAlt - The reference altitude to travel from.
rate - The rate of change of the altitude.
timeToTravel - The time interval to travel at the specified rate.
Method Detail

parseAltitude

public static Altitude parseAltitude(java.lang.String alt)
                              throws java.lang.NumberFormatException
Parses a String containing a number and a unit name to create an Altitude: if a unit field is not successfully parsed from the text, then the unit of the numeric value is assumed to be in feet.

NOTE: if the String is known to be just the altitude in feet, with no unit name, then execution is faster using the Altitude constructor (e.g., new Altitude(Double.parseDouble(altStr), Units.ft)) ).

Parameters:
alt - Altitude string in the format "### unitName" or "###" (feet).
Returns:
Returns the Altitude object parsed from the input String.
Throws:
java.lang.NumberFormatException - Number fails to parse after removing unit.

parseAlt

public static Altitude parseAlt(java.lang.String alt)
                         throws java.lang.NumberFormatException
Parses a String containing a number and a unit name to create an Altitude: if a unit field is not successfully parsed from the text, then the unit of the numeric value is assumed to be a flight level.

NOTE: if the String is known to be just the flight level, with no unit name, then execution is faster using the Altitude constructor (e.g., new Altitude(Double.parseDouble(altStr), Units.fl)) ).

Parameters:
alt - Altitude string in the format "### unitName" or "###" (fl).
Returns:
Returns the Altitude object parsed from the input String.
Throws:
java.lang.NumberFormatException - Number fails to parse after removing unit.

toAltitude

public static Altitude toAltitude(org.w3c.dom.Element altElem)
                           throws java.lang.IllegalArgumentException,
                                  org.w3c.dom.DOMException
Creates an Altitude from an XML element containing AttributeNodes for an altitude's value and units. Requires either text value or "value" attribute: looks for "units" attribute, but if it does not exist, parses the text/value altitude string to extract units (if no units will default to FL).

Parameters:
altElem - Altitude Element with unit attribute and a value.
Throws:
org.w3c.dom.DOMException - XML construction error.
java.lang.IllegalArgumentException - XML did not correctly specify altitude.

add

public Altitude add(Altitude theMeasure)
This summation method adds a value with like units. It overrides the method in the superclass and checks for like AMeasures as well as doing the cast for you.

Parameters:
theMeasure - the unit of measure you wish to add to this measure.
Returns:
a clone with the sum

sub

public Altitude sub(Altitude theMeasure)
This subtraction method subtracts a value with like units. It overrides the method in the superclass and checks for like AMeasures as well as doing the cast for you.

Parameters:
theMeasure - the unit of measure you wish to sub from this measure.
Returns:
a clone with the difference

eq

public boolean eq(Altitude 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(Altitude 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(Altitude 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(Altitude 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 less than or equal to.

le

public boolean le(Altitude 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 greater than or equal to.

aeq

public boolean aeq(Altitude altitude,
                   Altitude acceptableMargin)
Return whether the specified value is almost equal to this value (is within the acceptable margin).


aeq

public boolean aeq(Altitude theAltitude)
Almost equal defaults to within the ALT_TOLERANCE (50 ft).


asFL

public int asFL()
This method returns the flight level (FL) value as an integer, which is the altitude unit and precision used by the Mode C altitude report. The returned number therefore represents an altitude rounded to the nearest 100 feet, given in hundreds of feet.

Returns:
The Mode C flight level value as an integer.

toFL

public java.lang.String toFL()
Returns the flight level (FL) value as a three character String.

The flight level is the altitude unit and precision used by the Mode C altitude report. The returned number therefore represents an altitude rounded to the nearest 100 feet, given in hundreds of feet.

See Also:
asFL()

toDraText

public java.lang.String toDraText()
Overrides:
toDraText in class Distance
Returns:
Returns the information in DR&A string format.

toString

public java.lang.String toString()
This method returns the String representation of this object in the units with which it was constructed.

Overrides:
toString in class Distance
Returns:
a pretty string with the value and the units.
See Also:
Units