Last updated

API / geotoolkit / util / Unit / Unit

Class: Unit

util.Unit.Unit

Defines an interface, which represents an unit of measure, the ratio for new unit is computed with: y=(a+bx)/(c+dx)

Hierarchy

Table of contents

Constructors
[new Unit(name)](/solutions/geotoolkit/apis/classes/geotoolkit.util.unit.unit.md#new unit(name))[new Unit(name, quantityType, symbol, baseUnitSymbol, a, b, c, d, description)](/solutions/geotoolkit/apis/classes/geotoolkit.util.unit.unit.md#new unit(name, quantitytype, symbol, baseunitsymbol, a, b, c, d, description))
Methods
Css Properties
Name Type Description
anumberFactor
bnumberFactor
baseunitsymbolstringRepresents the unit symbol of it's base unit (example for volume, 'm3' can be the base unit)
cnumberFactor
dnumberFactor
descriptionstringIt represents the description of unit
namestringRepresent the name of the unit (example : 'pint')
symbolstringSymbol to represent the unit (example: 'pt' to represent pint)

Contents

Constructors

new Unit(name)

new Unit(name?)

Parameters

Name Type
Optional nameOptions

Overrides

AbstractUnit.constructor


new Unit(name, quantityType, symbol, baseUnitSymbol, a, b, c, d, description)

new Unit(name?, quantityType?, symbol?, baseUnitSymbol?, a?, b?, c?, d?, description?)

Parameters

Name Type Description
Optional namestring | Unitrepresent the name of the unit (example : 'pint') or properties object
Optional quantityTypestring | string[]represent the quantity type of the unit like length, time, pressure etc. (example: 'volume')
Optional symbolstringsymbol to represent the unit (example: 'pt' to represent pint)
Optional baseUnitSymbolstringrepresents the unit symbol of it's base unit (example for volume, 'm3' can be the base unit)
Optional anumberfactor
Optional bnumberfactor
Optional cnumberfactor
Optional dnumberfactor
Optional descriptionstringIt represents the description of unit

Overrides

AbstractUnit.constructor

Methods

belongsTo

belongsTo(type): boolean

Returns whether current unit belongs to the specified type(s)

Parameters

Name Type Description
typestring | string[]quantityType(s) to be tested

Returns

boolean

Overrides

AbstractUnit.belongsTo


canConvertTo

canConvertTo(other): boolean

Returns whether the unit conversation is possible from this unit to other unit

Parameters

Name Type Description
otherstring | AbstractUnitunit to be converted

Returns

boolean

Overrides

AbstractUnit.canConvertTo


clone

clone(): Unit

Returns a clone of the unit.

Returns

Unit

clone


convert

convert(value, other): number

Convert value to other unit if conversation is possible and giver converted value(s) in other unit

Parameters

Name Type Description
valuenumberspecific value(s) to be converted to other unit
otherstring | AbstractUnitrepresents the other unit to which the values will be converted

Returns

number

Overrides

AbstractUnit.convert

convert(value, other): number[]

Parameters

Name Type
valuenumber[]
otherstring | AbstractUnit

Returns

number[]

Overrides

AbstractUnit.convert


fromBaseUnit

fromBaseUnit(value): number

Converts value from base unit and gives value in current unit

Parameters

Name Type Description
valuenumbervalue to be converted

Returns

number

Overrides

AbstractUnit.fromBaseUnit


getBaseUnitSymbol

getBaseUnitSymbol(): string

Returns baseUnitSymbol of this unit

Returns

string

Overrides

AbstractUnit.getBaseUnitSymbol


getClassName

getClassName(): string

Returns

string

Inherited from

AbstractUnit.getClassName


getDescription

getDescription(): string

Returns the description of the unit

Returns

string

unit name

Overrides

AbstractUnit.getDescription


getName

getName(): string

Returns the name of the unit

Returns

string

Overrides

AbstractUnit.getName


getProperties

getProperties(): Options

Gets all the properties pertaining to this object

Returns

Options

An object containing the properties to set

Overrides

AbstractUnit.getProperties


getQuantityType

getQuantityType(): string[]

Returns the quantityTypes of this unit

Returns

string[]

Overrides

AbstractUnit.getQuantityType


getSymbol

getSymbol(): string

Returns the symbol of this unit

Returns

string

Overrides

AbstractUnit.getSymbol


sameAs

sameAs(other): boolean

Returns whether this unit is similar to other unit

Parameters

Name Type Description
otherstring | AbstractUnitother

Returns

boolean

Overrides

AbstractUnit.sameAs


setProperties

setProperties(properties?): Unit

Sets all the properties pertaining to this object

Parameters

Name Type Description
Optional propertiesOptionsAn object containing the properties to set

Returns

Unit

this

Overrides

AbstractUnit.setProperties


toBaseUnit

toBaseUnit(value): number

Converts value from current unit to base unit

Parameters

Name Type Description
valuenumbervalue to be converted

Returns

number

Overrides

AbstractUnit.toBaseUnit


toString

toString(): string

Returns unit string representation

Returns

string


getClassName

Static getClassName(): string

Returns

string

Inherited from

AbstractUnit.getClassName