Gyoto
|
GYOTO converters. More...
#include <GyotoUtils.h>
#include <GyotoSmartPointer.h>
#include <udunits2.h>
#include <string>
#include <sstream>
Go to the source code of this file.
Classes | |
class | Gyoto::Units::Unit |
Wrapper around ut_unit from udunits. More... | |
class | Gyoto::Units::Converter |
Wrapper around ut_converter from udunits. More... | |
Namespaces | |
Gyoto | |
Namespace for the Gyoto library. | |
Gyoto::Metric | |
Access to metrics. | |
Gyoto::Units | |
Units-related classes and functions. | |
Functions | |
ut_system * | Gyoto::Units::getSystem () |
Retrieve the unit system used in all of Gyoto. | |
void | Gyoto::Units::Init () |
Load and initialize all (non-context-sensitive) units. More... | |
double | Gyoto::Units::ToMeters (double value, const std::string &unit, const Gyoto::SmartPointer< Gyoto::Metric::Generic > &gg=NULL) |
Convert from arbitrary length unit to meters. More... | |
double | Gyoto::Units::FromMeters (double value, const std::string &unit, const Gyoto::SmartPointer< Gyoto::Metric::Generic > &gg=NULL) |
Convert to arbitrary length unit from meters. More... | |
double | Gyoto::Units::ToSeconds (double value, const std::string &unit, const Gyoto::SmartPointer< Gyoto::Metric::Generic > &gg=NULL) |
Convert from arbitrary time unit to seconds. More... | |
double | Gyoto::Units::FromSeconds (double value, const std::string &unit, const Gyoto::SmartPointer< Gyoto::Metric::Generic > &gg=NULL) |
Convert to arbitrary time unit from seconds. More... | |
double | Gyoto::Units::ToKilograms (double value, const std::string &unit) |
Convert from arbitrary mass unit to kilograms. More... | |
double | Gyoto::Units::FromKilograms (double value, const std::string &unit) |
Convert to arbitrary mass unit from kilograms. More... | |
double | Gyoto::Units::ToGeometrical (double value, const std::string &unit, const Gyoto::SmartPointer< Gyoto::Metric::Generic > &gg) |
Convert from arbitrary length unit to geometrical units. More... | |
double | Gyoto::Units::FromGeometrical (double value, const std::string &unit, const Gyoto::SmartPointer< Gyoto::Metric::Generic > &gg) |
Convert to arbitrary length unit from geometrical units. More... | |
double | Gyoto::Units::ToGeometricalTime (double value, const std::string &unit, const Gyoto::SmartPointer< Gyoto::Metric::Generic > &gg) |
Convert from arbitrary time unit to geometrical units. More... | |
double | Gyoto::Units::FromGeometricalTime (double value, const std::string &unit, const Gyoto::SmartPointer< Gyoto::Metric::Generic > &gg) |
Convert to arbitrary time unit from geometrical units. More... | |
double | Gyoto::Units::ToHerz (double value, const std::string &unit) |
Convert from arbitrary frequency unit to Herz. More... | |
double | Gyoto::Units::FromHerz (double value, const std::string &unit) |
Convert to arbitrary frequency unit from Herz. More... | |
bool | Gyoto::Units::areConvertible (const Unit &unit1, const Unit &unit2) |
Is it possible to convert between unit1 and unit2? More... | |
GYOTO converters.
As a (recommended) option, Gyoto can use the libudunits2 library by UCAR/Unidata (http://www.unidata.ucar.edu/software/udunits/udunits-2/udunits2.html) to perform conversions to and from various units. Since udunits parses units, the following are equivalent for instance: "mJy.sr-1", "mJy/sr", "1e-3Jy/sr". Gyoto considers every string as UTF-8: either use UTF-8 or stay with ASCII. This means "µ" can be used for "micro" and powers can be noted as superscripts: m³, pix².
In addition to the stock units known by udunits2, Gyoto registers the following (which may be used in any context): Jansky (symbol Jy), symbol "pc" for parsec, "sunradius", "sunmass", symbol "as" for "arcsec".
Other units are context-sensitive: "geometrical" allows converting between geometrical units and other legnth units, but only when a Metric is defined, and may not be used (yet) in compound units. Likewise, "geometrical_time" can be used as duration unit whenever a Metric is defined, but not in a compound unit.
When a Screen is defined, "pix" can be used as an angle unit (you need to call Screen::mapPixUnit() and Screen::unmapScreenUnit(), which is done automatically in certain contexts).
Units can often be specified using the "unit" XML attribute:
Units for output quantities are specified after the name of the quantity, in squared brackets, e.g.:
or