Package com.iizix.geo
Interface ILongitudeLatitude
- All Known Subinterfaces:
ILongitudeLatitudeAltitude
- All Known Implementing Classes:
GeoLocation
,RegionLocation
public interface ILongitudeLatitude
Interface used for geolocation with longitude and latitude.Programming note: DO NOT COMPARE WITH Double.NaN as e.g.
value==Double.NaN
, use
instead as comparison is always false.Double.isNaN(double)
- Author:
- Christopher Mindus
Field Summary
Fields Modifier and Type Field Description static double
EARTH_RADIUS
Radius of the earth.
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description static double
getDistance(double longitude1, double longitude2, double latitude1, double latitude2)
Calculate distance between two points in latitude and longitude.default double
getDistance(ILongitudeLatitude location)
Gets the distance in meters between this location and another.double
getLatitude()
Gets the latitude.double
getLongitude()
Gets the longitude.
Field Detail
EARTH_RADIUS
static final double EARTH_RADIUS
Radius of the earth.- See Also:
- Constant Field Values
Method Detail
getDistance
static double getDistance(double longitude1, double longitude2, double latitude1, double latitude2)
Calculate distance between two points in latitude and longitude. Uses Haversine method as its base.- Parameters:
longitude1
- Longitude 1.longitude2
- Longitude 2.latitude1
- Latitude 1.latitude2
- Latitude 2.- Returns:
- Distance in Meters, or Double.NaN if either values are
Double.isNaN()
.
getLongitude
double getLongitude()
Gets the longitude.- Returns:
- The longitude, or NaN if value is not present.
getLatitude
double getLatitude()
Gets the latitude.- Returns:
- The latitude, or NaN if value is not present.
getDistance
default double getDistance(ILongitudeLatitude location)
Gets the distance in meters between this location and another.- Parameters:
location
- The other location.- Returns:
- Distance in meters, Double.NaN if longitude/latitude values are not present.