当前位置: 首页>>代码示例>>C++>>正文


C++ CUnit::Convert方法代码示例

本文整理汇总了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;
}
开发者ID:BRAT-DEV,项目名称:main,代码行数:20,代码来源:Unit.cpp

示例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);
  }
}
开发者ID:adakite,项目名称:main,代码行数:87,代码来源:ExternalFilesAvisoGrid.cpp


注:本文中的CUnit::Convert方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。