A singleton class for dealing with units of measure in the TerraLib environment. More...
#include <UnitsOfMeasureManager.h>
Public Types | |
typedef std::map< unsigned int, UnitOfMeasurePtr > ::const_iterator | const_iterator |
typedef std::map< unsigned int, UnitOfMeasurePtr >::iterator | iterator |
Public Member Functions | |
bool | areConvertible (const std::string &unitFromName, const std::string &unitToName) const |
Check if two units of measure are compatible. More... | |
const_iterator | begin () const |
It returns an iterator to the beginning of the conteiner. More... | |
iterator | begin () |
It returns an iterator to the beginning of the conteiner. More... | |
void | clear () |
Removes all units from the catalogue. More... | |
const_iterator | end () const |
It returns an iterator to the end of the conteiner. More... | |
iterator | end () |
It returns an iterator to the end of the conteiner. More... | |
UnitOfMeasurePtr | find (unsigned int id) const |
Returns a unit of measure identified by its identificaton. More... | |
UnitOfMeasurePtr | find (const std::string &name) const |
Returns a unit of measure identified by its name. More... | |
UnitOfMeasurePtr | findBySymbol (const std::string &symbol) const |
Returns a unit of measure identified by its symbol. More... | |
double | getConversion (const std::string &unitFromName, const std::string &unitToName) const |
Calculates a multiplicative factor to convert from a given unit to its base unit and vice-versa. More... | |
void | getNames (UnitOfMeasurePtr &uom, std::vector< std::string > &names) const |
Retrieves the alternative names for a unit of measure. More... | |
void | init () |
It initializes the list of well kown units of measure. More... | |
void | insert (UnitOfMeasurePtr &uom) |
Inserts a new unit of measure to be managed. More... | |
void | insert (UnitOfMeasurePtr &uom, const std::vector< std::string > &alternativeNames) |
Inserts a new unit of measure to be managed and its alternative names. More... | |
void | remove (UnitOfMeasurePtr &uom) |
Removes a unit of measure from the manager. More... | |
std::size_t | size () const |
It returns the number of units in the manager. More... | |
Static Public Member Functions | |
static UnitsOfMeasureManager & | getInstance () |
It returns a reference to the singleton instance. More... | |
Protected Member Functions | |
UnitsOfMeasureManager () | |
It initializes the Singleton. More... | |
~UnitsOfMeasureManager () | |
Destructor. More... | |
Private Attributes | |
std::map< unsigned int, UnitOfMeasurePtr > | m_uoms |
std::map< std::string, unsigned int > | m_uomsIdxByName |
Friends | |
class | te::common::Singleton< UnitsOfMeasureManager > |
A singleton class for dealing with units of measure in the TerraLib environment.
This class manages a unique catalogue of known units of measure within the TerraLib environment.
Definition at line 54 of file UnitsOfMeasureManager.h.
typedef std::map<unsigned int, UnitOfMeasurePtr>::const_iterator te::common::UnitsOfMeasureManager::const_iterator |
Definition at line 60 of file UnitsOfMeasureManager.h.
typedef std::map<unsigned int, UnitOfMeasurePtr>::iterator te::common::UnitsOfMeasureManager::iterator |
Definition at line 61 of file UnitsOfMeasureManager.h.
|
protected |
It initializes the Singleton.
Definition at line 46 of file UnitsOfMeasureManager.cpp.
|
protected |
Destructor.
Definition at line 49 of file UnitsOfMeasureManager.cpp.
bool te::common::UnitsOfMeasureManager::areConvertible | ( | const std::string & | unitFromName, |
const std::string & | unitToName | ||
) | const |
Check if two units of measure are compatible.
Check if a unit can be converted to another.
unitFromName | A unit of measure name. |
unitToName | The name of unit to be converted to. |
Definition at line 177 of file UnitsOfMeasureManager.cpp.
|
inline |
It returns an iterator to the beginning of the conteiner.
Definition at line 218 of file UnitsOfMeasureManager.h.
References m_uoms.
Referenced by te::qt::plugins::cellspace::CreateCellularSpaceDialog::initUnitsOfMeasure().
|
inline |
It returns an iterator to the beginning of the conteiner.
Definition at line 223 of file UnitsOfMeasureManager.h.
References m_uoms.
void te::common::UnitsOfMeasureManager::clear | ( | ) |
Removes all units from the catalogue.
Definition at line 54 of file UnitsOfMeasureManager.cpp.
Referenced by te::common::Module::finalize().
|
inline |
It returns an iterator to the end of the conteiner.
Definition at line 228 of file UnitsOfMeasureManager.h.
References m_uoms.
Referenced by te::qt::plugins::cellspace::CreateCellularSpaceDialog::initUnitsOfMeasure().
|
inline |
It returns an iterator to the end of the conteiner.
Definition at line 233 of file UnitsOfMeasureManager.h.
References m_uoms.
te::common::UnitOfMeasurePtr te::common::UnitsOfMeasureManager::find | ( | unsigned int | id | ) | const |
Returns a unit of measure identified by its identificaton.
id | The unit identification. |
Definition at line 105 of file UnitsOfMeasureManager.cpp.
Referenced by te::gdal::GetBandProperty(), te::srs::SpatialReferenceSystemManager::getUnit(), te::srs::GeographicCoordinateSystem::getWKT(), and te::srs::ProjectedCoordinateSystem::getWKT().
te::common::UnitOfMeasurePtr te::common::UnitsOfMeasureManager::find | ( | const std::string & | name | ) | const |
Returns a unit of measure identified by its name.
id | The unit identification. |
Definition at line 115 of file UnitsOfMeasureManager.cpp.
te::common::UnitOfMeasurePtr te::common::UnitsOfMeasureManager::findBySymbol | ( | const std::string & | symbol | ) | const |
Returns a unit of measure identified by its symbol.
id | The unit symbol. |
Definition at line 132 of file UnitsOfMeasureManager.cpp.
Referenced by te::srs::SpatialReferenceSystemManager::getUnit().
double te::common::UnitsOfMeasureManager::getConversion | ( | const std::string & | unitFromName, |
const std::string & | unitToName | ||
) | const |
Calculates a multiplicative factor to convert from a given unit to its base unit and vice-versa.
unitFromName | A unit of measure name. |
unitToName | The name of unit to be converted to. |
Exception | If the conversion is not possible. |
Definition at line 155 of file UnitsOfMeasureManager.cpp.
References TE_TR.
Referenced by te::qt::plugins::cellspace::CreateCellularSpaceDialog::getResX(), te::qt::plugins::cellspace::CreateCellularSpaceDialog::getResY(), te::qt::plugins::cellspace::CreateCellularSpaceDialog::onColsLineEditEditingFinished(), and te::qt::plugins::cellspace::CreateCellularSpaceDialog::onRowsLineEditEditingFinished().
|
staticinherited |
It returns a reference to the singleton instance.
Referenced by te::common::Module::finalize(), te::gdal::GetBandProperty(), te::qt::plugins::cellspace::CreateCellularSpaceDialog::getResX(), te::qt::plugins::cellspace::CreateCellularSpaceDialog::getResY(), te::srs::SpatialReferenceSystemManager::getUnit(), te::srs::GeographicCoordinateSystem::getWKT(), te::srs::ProjectedCoordinateSystem::getWKT(), te::common::Module::initialize(), te::qt::plugins::cellspace::CreateCellularSpaceDialog::initUnitsOfMeasure(), te::common::Module::Module(), te::qt::plugins::cellspace::CreateCellularSpaceDialog::onColsLineEditEditingFinished(), te::qt::plugins::cellspace::CreateCellularSpaceDialog::onRowsLineEditEditingFinished(), and te::qt::plugins::cellspace::CreateCellularSpaceDialog::onUnitComboBoxChanged().
void te::common::UnitsOfMeasureManager::getNames | ( | UnitOfMeasurePtr & | uom, |
std::vector< std::string > & | names | ||
) | const |
Retrieves the alternative names for a unit of measure.
uom | Pointer to the unit of measure. Shouldn't be null; |
altNames | Reference to a vector of strings to return the alternative names (output). |
Definition at line 144 of file UnitsOfMeasureManager.cpp.
void te::common::UnitsOfMeasureManager::init | ( | ) |
It initializes the list of well kown units of measure.
The list is read from the JSON file TERRALIB_DIR/resources/json/uom.json.
Exception | It throws an exception if it is not possible to initialize the UOM list. |
Definition at line 192 of file UnitsOfMeasureManager.cpp.
References te::common::Angle, te::common::Area, te::common::FindInTerraLibPath(), insert(), te::common::Length, te::common::Scale, te::common::Speed, TE_TR, te::common::Time, and te::common::Volume.
Referenced by te::common::Module::initialize().
void te::common::UnitsOfMeasureManager::insert | ( | UnitOfMeasurePtr & | uom | ) |
Inserts a new unit of measure to be managed.
uom | Pointer to unit of measure to be managed. Shouldn't be null. The manager takes the pointer ownership. |
Exception | If the unit is already managed. |
Definition at line 60 of file UnitsOfMeasureManager.cpp.
void te::common::UnitsOfMeasureManager::insert | ( | UnitOfMeasurePtr & | uom, |
const std::vector< std::string > & | alternativeNames | ||
) |
Inserts a new unit of measure to be managed and its alternative names.
uom | Pointer to unit of measure to be managed. Shouldn't be null. The manager takes the pointer ownership. |
alternativeNames | The list of alternative (or auxiliary) names for identifying an unit of measure. |
Exception | If the unit is already managed. |
Definition at line 74 of file UnitsOfMeasureManager.cpp.
References insert().
void te::common::UnitsOfMeasureManager::remove | ( | UnitOfMeasurePtr & | uom | ) |
Removes a unit of measure from the manager.
uom | Pointer to unit of measure to be managed. Shouldn't be null. The manager will delete the pointer. |
te::common::Exception | If the unit is unknown to the manager. |
Definition at line 85 of file UnitsOfMeasureManager.cpp.
|
inline |
It returns the number of units in the manager.
Definition at line 213 of file UnitsOfMeasureManager.h.
References m_uoms.
|
friend |
Definition at line 56 of file UnitsOfMeasureManager.h.
|
private |
Definition at line 208 of file UnitsOfMeasureManager.h.
|
private |
Definition at line 209 of file UnitsOfMeasureManager.h.