org.hermit.geo
Class Distance

java.lang.Object
  extended by org.hermit.geo.Distance

public final class Distance
extends java.lang.Object

This class represents a geographic distance -- ie. a distance from or to a given geographic position.

Author:
Ian Cameron Smith

Field Summary
static Distance ZERO
          A distance equal to zero.
 
Constructor Summary
Distance(double metres)
          Create a Distance from a value given in metres.
 
Method Summary
 Distance add(Distance d)
          Return the sum of this and another Distance.
 java.lang.String describeNautical()
          Convert this distance into a descriptive string, using nautical measures.
 java.lang.String formatM()
          Format this position for user display in metres.
 java.lang.String formatNm()
          Format this position for user display in nautical miles.
static Distance fromFeet(double feet)
          Create a Distance from a distance given in feet.
static Distance fromNm(double nmiles)
          Create a Distance from a distance given in nautical miles.
 double getFeet()
          Get the distance in feet.
 double getMetres()
          Get the distance in metres.
 double getNm()
          Get the distance in nautical miles.
 java.lang.String toString()
          Format this position as a String.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

ZERO

public static final Distance ZERO
A distance equal to zero.

Constructor Detail

Distance

public Distance(double metres)
Create a Distance from a value given in metres.

Parameters:
metres - Source distance in metres.
Method Detail

fromFeet

public static Distance fromFeet(double feet)
Create a Distance from a distance given in feet.

Parameters:
feet - Source distance in feet.
Returns:
The new Distance.

fromNm

public static Distance fromNm(double nmiles)
Create a Distance from a distance given in nautical miles.

Parameters:
nmiles - Source distance in nautical miles.
Returns:
The new Distance.

getMetres

public final double getMetres()
Get the distance in metres.

Returns:
The distance in metres.

getFeet

public final double getFeet()
Get the distance in feet.

Returns:
The distance in feet.

getNm

public final double getNm()
Get the distance in nautical miles.

Returns:
The distance in nautical miles.

add

public Distance add(Distance d)
Return the sum of this and another Distance.

Parameters:
d - Distance to add to this one.
Returns:
Distance representing the sum of the two distances.

formatM

public java.lang.String formatM()
Format this position for user display in metres.

Returns:
The formatted distance.

formatNm

public java.lang.String formatNm()
Format this position for user display in nautical miles.

Returns:
The formatted distance.

describeNautical

public java.lang.String describeNautical()
Convert this distance into a descriptive string, using nautical measures.

Returns:
Description of this distance. Examples: "625 feet", "4.9 naut. miles", "252 naut. miles".

toString

public java.lang.String toString()
Format this position as a String.

Overrides:
toString in class java.lang.Object
Returns:
This position as a string, in nautical miles.