Class GeoPoint

java.lang.Object
org.apache.unomi.api.GeoPoint

public class GeoPoint extends Object
GeoPoint represents a point in geographical coordinate system using latitude and longitude.
  • Constructor Details

    • GeoPoint

      public GeoPoint(Double lat, Double lon)
      Instantiates a new GeoPoint
      Parameters:
      lat - latitude of the geo point
      lon - longitude of the geo point
  • Method Details

    • getLat

      public Double getLat()
      Retrieves latitude of the geo point
      Returns:
      geo point latitude
    • getLon

      public Double getLon()
      Retrieves longitude of the geo point
      Returns:
      geo point longitude
    • asString

      public String asString()
      Returns a string representation in the following format: "lat, long"
      Returns:
      String representation of geo point
    • distanceTo

      public double distanceTo(GeoPoint other)
      Calculates distance to geo point using Haversine formula in meters Note: does not account for altitude
      Parameters:
      other - GeoPoint to calculate distance to
      Returns:
      Distance in meters
    • fromMap

      public static GeoPoint fromMap(Map<String,Double> map)
      Instantiates geo point from map of coordinates
      Parameters:
      map - Map containing coordinates with keys "lat" and "lon"
      Returns:
      New geo point or null if map is not a valid geo point
      Throws:
      IllegalArgumentException - Thrown if the input is not valid
    • fromString

      public static GeoPoint fromString(String input)
      Instantiates geo point from string representation
      Parameters:
      input - String geo point representation in the following format: "lat, lon"
      Returns:
      New geo point or null if string is not a valid geo point
      Throws:
      IllegalArgumentException - Thrown if the input is not valid