Class GeoLocation

java.lang.Object
org.netxms.base.GeoLocation

public class GeoLocation extends Object
Geolocation encoding
  • Field Details

  • Constructor Details

    • GeoLocation

      public GeoLocation(NXCPMessage msg)
      Create geolocation object from NXCP message
      Parameters:
      msg - NXCP message
    • GeoLocation

      public GeoLocation(NXCPMessage msg, long baseId)
      Create geolocation object from NXCP message
      Parameters:
      msg - NXCP message
      baseId - 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 - Latitude
      lon - Longitude
    • GeoLocation

      public GeoLocation(double lat, double lon, int type, int accuracy, Date timestamp)
      Create geolocation object of given type, accuracy, and timestamp
      Parameters:
      lat - Latitude
      lon - Longitude
      type - geolocation type
      accuracy - location accuracy in meters
      timestamp - location timestamp
  • Method Details

    • isWithinArea

      public boolean isWithinArea(GeoLocation northWest, GeoLocation southEast)
      Check if this location is within given area.
      Parameters:
      northWest - top left (north west) corner of the area
      southEast - 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 border
      southBorder - 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

      public final Date getTimestamp()
      Get location's time stamp. May be null if not known.
      Returns:
      the timestamp
    • toString

      public String toString()
      Overrides:
      toString in class Object
      See Also:
    • latitudeToString

      public static String latitudeToString(double lat)
      Convert latitude from floating point to text representation
      Parameters:
      lat - latitude
      Returns:
      text representation of given latitude
    • longitudeToString

      public static String longitudeToString(double lon)
      Convert longitude from floating point to text representation
      Parameters:
      lon - longitude
      Returns:
      text representation of given longitude
    • getLatitudeAsString

      public String getLatitudeAsString()
      Returns:
      latitude as DMS string
    • getLongitudeAsString

      public 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 string
      lon - longitude string
      Returns:
      geolocation object
      Throws:
      GeoLocationFormatException - if the strings does not contain a parsable geolocation
    • parseGeoLocation

      public static GeoLocation parseGeoLocation(String s) throws GeoLocationFormatException
      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

      public Date getEndTimestamp()
      Get end timestamp
      Returns:
      end timestamp
    • setEndTimestamp

      public void setEndTimestamp(Date endTimestamp)
      Set end timestamp
      Parameters:
      endTimestamp - end timestamp
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
      See Also:
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
      See Also:
    • calculateDistance

      public int calculateDistance(GeoLocation location)
      Calculates distance between two location points
      Parameters:
      location - second location object
      Returns:
      the distance between two objects