public class GeoLocation extends Object
| Modifier and Type | Field and Description |
|---|---|
static int |
GPS |
static int |
MANUAL |
static int |
NETWORK |
static int |
UNSET |
| Constructor and Description |
|---|
GeoLocation(boolean isGPS)
Create geolocation object of type UNSET or GPS
|
GeoLocation(double lat,
double lon)
Create geolocation object of type MANUAL
|
GeoLocation(double lat,
double lon,
int type,
int accuracy,
Date timestamp)
Create geolocation object of given type, accuracy, and timestamp
|
GeoLocation(NXCPMessage msg)
Create geolocation object from NXCP message
|
GeoLocation(NXCPMessage msg,
long baseId)
Create geolocation object from NXCP message
|
| Modifier and Type | Method and Description |
|---|---|
int |
calculateDistance(GeoLocation location)
Calculates distance between two location points
|
boolean |
equals(Object obj) |
int |
getAccuracy()
Get location accuracy (in meters)
|
Date |
getEndTimestamp() |
double |
getLatitude()
Get latitude
|
String |
getLatitudeAsString() |
double |
getLongitude()
Get longitude
|
String |
getLongitudeAsString() |
Date |
getTimestamp()
Get location's time stamp.
|
int |
getType()
Get location type
|
int |
hashCode() |
boolean |
isAutomatic()
Returns true if location was obtained automatically (from GPS or network)
|
boolean |
isWithinArea(double northBorder,
double westBorder,
double southBorder,
double eastBorder)
Check if this location is within given area.
|
boolean |
isWithinArea(GeoLocation northWest,
GeoLocation southEast)
Check if this location is within given area.
|
static String |
latitudeToString(double lat)
Convert latitude from floating point to text representation
|
static String |
longitudeToString(double lon)
Convert longitude from floating point to text representation
|
static GeoLocation |
parseGeoLocation(String lat,
String lon)
Parse geolocation string.
|
void |
setEndTimestamp(Date endTimestamp) |
String |
toString() |
public static final int UNSET
public static final int MANUAL
public static final int GPS
public static final int NETWORK
public GeoLocation(NXCPMessage msg)
msg - NXCP messagepublic GeoLocation(NXCPMessage msg, long baseId)
msg - NXCP messagebaseId - base field IDpublic GeoLocation(boolean isGPS)
isGPS - if true set type to GPSpublic GeoLocation(double lat,
double lon)
lat - Latitudelon - Longitudepublic GeoLocation(double lat,
double lon,
int type,
int accuracy,
Date timestamp)
lat - Latitudelon - Longitudetype - geolocation typeaccuracy - location accuracy in meterstimestamp - location timestamppublic boolean isWithinArea(GeoLocation northWest, GeoLocation southEast)
northWest - top left (north west) corner of the areasouthEast - bottom right (south east) corner of the areapublic boolean isWithinArea(double northBorder,
double westBorder,
double southBorder,
double eastBorder)
northBorder - north area border (highest latitude)westBorder - west area bordersouthBorder - south area border (lowest latitude)eastBorder - east area borderpublic boolean isAutomatic()
public int getType()
public double getLatitude()
public double getLongitude()
public int getAccuracy()
public final Date getTimestamp()
public static String latitudeToString(double lat)
lat - latitudepublic static String longitudeToString(double lon)
lon - longitudepublic String getLatitudeAsString()
public String getLongitudeAsString()
public static GeoLocation parseGeoLocation(String lat, String lon) throws GeoLocationFormatException
lat - latitude stringlon - longitude stringGeoLocationFormatException - if the strings does not contain a parsable geolocationpublic Date getEndTimestamp()
public void setEndTimestamp(Date endTimestamp)
endTimestamp - public int calculateDistance(GeoLocation location)
location - second location objectCopyright © 2018. All rights reserved.