Class GlobalCoordinates

java.lang.Object
org.gavaghan.geodesy.GlobalCoordinates
All Implemented Interfaces:
Serializable, Comparable<GlobalCoordinates>
Direct Known Subclasses:
GlobalPosition

public class GlobalCoordinates extends Object implements Comparable<GlobalCoordinates>, Serializable

Encapsulation of latitude and longitude coordinates on a globe. Negative latitude is southern hemisphere. Negative longitude is western hemisphere.

Any angle may be specified for longtiude and latitude, but all angles will be canonicalized such that:

 -90 <= latitude <= +90 - 180 < longitude <= +180
 
Author:
Mike Gavaghan
See Also:
  • Constructor Details

    • GlobalCoordinates

      public GlobalCoordinates(double latitude, double longitude)
      Construct a new GlobalCoordinates. Angles will be canonicalized.
      Parameters:
      latitude - latitude in degrees
      longitude - longitude in degrees
  • Method Details

    • getLatitude

      public double getLatitude()
      Get latitude.
      Returns:
      latitude in degrees
    • setLatitude

      public void setLatitude(double latitude)
      Set latitude. The latitude value will be canonicalized (which might result in a change to the longitude). Negative latitude is southern hemisphere.
      Parameters:
      latitude - in degrees
    • getLongitude

      public double getLongitude()
      Get longitude.
      Returns:
      longitude in degrees
    • setLongitude

      public void setLongitude(double longitude)
      Set longitude. The longitude value will be canonicalized. Negative longitude is western hemisphere.
      Parameters:
      longitude - in degrees
    • compareTo

      public int compareTo(GlobalCoordinates other)
      Compare these coordinates to another set of coordiates. Western longitudes are less than eastern logitudes. If longitudes are equal, then southern latitudes are less than northern latitudes.
      Specified by:
      compareTo in interface Comparable<GlobalCoordinates>
      Parameters:
      other - instance to compare to
      Returns:
      -1, 0, or +1 as per Comparable contract
    • hashCode

      public int hashCode()
      Get a hash code for these coordinates.
      Overrides:
      hashCode in class Object
      Returns:
    • equals

      public boolean equals(Object obj)
      Compare these coordinates to another object for equality.
      Overrides:
      equals in class Object
      Parameters:
      other -
      Returns:
    • toString

      public String toString()
      Get coordinates as a string.
      Overrides:
      toString in class Object