Class GeoPosition
java.lang.Object
org.deltava.beans.schedule.GeoPosition
- All Implemented Interfaces:
Serializable,GeoLocation,GeospaceLocation
- Direct Known Subclasses:
FuzzyPosition
A class for working with latitude/longitude pairs.
- Since:
- 1.0
- Version:
- 11.0
- Author:
- Luke
- See Also:
-
Field Summary
Fields inherited from interface org.deltava.beans.GeoLocation
ALL, DEGREE_FEET, DEGREE_MILES, FEET_MILES, LAT_DIRECTIONS, LATITUDE, LON_DIRECTIONS, LONGITUDE, RADIAN_MILES -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new GeoPosition objectGeoPosition(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 TypeMethodDescriptionbooleanCalculates equality by determining if the two positions are within 1 mile of each other.intReturns the altitude of this position.static intgetDegrees(double latlon) Helper method to return back the degrees component of a latitude or longitude.doubleGet the latitude of this position.doubleGet the longitude of this position.static intgetMinutes(double latlon) Helper method to return back the minutes component of a latitude or longitude.static doublegetSeconds(double latlon) Helper method to return back the seconds component of a latitude or longitude.inthashCode()midPoint(GeoLocation gp2) Calculates the midpoint of a Great Circle route between two GeoPositions.voidsetAltitude(int alt) Updates the altitude of this position.voidsetLatitude(double lat) Sets the latitude and ensures its validity.voidsetLatitude(int deg, int min, int sec) Set the latitude using a degree/minute/second combo.voidsetLongitude(double lng) Sets the longitude and ensures its validity.voidsetLongitude(int deg, int min, int sec) Set the longitude using a degree/minute/second combo.toString()Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods 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
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:
getLatitudein interfaceGeoLocation- 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:
getLongitudein interfaceGeoLocation- 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:
getAltitudein interfaceGeospaceLocation- 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
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
-
hashCode
-
toString
-