Jeospace API

org.jeospace.measure.angle
Class SexagesimalAngle

java.lang.Object
  extended byorg.jeospace.measure.angle.SexagesimalAngle
All Implemented Interfaces:
Angle, java.lang.Cloneable, java.lang.Comparable

public class SexagesimalAngle
extends java.lang.Object
implements Angle, java.lang.Cloneable

SexagesimalAngle provides a concrete implementation of Angle which is designed for accurate manipulations of the sexagesimal sub-unit fields to the minimum value of 1 microsecond of degree.

Version:
$Revision: 1.1.1.1 $
Author:
Rex Melton
See Also:
Angle, DecimalAngle, DecimalAngleUnit, SexagesimalAngleType, SexagesimalAngleUnit

Field Summary
protected  long angle
          The value of this SexagesimalAngle.
 
Constructor Summary
SexagesimalAngle()
          Construct a SexagesimalAngle initialized to a value of 0.
SexagesimalAngle(Angle ang)
          Construct a SexagesimalAngle initialized to the specified value.
SexagesimalAngle(DecimalAngleUnit units, double value)
          Construct a SexagesimalAngle initialized to the value and units specified.
SexagesimalAngle(SexagesimalAngleType type, AngleSign sign, double unitsValue)
          Construct a SexagesimalAngle initialized to the value and units specified.
SexagesimalAngle(SexagesimalAngleType type, AngleSign sign, int unitsValue, double minutes)
          Construct a SexagesimalAngle initialized to the value and units specified.
SexagesimalAngle(SexagesimalAngleType type, AngleSign sign, int unitsValue, int minutes, double seconds)
          Construct a SexagesimalAngle initialized to the value and units specified.
SexagesimalAngle(SexagesimalAngleType type, AngleSign sign, int unitsValue, int minutes, int seconds, int microseconds)
          Construct a SexagesimalAngle initialized to the value and units specified.
 
Method Summary
 void add(Angle ang)
          Add to this SexagesimalAngle the passed Angle.
 void add(DecimalAngleUnit units, double value)
          Add to this SexagesimalAngle the double value in the specified DecimalAngleUnits.
 void add(SexagesimalAngleUnit units, int value)
          Add to this SexagesimalAngle the value in the specified SexagesimalAngleUnits.
 void changeSign()
          Change the sign of this SexagesimalAngle.
 void clear()
          Set the value of this SexagesimalAngle to 0.
 void clearAndSetField(SexagesimalAngleUnit units, int value)
          Clear the specified SexagesimalAngleUnit field of this SexagesimalAngle object and set the specified integer value to the field.
 void clearField(SexagesimalAngleUnit units)
          Set the value of the specified SexagesimalAngleUnit field of this SexagesimalAngle to 0.
 java.lang.Object clone()
          Return a copy of this SexagesimalAngle object.
 int compareTo(Angle that)
          Compare this object with the argument for order.
 int compareTo(java.lang.Object obj)
          Compare this object with the argument for order.
 boolean equals(java.lang.Object obj)
          Compare two Angles for equality.
 double get(DecimalAngleUnit units)
          Return the double value of this SexagesimalAngle in the specified DecimalAngleUnits.
 int getField(SexagesimalAngleUnit units)
          Return the integer value for the specified field contained in this SexagesimalAngle object.
 int[] getFields(SexagesimalAngleType type)
          Return the integer array of field values contained in this SexagesimalAngle cooresponding to the specified SexagesimalAngleType.
 AngleSign getSign()
          Get the AngleSign of this SexagesimalAngle.
 long getValueInMicroseconds(SexagesimalAngleType type)
          Return the long value of this SexagesimalAngle in units of microseconds of the specified SexagesimalAngleType.
 int hashCode()
          Return the hashcode
 void normalize(AngleNorm option)
          Normalize the value of this SexagesimalAngle as specified by the option field.
 void set(Angle ang)
          Set this SexagesimalAngle to the specified value.
 void set(DecimalAngleUnit units, double value)
          Set the value of this SexagesimalAngle to the specified DecimalAngleUnits value.
 void set(SexagesimalAngleType type, AngleSign sign, double unitsValue)
          Set this SexagesimalAngle to the specified value in the SexagesimalAngleType.
 void set(SexagesimalAngleType type, AngleSign sign, int unitsValue, double minutes)
          Set this SexagesimalAngle to the specified value in the SexagesimalAngleType.
 void set(SexagesimalAngleType type, AngleSign sign, int unitsValue, int minutes, double seconds)
          Set this SexagesimalAngle to the specified value in the SexagesimalAngleType.
 void set(SexagesimalAngleType type, AngleSign sign, int unitsValue, int minutes, int seconds, int microseconds)
          Set this SexagesimalAngle to the specified value in the SexagesimalAngleType.
 void setValueInMicroseconds(SexagesimalAngleType type, long value)
          Set this SexagesimalAngle to the specified value of microseconds of the SexagesimalAngleType.
 void subtract(Angle ang)
          Subtract from this SexagesimalAngle the passed Angle.
 java.lang.String toString()
          Return a string representation of this SexagesimalAngle in decimal degrees.
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

