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 Double.isNaN(double)
- Author:
- Christopher Mindus
- Field SummaryFieldsModifier and TypeFieldDescription- final doubleThe accuracy value returned by an implementation should correspond to a 95% confidence level.- final doubleThe altitude attribute denotes the height of the location, specified in meters above the [WGS84] ellipsoid.- final doubleThe altitudeAccuracy value returned by an implementation should correspond to a 95% confidence level.- final intThe error code from last request of a location: -1 = Not available, 0 = OK, 1 = PERMISSION_DENIED, 2 = UNAVAILABLE, 3 = TIMEOUT.- final StringThe error message for last failed attempt to get a location.- final doubleThe 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 booleanFlag for available API.- final doubleThe latitude attribute coordinate is specified in decimal degrees.- final doubleThe longitude attributes coordinate is specified in decimal degrees.- final doubleThe speed attribute denotes the magnitude of the horizontal component of the hosting device's current velocity and is specified in meters per second.- final longThe 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 SummaryConstructorsConstructorDescription- 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 SummaryModifier and TypeMethodDescription- booleanCheck for equality.- doubleGets the altitude in meters.- doubleGets the latitude.- doubleGets the longitude.- longGets the time in millisecond since the epoch that this event was constructed.- int- hashCode()Gets the hash code of this instance.- static GeoLocationConstructs a GeoLocation from a JSON string.- static GeoLocation- of- (JSONObject jo) Constructs a GeoLocation from a JSONObject.- paramString- (String sep) The parameter string inside the "toString()".Gets the JSONObject of this geolocation.Returns the JSON representation of the GeoLocation instance.- toString()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- isAvailablepublic final boolean isAvailableFlag for available API.
- errorCodepublic final int errorCodeThe error code from last request of a location:- -1 = Not available,
- 0 = OK,
- 1 = PERMISSION_DENIED,
- 2 = UNAVAILABLE,
- 3 = TIMEOUT.
 
- errorMessageThe 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.
- timestampDevicepublic final long timestampDeviceThe timestamp of the location generated for the device location in milliseconds, since January 1, 1970, -1L if not available.
- latitudepublic final double latitudeThe latitude attribute coordinate is specified in decimal degrees. If latitude is not provided,- Double.NaNis set.- Programming note: DO NOT COMPARE WITH Double.NaN as e.g. - value==Double.NaN, use- Double.isNaN(double)
- longitudepublic final double longitudeThe longitude attributes coordinate is specified in decimal degrees. If longitude is not provided,- Double.NaNis set.- Programming note: DO NOT COMPARE WITH Double.NaN as e.g. - value==Double.NaN, use- Double.isNaN(double)
- altitudepublic 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 is- Double.NaN. If altitude is not provided,- Double.NaNis set.- Programming note: DO NOT COMPARE WITH Double.NaN as e.g. - value==Double.NaN, use- Double.isNaN(double)
- accuracypublic final double accuracyThe accuracy value returned by an implementation should correspond to a 95% confidence level. If accuracy is not provided,- Double.NaNis set.- Programming note: DO NOT COMPARE WITH Double.NaN as e.g. - value==Double.NaN, use- Double.isNaN(double)
- altitudeAccuracypublic final double altitudeAccuracyThe altitudeAccuracy value returned by an implementation should correspond to a 95% confidence level. If altitudeAccuracy is not provided,- Double.NaNis set.- Programming note: DO NOT COMPARE WITH Double.NaN as e.g. - value==Double.NaN, use- Double.isNaN(double)
- headingpublic 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 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)
- speedpublic 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 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)
 
- Constructor Details- GeoLocationpublic 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.
 
- GeoLocationpublic 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.
 
- GeoLocationpublic 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- getTimestamppublic long getTimestamp()Gets the time in millisecond since the epoch that this event was constructed.- Returns:
- A value in milliseconds.
 
- getLongitudepublic double getLongitude()Gets the longitude.- Specified by:
- getLongitudein interface- ILongitudeLatitude
- Returns:
- The longitude, or NaN if value is not present.
 
- getLatitudepublic double getLatitude()Gets the latitude.- Specified by:
- getLatitudein interface- ILongitudeLatitude
- Returns:
- The latitude, or NaN if value is not present.
 
- getAltitudepublic double getAltitude()Gets the altitude in meters.- Specified by:
- getAltitudein interface- ILongitudeLatitudeAltitude
- Returns:
- The altitude, or NaN if not available.
 
- equalsCheck for equality. This method is not thread safe.
- hashCodepublic int hashCode()Gets the hash code of this instance.
- paramStringThe parameter string inside the "toString()".- Parameters:
- sep- The Separator "," is used by toString().
- Returns:
- The paramString.
 
- toStringCreates the string representation of this location. This method is not thread safe.
- toJSONStringReturns the JSON representation of the GeoLocation instance.- Returns:
- A JSON String.
 
- toJSONObjectGets the JSONObject of this geolocation.- Returns:
- The JSONObject.
 
- ofConstructs a GeoLocation from a JSON string.- Parameters:
- json- The GeoLocation in JSON format.
- Throws:
- IllegalArgumentException- If it failed parsing.
 
- ofConstructs a GeoLocation from a JSONObject.- Parameters:
- jo- The GeoLocation JSONObject.
- Throws:
- IllegalArgumentException- If it failed parsing.