|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.deegree.cs.CRSIdentifiable
org.deegree.cs.components.Unit
public final class Unit
The Unit class defines a mechanism to convert between different measurements units, such as british_yard
and meter.
| Field Summary | |
|---|---|
static Unit |
ARC_SEC
Unit of angle, which is defined to be 1/3600 of a degree, or PI/(180*3600) Radian. |
static Unit |
BRITISHYARD
British yard; unit of length. |
static Unit |
CLARK_FOOT
Clarkse foot; unit of length, with base unit of 0.304797 meter. |
static Unit |
DAY
Unit of time. |
static Unit |
DEGREE
Unit of angle. |
static IUnit |
DMSH
1 degree minute second hemisphere = 1 degree |
static Unit |
FOOT
foot; unit of length, with base unit of 0.304 meter. |
static Unit |
INDIAN_FOOT
Indian foot; unit of length, with base unit of 0.304799 meter. |
static Unit |
METRE
Base unit of length. |
static Unit |
MILLISECOND
Unit of time. |
static Unit |
RADIAN
Unit of angle. |
static Unit |
SECOND
Base unit of time. |
static Unit |
USFOOT
US foot; unit of length, with base unit of 0.304 meter. |
| Constructor Summary | |
|---|---|
Unit(String symbol,
String name)
Unit constructor. |
|
Unit(String symbol,
String name,
CRSCodeType code)
Unit constructor. |
|
Unit(String symbol,
String name,
CRSCodeType code,
double scale,
IUnit baseType)
Unit constructor. |
|
Unit(String symbol,
String name,
double scale,
IUnit baseType)
Unit constructor, which uses the name as the id. |
|
| Method Summary | |
|---|---|
boolean |
canConvert(IUnit other)
Check if amount of the specified unit can be converted into amount of this unit. |
double |
convert(double value,
IUnit targetUnit)
Convert a value in this unit to the given unit if possible. |
static Unit |
createUnitFromString(String unit)
Will create a unit from the given String. |
boolean |
equals(Object object)
Compare this unit symbol with the specified object for equality. |
IUnit |
getBaseType()
|
double |
getScale()
|
int |
hashCode()
Implementation as proposed by Joshua Block in Effective Java (Addison-Wesley 2001), which supplies an even distribution and is relatively fast. |
boolean |
isBaseType()
|
double |
toBaseUnits(double value)
Convert a value in this unit to the base unit, e.g. degree->radians |
String |
toString()
|
| Methods inherited from class org.deegree.cs.CRSIdentifiable |
|---|
addAreaOfUse, addName, checkForNullObject, checkForNullObject, checkForNullObject, getAreaOfUse, getAreaOfUseBBox, getAreasOfUse, getCode, getCodeAndName, getCodes, getDescription, getDescriptions, getId, getName, getNames, getOrignalCodeStrings, getVersion, getVersions, hasCode, hasId, hasIdOrName, setDefaultAreaOfUse, setDefaultDescription, setDefaultId, setDefaultName, setDefaultVersion |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface org.deegree.cs.CRSResource |
|---|
addAreaOfUse, addName, getAreaOfUse, getAreaOfUseBBox, getAreasOfUse, getCode, getCodeAndName, getCodes, getDescription, getDescriptions, getName, getNames, getOrignalCodeStrings, getVersion, getVersions, hasCode, hasId, hasIdOrName, setDefaultAreaOfUse, setDefaultDescription, setDefaultId, setDefaultName, setDefaultVersion |
| Methods inherited from interface org.deegree.commons.tom.Object |
|---|
getId |
| Field Detail |
|---|
public static final Unit RADIAN
public static final Unit DEGREE
public static final IUnit DMSH
public static final Unit ARC_SEC
public static final Unit METRE
public static final Unit BRITISHYARD
public static final Unit FOOT
public static final Unit USFOOT
public static final Unit CLARK_FOOT
public static final Unit INDIAN_FOOT
public static final Unit SECOND
public static final Unit MILLISECOND
public static final Unit DAY
| Constructor Detail |
|---|
public Unit(String symbol,
String name,
CRSCodeType code)
symbol - name - of the unit, e.g. metrecode - of the unit
public Unit(String symbol,
String name)
symbol - name - of the unit, e.g. metre
public Unit(String symbol,
String name,
double scale,
IUnit baseType)
symbol - of the units, e.g. 'm'name - human readable name, e.g. metrescale - to convert to the base type.baseType - the baseType
public Unit(String symbol,
String name,
CRSCodeType code,
double scale,
IUnit baseType)
symbol - of the units, e.g. 'm'name - human readable name, e.g. metrecode - of the unit.scale - to convert to the base type.baseType - the baseType| Method Detail |
|---|
public static Unit createUnitFromString(String unit)
null will be returned.
- Parameters:
unit - to convert to an actual unit.
- Returns:
- a unit or
null
public boolean canConvert(IUnit other)
canConvert in interface IUnitother -
public final double convert(double value,
IUnit targetUnit)
convert in interface IUnitvalue - to be convertedtargetUnit - to convert to
IllegalArgumentException - if no conversion can be applied.public final double toBaseUnits(double value)
toBaseUnits in interface IUnitvalue - to be converted
public String toString()
toString in class CRSIdentifiablepublic boolean equals(Object object)
equals in class CRSIdentifiablepublic int hashCode()
Combining the hash code(s) computed above: result = 37 * result + code;
hashCode in class CRSIdentifiableObject.hashCode()public final double getScale()
getScale in interface IUnitpublic final boolean isBaseType()
isBaseType in interface IUnitpublic IUnit getBaseType()
getBaseType in interface IUnit
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||