angle

protected long angle
The value of this SexagesimalAngle.

Constructor Detail

SexagesimalAngle

public SexagesimalAngle()
Construct a SexagesimalAngle initialized to a value of 0.


SexagesimalAngle

public SexagesimalAngle(Angle ang)
Construct a SexagesimalAngle initialized to the specified value.

Parameters:
ang - the Angle object to duplicate.

SexagesimalAngle

public SexagesimalAngle(DecimalAngleUnit units,
                        double value)
Construct a SexagesimalAngle initialized to the value and units specified.

Parameters:
units - the DecimalAngleUnits of value being input.
value - the input value

SexagesimalAngle

public SexagesimalAngle(SexagesimalAngleType type,
                        AngleSign sign,
                        double unitsValue)
Construct a SexagesimalAngle initialized to the value and units specified.

Parameters:
type - the SexagesimalAngleType.
sign - the AngleSign.
unitsValue - the double value of the primary units of the SexagesimalAngleType.

SexagesimalAngle

public SexagesimalAngle(SexagesimalAngleType type,
                        AngleSign sign,
                        int unitsValue,
                        double minutes)
Construct a SexagesimalAngle initialized to the value and units specified.

Parameters:
type - the SexagesimalAngleType.
sign - the AngleSign.
unitsValue - the integer value of the primary units of the SexagesimalAngleType.
minutes - the double value of the minutes sub-unit of the SexagesimalAngleType.

SexagesimalAngle

public SexagesimalAngle(SexagesimalAngleType type,
                        AngleSign sign,
                        int unitsValue,
                        int minutes,
                        double seconds)
Construct a SexagesimalAngle initialized to the value and units specified.

Parameters:
type - the SexagesimalAngleType.
sign - the AngleSign.
unitsValue - the integer value of the primary units of the SexagesimalAngleType.
minutes - the integer value of the minutes sub-unit of the SexagesimalAngleType.
seconds - the double value of the seconds sub-unit of the SexagesimalAngleType.

SexagesimalAngle

public SexagesimalAngle(SexagesimalAngleType type,
                        AngleSign sign,
                        int unitsValue,
                        int minutes,
                        int seconds,
                        int microseconds)
Construct a SexagesimalAngle initialized to the value and units specified.

Parameters:
type - the SexagesimalAngleType.
sign - the AngleSign.
unitsValue - the integer value of the primary units of the SexagesimalAngleType.
minutes - the integer value of the minutes sub-unit of the SexagesimalAngleType.
seconds - the integer value of the seconds sub-unit of the SexagesimalAngleType.
microseconds - the integer value of the microseconds sub-unit of the SexagesimalAngleType.
Method Detail

set

public void set(Angle ang)
Set this SexagesimalAngle to the specified value.

Specified by:
set in interface Angle
Parameters:
ang - the Angle object to duplicate.

clear

public void clear()
Set the value of this SexagesimalAngle to 0.

Specified by:
clear in interface Angle

changeSign

public void changeSign()
Change the sign of this SexagesimalAngle.

