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
Method Summary
Modifier and TypeMethodDescriptionstatic 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
Gets the latitude.double
Gets the longitude.
Field Details
EARTH_RADIUS
static final double EARTH_RADIUSRadius of the earth.- See Also:
Method Details
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
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.