org.gavaghan.geodesy
Class GlobalPosition

java.lang.Object
  extended by org.gavaghan.geodesy.GlobalCoordinates
      extended by org.gavaghan.geodesy.GlobalPosition
All Implemented Interfaces:
java.io.Serializable, java.lang.Comparable<GlobalCoordinates>

public class GlobalPosition
extends GlobalCoordinates

Encapsulates a three dimensional location on a globe (GlobalCoordinates combined with an elevation in meters above a reference ellipsoid).

See documentation for GlobalCoordinates for details on how latitude and longitude measurements are canonicalized.

Author:
Mike Gavaghan
See Also:
Serialized Form

Constructor Summary
GlobalPosition(double latitude, double longitude, double elevation)
          Creates a new instance of GlobalPosition.
GlobalPosition(GlobalCoordinates coords, double elevation)
          Creates a new instance of GlobalPosition.
 
Method Summary
 int compareTo(GlobalPosition other)
          Compare this position to another.
 boolean equals(java.lang.Object obj)
          Compare this position to another object for equality.
 double getElevation()
          Get elevation.
 int hashCode()
          Get a hash code for this position.
 void setElevation(double elevation)
          Set the elevation.
 java.lang.String toString()
          Get position as a string.
 
Methods inherited from class org.gavaghan.geodesy.GlobalCoordinates
compareTo, getLatitude, getLongitude, setLatitude, setLongitude
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

GlobalPosition

public GlobalPosition(double latitude,
                      double longitude,
                      double elevation)
Creates a new instance of GlobalPosition.

Parameters:
latitude - latitude in degrees
longitude - longitude in degrees
elevation - elevation, in meters, above the reference ellipsoid

GlobalPosition

public GlobalPosition(GlobalCoordinates coords,
                      double elevation)
Creates a new instance of GlobalPosition.

Parameters:
coords - coordinates of the position
elevation - elevation, in meters, above the reference ellipsoid
Method Detail

getElevation

public double getElevation()
Get elevation.

Returns:
elevation about the ellipsoid in meters.

setElevation

public void setElevation(double elevation)
Set the elevation.

Parameters:
elevation - elevation about the ellipsoid in meters.

compareTo

public int compareTo(GlobalPosition other)
Compare this position to another. Western longitudes are less than eastern logitudes. If longitudes are equal, then southern latitudes are less than northern latitudes. If coordinates are equal, lower elevations are less than higher elevations

Parameters:
other - instance to compare to
Returns:
-1, 0, or +1 as per Comparable contract

hashCode

public int hashCode()
Get a hash code for this position.

Overrides:
hashCode in class GlobalCoordinates
Returns:

equals

public boolean equals(java.lang.Object obj)
Compare this position to another object for equality.

Overrides:
equals in class GlobalCoordinates
Parameters:
other -
Returns:

toString

public java.lang.String toString()
Get position as a string.

Overrides:
toString in class GlobalCoordinates