public enum DistanceUnit extends java.lang.Enum<DistanceUnit>
| Enum Constant and Description |
|---|
CM
Represents the centimeter unit.
|
DEGREES
Represents the lat long degree unit.
|
FT
Represents the american foot unit.
|
IN
Represents the american inch unit.
|
KM
Represents the kilometer unit.
|
M
Represents the meter unit.
|
MI
Represents the american mile unit.
|
MINUTE
Represents the lat long minute unit.
|
MM
Represents the millimeter unit.
|
PX
Represents the pixel unit.
|
SECOND
Represents the lat long second unit.
|
YD
Represents the american yard unit.
|
| Modifier and Type | Method and Description |
|---|---|
double |
convertTo(double value,
DistanceUnit targetUnit)
Convert values in this unit to the equivalent value in another unit.
|
static DistanceUnit |
fromProjection(org.opengis.referencing.crs.CoordinateReferenceSystem projection)
Determine the unit of the given projection.
|
static DistanceUnit |
fromString(java.lang.String val)
Parse the value and return the identified unit object.
|
DistanceUnit[] |
getAllUnits()
Return the sorted list (from smallest to biggest) of units sharing the
same base unit.
|
static DistanceUnit |
getBestUnit(double value,
DistanceUnit unit)
Return the first unit that would give a value >=1.
|
boolean |
isBase() |
boolean |
isSameBaseUnit(DistanceUnit target)
Check if this unit and the target unit have the same "base" unit IE inches and feet have same base unit.
|
java.lang.String |
toString() |
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.
|
public static final DistanceUnit M
public static final DistanceUnit MM
public static final DistanceUnit CM
public static final DistanceUnit KM
public static final DistanceUnit FT
public static final DistanceUnit IN
public static final DistanceUnit YD
public static final DistanceUnit MI
public static final DistanceUnit DEGREES
public static final DistanceUnit MINUTE
public static final DistanceUnit SECOND
public static final DistanceUnit PX
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 boolean isBase()
public double convertTo(double value,
DistanceUnit targetUnit)
DistanceUnit.M.convertTo(1.0, DistanceUnit.MM)==1000.0
value - a value in the same unit as this DistanceUnittargetUnit - the unit to convert value to (from this unit)public boolean isSameBaseUnit(DistanceUnit target)
target - the unit to compare to this unit.public final java.lang.String toString()
toString in class java.lang.Enum<DistanceUnit>public static DistanceUnit fromString(java.lang.String val)
val - the string to parse.public final DistanceUnit[] getAllUnits()
public static DistanceUnit getBestUnit(double value, DistanceUnit unit)
value - the valueunit - the unit of the valuepublic static DistanceUnit fromProjection(org.opengis.referencing.crs.CoordinateReferenceSystem projection)
projection - the projection to determine