Enum DistanceUnit
- java.lang.Object
-
- java.lang.Enum<DistanceUnit>
-
- org.gbif.api.model.occurrence.geo.DistanceUnit
-
- All Implemented Interfaces:
Serializable
,Comparable<DistanceUnit>
public enum DistanceUnit extends Enum<DistanceUnit>
The DistanceUnit enumerates several units for measuring distances. These units provide methods for converting strings and methods to convert units among each others.The default unit used within this project isMETERS
which is defined byDEFAULT
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
DistanceUnit.Distance
static class
DistanceUnit.GeoDistance
-
Enum Constant Summary
Enum Constants Enum Constant Description CENTIMETERS
FEET
INCH
KILOMETERS
METERS
MILES
MILLIMETERS
NAUTICALMILES
YARD
-
Field Summary
Fields Modifier and Type Field Description static DistanceUnit
DEFAULT
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static double
convert(double distance, DistanceUnit from, DistanceUnit to)
Converts the given distance from the given DistanceUnit, to the given DistanceUnitdouble
getMeters()
String[]
getNames()
static DistanceUnit.Distance
parseDistance(String distance)
Parse aDistanceUnit.Distance
from a given StringString
toString()
String
toString(double distance)
Convert a value to a distance stringstatic DistanceUnit
valueOf(String name)
Returns the enum constant of this type with the specified name.static DistanceUnit[]
values()
Returns an array containing the constants of this enum type, in the order they are declared.
-
-
-
Enum Constant Detail
-
INCH
public static final DistanceUnit INCH
-
YARD
public static final DistanceUnit YARD
-
FEET
public static final DistanceUnit FEET
-
KILOMETERS
public static final DistanceUnit KILOMETERS
-
NAUTICALMILES
public static final DistanceUnit NAUTICALMILES
-
MILLIMETERS
public static final DistanceUnit MILLIMETERS
-
CENTIMETERS
public static final DistanceUnit CENTIMETERS
-
MILES
public static final DistanceUnit MILES
-
METERS
public static final DistanceUnit METERS
-
-
Field Detail
-
DEFAULT
public static final DistanceUnit DEFAULT
-
-
Method Detail
-
values
public static DistanceUnit[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:for (DistanceUnit c : DistanceUnit.values()) System.out.println(c);
- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
public static DistanceUnit valueOf(String name)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)- Parameters:
name
- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException
- if this enum type has no constant with the specified nameNullPointerException
- if the argument is null
-
getMeters
public double getMeters()
-
toString
public String toString(double distance)
Convert a value to a distance string- Parameters:
distance
- value to convert- Returns:
- String representation of the distance
-
toString
public String toString()
- Overrides:
toString
in classEnum<DistanceUnit>
-
parseDistance
public static DistanceUnit.Distance parseDistance(String distance)
Parse aDistanceUnit.Distance
from a given String- Parameters:
distance
- String defining aDistanceUnit.Distance
- Returns:
- parsed
DistanceUnit.Distance
-
convert
public static double convert(double distance, DistanceUnit from, DistanceUnit to)
Converts the given distance from the given DistanceUnit, to the given DistanceUnit- Parameters:
distance
- Distance to convertfrom
- Unit to convert the distance fromto
- Unit of distance to convert to- Returns:
- Given distance converted to the distance in the given unit
-
-