te::common::UnitOfMeasure Class Reference

A class to represent units of measure. More...

#include <UnitOfMeasure.h>

Public Member Functions

const unsigned int getBaseUnitId () const
 Returns the base unit id from which this unit derives of. More...
 
void getConversionFactors (double &A, double &B, double &C, double &D) const
 Returns the conversion factors to convert the unit to its base unit. More...
 
double getConversionValue () const
 Returns a multiplicative value to convert the unit to its base unit. More...
 
const std::string & getDescription () const
 Returns the unit of measure description. More...
 
unsigned int getId () const
 Returns the unit of measure identification. More...
 
const std::string & getName () const
 Returns the unit of measure oficial name. More...
 
const std::string & getSymbol () const
 Returns the unit of measure symbol. More...
 
MeasureType getType () const
 Returns the unit of measure type. More...
 
std::string getWKT () const
 Returns the WKT description of a unit of measure. More...
 
bool isBaseUnit () const
 Returns true if this is a base unit; otherwise returns false. More...
 
void setDescription (const std::string &description)
 Sets the unit of measure description. More...
 
 UnitOfMeasure (unsigned int id, const std::string &name, const std::string &symbol, MeasureType type, const std::string &description="")
 Creates a new base unit of measure. More...
 
 UnitOfMeasure (unsigned int id, const std::string &name, const std::string &symbol, MeasureType type, unsigned int baseUnitId, double A, double B=0.0, double C=0.0, double D=1.0, const std::string &description="")
 Creates a new derived unit of measure. More...
 
 ~UnitOfMeasure ()
 Destructor. More...
 

Private Attributes

double m_a
 
double m_b
 
unsigned int m_baseUnitId
 Unique identification number of the base unit to which a conversion operation is provided. More...
 
double m_c
 
double m_d
 
std::string m_description
 unit of measure description. More...
 
unsigned int m_id
 Unique identification number for a unit of measure. More...
 
std::string m_name
 unit of measure name according to SI. More...
 
std::string m_symbol
 Unit symbol. More...
 
MeasureType m_type
 Unit type of measure. More...
 

Detailed Description

A class to represent units of measure.

The use of a unit of measure is meant to encompass the means by which a measured value is tied explicitly to its unit of measure.

Units of measure can be Base or Derived. Base units are well-defined units which by convention are regarded as dimensionally independent. There is only one Base Unit per type of measure.

Derived units are those formed by combining base units according to the algebraic relations linking the corresponding quantities.

Units have an unique numerical identification, an oficial name, a symbol, the type of measures that they refer to and an optional description. Derived Units also have the identification of its Base Unit and 4 factors to relate them, using the following formula:

Y = (AX + B) / (CX + D)

where Y is the measure in the derived unit and X is measure in base unit.

See also
UnitsOfMeasureManager

Definition at line 74 of file UnitOfMeasure.h.

Constructor & Destructor Documentation

te::common::UnitOfMeasure::UnitOfMeasure ( unsigned int  id,
const std::string &  name,
const std::string &  symbol,
MeasureType  type,
const std::string &  description = "" 
)

Creates a new base unit of measure.

Parameters
idUnique identification number.
nameUnit official name.
symbolUnit symbol.
typeUnit type of measure.
descriptionUnit description (by default empty).
te::common::UnitOfMeasure::UnitOfMeasure ( unsigned int  id,
const std::string &  name,
const std::string &  symbol,
MeasureType  type,
unsigned int  baseUnitId,
double  A,
double  B = 0.0,
double  C = 0.0,
double  D = 1.0,
const std::string &  description = "" 
)

Creates a new derived unit of measure.

Parameters
idUnit unique identification number for a unit of measure.
nameUnit official name.
symbolUnit symbol.
typeUnit type of measure
baseUnitIdIdentification of the base unit from which this is derived of.
AA factor in the conversion formula.
BB factor in the conversion formula.
CC factor in the conversion formula.
DD factor in the conversion formula.
descriptionUnit description (by default empty).
Note
(C + D) can not be zero.
te::common::UnitOfMeasure::~UnitOfMeasure ( )

Destructor.

Member Function Documentation

const unsigned int te::common::UnitOfMeasure::getBaseUnitId ( ) const

Returns the base unit id from which this unit derives of.

Returns
The base unit id from which this unit derives of.
void te::common::UnitOfMeasure::getConversionFactors ( double &  A,
double &  B,
double &  C,
double &  D 
) const

Returns the conversion factors to convert the unit to its base unit.

Parameters
ATo return the A factor in the conversion formula (output).
BTo return the B factor in the conversion formula (output).
CTo return the C factor in the conversion formula (output).
DTo return the D factor in the conversion formula (output).
Note
If this is a base unit, the return values are A=1, B=0, C=0 and D=1.
double te::common::UnitOfMeasure::getConversionValue ( ) const

Returns a multiplicative value to convert the unit to its base unit.

The retuned value is calculated as (A + B)/(C + D) rounded to a double.

Returns
A multiplicative value to convert the unit to its base unit.
Note
If this is a base unit, the returned value is 1.0.
const std::string& te::common::UnitOfMeasure::getDescription ( ) const

Returns the unit of measure description.

Returns
The unit of measure description.
unsigned int te::common::UnitOfMeasure::getId ( ) const

Returns the unit of measure identification.

Returns
The unit of measure identification.
const std::string& te::common::UnitOfMeasure::getName ( ) const

Returns the unit of measure oficial name.

Returns
The unit of measure oficial name.
const std::string& te::common::UnitOfMeasure::getSymbol ( ) const

Returns the unit of measure symbol.

Returns
The unit of measure symbol (e.g. kg, m or km).
MeasureType te::common::UnitOfMeasure::getType ( ) const

Returns the unit of measure type.

Returns
The unit of measure type.
std::string te::common::UnitOfMeasure::getWKT ( ) const

Returns the WKT description of a unit of measure.

Returns
The WKT description of a unit of measure.
bool te::common::UnitOfMeasure::isBaseUnit ( ) const

Returns true if this is a base unit; otherwise returns false.

void te::common::UnitOfMeasure::setDescription ( const std::string &  description)

Sets the unit of measure description.

Parameters
descriptionThe unit of measure description.

Member Data Documentation

double te::common::UnitOfMeasure::m_a
private

Definition at line 206 of file UnitOfMeasure.h.

double te::common::UnitOfMeasure::m_b
private

Definition at line 207 of file UnitOfMeasure.h.

unsigned int te::common::UnitOfMeasure::m_baseUnitId
private

Unique identification number of the base unit to which a conversion operation is provided.

Definition at line 204 of file UnitOfMeasure.h.

double te::common::UnitOfMeasure::m_c
private

Definition at line 208 of file UnitOfMeasure.h.

double te::common::UnitOfMeasure::m_d
private

Definition at line 209 of file UnitOfMeasure.h.

std::string te::common::UnitOfMeasure::m_description
private

unit of measure description.

Definition at line 202 of file UnitOfMeasure.h.

unsigned int te::common::UnitOfMeasure::m_id
private

Unique identification number for a unit of measure.

Definition at line 198 of file UnitOfMeasure.h.

std::string te::common::UnitOfMeasure::m_name
private

unit of measure name according to SI.

Definition at line 199 of file UnitOfMeasure.h.

std::string te::common::UnitOfMeasure::m_symbol
private

Unit symbol.

Definition at line 200 of file UnitOfMeasure.h.

MeasureType te::common::UnitOfMeasure::m_type
private

Unit type of measure.

Definition at line 201 of file UnitOfMeasure.h.


The documentation for this class was generated from the following file: