Package com.storedobject.common
Class Geolocation
java.lang.Object
com.storedobject.common.Geolocation
-
Constructor Summary
ConstructorsConstructorDescriptionDefault constructor for the Geolocation class.Geolocation(double latitudeInDegrees, char latitudeDirection, double longitudeInDegrees, char longitudeDirection) Constructs a Geolocation object with the specified latitude and longitude values, provided in degrees and cardinal direction indicators.Geolocation(double latitudeInDegrees, double longitudeInDegrees) Constructs a Geolocation object with the specified latitude and longitude values in degrees.Geolocation(int latitudeInSeconds, int longitudeInSeconds) Constructs a Geolocation object with the specified latitude and longitude values in seconds.Geolocation(int latitudeInSeconds, int longitudeInSeconds, int altitudeInMeters) Constructs a Geolocation object with the specified latitude, longitude, and altitude values.Geolocation(int latitudeDegrees, int latitudeMinutes, int latitudeSeconds, char latitudeDirection, int longitudeDegrees, int longitudeMinutes, int longitudeSeconds, char longitudeDirection) Constructs a Geolocation object with the specified latitude and longitude values, provided in degrees, minutes, seconds, and direction.Geolocation(Geolocation location) Copy constructor for theGeolocationclass.Geolocation(Object value) Constructs a Geolocation object and initializes it with the provided value.Geolocation(String value) Constructs a Geolocation object and initializes it with the provided value.Geolocation(BigDecimal latitudeInDegrees, char latitudeDirection, BigDecimal longitudeInDegrees, char longitudeDirection) Constructs a Geolocation object with the specified latitude and longitude values, provided in degrees and cardinal direction indicators. -
Method Summary
Modifier and TypeMethodDescriptionintdistance(Geolocation location) Distance between this location and another location.doubledistanceAsDouble(Geolocation location) Distance between this location and another location.booleanintRetrieves the current altitude.intgetHeading(Geolocation location) Calculates the directional heading in seconds of arc from the current location to the specified target location.intRetrieves the latitude value.doubleRetrieves the latitude value in degree representation.intRetrieves the longitude value.doubleConverts the longitude value from arcseconds to degrees.Get the storable value for this Geolocation.intCalculates the time difference in minutes based on the longitude.voidset(double latitudeInDegrees, double longitudeInDegrees) Sets the latitude and longitude values using the provided degrees.voidset(int latitudeInSeconds, char latitudeDirection, int longitudeInSeconds, char longitudeDirection) Sets the coordinates for latitude and longitude using their respective values in seconds and directional characters.voidset(int latitudeInSeconds, int longitudeInSeconds) Sets the geographical coordinates using latitude and longitude values in seconds.voidset(int latitudeInSeconds, int longitudeInSeconds, int altitudeInMeters) Updates the geographical coordinates and altitude for the object.voidset(int latitudeDegrees, int latitudeMinutes, int latitudeSeconds, char latitudeDirection, int longitudeDegrees, int longitudeMinutes, int longitudeSeconds, char longitudeDirection) Sets the geographic coordinates with the provided latitude and longitude values, expressed in degrees, minutes, seconds, and direction.voidset(Geolocation location) Updates the geographical coordinates and altitude of the current object.voidSets the internal coordinates and altitude based on the provided object.voidSets the geographic coordinates based on the provided latitude and longitude strings.voidset(BigDecimal latitudeInDegrees, char latitudeDirection, BigDecimal longitudeInDegrees, char longitudeDirection) Sets the geographical coordinates using latitude and longitude values along with their directions.voidset(BigDecimal latitudeInDegrees, BigDecimal longitudeInDegrees) Sets the geographic coordinates using latitude and longitude in degrees.voidsetAltitude(int altitudeInMeters) Sets the altitude value in meters.voidsetLatitude(int latitudeInSeconds) Sets the latitude value in seconds, adjusting it to ensure it remains within the valid range.voidsetLatitudeDegree(double latitudeInDegrees) Sets the latitude in degrees by converting it to seconds and passing it to the method that accepts latitude in seconds.voidsetLongitude(int longitudeInSeconds) Sets the longitude value in seconds.voidsetLongitudeDegree(double longitudeInDegrees) Sets the geographical longitude in degrees.toString()toString(boolean aviationStandard) Converts the object into a string representation based on the specified format.
-
Constructor Details
-
Geolocation
public Geolocation()Default constructor for the Geolocation class. Initializes a Geolocation object with no specific location data. -
Geolocation
public Geolocation(int latitudeInSeconds, int longitudeInSeconds) Constructs a Geolocation object with the specified latitude and longitude values in seconds. The latitude and longitude are internally set using thesetmethod.- Parameters:
latitudeInSeconds- The latitude value in seconds. Positive values indicate North, while negative values indicate South.longitudeInSeconds- The longitude value in seconds. Positive values indicate East, while negative values indicate West.
-
Geolocation
public Geolocation(double latitudeInDegrees, double longitudeInDegrees) Constructs a Geolocation object with the specified latitude and longitude values in degrees. The latitude and longitude are internally set asBigDecimalvalues using thesetmethod.- Parameters:
latitudeInDegrees- The latitude value in degrees. Positive values indicate North, while negative values indicate South.longitudeInDegrees- The longitude value in degrees. Positive values indicate East, while negative values indicate West.
-
Geolocation
public Geolocation(int latitudeInSeconds, int longitudeInSeconds, int altitudeInMeters) Constructs a Geolocation object with the specified latitude, longitude, and altitude values. The latitude and longitude are provided in seconds, and the altitude is provided in meters. The values are internally set using thesetmethod.- Parameters:
latitudeInSeconds- The latitude value in seconds. Positive values indicate North, while negative values indicate South.longitudeInSeconds- The longitude value in seconds. Positive values indicate East, while negative values indicate West.altitudeInMeters- The altitude value in meters above sea level.
-
Geolocation
Copy constructor for theGeolocationclass. Creates a newGeolocationinstance by copying the values from anotherGeolocationobject.- Parameters:
location- TheGeolocationobject to copy. Ifnull, the new instance will be initialized with default values.
-
Geolocation
public Geolocation(int latitudeDegrees, int latitudeMinutes, int latitudeSeconds, char latitudeDirection, int longitudeDegrees, int longitudeMinutes, int longitudeSeconds, char longitudeDirection) Constructs a Geolocation object with the specified latitude and longitude values, provided in degrees, minutes, seconds, and direction.- Parameters:
latitudeDegrees- The degrees component of the latitude value. Must be a non-negative integer.latitudeMinutes- The minutes component of the latitude value. Must be a non-negative integer less than 60.latitudeSeconds- The seconds component of the latitude value. Must be a non-negative integer less than 60.latitudeDirection- The direction of the latitude ('N' for North or 'S' for South).longitudeDegrees- The degrees component of the longitude value. Must be a non-negative integer.longitudeMinutes- The minutes component of the longitude value. Must be a non-negative integer less than 60.longitudeSeconds- The seconds component of the longitude value. Must be a non-negative integer less than 60.longitudeDirection- The direction of the longitude ('E' for East or 'W' for West).
-
Geolocation
public Geolocation(double latitudeInDegrees, char latitudeDirection, double longitudeInDegrees, char longitudeDirection) Constructs a Geolocation object with the specified latitude and longitude values, provided in degrees and cardinal direction indicators.- Parameters:
latitudeInDegrees- The latitude value in degrees. Must be non-negative. Positive values indicate North, while negative values are determined by the latitudeDirection ('N' or 'S').latitudeDirection- The direction of the latitude. Valid values are 'N' (North) and 'S' (South).longitudeInDegrees- The longitude value in degrees. Must be non-negative. Positive values indicate East, while negative values are determined by the longitudeDirection ('E' or 'W').longitudeDirection- The direction of the longitude. Valid values are 'E' (East) and 'W' (West).
-
Geolocation
public Geolocation(BigDecimal latitudeInDegrees, char latitudeDirection, BigDecimal longitudeInDegrees, char longitudeDirection) Constructs a Geolocation object with the specified latitude and longitude values, provided in degrees and cardinal direction indicators.- Parameters:
latitudeInDegrees- The latitude value in degrees. Must be a non-negative BigDecimal. The latitude direction determines whether the value is North or South.latitudeDirection- The direction of the latitude. Valid values are 'N' (North) and 'S' (South).longitudeInDegrees- The longitude value in degrees. Must be a non-negative BigDecimal. The longitude direction determines whether the value is East or West.longitudeDirection- The direction of the longitude. Valid values are 'E' (East) and 'W' (West).
-
Geolocation
Constructs a Geolocation object and initializes it with the provided value.- Parameters:
value- the geolocation value to be set, typically in a format such as latitude and longitude.
-
Geolocation
Constructs a Geolocation object and initializes it with the provided value.- Parameters:
value- the initial value to set for the Geolocation object. The type and format of this value depend on the implementation of the set method.
-
-
Method Details
-
set
Updates the geographical coordinates and altitude of the current object.- Parameters:
location- the Geolocation object containing latitude, longitude, and altitude values. If null, default values of 0 for latitude, longitude, and altitude are used.
-
set
public void set(int latitudeInSeconds, int longitudeInSeconds, int altitudeInMeters) Updates the geographical coordinates and altitude for the object.- Parameters:
latitudeInSeconds- the latitude value in seconds, where positive values indicate north and negative values indicate southlongitudeInSeconds- the longitude value in seconds, where positive values indicate east and negative values indicate westaltitudeInMeters- the altitude value in meters above sea level
-
set
public void set(int latitudeInSeconds, int longitudeInSeconds) Sets the geographical coordinates using latitude and longitude values in seconds. The altitude is implicitly set to 0.- Parameters:
latitudeInSeconds- the latitude value in secondslongitudeInSeconds- the longitude value in seconds
-
set
public void set(int latitudeInSeconds, char latitudeDirection, int longitudeInSeconds, char longitudeDirection) Sets the coordinates for latitude and longitude using their respective values in seconds and directional characters.- Parameters:
latitudeInSeconds- the latitude value in seconds, where positive indicates North and negative indicates SouthlatitudeDirection- the direction of the latitude, either 'N' for North or 'S' for SouthlongitudeInSeconds- the longitude value in seconds, where positive indicates East and negative indicates WestlongitudeDirection- the direction of the longitude, either 'E' for East or 'W' for West
-
set
public void set(int latitudeDegrees, int latitudeMinutes, int latitudeSeconds, char latitudeDirection, int longitudeDegrees, int longitudeMinutes, int longitudeSeconds, char longitudeDirection) Sets the geographic coordinates with the provided latitude and longitude values, expressed in degrees, minutes, seconds, and direction.- Parameters:
latitudeDegrees- the degrees part of the latitudelatitudeMinutes- the minutes part of the latitudelatitudeSeconds- the seconds part of the latitudelatitudeDirection- the direction of the latitude ('N' for north, 'S' for south)longitudeDegrees- the degrees part of the longitudelongitudeMinutes- the minutes part of the longitudelongitudeSeconds- the seconds part of the longitudelongitudeDirection- the direction of the longitude ('E' for east, 'W' for west)
-
set
public void set(double latitudeInDegrees, double longitudeInDegrees) Sets the latitude and longitude values using the provided degrees.- Parameters:
latitudeInDegrees- the latitude value in degreeslongitudeInDegrees- the longitude value in degrees
-
set
Sets the geographic coordinates using latitude and longitude in degrees.- Parameters:
latitudeInDegrees- the latitude value in degreeslongitudeInDegrees- the longitude value in degrees
-
set
public void set(BigDecimal latitudeInDegrees, char latitudeDirection, BigDecimal longitudeInDegrees, char longitudeDirection) Sets the geographical coordinates using latitude and longitude values along with their directions.- Parameters:
latitudeInDegrees- the latitude value in degreeslatitudeDirection- the direction of latitude, e.g., 'N' for North or 'S' for SouthlongitudeInDegrees- the longitude value in degreeslongitudeDirection- the direction of longitude, e.g., 'E' for East or 'W' for West
-
set
Sets the geographic coordinates based on the provided latitude and longitude strings. The method attempts to recognize and parse standard latitude and longitude formats such as: - ddNdddE - ddmmNdddmmE - ddmmNddmmE If the input strings do not match any recognizable pattern, default values are assigned.- Parameters:
latitude- The latitude string representing the north-south position. It may end with 'N' or 'S' to indicate direction.longitude- The longitude string representing the east-west position. It may end with 'E' or 'W' to indicate direction.
-
set
Sets the internal coordinates and altitude based on the provided object. The method interprets the input in various formats and extracts the relevant components (latitude, longitude, altitude) accordingly. If the input format does not conform to the expected patterns, appropriate error handling is executed.- Parameters:
object- The input object containing coordinate data. It can be in different formats such as: - A string representation in degree-minute-second format. - A string with latitude and longitude separated by a delimiter (e.g., spaces or commas). - A string wrapped in parentheses containing coordinates. - A numeric representation or other parsable forms.
-
toString
-
toString
Converts the object into a string representation based on the specified format. If the aviation standard is true, it generates a string representation following aviation-specific formatting rules.- Parameters:
aviationStandard- a boolean flag indicating whether the output should follow aviation-specific formatting rules. If false, the default string representation is returned.- Returns:
- a string representation of the object. The format of the returned
string depends on the value of the
aviationStandardparameter.
-
setLatitudeDegree
public void setLatitudeDegree(double latitudeInDegrees) Sets the latitude in degrees by converting it to seconds and passing it to the method that accepts latitude in seconds.- Parameters:
latitudeInDegrees- the latitude value in degrees to be converted and set as latitude in seconds
-
setLongitudeDegree
public void setLongitudeDegree(double longitudeInDegrees) Sets the geographical longitude in degrees.- Parameters:
longitudeInDegrees- the longitude value in decimal degrees to be set. This value is expected to represent the geographical longitude as a double.
-
getLatitude
public int getLatitude()Retrieves the latitude value.- Returns:
- the latitude as an integer
-
setLatitude
public void setLatitude(int latitudeInSeconds) Sets the latitude value in seconds, adjusting it to ensure it remains within the valid range. The latitude value is normalized to the range [-SECONDS_90, SECONDS_90].- Parameters:
latitudeInSeconds- the latitude in seconds to be set. Values exceeding the range will be normalized.
-
getLongitude
public int getLongitude()Retrieves the longitude value.- Returns:
- the longitude as an integer.
-
setLongitude
public void setLongitude(int longitudeInSeconds) Sets the longitude value in seconds. The input value is normalized to ensure it stays within the valid range of -180 to 180 degrees, represented in seconds.- Parameters:
longitudeInSeconds- the longitude value in seconds, which may initially fall outside the valid range. The method adjusts it as necessary to fit within the proper limits.
-
getAltitude
public int getAltitude()Retrieves the current altitude.- Returns:
- the altitude as an integer value
-
setAltitude
public void setAltitude(int altitudeInMeters) Sets the altitude value in meters.- Parameters:
altitudeInMeters- the altitude to set, specified in meters
-
getStorableValue
Get the storable value for this Geolocation.- Specified by:
getStorableValuein interfaceStorable- Returns:
- Storable value.
-
getLatitudeDegree
public double getLatitudeDegree()Retrieves the latitude value in degree representation.- Returns:
- the latitude in degrees as a double, converted from seconds.
-
getLongitudeDegree
public double getLongitudeDegree()Converts the longitude value from arcseconds to degrees.- Returns:
- the longitude in degrees as a double value
-
distance
Distance between this location and another location.- Parameters:
location- Another location- Returns:
- Distance in meters
-
distanceAsDouble
Distance between this location and another location.- Parameters:
location- Another location- Returns:
- Distance in meters
-
getHeading
Calculates the directional heading in seconds of arc from the current location to the specified target location.- Parameters:
location- the target location of type Geolocation, containing latitude and longitude- Returns:
- the heading in seconds of arc, representing the angle relative to true north
-
getTimeDifferenceInMinutes
public int getTimeDifferenceInMinutes()Calculates the time difference in minutes based on the longitude. The method uses the formula: (1440 * longitude) / 360 / 3600 where: - 1440 is the total number of minutes in a day. - longitude is measured in degrees. - 360 represents the total degrees of longitude. - 3600 accounts for conversion to seconds.- Returns:
- the time difference in minutes as an integer value.
-
equals
-