Class GeoLocation

  • All Implemented Interfaces:
    ILongitudeLatitude, ILongitudeLatitudeAltitude

    public class GeoLocation
    extends java.lang.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
      double accuracy
      The accuracy value returned by an implementation should correspond to a 95% confidence level.
      double altitude
      The altitude attribute denotes the height of the location, specified in meters above the [WGS84] ellipsoid.
      double altitudeAccuracy
      The altitudeAccuracy value returned by an implementation should correspond to a 95% confidence level.
      int errorCode
      The error code from last request of a location: -1 = Not available, 0 = OK, 1 = PERMISSION_DENIED, 2 = UNAVAILABLE, 3 = TIMEOUT.
      java.lang.String errorMessage
      The error message for last failed attempt to get a location.
      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.
      boolean isAvailable
      Flag for available API.
      double latitude
      The latitude attribute coordinate is specified in decimal degrees.
      double longitude
      The longitude attributes coordinate is specified in decimal degrees.
      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.
      long timestamp
      The timestamp of the location in milliseconds when the server has received the location, since January 1, 1970, -1L if not available.
      long timestampDevice
      The timestamp of the location generated for the device location in milliseconds, since January 1, 1970, -1L if not available.
    • Constructor Summary

      Constructors 
      Constructor Description
      GeoLocation​(boolean isAvailable, int errorCode, java.lang.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.
    • Field Detail

      • 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 java.lang.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 timestamp of the location in milliseconds when the server has received the location, since January 1, 1970, -1L if not available.
      • 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 Detail

      • 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,
                           java.lang.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 Detail

      • 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​(java.lang.Object o)
        Check for equality. This method is not thread safe.
        Overrides:
        equals in class java.lang.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 java.lang.Object
        Returns:
        The hash code.
      • toString

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