Specified by:
changeSign in interface Angle

getSign

public AngleSign getSign()
Get the AngleSign of this SexagesimalAngle.

Specified by:
getSign in interface Angle
Returns:
the sign of the value of the angle. An angle with a value zero will return AngleSign.POSITIVE by default.

add

public void add(Angle ang)
Add to this SexagesimalAngle the passed Angle.

Specified by:
add in interface Angle
Parameters:
ang - an Angle.

subtract

public void subtract(Angle ang)
Subtract from this SexagesimalAngle the passed Angle.

Specified by:
subtract in interface Angle
Parameters:
ang - an Angle.

normalize

public void normalize(AngleNorm option)
Normalize the value of this SexagesimalAngle as specified by the option field.

Specified by:
normalize in interface Angle
Parameters:
option - the AngleNorm identifier

Note: java.lang.Math trigonometric functions have precision problems with very large angle values. Therefore, angles of very large size should be normalized prior to passing their values to java.lang.Math trigonometric functions.


set

public void set(DecimalAngleUnit units,
                double value)
Set the value of this SexagesimalAngle to the specified DecimalAngleUnits value.

Specified by:
set in interface Angle
Parameters:
units - the DecimalAngleUnits.
value - the double value.

get

public double get(DecimalAngleUnit units)
Return the double value of this SexagesimalAngle in the specified DecimalAngleUnits.

Specified by:
get in interface Angle
Parameters:
units - the DecimalAngleUnits.
Returns:
the double value of this Angle.

add

public void add(DecimalAngleUnit units,
                double value)
Add to this SexagesimalAngle the double value in the specified DecimalAngleUnits.

Specified by:
add in interface Angle
Parameters:
units - the DecimalAngleUnits.
value - the double value.

set

public void set(SexagesimalAngleType type,
                AngleSign sign,
                double unitsValue)
Set this SexagesimalAngle to the specified value in the SexagesimalAngleType.

Specified by:
set in interface Angle
Parameters:
type - the SexagesimalAngleType.
sign - the AngleSign.
unitsValue - double integer value of the primary units of the SexagesimalAngleType.

set

public void set(SexagesimalAngleType type,
                AngleSign sign,
                int unitsValue,
                double minutes)
Set this SexagesimalAngle to the specified value in the SexagesimalAngleType.

Specified by:
set in interface Angle
Parameters:
type - the SexagesimalAngleType.
sign - the AngleSign.
unitsValue - the integer value of the primary units of the SexagesimalAngleType.
minutes - the double value of the minutes sub-unit of the SexagesimalAngleType.

set

public void set(SexagesimalAngleType type,
                AngleSign sign,
                int unitsValue,
                int minutes,
                double seconds)
Set this SexagesimalAngle to the specified value in the SexagesimalAngleType.

Specified by:
set in interface Angle
Parameters:
type - the SexagesimalAngleType.
sign - the AngleSign.
unitsValue - the integer value of the primary units of the SexagesimalAngleType.
minutes - the integer value of the minutes sub-unit of the SexagesimalAngleType.
seconds - the double value of the seconds sub-unit of the SexagesimalAngleType.

set

public void set(SexagesimalAngleType type,
                AngleSign sign,
                int unitsValue,
                int minutes,
                int seconds,
                int microseconds)
Set this SexagesimalAngle to the specified value in the SexagesimalAngleType.

Specified by:
set in interface Angle
Parameters:
type - the SexagesimalAngleType.
sign - the AngleSign.
unitsValue - the integer value of the primary units of the SexagesimalAngleType.
minutes - the integer value of the minutes sub-unit of the SexagesimalAngleType.
seconds - the integer value of the seconds sub-unit of the SexagesimalAngleType.
microseconds - the integer value of the microseconds sub-unit of the SexagesimalAngleType.

setValueInMicroseconds

public void setValueInMicroseconds(SexagesimalAngleType type,
                                   long value)
Set this SexagesimalAngle to the specified value of microseconds of the SexagesimalAngleType. (i.e. either in microseconds of of degree or microseconds of hour)

