Class GeoLocation

java.lang.Object
com.iizix.prop.GeoLocation
All Implemented Interfaces:
ILongitudeLatitude, ILongitudeLatitudeAltitude

public class GeoLocation extends Object implements ILongitudeLatitudeAltitude
Geographical location data object used to retrieve a location from GeoProps. This class is not thread safe and is intended to simply carry the geographical location information.

Programming note: DO NOT COMPARE WITH Double.NaN as e.g. value==Double.NaN, use Double.isNaN(double) instead as comparison is always false.

Author:
Christopher Mindus
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    final double
    The accuracy value returned by an implementation should correspond to a 95% confidence level.
    final double
    The altitude attribute denotes the height of the location, specified in meters above the [WGS84] ellipsoid.
    final double
    The altitudeAccuracy value returned by an implementation should correspond to a 95% confidence level.
    final int
    The error code from last request of a location: -1 = Not available, 0 = OK, 1 = PERMISSION_DENIED, 2 = UNAVAILABLE, 3 = TIMEOUT.
    final String
    The error message for last failed attempt to get a location.
    final double
    The heading attribute denotes the direction of travel of the hosting device and is specified in degrees, where 0<=heading<360, counting clockwise relative to the true north.
    final boolean
    Flag for available API.
    final double
    The latitude attribute coordinate is specified in decimal degrees.
    final double
    The longitude attributes coordinate is specified in decimal degrees.
    final double
    The speed attribute denotes the magnitude of the horizontal component of the hosting device's current velocity and is specified in meters per second.
    final long
    The nanoTime of the location in milliseconds when the server has received the location.
    final long
    The timestamp of the location generated for the device location in milliseconds, since January 1, 1970, -1L if not available.

    Fields inherited from interface com.iizix.geo.ILongitudeLatitude

    EARTH_RADIUS
  • Constructor Summary

    Constructors
    Constructor
    Description
    GeoLocation(boolean isAvailable, int errorCode, String errorMessage, long timestamp, double latitude, double longitude, double altitude, double accuracy, double altitudeAccuracy, double heading, double speed)
    Constructor.
    GeoLocation(double latitude, double longitude)
    Constructor for very low accuracy without altitude or speed.
    GeoLocation(long timestamp, double latitude, double longitude, double altitude, double accuracy, double speed)
    Constructor.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Check for equality.
    double
    Gets the altitude in meters.
    double
    Gets the latitude.
    double
    Gets the longitude.
    int
    Gets the hash code of this instance.
    Creates the string representation of this location.

    Methods inherited from class java.lang.Object

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

    Methods inherited from interface com.iizix.geo.ILongitudeLatitude

    getDistance

    Methods inherited from interface com.iizix.geo.ILongitudeLatitudeAltitude

    getDistance
  • Field Details

    • isAvailable

      public final boolean isAvailable
      Flag for available API.
    • errorCode

      public final int errorCode
      The error code from last request of a location:
      • -1 = Not available,
      • 0 = OK,
      • 1 = PERMISSION_DENIED,
      • 2 = UNAVAILABLE,
      • 3 = TIMEOUT.
    • errorMessage

      public final String errorMessage
      The error message for last failed attempt to get a location. If the errorCode is zero, then this message does not apply. The message can be null for no message ever encountered.
    • timestamp

      public final long timestamp
      The nanoTime of the location in milliseconds when the server has received the location.
    • timestampDevice

      public final long timestampDevice
      The timestamp of the location generated for the device location in milliseconds, since January 1, 1970, -1L if not available.
    • latitude

      public final double latitude
      The latitude attribute coordinate is specified in decimal degrees. If latitude is not provided, Double.NaN is set.

      Programming note: DO NOT COMPARE WITH Double.NaN as e.g. value==Double.NaN, use Double.isNaN(double) instead as comparison is always false.

    • longitude

      public final double longitude
      The longitude attributes coordinate is specified in decimal degrees. If longitude is not provided, Double.NaN is set.

      Programming note: DO NOT COMPARE WITH Double.NaN as e.g. value==Double.NaN, use Double.isNaN(double) instead as comparison is always false.

    • altitude

      public final double altitude
      The altitude attribute denotes the height of the location, specified in meters above the [WGS84] ellipsoid. If the implementation cannot provide altitude information, the value of this attribute is Double.NaN. If altitude is not provided, Double.NaN is set.

      Programming note: DO NOT COMPARE WITH Double.NaN as e.g. value==Double.NaN, use Double.isNaN(double) instead as comparison is always false.

    • accuracy

      public final double accuracy
      The accuracy value returned by an implementation should correspond to a 95% confidence level. If accuracy is not provided, Double.NaN is set.

      Programming note: DO NOT COMPARE WITH Double.NaN as e.g. value==Double.NaN, use Double.isNaN(double) instead as comparison is always false.

    • altitudeAccuracy

      public final double altitudeAccuracy
      The altitudeAccuracy value returned by an implementation should correspond to a 95% confidence level. If altitudeAccuracy is not provided, Double.NaN is set.

      Programming note: DO NOT COMPARE WITH Double.NaN as e.g. value==Double.NaN, use Double.isNaN(double) instead as comparison is always false.

    • heading

      public final double heading
      The heading attribute denotes the direction of travel of the hosting device and is specified in degrees, where 0<=heading<360, counting clockwise relative to the true north. If the implementation cannot provide heading information, the value of this attribute is Double.NaN. If the hosting device is stationary (i.e. the value of the speed attribute is 0), then the value of the heading attribute is Double.NaN.

      Programming note: DO NOT COMPARE WITH Double.NaN as e.g. value==Double.NaN, use Double.isNaN(double) instead as comparison is always false.

    • speed

      public final double speed
      The speed attribute denotes the magnitude of the horizontal component of the hosting device's current velocity and is specified in meters per second. If the implementation cannot provide speed information, the value of this attribute is Double.NaN. Otherwise, the value of the speed attribute is a non-negative real number.

      Programming note: DO NOT COMPARE WITH Double.NaN as e.g. value==Double.NaN, use Double.isNaN(double) instead as comparison is always false.

  • Constructor Details

    • GeoLocation

      public GeoLocation(double latitude, double longitude)
      Constructor for very low accuracy without altitude or speed.

      The timestamp is set to "now", and the altitude and speed is set to Double.NaN. Accuracy is set to 0d.

      Parameters:
      latitude - Latitude coordinate.
      longitude - Longitude coordinate.
    • GeoLocation

      public GeoLocation(long timestamp, double latitude, double longitude, double altitude, double accuracy, double speed)
      Constructor.

      Altitude accuracy and heading are assumed not specified.

      Parameters:
      timestamp - Timestamp in milliseconds since the epoch (1st Jan 1970 0:00:00 GMT).
      latitude - Latitude coordinate.
      longitude - Longitude coordinate.
      altitude - Height of location in meters.
      accuracy - Accuracy in percent.
      speed - Speed attribute.
    • GeoLocation

      public GeoLocation(boolean isAvailable, int errorCode, String errorMessage, long timestamp, double latitude, double longitude, double altitude, double accuracy, double altitudeAccuracy, double heading, double speed)
      Constructor.
      Parameters:
      isAvailable - Flag for geolocation availability.
      errorCode - Error code from last request of a location, 0 for no error.
      errorMessage - Error message, or null for no error.
      timestamp - Timestamp in milliseconds since the epoch (1st Jan 1970 0:00:00 GMT).
      latitude - Latitude coordinate.
      longitude - Longitude coordinate.
      altitude - Height of location in meters.
      accuracy - Accuracy in percent.
      altitudeAccuracy - Altitude accuracy in percent.
      heading - Heading attribute.
      speed - Speed attribute.
  • Method Details

    • getLongitude

      public double getLongitude()
      Gets the longitude.
      Specified by:
      getLongitude in interface ILongitudeLatitude
      Returns:
      The longitude, or NaN if value is not present.
    • getLatitude

      public double getLatitude()
      Gets the latitude.
      Specified by:
      getLatitude in interface ILongitudeLatitude
      Returns:
      The latitude, or NaN if value is not present.
    • getAltitude

      public double getAltitude()
      Gets the altitude in meters.
      Specified by:
      getAltitude in interface ILongitudeLatitudeAltitude
      Returns:
      The altitude, or NaN if not available.
    • equals

      public boolean equals(Object o)
      Check for equality. This method is not thread safe.
      Overrides:
      equals in class Object
      Parameters:
      o - Another object.
      Returns:
      true if it's the same GeoLocation object values, false otherwise.
    • hashCode

      public int hashCode()
      Gets the hash code of this instance.
      Overrides:
      hashCode in class Object
      Returns:
      The hash code.
    • toString

      public String toString()
      Creates the string representation of this location. This method is not thread safe.
      Overrides:
      toString in class Object
      Returns:
      Location String as "className[isAvailable=boolean,errorCode=nn (REASON),...]".