本文整理汇总了C++中CUnit::Convert方法的典型用法代码示例。如果您正苦于以下问题:C++ CUnit::Convert方法的具体用法?C++ CUnit::Convert怎么用?C++ CUnit::Convert使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CUnit
的用法示例。
在下文中一共展示了CUnit::Convert方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ConvertToBaseUnit
//----------------------------------------
double CUnit::ConvertToBaseUnit(const double fromValue, double defaultValue /* = CTools::m_defaultValueDOUBLE */)
{
double out = defaultValue;
if (isDefaultValue(fromValue))
{
if (!isDefaultValue(defaultValue))
{
out = ConvertToBaseUnit(defaultValue);
}
return out;
}
CUnit unit = *this;
unit.SetConversionToBaseUnit();
out = unit.Convert(fromValue);
return out;
}
示例2: CFileException
// If WantedUnit is "", the returned value is in base (SI) unit.
void CExternalFilesAvisoGrid::GetValue
(const string &name,
double &value,
const string &wantedUnit)
{
uint32_t start[3];
uint32_t count[3] = {1, 1, 1};
MustBeOpened();
if (m_latIndex == AT_BEGINNING)
{
throw CFileException(CTools::Format("PROGRAM ERROR: Try to access file ('%s' field) while file is already rewinded (NextRecord must be called)",
name.c_str()),
GetName(),
BRATHL_LOGIC_ERROR);
}
if (CurrentMeasure() >= m_nbMeasures)
{
throw CFileException(CTools::Format("PROGRAM ERROR: Try to access file ('%s' field) while all measurements have been read",
name.c_str()),
GetName(),
BRATHL_LOGIC_ERROR);
}
start[0] = m_lonIndex;
start[1] = m_latIndex;
start[2] = m_depthIndex;
// Find field def.
CFieldNetCdf* var = GetFieldNetCdf(name);
int32_t netCdfId = var->GetNetCdfId();
if (netCdfId < 0)
{
int32_t index;
switch (netCdfId)
{
//---------------------------
case INTERNAL_LAT_ID:
//---------------------------
index = m_latIndex;
break;
//---------------------------
case INTERNAL_LON_ID:
//---------------------------
index = m_lonIndex;
break;
//---------------------------
case INTERNAL_DEPTH_ID:
//---------------------------
index = m_depthIndex;
break;
//---------------------------
default:
//---------------------------
throw CException(CTools::Format("PROGRAM ERROR: Unknown pseudo netcdf id %d",
netCdfId),
BRATHL_LOGIC_ERROR);
}
value = var->GetValues()[index];
CUnit unit = var->GetUnit();
if ((wantedUnit != "") && (wantedUnit != CUnit::m_UNIT_SI))
{
unit.SetConversionTo(wantedUnit);
}
value = unit.Convert(value);
}
else
{
int nbDims = m_file.GetVarNbDims(netCdfId);
if (nbDims != 2)
{
nbDims = 3;
}
m_file.ReadVar(name, nbDims, start, count, &value, wantedUnit);
}
}