uavsim.datatypes
Class A_LatitudeLongitude<_TYPE_ extends A_LatitudeLongitude<?>>

java.lang.Object
  extended by uavsim.datatypes.A_LatitudeLongitude<_TYPE_>
Type Parameters:
_TYPE_ - - the measurement type: latitude or longitude
All Implemented Interfaces:
java.lang.Comparable<_TYPE_>, I_Unitable<_TYPE_>
Direct Known Subclasses:
Latitude, Longitude

public abstract class A_LatitudeLongitude<_TYPE_ extends A_LatitudeLongitude<?>>
extends java.lang.Object
implements I_Unitable<_TYPE_>

Defines the shared aspects of a latitude and longitude in terms of Universal Transverse Mercator (UTM) coordinates. Only northern and western hemispheres are currently supported.

Author:
Dan Tappan [16.07.11]

Nested Class Summary
static class A_LatitudeLongitude.E_Format
          The enumeration defines the format of the encoding.
 
Field Summary
protected  int _degrees
          the degrees
protected  int _minutes
          the minutes
protected  double _seconds
          the seconds
private static java.text.DecimalFormat FORMAT
          the format for pretty-printing values
static int MINUTES_PER_DEGREE
          the number of minutes of distance in a degree
static int SECONDS_PER_MINUTE
          the number of seconds in a minute of distance
 
Constructor Summary
A_LatitudeLongitude(double encoding)
          Creates an abstract object for latitude or longitude from the decimal encoding format.
A_LatitudeLongitude(double encoding, A_LatitudeLongitude.E_Format format)
          Creates an abstract object for latitude or longitude.
A_LatitudeLongitude(int degrees, int minutes, double seconds, int degreesModulo)
          Creates an object for abstract latitude or longitude.
 
Method Summary
 int compareTo(_TYPE_ coordinate)
          
private  double encodeAsDecimal(int degrees, int minutes, double seconds)
          Encodes the coordinate in decimal format
 java.lang.String formatString(boolean isPadded, char hemisphere)
          Formats the coordinate appropriately.
 double getDecimalEncoding()
          Gets the encoding.
 int getDegrees()
          Gets the degrees.
 int getMinutes()
          Gets the minutes.
 double getMinutesAndSeconds()
          Gets the minutes and seconds with minutes as the whole-number part and seconds as the fractional-part as a percent of 60.
 double getSeconds()
          Gets the seconds.
 int getSecondsInt()
          Gets the seconds as an integer.
 double getSecondsTenth()
          Gets the seconds rounded to a tenth.
 double getValue_()
          Returns the numerical value of this unit.
abstract  _TYPE_ round(_TYPE_ image)
          Rounds the coordinate to the nearest degree, minute, or second.
protected  double round2(_TYPE_ image)
          Rounds the coordinate to the nearest degree, minute, or second.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface uavsim.datatypes.I_Unitable
add_, subtract_
 

Field Detail

_degrees

protected final int _degrees
the degrees


_minutes

protected final int _minutes
the minutes


_seconds

protected final double _seconds
the seconds


FORMAT

private static final java.text.DecimalFormat FORMAT
the format for pretty-printing values


MINUTES_PER_DEGREE

public static final int MINUTES_PER_DEGREE
the number of minutes of distance in a degree

See Also:
Constant Field Values

SECONDS_PER_MINUTE

public static final int SECONDS_PER_MINUTE
the number of seconds in a minute of distance

See Also:
Constant Field Values
Constructor Detail

A_LatitudeLongitude

public A_LatitudeLongitude(double encoding)
Creates an abstract object for latitude or longitude from the decimal encoding format.

Parameters:
encoding - - the encoding

A_LatitudeLongitude

public A_LatitudeLongitude(double encoding,
                           A_LatitudeLongitude.E_Format format)
Creates an abstract object for latitude or longitude.

Parameters:
encoding - - the encoding
format - - the encoding format

A_LatitudeLongitude

public A_LatitudeLongitude(int degrees,
                           int minutes,
                           double seconds,
                           int degreesModulo)
Creates an object for abstract latitude or longitude.

Parameters:
degrees - - the degrees
minutes - - the minutes
seconds - - the seconds
degreesModulo - - the modulo for wrapping degrees (90 for latitude, 180 for longitude)
Method Detail

compareTo

public int compareTo(_TYPE_ coordinate)

Specified by:
compareTo in interface java.lang.Comparable<_TYPE_ extends A_LatitudeLongitude<?>>

encodeAsDecimal

private double encodeAsDecimal(int degrees,
                               int minutes,
                               double seconds)
Encodes the coordinate in decimal format

Parameters:
degrees - - the degrees
minutes - - the minutes
seconds - - the seconds
Returns:
the encoding

formatString

public java.lang.String formatString(boolean isPadded,
                                     char hemisphere)
Formats the coordinate appropriately. The underscore (_) substitutes for an optional space between the number and hemisphere designator.

Parameters:
isPadded - - whether to pad the format
hemisphere - - the hemisphere, either N or W
Returns:
the string

getDecimalEncoding

public double getDecimalEncoding()
Gets the encoding.

Returns:
the encoding

getDegrees

public int getDegrees()
Gets the degrees.

Returns:
the degrees

getMinutes

public int getMinutes()
Gets the minutes.

Returns:
the minutes

getMinutesAndSeconds

public double getMinutesAndSeconds()
Gets the minutes and seconds with minutes as the whole-number part and seconds as the fractional-part as a percent of 60.

Returns:
the minutes and seconds

getSeconds

public double getSeconds()
Gets the seconds.

Returns:
the seconds

getSecondsInt

public int getSecondsInt()
Gets the seconds as an integer.

Returns:
the seconds

getSecondsTenth

public double getSecondsTenth()
Gets the seconds rounded to a tenth.

Returns:
the seconds

getValue_

public double getValue_()
Returns the numerical value of this unit.

Specified by:
getValue_ in interface I_Unitable<_TYPE_ extends A_LatitudeLongitude<?>>
Returns:
the value

round

public abstract _TYPE_ round(_TYPE_ image)
Rounds the coordinate to the nearest degree, minute, or second. All fields to the right of the selected one become zero.

Parameters:
image - - the image; the one and only one nonzero field specifies the field to round
Returns:
the coordinate

round2

protected double round2(_TYPE_ image)
Rounds the coordinate to the nearest degree, minute, or second. All fields to the right of the selected one become zero. This is a polymorphic helper method.

Parameters:
image - - the image; the one and only one nonzero field specifies the field to round
Returns:
the coordinate