Package org.apache.unomi.api
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.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description String
asString()
Returns a string representation in the following format: "lat, long"double
distanceTo(GeoPoint other)
Calculates distance to geo point using Haversine formula in meters Note: does not account for altitudestatic GeoPoint
fromMap(Map<String,Double> map)
Instantiates geo point from map of coordinatesstatic GeoPoint
fromString(String input)
Instantiates geo point from string representationDouble
getLat()
Retrieves latitude of the geo pointDouble
getLon()
Retrieves longitude of the geo point
-
-
-
Method Detail
-
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
-
-