public enum DistanceUnit extends java.lang.Enum<DistanceUnit> implements Writeable
getEarthCircumference() refer to
the earth ellipsoid defined in GeoUtils. The default unit used within
this project is METERS which is defined by DEFAULT| Modifier and Type | Class and Description |
|---|---|
static class |
DistanceUnit.Distance
This class implements a value+unit tuple.
|
Writeable.Reader<V>, Writeable.Writer<V>| Enum Constant and Description |
|---|
CENTIMETERS |
FEET |
INCH |
KILOMETERS |
METERS |
MILES |
MILLIMETERS |
NAUTICALMILES |
YARD |
| Modifier and Type | Field and Description |
|---|---|
static DistanceUnit |
DEFAULT |
| Modifier and Type | Method and Description |
|---|---|
double |
convert(double distance,
DistanceUnit unit)
Convert a given value into another unit
|
static double |
convert(double distance,
DistanceUnit from,
DistanceUnit to)
Converts the given distance from the given DistanceUnit, to the given DistanceUnit
|
double |
fromMeters(double distance)
Convert a value given in meters to a value of this unit
|
static DistanceUnit |
fromString(java.lang.String unit)
Convert a String to a
DistanceUnit |
double |
getDistancePerDegree()
Measures a longitude in this unit
|
double |
getEarthCircumference()
Measures the circumference of earth in this unit
|
double |
getEarthRadius()
Measures the radius of earth in this unit
|
double |
parse(java.lang.String distance,
DistanceUnit defaultUnit)
Parses a given distance and converts it to this unit.
|
static double |
parse(java.lang.String distance,
DistanceUnit defaultUnit,
DistanceUnit to)
Parses a given distance and converts it to the specified unit.
|
static DistanceUnit |
parseUnit(java.lang.String distance,
DistanceUnit defaultUnit)
Parses the suffix of a given distance string and return the corresponding
DistanceUnit |
static DistanceUnit |
readFromStream(StreamInput in)
Read a
DistanceUnit from a StreamInput. |
double |
toMeters(double distance)
Convert a value into meters
|
java.lang.String |
toString() |
java.lang.String |
toString(double distance)
Convert a value to a distance string
|
static DistanceUnit |
valueOf(java.lang.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.
|
void |
writeTo(StreamOutput out)
Write a
DistanceUnit to a StreamOutput. |
public static final DistanceUnit INCH
public static final DistanceUnit YARD
public static final DistanceUnit FEET
public static final DistanceUnit KILOMETERS
public static final DistanceUnit NAUTICALMILES
public static final DistanceUnit MILLIMETERS
public static final DistanceUnit CENTIMETERS
public static final DistanceUnit MILES
public static final DistanceUnit METERS
public static final DistanceUnit DEFAULT
public static DistanceUnit[] values()
for (DistanceUnit c : DistanceUnit.values()) System.out.println(c);
public static DistanceUnit valueOf(java.lang.String name)
name - the name of the enum constant to be returned.java.lang.IllegalArgumentException - if this enum type has no constant with the specified namejava.lang.NullPointerException - if the argument is nullpublic double getEarthCircumference()
public double getEarthRadius()
public double getDistancePerDegree()
public double toMeters(double distance)
distance - distance in this unitpublic double fromMeters(double distance)
distance - distance in meterspublic double convert(double distance,
DistanceUnit unit)
distance - value in this unitunit - source unitpublic java.lang.String toString(double distance)
distance - value to convertpublic java.lang.String toString()
toString in class java.lang.Enum<DistanceUnit>public static double convert(double distance,
DistanceUnit from,
DistanceUnit to)
distance - Distance to convertfrom - Unit to convert the distance fromto - Unit of distance to convert topublic static double parse(java.lang.String distance,
DistanceUnit defaultUnit,
DistanceUnit to)
distance - String defining a distance (value and unit)defaultUnit - unit assumed if none is definedto - unit of resultpublic double parse(java.lang.String distance,
DistanceUnit defaultUnit)
distance - String defining a distance (value and unit)defaultUnit - unit to expect if none if providedpublic static DistanceUnit fromString(java.lang.String unit)
DistanceUnitunit - name of the unitjava.lang.IllegalArgumentException - if no unit matches the given namepublic static DistanceUnit parseUnit(java.lang.String distance, DistanceUnit defaultUnit)
DistanceUnitdistance - string representing a distancedefaultUnit - default unit to use, if no unit is provided by the stringpublic static DistanceUnit readFromStream(StreamInput in) throws java.io.IOException
DistanceUnit from a StreamInput.in - StreamInput to read the DistanceUnit fromDistanceUnit read from the StreamInputjava.io.IOException - if no unit can be read from the StreamInputjava.lang.IllegalArgumentException - if no matching DistanceUnit can be foundpublic void writeTo(StreamOutput out) throws java.io.IOException
DistanceUnit to a StreamOutput.writeTo in interface Writeableout - StreamOutput to write tojava.io.IOException