Class GeoPosition

java.lang.Object
org.deltava.beans.schedule.GeoPosition
All Implemented Interfaces:
Serializable, GeoLocation, GeospaceLocation
Direct Known Subclasses:
FuzzyPosition

public class GeoPosition extends Object implements GeospaceLocation, Serializable
A class for working with latitude/longitude pairs.
Since:
1.0
Version:
11.0
Author:
Luke
See Also:
  • Field Summary

  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates a new GeoPosition object
    GeoPosition(double lat, double lon)
    Creates a new GeoPosition object with a particular latitude and longitude.
    GeoPosition(double lat, double lon, int altitude)
    Creates a new GeoPosition object with a particular latitude and longitude.
    Creates a GeoPosition object from another object that supports lat/lon coordinates.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Calculates equality by determining if the two positions are within 1 mile of each other.
    int
    Returns the altitude of this position.
    static int
    getDegrees(double latlon)
    Helper method to return back the degrees component of a latitude or longitude.
    double
    Get the latitude of this position.
    double
    Get the longitude of this position.
    static int
    getMinutes(double latlon)
    Helper method to return back the minutes component of a latitude or longitude.
    static double
    getSeconds(double latlon)
    Helper method to return back the seconds component of a latitude or longitude.
    int
     
    Calculates the midpoint of a Great Circle route between two GeoPositions.
    void
    setAltitude(int alt)
    Updates the altitude of this position.
    void
    setLatitude(double lat)
    Sets the latitude and ensures its validity.
    void
    setLatitude(int deg, int min, int sec)
    Set the latitude using a degree/minute/second combo.
    void
    setLongitude(double lng)
    Sets the longitude and ensures its validity.
    void
    setLongitude(int deg, int min, int sec)
    Set the longitude using a degree/minute/second combo.
     

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait

    Methods inherited from interface org.deltava.beans.GeoLocation

    distanceFeet, distanceTo
  • Constructor Details

    • GeoPosition

      public GeoPosition()
      Creates a new GeoPosition object
    • GeoPosition

      public GeoPosition(double lat, double lon, int altitude)
      Creates a new GeoPosition object with a particular latitude and longitude.
      Parameters:
      lat - the latitude in degrees (and some fraction thereof)
      lon - the longitude in degrees (and some fraction thereof)
      altitude - the altitude in feet above mean sea level
      Throws:
      IllegalArgumentException - if latitude or longitude fail validation
      See Also:
    • GeoPosition

      public GeoPosition(double lat, double lon)
      Creates a new GeoPosition object with a particular latitude and longitude.
      Parameters:
      lat - The latitude in degrees (and some fraction thereof)
      lon - The longitude in degrees (and some fraction thereof)
      Throws:
      IllegalArgumentException - if latitude or longitude fail validation
      See Also:
    • GeoPosition

      public GeoPosition(GeoLocation gl)
      Creates a GeoPosition object from another object that supports lat/lon coordinates. This is useful when "lightening" an object down to a simple coordinate pair.
      Parameters:
      gl - the GeoLocation
  • Method Details

    • getDegrees

      public static int getDegrees(double latlon)
      Helper method to return back the degrees component of a latitude or longitude.
      Parameters:
      latlon - The latitude or longitude
      Returns:
      The degrees component of the position
    • getMinutes

      public static int getMinutes(double latlon)
      Helper method to return back the minutes component of a latitude or longitude.
      Parameters:
      latlon - The latitude or longitude
      Returns:
      The minutes component of the position
    • getSeconds

      public static double getSeconds(double latlon)
      Helper method to return back the seconds component of a latitude or longitude.
      Parameters:
      latlon - The latitude or longitude
      Returns:
      The seconds component of the position
    • getLatitude

      public double getLatitude()
      Get the latitude of this position.
      Specified by:
      getLatitude in interface GeoLocation
      Returns:
      the latitude in degrees (and some fraction thereof) (values invalid input: '<' 0 are South of the Equator)
    • getLongitude

      public double getLongitude()
      Get the longitude of this position.
      Specified by:
      getLongitude in interface GeoLocation
      Returns:
      the longitude in degrees (and some fraction thereof) (values invalid input: '<' 0 are West of the Greenwich Meridian)
    • getAltitude

      public int getAltitude()
      Returns the altitude of this position.
      Specified by:
      getAltitude in interface GeospaceLocation
      Returns:
      the altitude in feet above mean sea level, or 0 if undefined
    • setAltitude

      public void setAltitude(int alt)
      Updates the altitude of this position.
      Parameters:
      alt - the altitude in feet above mean sea level, or 0 if undefined
    • setLatitude

      public void setLatitude(double lat)
      Sets the latitude and ensures its validity.
      Parameters:
      lat - The latitude to set in degrees (values invalid input: '<' 0 are South of the Equator)
    • setLongitude

      public void setLongitude(double lng)
      Sets the longitude and ensures its validity. If longitude values of greater than 180 degrees or less than -180 are specified, they are "wrapped" around the International Date line
      Parameters:
      lng - The longitude to set in degrees (values invalid input: '<' 0 are West of the Greenwich Meridian)
    • setLatitude

      public void setLatitude(int deg, int min, int sec)
      Set the latitude using a degree/minute/second combo.
      Parameters:
      deg - Degrees (values invalid input: '<' 0 are South of the Equator)
      min - Minutes (can be > 59)
      sec - Seconds (can be > 59)
      Throws:
      IllegalArgumentException - The latitude is invalid input: '<' 90 or > -90 degrees
      See Also:
    • setLongitude

      public void setLongitude(int deg, int min, int sec)
      Set the longitude using a degree/minute/second combo.
      Parameters:
      deg - Degrees (values invalid input: '<' 0 are West of the Greenwich Meridian)
      min - Minutes (can be > 59)
      sec - Seconds (can be > 59)
      Throws:
      IllegalArgumentException - The latitude is invalid input: '<' 90 or > -90 degrees
      See Also:
    • midPoint

      public GeoPosition midPoint(GeoLocation gp2)
      Calculates the midpoint of a Great Circle route between two GeoPositions.
      Parameters:
      gp2 - the other Position
      Returns:
      a GeoPosition storing the midpoint between the two positions
      Throws:
      NullPointerException - if gp2 is null
    • equals

      public boolean equals(Object o2)
      Calculates equality by determining if the two positions are within 1 mile of each other.
      Overrides:
      equals in class Object
      See Also:
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object