Package org.netxms.base
Class GeoLocation
java.lang.Object
org.netxms.base.GeoLocation
Geolocation encoding
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionGeoLocation(boolean isGPS) Create geolocation object of type UNSET or GPSGeoLocation(double lat, double lon) Create geolocation object of type MANUALGeoLocation(double lat, double lon, int type, int accuracy, Date timestamp) Create geolocation object of given type, accuracy, and timestampGeoLocation(NXCPMessage msg) Create geolocation object from NXCP messageGeoLocation(NXCPMessage msg, long baseId) Create geolocation object from NXCP message -
Method Summary
Modifier and TypeMethodDescriptionintcalculateDistance(GeoLocation location) Calculates distance between two location pointsbooleanintGet location accuracy (in meters)Get end timestampdoubleGet latitudedoubleGet longitudefinal DateGet location's time stamp.intgetType()Get location typeinthashCode()booleanReturns true if location was obtained automatically (from GPS or network)booleanisWithinArea(double northBorder, double westBorder, double southBorder, double eastBorder) Check if this location is within given area.booleanisWithinArea(GeoLocation northWest, GeoLocation southEast) Check if this location is within given area.static StringlatitudeToString(double lat) Convert latitude from floating point to text representationstatic StringlongitudeToString(double lon) Convert longitude from floating point to text representationstatic GeoLocationParse geolocation string where latitude and longitude placed together and separated by space(s).static GeoLocationparseGeoLocation(String lat, String lon) Parse geolocation string.voidsetEndTimestamp(Date endTimestamp) Set end timestamptoString()
-
Field Details
-
UNSET
public static final int UNSET- See Also:
-
MANUAL
public static final int MANUAL- See Also:
-
GPS
public static final int GPS- See Also:
-
NETWORK
public static final int NETWORK- See Also:
-
-
Constructor Details
-
GeoLocation
Create geolocation object from NXCP message- Parameters:
msg- NXCP message
-
GeoLocation
Create geolocation object from NXCP message- Parameters:
msg- NXCP messagebaseId- base field ID
-
GeoLocation
public GeoLocation(boolean isGPS) Create geolocation object of type UNSET or GPS- Parameters:
isGPS- if true set type to GPS
-
GeoLocation
public GeoLocation(double lat, double lon) Create geolocation object of type MANUAL- Parameters:
lat- Latitudelon- Longitude
-
GeoLocation
Create geolocation object of given type, accuracy, and timestamp- Parameters:
lat- Latitudelon- Longitudetype- geolocation typeaccuracy- location accuracy in meterstimestamp- location timestamp
-
-
Method Details
-
isWithinArea
Check if this location is within given area.- Parameters:
northWest- top left (north west) corner of the areasouthEast- bottom right (south east) corner of the area- Returns:
- true if this location is within given area
-
isWithinArea
public boolean isWithinArea(double northBorder, double westBorder, double southBorder, double eastBorder) Check if this location is within given area.- Parameters:
northBorder- north area border (highest latitude)westBorder- west area bordersouthBorder- south area border (lowest latitude)eastBorder- east area border- Returns:
- true if this location is within given area
-
isAutomatic
public boolean isAutomatic()Returns true if location was obtained automatically (from GPS or network)- Returns:
- true if location was obtained automatically (from GPS or network)
-
getType
public int getType()Get location type- Returns:
- location type
-
getLatitude
public double getLatitude()Get latitude- Returns:
- the latitude
-
getLongitude
public double getLongitude()Get longitude- Returns:
- the longitude
-
getAccuracy
public int getAccuracy()Get location accuracy (in meters)- Returns:
- location accuracy (in meters)
-
getTimestamp
Get location's time stamp. May be null if not known.- Returns:
- the timestamp
-
toString
-
latitudeToString
Convert latitude from floating point to text representation- Parameters:
lat- latitude- Returns:
- text representation of given latitude
-
longitudeToString
Convert longitude from floating point to text representation- Parameters:
lon- longitude- Returns:
- text representation of given longitude
-
getLatitudeAsString
- Returns:
- latitude as DMS string
-
getLongitudeAsString
- Returns:
- longitude as DMS string
-
parseGeoLocation
public static GeoLocation parseGeoLocation(String lat, String lon) throws GeoLocationFormatException Parse geolocation string. Latitude and longitude must be given either as numeric values or in DMS form.- Parameters:
lat- latitude stringlon- longitude string- Returns:
- geolocation object
- Throws:
GeoLocationFormatException- if the strings does not contain a parsable geolocation
-
parseGeoLocation
Parse geolocation string where latitude and longitude placed together and separated by space(s). Latitude and longitude must be given either as numeric values or in DMS form.- Parameters:
s- geolocation string- Returns:
- geolocation object
- Throws:
GeoLocationFormatException- if the string does not contain a parsable geolocation
-
getEndTimestamp
Get end timestamp- Returns:
- end timestamp
-
setEndTimestamp
Set end timestamp- Parameters:
endTimestamp- end timestamp
-
hashCode
public int hashCode() -
equals
-
calculateDistance
Calculates distance between two location points- Parameters:
location- second location object- Returns:
- the distance between two objects
-