Class GeoLocation
- All Implemented Interfaces:
ILongitudeLatitude
,ILongitudeLatitudeAltitude
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
instead as comparison is always false.Double.isNaN(double)
- Author:
- Christopher Mindus
Field Summary
Modifier and TypeFieldDescriptionfinal 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
ConstructorDescriptionGeoLocation
(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
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 isAvailableFlag for available API.errorCode
public final int errorCodeThe error code from last request of a location:- -1 = Not available,
- 0 = OK,
- 1 = PERMISSION_DENIED,
- 2 = UNAVAILABLE,
- 3 = TIMEOUT.
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 timestampThe nanoTime of the location in milliseconds when the server has received the location.timestampDevice
public final long timestampDeviceThe timestamp of the location generated for the device location in milliseconds, since January 1, 1970, -1L if not available.latitude
public final double latitudeThe 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
instead as comparison is always false.Double.isNaN(double)
longitude
public final double longitudeThe 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
instead as comparison is always false.Double.isNaN(double)
altitude
public final double altitudeThe 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 isDouble.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
instead as comparison is always false.Double.isNaN(double)
accuracy
public final double accuracyThe 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
instead as comparison is always false.Double.isNaN(double)
altitudeAccuracy
public final double altitudeAccuracyThe 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
instead as comparison is always false.Double.isNaN(double)
heading
public final double headingThe 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 isDouble.NaN
. If the hosting device is stationary (i.e. the value of the speed attribute is 0), then the value of the heading attribute isDouble.NaN
.Programming note: DO NOT COMPARE WITH Double.NaN as e.g.
value==Double.NaN
, use
instead as comparison is always false.Double.isNaN(double)
speed
public final double speedThe 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 isDouble.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
instead as comparison is always false.Double.isNaN(double)
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 interfaceILongitudeLatitude
- Returns:
- The longitude, or NaN if value is not present.
getLatitude
public double getLatitude()Gets the latitude.- Specified by:
getLatitude
in interfaceILongitudeLatitude
- Returns:
- The latitude, or NaN if value is not present.
getAltitude
public double getAltitude()Gets the altitude in meters.- Specified by:
getAltitude
in interfaceILongitudeLatitudeAltitude
- Returns:
- The altitude, or NaN if not available.
equals
Check for equality. This method is not thread safe.hashCode
public int hashCode()Gets the hash code of this instance.toString
Creates the string representation of this location. This method is not thread safe.