Specified by:
setValueInMicroseconds in interface Angle
Parameters:
type - the SexagesimalAngleType.
value - the long value in microseconds to set for this Angle.

getValueInMicroseconds

public long getValueInMicroseconds(SexagesimalAngleType type)
Return the long value of this SexagesimalAngle in units of microseconds of the specified SexagesimalAngleType. (i.e. either in microseconds of of degree or microseconds of hour)

Specified by:
getValueInMicroseconds in interface Angle
Parameters:
type - the SexagesimalAngleType.
Returns:
the long value of this Angle in microseconds.

add

public void add(SexagesimalAngleUnit units,
                int value)
Add to this SexagesimalAngle the value in the specified SexagesimalAngleUnits.

Specified by:
add in interface Angle
Parameters:
units - the SexagesimalAngleUnits.
value - the integer value.

clearField

public void clearField(SexagesimalAngleUnit units)
Set the value of the specified SexagesimalAngleUnit field of this SexagesimalAngle to 0.

Parameters:
units - the SexagesimalAngleUnit field to clear;

getFields

public int[] getFields(SexagesimalAngleType type)
Return the integer array of field values contained in this SexagesimalAngle cooresponding to the specified SexagesimalAngleType.

Parameters:
type - the SexagesimalAngleType of the fields to return.
Returns:
the integer array of field values.

Notes:

1) Very large angles with hour/degree fields larger than an int will be truncated.

2) The sign of the angle is maintained for the total value, not by individual field. The values returned will always be positive. To determine the sign of the angle, use the getSign( ) method.


getField

public int getField(SexagesimalAngleUnit units)
Return the integer value for the specified field contained in this SexagesimalAngle object.

Parameters:
units - the SexagesimalAngleUnit field being requested;
Returns:
the integer value for the specified field.

Notes:

1) Very large angles with hour/degree fields larger than an int will be truncated.

2) The sign of the angle is maintained for the total value, not by individual field. The value returned will always be positive. To determine the the sign of the angle, use the getSign( ) method.


clearAndSetField

public void clearAndSetField(SexagesimalAngleUnit units,
                             int value)
Clear the specified SexagesimalAngleUnit field of this SexagesimalAngle object and set the specified integer value to the field.

Parameters:
units - the SexagesimalAngleUnit field to clear and add to.
value - the value to add to the field.

Notes: This method is a convenience combination of clearField( units ) followed by add( units, value ). The sign of the value is adjusted based on the sign of the complete angle object (i.e. value is set positive if the angle is positive, value is set negative if the angle is negative). The implications of this are: 1) Specifying a value that is greater than the maximum field value (59 for minutes or seconds, 999999 for microseconds) will result in a change to more significant fields (i.e. subunits). 2) Specifying a negative value will result in changes to fields other than the one specified as the operation becomes a decrement by the value to the field which has been set to 0 by the clear operation.


clone

public java.lang.Object clone()
Return a copy of this SexagesimalAngle object. Overrides Cloneable.

Returns:
a copy of this SexagesimalAngle object.

hashCode

public int hashCode()
Return the hashcode

Returns:
the hash code value for this object

equals

public boolean equals(java.lang.Object obj)
Compare two Angles for equality. The result is true if and only if the argument object is not null, is an Angle object ( including classes implementing Angle ) and represents an angle of the same sign and magnitude as this Angle.

Parameters:
obj - the object to compare with
Returns:
true if the Angles are the same; false otherwise.

toString

public java.lang.String toString()
Return a string representation of this SexagesimalAngle in decimal degrees.

Returns:
a string representation of this SexagesimalAngle

compareTo

public int compareTo(Angle that)
Compare this object with the argument for order.

Specified by:
compareTo in interface Angle
Parameters:
that - the Angle to compare
Returns:
a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.

compareTo

public int compareTo(java.lang.Object obj)
Compare this object with the argument for order.

Specified by:
compareTo in interface Angle
Parameters:
obj - the Object to compare
Returns:
a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.
Throws:
ClassCastException - if the argument is not an Angle.

Jeospace API

Copyright © 2006 - jeospace.org