Package org.apache.unomi.api
Class GeoPoint
java.lang.Object
org.apache.unomi.api.GeoPoint
GeoPoint represents a point in geographical coordinate system using latitude and longitude.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionasString()
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
Instantiates geo point from map of coordinatesstatic GeoPoint
fromString
(String input) Instantiates geo point from string representationgetLat()
Retrieves latitude of the geo pointgetLon()
Retrieves longitude of the geo point
-
Constructor Details
-
GeoPoint
Instantiates a new GeoPoint- Parameters:
lat
- latitude of the geo pointlon
- longitude of the geo point
-
-
Method Details
-
getLat
Retrieves latitude of the geo point- Returns:
- geo point latitude
-
getLon
Retrieves longitude of the geo point- Returns:
- geo point longitude
-
asString
Returns a string representation in the following format: "lat, long"- Returns:
- String representation of geo point
-
distanceTo
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
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
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
-