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


C++ Parameters函数代码示例

本文整理汇总了C++中Parameters函数的典型用法代码示例。如果您正苦于以下问题:C++ Parameters函数的具体用法?C++ Parameters怎么用?C++ Parameters使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了Parameters函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: Parameters

//---------------------------------------------------------
bool CLines_From_Points::On_Execute(void)
{
	int			Order, Separate, Elevation;
	CSG_String	s;
	CSG_Shape	*pLine , *pPoint;
	CSG_Shapes	*pLines, *pPoints;

	pPoints		= Parameters("POINTS"   )->asShapes();
	pLines		= Parameters("LINES"    )->asShapes();
	Order		= Parameters("ORDER"    )->asInt();
	Separate	= Parameters("SEPARATE" )->asInt();
	Elevation	= Parameters("ELEVATION")->asInt();

	//-------------------------------------------------
	if(	pPoints->Get_Count() < 1 )
	{
		return( false );
	}

	//-------------------------------------------------
	pLines->Create(SHAPE_TYPE_Line, pPoints->Get_Name(), NULL, Elevation >= 0 ? SG_VERTEX_TYPE_XYZ : SG_VERTEX_TYPE_XY);

	pLines->Add_Field(SG_T("ID"), SG_DATATYPE_Int);

	if( Separate >= 0 )
	{
		pLines->Add_Field(pPoints->Get_Field_Name(Separate), pPoints->Get_Field_Type(Separate));

		pPoints->Set_Index(Separate, TABLE_INDEX_Ascending, Order, TABLE_INDEX_Ascending);
	}
	else
	{
		pPoints->Set_Index(Order, TABLE_INDEX_Ascending);
	}

	//-------------------------------------------------
	for(int iPoint=0; iPoint<pPoints->Get_Count(); iPoint++)
	{
		pPoint	= pPoints->Get_Shape_byIndex(iPoint);

		if( pLines->Get_Count() == 0 || (Separate >= 0 && s.Cmp(pPoint->asString(Separate))) )
		{
			pLine	= pLines->Add_Shape();

			pLine->Set_Value(0, pLines->Get_Count());

			if( Separate >= 0 )
			{
				pLine->Set_Value(1, s = pPoint->asString(Separate));
			}
		}

		pLine->Add_Point(pPoint->Get_Point(0));

		if( Elevation >= 0 )
		{
			pLine->Set_Z(pPoint->asDouble(Elevation), iPoint);
		}
	}

	return( true );
}
开发者ID:johanvdw,项目名称:saga-debian,代码行数:63,代码来源:Lines_From_Points.cpp

示例2: WinMain

WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR lpCmdLine, int)
{
  try
  {
    GetWindowsVersion();
  }
  catch(Exception * E)
  {
    MessageBox(NULL,E->Message.c_str(),"错误",MB_OK | MB_ICONSTOP);
    return 99;
  }
  DateSeparator   = '-';
  ShortDateFormat = "yyyy-m-d";
  try
  {
    ProcessExitCode = 0;
    frmExportToDB = NULL;
    SlentMode = false;
    LogFile = NULL;
    Application->Initialize();
    Application->Title = "PowerBill通用话单查询转换系统";
     InCmdMode = strlen(lpCmdLine) > 0;
    FTPTimeout = -1;
    //分析参数
    if(InCmdMode)
    {
      AnsiString Parameters(lpCmdLine);
      AnsiString ListFileName  = "";
      AnsiString LogFileName   = "";
      AnsiString TableName = "";
      AnsiString DBName    = "";
      AnsiString BillName  = "";
      AnsiString TempPath  = "";
      bool TransFieldValue = false;
      int MaxError = 0;
      int pos1 = 1;
      int pos2 = Parameters.Pos("=");
      AnsiString ParamName,ParamValue;
      AnsiString Message;
      bool VerifyFile = true;
      int JobMode = 1;
      AnsiString DirList;
      AnsiString FTPServer;
      while(pos2 > 0)
      {
        ParamName  = LowerCase(Parameters.SubString(pos1,pos2 - 1).Trim());
        Parameters = Parameters.SubString(pos2 + 1,Parameters.Length() - pos2);
        if(Parameters.SubString(1,1) == "\"")
        {
          Parameters = Parameters.SubString(2,Parameters.Length() - 1);
          pos2 = Parameters.Pos("\"");
          if(pos2 < 1)
            break;
          ParamValue = Parameters.SubString(1,pos2 - 1);
          Parameters = Parameters.SubString(pos2 + 1,Parameters.Length() - pos2);
          pos2 = GetNextCharPos(Parameters.c_str());
          Parameters = Parameters.SubString(pos2,Parameters.Length() - pos2 + 1);
        }
        else
        {
          pos2 = Parameters.Pos(" ");
          if(pos2 < 1)
          {
            ParamValue = Parameters.SubString(1,Parameters.Length());
          }
          else
          {
            ParamValue = Parameters.SubString(1,pos2 - 1);
            Parameters = Parameters.SubString(pos2 + 1,Parameters.Length() - ParamValue.Length());
            pos2 = GetNextCharPos(Parameters.c_str());
            Parameters = Parameters.SubString(pos2 + 1,Parameters.Length() - pos2);
          }
        }

        if(ParamName == "files")
          ListFileName = ParamValue;
        else if(ParamName == "db")
          DBName = ParamValue;
        else if(ParamName == "table")
          TableName = ParamValue;
        else if(ParamName == "silent")
          SlentMode = ParamValue == "1" || ParamValue.LowerCase() == "true" || ParamValue.LowerCase() == "yes";
        else if(ParamName == "log")
          LogFileName = ParamValue;
        else if(ParamName == "maxdberrors")
        {
          if(IsNumber(ParamValue.c_str()))
            MaxError = StrToInt(ParamValue);
          else
            Message += "最大错误数无效[" + ParamValue + "];";
        }
        else if(ParamName == "tempdir")
        {
          TempPath = ParamValue;
        }
        else if(ParamName == "billname")
          BillName = ParamValue;
        else if(ParamName == "trans")
          TransFieldValue = ParamValue == "1" || ParamValue.LowerCase() == "true" || ParamValue.LowerCase() == "yes";
        //else if(ParamName == "verifyfile")
//.........这里部分代码省略.........
开发者ID:josecohenca,项目名称:xmlconvertsql,代码行数:101,代码来源:ibill.cpp

示例3: ConsumeToken


//.........这里部分代码省略.........
    else if(currenttoken->type == Escriba)
    {
        ConsumeToken();
        vector<ExpressionNode*> exprList=ExpressionListNotNull();
        return new EscribaNode(exprList);
    }
    else if(currenttoken->type == Mientras)
    {
        ConsumeToken();
        ExpressionNode * condition=Expresion();
        if(currenttoken->type != Haga)
            throw invalid_argument("Se esperaba palabra reservada haga.  Row:"+to_string(currenttoken->row)+"Column:"+to_string(currenttoken->column));
        ConsumeToken();
        vector<StatementNode*>code=InstructionList();
        if(currenttoken->type != Fin)
            throw invalid_argument("Se esperaba palabra reservada fin.  Row:"+to_string(currenttoken->row)+"Column:"+to_string(currenttoken->column));
        ConsumeToken();
        if(currenttoken->type != Mientras)
            throw invalid_argument("Se esperaba palabra reservada mientras.  Row:"+to_string(currenttoken->row)+"Column:"+to_string(currenttoken->column));
        ConsumeToken();
        return new MientrasNode(condition,code);
    }
    else if(currenttoken->type == Repita)
    {
        ConsumeToken();
        vector<StatementNode*> code=InstructionList();
        if(currenttoken->type != Hasta)
            throw invalid_argument("Se esperaba palabra reservada hasta.  Row:"+to_string(currenttoken->row)+"Column:"+to_string(currenttoken->column));
        ConsumeToken();
        ExpressionNode*condition=Expresion();
        return new RepitaNode(code,condition);
    }
    else if(currenttoken->type == Caso)
    {
        ConsumeToken();
        VariableNode * id=Variable();
        vector<CasoLineNode*> cases=CasoList();
        vector<StatementNode*> defaultcase=CasoSino();
        if(currenttoken->type != Fin)
            throw invalid_argument("Se esperaba palabra reservada fin.  Row:"+to_string(currenttoken->row)+"Column:"+to_string(currenttoken->column));
        ConsumeToken();
        if(currenttoken->type != Caso)
            throw invalid_argument("Se esperaba palabra reservada caso.  Row:"+to_string(currenttoken->row)+"Column:"+to_string(currenttoken->column));
        ConsumeToken();
        return new CasoNode(id,cases,defaultcase);
    }
    else if(currenttoken->type == Abrir)
    {
        ConsumeToken();
        string archiveId=Archive();
        if(currenttoken->type != Como)
            throw invalid_argument("Se esperaba palabra reservada como.  Row:"+to_string(currenttoken->row)+"Column:"+to_string(currenttoken->column));
        ConsumeToken();
        VariableNode* archiveType=Variable();
        vector<ModeNode*> modes=ModeList();
        return new AbrirArchivoNode(archiveId,archiveType,modes);
    }
    else if(currenttoken->type == Cerrar)
    {
        ConsumeToken();
        VariableNode* id= Variable();
        return new CerrarArchivoNode(id);
    }
    else if(currenttoken->type == Leer)
    {
        ConsumeToken();
        VariableNode* archive=Variable();
        if(currenttoken->type != Coma)
            throw invalid_argument("Se esperaba ,.  Row:"+to_string(currenttoken->row)+"Column:"+to_string(currenttoken->column));
        ConsumeToken();
        VariableNode* data=Variable();
        return new LeerArchivoNode(archive,data);
    }
    else if(currenttoken->type == Escribir)
    {
        ConsumeToken();
        VariableNode* archive=Variable();
        if(currenttoken->type != Coma)
            throw invalid_argument("Se esperaba ,.  Row:"+to_string(currenttoken->row)+"Column:"+to_string(currenttoken->column));
        ConsumeToken();
        VariableNode* data=Variable();
        return new EscribirArchivoNode(archive,data);
    }
    else if(currenttoken->type == Llamar)
    {
        ConsumeToken();
        if(currenttoken->type != Id)
            throw invalid_argument("Se esperaba un id.  Row:"+to_string(currenttoken->row)+"Column:"+to_string(currenttoken->column));
        string id=currenttoken->lexeme;
        ConsumeToken();
        vector<ExpressionNode*> parameters=Parameters();
        return new LlamarNode(id,parameters);
    }
    else if(currenttoken->type == Retorne)
    {
        ConsumeToken();
        ExpressionNode* id=Expresion();
        return new RetorneNode(id);
    }
}
开发者ID:armejiaf,项目名称:CompiProject,代码行数:101,代码来源:parser.cpp

示例4: Parameters

bool CSimulateVariableWind::AssignParameters(){

	int x,y;

	m_pDEM = Parameters("DEM")->asGrid();
	m_pFuelGrid = Parameters("FUEL")->asGrid();

	m_iWindDirGrids	= Parameters("WINDDIR")->asInt();
	m_pWindDirGrids	=(CSG_Grid **)Parameters("WINDDIR")->asPointer();
	m_iWindSpdGrids	= Parameters("WINDSPD")->asInt();
	m_pWindSpdGrids	=(CSG_Grid **)Parameters("WINDSPD")->asPointer();
	m_pM1Grid = Parameters("M1H")->asGrid();
	m_pM10Grid = Parameters("M10H")->asGrid();
	m_pM100Grid = Parameters("M100H")->asGrid();
	m_pMHerbGrid = Parameters("MHERB")->asGrid();
	m_pMWoodGrid = Parameters("MWOOD")->asGrid();
	m_pTimeGrid = Parameters("TIME")->asGrid();
	m_pFlameGrid = Parameters("FLAME")->asGrid();
	m_pIntensityGrid = Parameters("INTENSITY")->asGrid();

	m_fTimeLimit = Parameters("SIMULATIONTIME")->asInt();

	m_fIgnTime = Parameters("IGNTIME")->asDouble();
	m_fInterval = Parameters("INTERVAL")->asDouble();

	m_fWorldX = Parameters("COORDX")->asDouble();
	m_fWorldY = Parameters("COORDY")->asDouble();
	m_iGridX = (int) ((m_fWorldX - m_pDEM->Get_XMin()) / m_pDEM->Get_Cellsize());
	m_iGridY = (int) ((m_fWorldY - m_pDEM->Get_YMin()) / m_pDEM->Get_Cellsize());

    m_Catalog = Fire_FuelCatalogCreateStandard("Standard", 13);
    Fire_FlameLengthTable(m_Catalog, 500, 0.1);

	if (!m_iWindDirGrids){
		m_pWindDirGrids = new CSG_Grid*[1];
		m_pWindDirGrids[0] = SG_Create_Grid(m_pDEM);
		m_pWindDirGrids[0]->Assign(Parameters("DEFAULTWINDDIR")->asDouble());
		m_bDeleteWindDirGrid = true;
	}//if
	else{
		m_bDeleteWindDirGrid = false;
	}//else
	
	if (!m_iWindSpdGrids){
		m_pWindSpdGrids = new CSG_Grid*[1];
		m_pWindSpdGrids[0] = SG_Create_Grid(m_pDEM);
		m_pWindSpdGrids[0]->Assign(Parameters("DEFAULTWINDSPD")->asDouble());
		m_bDeleteWindSpdGrid = true;
	}//if
	else{
		m_bDeleteWindSpdGrid = false;
	}//else

	//substitute no-data values
	for(y=0; y<Get_NY() && Set_Progress(y); y++){		
		for(x=0; x<Get_NX(); x++){

			/*if (m_pWindSpdGrid->is_NoData(x, y)){
				m_pWindSpdGrid->Set_Value(x, y, 0.);
			}//if
			if (m_pWindDirGrid->is_NoData(x, y)){
				m_pWindDirGrid->Set_Value(x, y, 0.);
			}//if*/
			if (m_pM1Grid->is_NoData(x, y)){
				m_pM1Grid->Set_Value(x, y, 0.);
			}//if
			if (m_pM10Grid->is_NoData(x, y)){
				m_pM10Grid->Set_Value(x, y, 0.);
			}//if
			if (m_pM100Grid->is_NoData(x, y)){
				m_pM100Grid->Set_Value(x, y, 0.);
			}//if
			if (m_pMHerbGrid->is_NoData(x, y)){
				m_pMHerbGrid->Set_Value(x, y, 0.);
			}//if
			if (m_pMWoodGrid->is_NoData(x, y)){
				m_pMWoodGrid->Set_Value(x, y, 0.);
			}//if

		}//for
	}//for

	m_pReactionIntensityGrid	= SG_Create_Grid(m_pDEM, SG_DATATYPE_Double);
	m_pEffectiveWindGrid		= SG_Create_Grid(m_pDEM, SG_DATATYPE_Double);
	m_pHeatPerUnitAreaGrid		= SG_Create_Grid(m_pDEM, SG_DATATYPE_Double);

	//-----------------------------------------------------
	m_pSlopeGrid	= SG_Create_Grid(m_pDEM, SG_DATATYPE_Float);
	m_pAspectGrid	= SG_Create_Grid(m_pDEM, SG_DATATYPE_Float);

	for(y=0; y<Get_NY() && Set_Progress(y); y++)
	{
		for(x=0; x<Get_NX(); x++)
		{
			double	Slope, Aspect;

			if( m_pDEM->Get_Gradient(x, y, Slope, Aspect) )
			{
				m_pSlopeGrid ->Set_Value(x, y, Slope);
				m_pAspectGrid->Set_Value(x, y, Aspect);
//.........这里部分代码省略.........
开发者ID:Fooway,项目名称:SAGA-GIS-git-mirror,代码行数:101,代码来源:SimulateVariableWind.cpp

示例5: Parameters

//---------------------------------------------------------
bool CSelect_Location::On_Execute(void)
{
	int		Method, Condition;

	m_pShapes		= Parameters("SHAPES")		->asShapes();
	m_pLocations	= Parameters("LOCATIONS")	->asShapes();
	Condition		= Parameters("CONDITION")	->asInt();
	Method			= Parameters("METHOD")		->asInt();

	//-----------------------------------------------------
	switch( Condition )
	{
	case 0:	// intersect
		if( ((m_pShapes   ->Get_Type() == SHAPE_TYPE_Point || m_pShapes   ->Get_Type() == SHAPE_TYPE_Points) && m_pLocations->Get_Type() != SHAPE_TYPE_Polygon)
		||	((m_pLocations->Get_Type() == SHAPE_TYPE_Point || m_pLocations->Get_Type() == SHAPE_TYPE_Points) && m_pShapes   ->Get_Type() != SHAPE_TYPE_Polygon) )
		{
			Error_Set(_TL("points can only intersect with polygons"));

			return( false );
		}
		break;

	case 1:	// are completely within
	case 3:	// have their centroid in
		if( m_pLocations->Get_Type() != SHAPE_TYPE_Polygon )
		{
			Error_Set(_TL("this operation requires locations to be of type polygon"));

			return( false );
		}
		break;

	case 2:	// completely contain
	case 4:	// contain the centroid of
		if( m_pShapes->Get_Type() != SHAPE_TYPE_Polygon )
		{
			Error_Set(_TL("this operation requires selectable shapes to be of type polygon"));

			return( false );
		}
		break;
	}

	//-----------------------------------------------------
	for(int i=0; i<m_pShapes->Get_Count() && Set_Progress(i, m_pShapes->Get_Count()); i++)
	{
		CSG_Shape	*pShape	= m_pShapes->Get_Shape(i);

		switch( Method )
		{
		case 0:	// New selection
			if( ( pShape->is_Selected() && !Do_Select(pShape, Condition))
			||	(!pShape->is_Selected() &&  Do_Select(pShape, Condition)) )
			{
				m_pShapes->Select(i, true);
			}
			break;

		case 1:	// Add to current selection
			if(  !pShape->is_Selected() &&  Do_Select(pShape, Condition) )
			{
				m_pShapes->Select(i, true);
			}
			break;

		case 2:	// Select from current selection
			if(   pShape->is_Selected() && !Do_Select(pShape, Condition) )
			{
				m_pShapes->Select(i, true);
			}
			break;

		case 3:	// Remove from current selection
			if(   pShape->is_Selected() &&  Do_Select(pShape, Condition) )
			{
				m_pShapes->Select(i, true);
			}
			break;
		}
	}

	//-----------------------------------------------------
	Message_Add(CSG_String::Format(SG_T("%s: %d"), _TL("selected shapes"), m_pShapes->Get_Selection_Count()));

	DataObject_Update(m_pShapes);

	return( true );
}
开发者ID:Fooway,项目名称:SAGA-GIS-git-mirror,代码行数:89,代码来源:SelectByTheme.cpp

示例6: return

//---------------------------------------------------------
bool CGW_Multi_Regression_Grid::Initialize(CSG_Shapes *pPoints, int iDependent, CSG_Parameter_Grid_List *pPredictors)
{
	//-----------------------------------------------------
	if( (m_nPredictors = pPredictors->Get_Count()) <= 0 )
	{
		return( false );
	}

	if( !pPoints->Get_Extent().Intersects(Get_System()->Get_Extent()) )
	{
		return( false );
	}

	//-----------------------------------------------------
	int	iPredictor, Interpolation	= GRID_INTERPOLATION_BSpline;

	m_Points.Create   (SHAPE_TYPE_Point);
	m_Points.Set_Name (Parameters("DEPENDENT")->asString());
	m_Points.Add_Field(Parameters("DEPENDENT")->asString(), SG_DATATYPE_Double);

	for(iPredictor=0; iPredictor<pPredictors->Get_Count(); iPredictor++)
	{
		m_Points.Add_Field(pPredictors->asGrid(iPredictor)->Get_Name(), SG_DATATYPE_Double);
	}

	//-----------------------------------------------------
	for(int iPoint=0; iPoint<pPoints->Get_Count() && Set_Progress(iPoint, pPoints->Get_Count()); iPoint++)
	{
		CSG_Shape	*pPoint	= pPoints->Get_Shape(iPoint);

		if( !pPoint->is_NoData(iDependent) )
		{
			CSG_Vector	z(1 + m_nPredictors);	z[0]	= pPoint->asDouble(iDependent);
			TSG_Point	Point	= pPoint->Get_Point(0);
			bool		bAdd	= true;

			for(iPredictor=0; bAdd && iPredictor<m_nPredictors; iPredictor++)
			{
				if( !pPredictors->asGrid(iPredictor)->Get_Value(Point, z[iPredictor + 1], Interpolation) )
				{
					bAdd	= false;
				}
			}

			if( bAdd )
			{
				(pPoint	= m_Points.Add_Shape())->Add_Point(Point);

				for(iPredictor=0; iPredictor<=m_nPredictors; iPredictor++)
				{
					pPoint->Set_Value(iPredictor, z[iPredictor]);
				}
			}
		}
	}

	//-----------------------------------------------------
	m_nPoints_Min	= Parameters("SEARCH_POINTS_MIN")->asInt   ();
	m_nPoints_Max	= Parameters("SEARCH_POINTS_ALL")->asInt   () == 0
					? Parameters("SEARCH_POINTS_MAX")->asInt   () : 0;
	m_Radius		= Parameters("SEARCH_RANGE"     )->asInt   () == 0
					? Parameters("SEARCH_RADIUS"    )->asDouble() : 0.0;
	m_Direction		= Parameters("SEARCH_DIRECTION" )->asInt   () == 0 ? -1 : 4;

	m_Weighting.Set_Parameters(&Parameters);

	return( m_Points.Get_Count() > m_nPredictors
		&& ((m_nPoints_Max <= 0 && m_Radius <= 0.0) || m_Search.Create(&m_Points, -1))
	);
}
开发者ID:johanvdw,项目名称:saga-debian,代码行数:71,代码来源:gw_multi_regression_grid.cpp

示例7: Parameters

//---------------------------------------------------------
bool CTasseled_Cap::On_Execute(void)
{
	CSG_Grid	*pBand[6], *pBright, *pGreen, *pWet;

	pBand[0]	= Parameters("BLUE"      )->asGrid();
	pBand[1]	= Parameters("GREEN"     )->asGrid();
	pBand[2]	= Parameters("RED"       )->asGrid();
	pBand[3]	= Parameters("NIR"       )->asGrid();
	pBand[4]	= Parameters("MIR1"      )->asGrid();
	pBand[5]	= Parameters("MIR2"      )->asGrid();

	pBright		= Parameters("BRIGHTNESS")->asGrid();
	pGreen		= Parameters("GREENNESS" )->asGrid();
	pWet		= Parameters("WETNESS"   )->asGrid();

	DataObject_Set_Colors(pBright, 100, SG_COLORS_BLACK_WHITE  , false);
	DataObject_Set_Colors(pGreen , 100, SG_COLORS_WHITE_GREEN  , false);
	DataObject_Set_Colors(pWet   , 100, SG_COLORS_RED_GREY_BLUE, false);

	for(int y=0; y<Get_NY() && Set_Progress(y); y++)
	{
		for(int x=0; x<Get_NX(); x++)
		{
			if(	pBand[0]->is_NoData(x, y)
			||	pBand[1]->is_NoData(x, y)
			||	pBand[2]->is_NoData(x, y)
			||	pBand[3]->is_NoData(x, y)
			||	pBand[4]->is_NoData(x, y)
			||	pBand[5]->is_NoData(x, y)
			)
			{
				pBright	->Set_NoData(x, y);
				pGreen	->Set_NoData(x, y);
				pWet	->Set_NoData(x, y);
			}
			else
			{
				double	b[6];

				b[0]	= pBand[0]->asDouble(x, y);
				b[1]	= pBand[1]->asDouble(x, y);
				b[2]	= pBand[2]->asDouble(x, y);
				b[3]	= pBand[3]->asDouble(x, y);
				b[4]	= pBand[4]->asDouble(x, y);
				b[5]	= pBand[5]->asDouble(x, y);

			    pBright	->Set_Value(x, y,
					 0.3037 * b[0] + 0.2793 * b[1] + 0.4743 * b[2] + 0.5585 * b[3] + 0.5082 * b[4] + 0.1863 * b[5]
				);

				pGreen	->Set_Value(x, y,
					-0.2848 * b[0] - 0.2435 * b[1] - 0.5436 * b[2] + 0.7243 * b[3] + 0.0840 * b[4] - 0.1800 * b[5]
				);

				pWet	->Set_Value(x, y,
					 0.1509 * b[0] + 0.1973 * b[1] + 0.3279 * b[2] + 0.3406 * b[3] - 0.7112 * b[4] - 0.4572 * b[5]
				);
			}
		}
	}

	return( true );
}
开发者ID:johanvdw,项目名称:saga-debian,代码行数:64,代码来源:tasseled_cap.cpp

示例8: Parameters

//---------------------------------------------------------
bool CGWR_Grid_Downscaling::On_Execute(void)
{
	//-----------------------------------------------------
	CSG_Parameter_Grid_List	*pPredictors	= Parameters("PREDICTORS")->asGridList();

	if( (m_nPredictors = pPredictors->Get_Count()) <= 0 )
	{
		return( false );
	}

	m_pDependent	= Parameters("DEPENDENT")->asGrid();

	if( !m_pDependent->Get_Extent().Intersects(Get_System()->Get_Extent()) )
	{
		return( false );
	}

	//-----------------------------------------------------
	int		i;

	Process_Set_Text(_TL("upscaling of predictors"));

	m_pPredictors	= (CSG_Grid **)SG_Calloc(m_nPredictors    , sizeof(CSG_Grid *));
	m_pModel		= (CSG_Grid **)SG_Calloc(m_nPredictors + 1, sizeof(CSG_Grid *));

	for(i=0; i<m_nPredictors; i++)
	{
		m_pPredictors[i]	= SG_Create_Grid(m_pDependent->Get_System());
		m_pPredictors[i]	->Assign(pPredictors->asGrid(i), GRID_INTERPOLATION_NearestNeighbour);	// GRID_INTERPOLATION_Mean_Cells

		m_pModel     [i]	= SG_Create_Grid(m_pDependent->Get_System());
		m_pModel     [i]	->Set_Name(CSG_String::Format(SG_T("%s [%s]"), pPredictors->asGrid(i)->Get_Name(), _TL("Factor")));
	}

	m_pModel[m_nPredictors]	= SG_Create_Grid(m_pDependent->Get_System());
	m_pModel[m_nPredictors]	->Set_Name(_TL("Intercept"));

	//-----------------------------------------------------
	Process_Set_Text(_TL("model creation"));

	bool	bResult	= Get_Model();

	//-----------------------------------------------------
	for(i=0; i<m_nPredictors; i++)
	{
		delete(m_pPredictors[i]);

		m_pPredictors[i]	= pPredictors->asGrid(i);
	}

	//-----------------------------------------------------
	if( bResult )
	{
		Process_Set_Text(_TL("downscaling"));

		bResult	= Set_Model();
	}

	//-----------------------------------------------------
	if( Parameters("MODEL_OUT")->asBool() )
	{
		CSG_Parameter_Grid_List	*pModel	= Parameters("MODEL")->asGridList();

		pModel->Del_Items();
		pModel->Add_Item(m_pModel[m_nPredictors]);

		for(i=0; i<m_nPredictors; i++)
		{
			pModel->Add_Item(m_pModel[i]);
		}
	}
	else
	{
		for(i=0; i<=m_nPredictors; i++)
		{
			delete(m_pModel[i]);
		}
	}

	SG_FREE_SAFE(m_pModel);
	SG_FREE_SAFE(m_pPredictors);

	return( bResult );
}
开发者ID:johanvdw,项目名称:saga-debian,代码行数:85,代码来源:gwr_grid_downscaling.cpp

示例9: Parameters

//---------------------------------------------------------
bool CLAS_Import::On_Execute(void)
{
	CSG_Parameter_PointCloud_List	*pPointsList;
	bool			bValidity;
	CSG_Strings		Files;
	int				RGBrange;
	int				cntInvalid = 0;


	bValidity		= Parameters("VALID")->asBool();
	RGBrange		= Parameters("RGB_RANGE")->asInt();
	
	//-----------------------------------------------------
	if( !Parameters("FILES")->asFilePath()->Get_FilePaths(Files) )
	{
		return( false );
	}

	//-----------------------------------------------------
	pPointsList	= Parameters("POINTS")->asPointCloudList();
	pPointsList	->Del_Items();

	for(int i=0; i<Files.Get_Count(); i++)
	{
		SG_UI_Msg_Add(CSG_String::Format(_TL("Parsing %s ... "), SG_File_Get_Name(Files[i], true).c_str()), true);

		std::ifstream   ifs;

		ifs.open(Files[i].b_str(), std::ios::in | std::ios::binary);
		if( !ifs )
		{
			SG_UI_Msg_Add_Error(CSG_String::Format(_TL("Unable to open LAS file!")));
			continue;
		}

		//-----------------------------------------------------
		// Check if LAS version is supported
		liblas::LASReader *pReader;
		try {
			pReader = new liblas::LASReader(ifs);
		}
		catch(std::exception &e) {
			SG_UI_Msg_Add_Error(CSG_String::Format(_TL("LAS header exception: %s"), e.what()));
			ifs.close();
			return( false );
		}
		catch(...) {
			SG_UI_Msg_Add_Error(CSG_String::Format(_TL("Unknown LAS header exception!")));
			ifs.close();
			return( false );
		}
	
		delete (pReader);
		ifs.clear();
		//-----------------------------------------------------


		liblas::LASReader reader(ifs);

		liblas::LASHeader const& header = reader.GetHeader();


		//-----------------------------------------------------
		int		nFields, iField[VAR_Count];

		CSG_PointCloud	*pPoints	= SG_Create_PointCloud();
		pPoints->Set_Name(SG_File_Get_Name(Files[i], false));

		nFields		= 3;

		ADD_FIELD("T", VAR_T, _TL("gps-time")							, SG_DATATYPE_Double);	// SG_DATATYPE_Long
		ADD_FIELD("i", VAR_i, _TL("intensity")							, SG_DATATYPE_Float);	// SG_DATATYPE_Word
		ADD_FIELD("a", VAR_a, _TL("scan angle")							, SG_DATATYPE_Float);	// SG_DATATYPE_Byte
		ADD_FIELD("r", VAR_r, _TL("number of the return")				, SG_DATATYPE_Int);
		ADD_FIELD("c", VAR_c, _TL("classification")						, SG_DATATYPE_Int);		// SG_DATATYPE_Byte
		ADD_FIELD("u", VAR_u, _TL("user data")							, SG_DATATYPE_Double);	// SG_DATATYPE_Byte
		ADD_FIELD("n", VAR_n, _TL("number of returns of given pulse")	, SG_DATATYPE_Int);
		ADD_FIELD("R", VAR_R, _TL("red channel color")					, SG_DATATYPE_Int);		// SG_DATATYPE_Word
		ADD_FIELD("G", VAR_G, _TL("green channel color")				, SG_DATATYPE_Int);
		ADD_FIELD("B", VAR_B, _TL("blue channel color")					, SG_DATATYPE_Int);
		ADD_FIELD("e", VAR_e, _TL("edge of flight line flag")			, SG_DATATYPE_Char);
		ADD_FIELD("d", VAR_d, _TL("direction of scan flag")				, SG_DATATYPE_Char);
		ADD_FIELD("p", VAR_p, _TL("point source ID")					, SG_DATATYPE_Int);		// SG_DATATYPE_Word
		ADD_FIELD("C", VAR_C, _TL("rgb color")							, SG_DATATYPE_Int);

		//-----------------------------------------------------
		int		iPoint	= 0;

		try {
			while( reader.ReadNextPoint() )
			{
				if (iPoint % 100000)
					SG_UI_Process_Set_Progress(iPoint, header.GetPointRecordsCount()); 

				liblas::LASPoint const& point = reader.GetPoint();

				if( bValidity )
				{
					if( !point.IsValid() )
//.........这里部分代码省略.........
开发者ID:Fooway,项目名称:SAGA-GIS-git-mirror,代码行数:101,代码来源:las_import.cpp

示例10: Parameters

//---------------------------------------------------------
bool CGrid_Export::On_Execute(void)
{
	//-----------------------------------------------------
	int			y, iy, Method;
	double		dTrans;
	CSG_Grid	*pGrid, *pShade, Grid, Shade;

	//-----------------------------------------------------
	pGrid		= Parameters("GRID"			)->asGrid();
	pShade		= Parameters("SHADE"		)->asGrid();
	Method		= Parameters("COLOURING"	)->asInt ();
	dTrans		= Parameters("SHADE_TRANS"	)->asDouble() / 100.0;

	if( !pGrid )
	{
		return( false );
	}

	//-----------------------------------------------------
	if( Method == 5 )	// same as in graphical user interface
	{
		if( !SG_UI_DataObject_asImage(pGrid, &Grid) )
		{
			Error_Set("could not retrieve colour coding from graphical user interface.");

			return( false );
		}
	}
	else
	{
		double		zMin, zScale;
		CSG_Colors	Colors;
		CSG_Table	LUT;

		if( SG_UI_Get_Window_Main() )
		{
			Colors.Assign(Parameters("COL_PALETTE")->asColors());
		}
		else
		{
			Colors.Set_Palette(
				Parameters("COL_PALETTE")->asInt (),
				Parameters("COL_REVERT" )->asBool(),
				Parameters("COL_COUNT"  )->asInt ()
			);
		}

		switch( Method )
		{
		case 0:	// stretch to grid's standard deviation
			zMin	= pGrid->Get_Mean() -  Parameters("STDDEV")->asDouble() * pGrid->Get_StdDev();
			zScale	= Colors.Get_Count() / (2 * Parameters("STDDEV")->asDouble() * pGrid->Get_StdDev());
			break;

		case 1:	// stretch to grid's value range
			zMin	= pGrid->Get_ZMin();
			zScale	= Colors.Get_Count() / pGrid->Get_ZRange();
			break;

		case 2:	// stretch to specified value range
			zMin	= Parameters("STRETCH")->asRange()->Get_LoVal();
			if( zMin >= (zScale = Parameters("STRETCH")->asRange()->Get_HiVal()) )
			{
				Error_Set(_TL("invalid user specified value range."));

				return( false );
			}
			zScale	= Colors.Get_Count() / (zScale - zMin);
			break;

		case 3:	// lookup table
			if( !Parameters("LUT")->asTable() || Parameters("LUT")->asTable()->Get_Field_Count() < 5 )
			{
				Error_Set(_TL("invalid lookup table."));

				return( false );
			}

			LUT.Create(*Parameters("LUT")->asTable());
			break;

		case 4:	// rgb coded values
			break;
		}

		//-------------------------------------------------
		Grid.Create(*Get_System(), SG_DATATYPE_Int);

		for(y=0, iy=Get_NY()-1; y<Get_NY() && Set_Progress(y); y++, iy--)
		{
			#pragma omp parallel for
			for(int x=0; x<Get_NX(); x++)
			{
				double	z	= pGrid->asDouble(x, y);

				if( Method == 3 )	// lookup table
				{
					int	i, iColor	= -1;

//.........这里部分代码省略.........
开发者ID:Fooway,项目名称:SAGA-GIS-git-mirror,代码行数:101,代码来源:grid_export.cpp

示例11: Parameters

//---------------------------------------------------------
bool Cdirectional1::On_Execute(void)
{
	int  x, y, r1, dxmax, dymax, ix, ax, ay, bx, by, iy, iv, iw, n;
	double  r2, ang, a, si, si2, co, co2, cosi, sico, r2co, r2si, Sum;
	CSG_Grid  *pInput, *pResult;

	pInput = Parameters("INPUT")->asGrid();
	pResult = Parameters("RESULT")->asGrid();
	ang = Parameters("ANG")->asDouble();
	r1 = Parameters("R1")->asInt();
	r2 = Parameters("R2")->asDouble();

	//-----------------------------------------------------
	a = ang * 6.283185307179586 / 360;
	si = sin(a);
	co = cos(a);
	si2 = si * si;
	co2 = co * co;
	dxmax = (int)((r1*sqrt(co2))+(r2*sqrt(si2)));
	dymax = (int)((r1*sqrt(si2))+(r2*sqrt(co2)));

	if(si2 >= co2)
	{
		cosi = co / si;
		r2si = r2 / sqrt(si2);
		for(y=0; y<Get_NY() && Set_Progress(y); y++)
		{
			for(x=0; x<Get_NX(); x++)
			{
				Sum = 0.0;
				n = 0;
				//----------------------------------------------------
				if( (ax = x - dxmax) <  0 )		{	ax = 0;			}	
				if( (bx = x + dxmax) >= Get_NX() )	{	bx = Get_NX() - 1;	}
				if( (ay = y - dymax) <  0 )		{	ay = 0;			}
				if( (by = y + dymax) >= Get_NY() )	{	by = Get_NY() - 1;	}
				//-----------------------------------------------------
				for(ix=ax; ix<=bx; ix++)
				{
					iv = x - ix;
					for(iy=ay; iy<=by; iy++)
					{
						iw = y - iy;
						if( iv >= (iw*cosi - r2si) && iv <= (iw*cosi + r2si))
						{
							Sum += pInput->asDouble(ix, iy);
							n++;
						}
					}
				}
				if( n > 0 )
				{
					pResult->Set_Value(x, y, Sum/n);
				}
			}
		}
	}

	if(si2 < co2)
	{
		sico = si / co;
		r2co = r2 / sqrt(co2);
		for(y=0; y<Get_NY() && Set_Progress(y); y++)
		{
			for(x=0; x<Get_NX(); x++)
			{
				Sum = 0.0;
				n = 0;
				//----------------------------------------------------
				if( (ax = x - dxmax) <  0 )		{	ax = 0;			}	
				if( (bx = x + dxmax) >= Get_NX() )	{	bx = Get_NX() - 1;	}
				if( (ay = y - dymax) <  0 )		{	ay = 0;			}
				if( (by = y + dymax) >= Get_NY() )	{	by = Get_NY() - 1;	}
				//-----------------------------------------------------
				for(iy=ay; iy<=by; iy++)
				{
					iw = y - iy;
					for(ix=ax; ix<=bx; ix++)
					{
						iv = x - ix;
						if( iw >= (iv*sico - r2co) && iw <= (iv*sico + r2co))
						{
							Sum += pInput->asDouble(ix, iy);
							n++;
						}
					}
				}
				if( n > 0 )
				{
					pResult->Set_Value(x, y, Sum/n);
				}
			}
		}
	}
	return( true );
}
开发者ID:johanvdw,项目名称:SAGA-GIS-git-mirror,代码行数:97,代码来源:directional1.cpp

示例12: Parameters

//---------------------------------------------------------
bool CGrid_Cross_Profiles::On_Execute(void)
{
	int			iLine, iPart, iPoint, nSamples;
	double		Distance, Length, dLine, dist, dx, dy;
	TSG_Point	iPt, jPt, dPt, aPt, bPt;
	CSG_Shapes		*pLines, *pProfiles;
	CSG_Shape		*pLine, *pProfile;

	//-----------------------------------------------------
	m_pDEM		= Parameters("DEM")			->asGrid();
	pProfiles	= Parameters("PROFILES")	->asShapes();
	pLines		= Parameters("LINES")		->asShapes();
	Distance	= Parameters("DIST_LINE")	->asDouble();
	Length		= Parameters("DIST_PROFILE")->asDouble();
	nSamples	= Parameters("NUM_PROFILE")	->asInt();

	//-----------------------------------------------------
	pProfiles->Create(SHAPE_TYPE_Line, _TL("Profiles"));
	pProfiles->Add_Field("ID"	, SG_DATATYPE_Int);
	pProfiles->Add_Field("LINE"	, SG_DATATYPE_Int);
	pProfiles->Add_Field("PART"	, SG_DATATYPE_Int);

	for(iPoint=0; iPoint<nSamples; iPoint++)
	{
		pProfiles->Add_Field(CSG_String::Format(SG_T("X%03d"), iPoint), SG_DATATYPE_Double);
	}

	//-----------------------------------------------------
	for(iLine=0; iLine<pLines->Get_Count() && Set_Progress(iLine, pLines->Get_Count()); iLine++)
	{
		pLine	= pLines->Get_Shape(iLine);

		for(iPart=0; iPart<pLine->Get_Part_Count(); iPart++)
		{
			if( pLine->Get_Point_Count(iPart) > 1 )
			{
				dist	= 0.0;
				iPt		= pLine->Get_Point(0, iPart);

				for(iPoint=1; iPoint<pLine->Get_Point_Count(iPart); iPoint++)
				{
					jPt		= iPt;
					iPt		= pLine->Get_Point(iPoint, iPart);
					dx		= iPt.x - jPt.x;
					dy		= iPt.y - jPt.y;
					dLine	= sqrt(dx*dx + dy*dy);
					dx		/= dLine;
					dy		/= dLine;

					while( dist < dLine )
					{
						dPt.x	= jPt.x + dist * dx;
						dPt.y	= jPt.y + dist * dy;

						if( m_pDEM->is_InGrid_byPos(dPt) )
						{
							aPt.x	= dPt.x + dy * Length;
							aPt.y	= dPt.y - dx * Length;
							bPt.x	= dPt.x - dy * Length;
							bPt.y	= dPt.y + dx * Length;

							pProfile	= pProfiles->Add_Shape();
							pProfile->Add_Point(aPt);
							pProfile->Add_Point(bPt);
							pProfile->Set_Value(0, pProfiles->Get_Count());
							pProfile->Set_Value(1, iLine);
							pProfile->Set_Value(2, iPart);

							Get_Profile(pProfile, aPt, bPt, nSamples);
						}

						dist	+= Distance;
					}

					dist	-= dLine;
				}
			}
		}
	}

	//-----------------------------------------------------
	if( pProfiles->Get_Count() > 0 )
	{
		if( Parameters("DOCUMENT")->asString() )
		{
			Make_Report(Parameters("DOCUMENT")->asString(), m_pDEM, pLines, pProfiles, Distance);
		}

		return( true );
	}

	return( false );
}
开发者ID:am2222,项目名称:SAGA-GIS,代码行数:94,代码来源:Grid_Cross_Profiles.cpp

示例13: Parameters

//---------------------------------------------------------
bool CGSGrid_Statistics_To_Table::On_Execute(void)
{
	//-----------------------------------------------------
	CSG_Parameter_Grid_List	*pGrids	= Parameters("GRIDS")->asGridList();

	if( pGrids->Get_Count() < 1 )
	{
		Error_Set(_TL("no grids in selection"));

		return( false );
	}

	//-----------------------------------------------------
	CSG_Table	*pTable	= Parameters("STATS")->asTable();

	pTable->Destroy();
	pTable->Set_Name(_TL("Statistics for Grids"));
	pTable->Add_Field(_TL("NAME"), SG_DATATYPE_String);

	if( Parameters("DATA_CELLS"  )->asBool() )	pTable->Add_Field(_TL("DATA_CELLS"  ), SG_DATATYPE_Int);
	if( Parameters("NODATA_CELLS")->asBool() )	pTable->Add_Field(_TL("NODATA_CELLS"), SG_DATATYPE_Int);
	if( Parameters("CELLSIZE"    )->asBool() )	pTable->Add_Field(_TL("CELLSIZE"    ), SG_DATATYPE_Double);
	if( Parameters("MEAN"        )->asBool() )	pTable->Add_Field(_TL("MEAN"        ), SG_DATATYPE_Double);
	if( Parameters("MIN"         )->asBool() )	pTable->Add_Field(_TL("MIN"         ), SG_DATATYPE_Double);
	if( Parameters("MAX"         )->asBool() )	pTable->Add_Field(_TL("MAX"         ), SG_DATATYPE_Double);
	if( Parameters("RANGE"       )->asBool() )	pTable->Add_Field(_TL("RANGE"       ), SG_DATATYPE_Double);
	if( Parameters("VAR"         )->asBool() )	pTable->Add_Field(_TL("VAR"         ), SG_DATATYPE_Double);
	if( Parameters("STDDEV"      )->asBool() )	pTable->Add_Field(_TL("STDDEV"      ), SG_DATATYPE_Double);
	if( Parameters("STDDEVLO"    )->asBool() )	pTable->Add_Field(_TL("STDDEVLO"    ), SG_DATATYPE_Double);
	if( Parameters("STDDEVHI"    )->asBool() )	pTable->Add_Field(_TL("STDDEVHI"    ), SG_DATATYPE_Double);
	if( Parameters("PCTL"        )->asBool() )	pTable->Add_Field(_TL("PCTL"        ), SG_DATATYPE_Double);

	if( pTable->Get_Field_Count() <= 1 )
	{
		Error_Set(_TL("no parameter output specified"));

		return( false );
	}

	double	dRank	= Parameters("PCTL")->asBool() ? Parameters("PCTL_VAL")->asDouble() : -1.0;

	//-----------------------------------------------------
	for(int i=0; i<pGrids->Get_Count() && Process_Get_Okay(); i++)
	{
		CSG_Grid			*pGrid		= pGrids->asGrid(i);
		CSG_Table_Record	*pRecord	= pTable->Add_Record();

		pRecord->Set_Value("NAME"        , pGrid->Get_Name());
		pRecord->Set_Value("DATA_CELLS"  , pGrid->Get_NCells() - pGrid->Get_NoData_Count());
		pRecord->Set_Value("NODATA_CELLS", pGrid->Get_NoData_Count());
		pRecord->Set_Value("CELLSIZE"    , pGrid->Get_Cellsize());
		pRecord->Set_Value("MEAN"        , pGrid->Get_ArithMean());
		pRecord->Set_Value("MIN"         , pGrid->Get_ZMin());
		pRecord->Set_Value("MAX"         , pGrid->Get_ZMax());
		pRecord->Set_Value("RANGE"       , pGrid->Get_ZRange());
		pRecord->Set_Value("VAR"         , pGrid->Get_Variance());
		pRecord->Set_Value("STDDEV"      , pGrid->Get_StdDev());
		pRecord->Set_Value("STDDEVLO"    , pGrid->Get_ArithMean() - pGrid->Get_StdDev());
		pRecord->Set_Value("STDDEVHI"    , pGrid->Get_ArithMean() + pGrid->Get_StdDev());

		if( dRank > 0.0 && dRank < 100.0 )
		{
			pRecord->Set_Value("PCTL", pGrid->Get_Percentile(dRank));	// this is a time consuming operation
		}
	}

	if( dRank > 0.0 && dRank < 100.0 )
	{
		pTable->Set_Field_Name(pTable->Get_Field_Count() - 1, CSG_String::Format(SG_T("%s%02d"), _TL("PCTL"), (int)dRank));
	}

	return( true );
}
开发者ID:johanvdw,项目名称:saga-debian,代码行数:74,代码来源:GSGrid_Statistics.cpp

示例14: Points

//---------------------------------------------------------
bool CKriging_Regression::On_Execute(void)
{
	//-----------------------------------------------------
	CSG_Shapes	Points(SHAPE_TYPE_Point);

	CSG_Grid	*pPrediction	= Parameters("PREDICTION")->asGrid();
	CSG_Grid	*pRegression	= Parameters("REGRESSION")->asGrid();
	CSG_Grid	*pResiduals		= Parameters("RESIDUALS" )->asGrid();
	CSG_Grid	*pVariance		= Parameters("VARIANCE"  )->asGrid();

	//-----------------------------------------------------
	if( !pResiduals )
	{
		pResiduals	= pPrediction;
	}

	//-----------------------------------------------------
	SG_RUN_TOOL_ExitOnError("statistics_regression", 1,	// Multiple Regression Analysis (Points and Predictor Grids)
			SG_TOOL_PARAMETER_SET("PREDICTORS", Parameters("PREDICTORS"))
		&&	SG_TOOL_PARAMETER_SET("POINTS"    , Parameters("POINTS"    ))
		&&	SG_TOOL_PARAMETER_SET("ATTRIBUTE" , Parameters("FIELD"     ))
		&&	SG_TOOL_PARAMETER_SET("INFO_COEFF", Parameters("INFO_COEFF"))
		&&	SG_TOOL_PARAMETER_SET("INFO_MODEL", Parameters("INFO_MODEL"))
		&&	SG_TOOL_PARAMETER_SET("INFO_STEPS", Parameters("INFO_STEPS"))
		&&	SG_TOOL_PARAMETER_SET("RESAMPLING", Parameters("RESAMPLING"))
		&&	SG_TOOL_PARAMETER_SET("COORD_X"   , Parameters("COORD_X"   ))
		&&	SG_TOOL_PARAMETER_SET("COORD_Y"   , Parameters("COORD_Y"   ))
		&&	SG_TOOL_PARAMETER_SET("INTERCEPT" , Parameters("INTERCEPT" ))
		&&	SG_TOOL_PARAMETER_SET("METHOD"    , Parameters("METHOD"    ))
		&&	SG_TOOL_PARAMETER_SET("P_VALUE"   , Parameters("P_VALUE"   ))
		&&	SG_TOOL_PARAMETER_SET("REGRESSION", pRegression)
		&&	SG_TOOL_PARAMETER_SET("RESIDUALS" , &Points )
	);

	//-----------------------------------------------------
	CSG_Tool	*pK	= Parameters("KRIGING")->asInt() == 0 ? (CSG_Tool *)&m_SK : (CSG_Tool *)&m_OK;

	Process_Set_Text(pK->Get_Name());

	pK->Set_Manager(NULL);

	if( !pK->Set_Parameter("POINTS"           , &Points)
	||  !pK->Set_Parameter("FIELD"            , 2)	// residual
	||  !pK->Set_Parameter("LOG"              , Parameters("LOG"              ))
	||  !pK->Set_Parameter("BLOCK"            , Parameters("BLOCK"            ))
	||  !pK->Set_Parameter("DBLOCK"           , Parameters("DBLOCK"           ))
	||  !pK->Set_Parameter("SEARCH_RANGE"     , Parameters("SEARCH_RANGE"     ))
	||  !pK->Set_Parameter("SEARCH_RADIUS"    , Parameters("SEARCH_RADIUS"    ))
	||  !pK->Set_Parameter("SEARCH_POINTS_ALL", Parameters("SEARCH_POINTS_ALL"))
	||  !pK->Set_Parameter("SEARCH_POINTS_MIN", Parameters("SEARCH_POINTS_MIN"))
	||  !pK->Set_Parameter("SEARCH_POINTS_MAX", Parameters("SEARCH_POINTS_MAX"))
	||  !pK->Set_Parameter("SEARCH_DIRECTION" , Parameters("SEARCH_DIRECTION" ))
	||  !pK->Set_Parameter("TARGET_DEFINITION", 1)	// grid or grid system
	||  !pK->Set_Parameter("PREDICTION"       , pResiduals)
	||  !pK->Set_Parameter("VARIANCE"         , pVariance )

	|| (!SG_UI_Get_Window_Main() && (	// saga_cmd
	    !pK->Set_Parameter("VAR_MAXDIST"      , Parameters("VAR_MAXDIST"      ))
	||  !pK->Set_Parameter("VAR_NCLASSES"     , Parameters("VAR_NCLASSES"     ))
	||  !pK->Set_Parameter("VAR_NSKIP"        , Parameters("VAR_NSKIP"        ))
	||  !pK->Set_Parameter("VAR_MODEL"        , Parameters("VAR_MODEL"        )))) )
	{
		Error_Set(CSG_String::Format("%s [%s].[%s]", _TL("could not initialize tool"), _TL("statistics_regression"), pK->Get_Name().c_str()));

		return( false );
	}

	if( !pK->Execute() )
	{
		Error_Set(CSG_String::Format("%s [%s].[%s]", _TL("could not execute tool"   ), _TL("statistics_regression"), pK->Get_Name().c_str()));

		return( false );
	}

	//-----------------------------------------------------
	#pragma omp parallel for
	for(int y=0; y<Get_NY(); y++)
	{
		for(int x=0; x<Get_NX(); x++)
		{
			if( pRegression->is_NoData(x, y) || pResiduals->is_NoData(x, y) )
			{
				pPrediction->Set_NoData(x, y);
			}
			else
			{
				pPrediction->Set_Value(x, y, pRegression->asDouble(x, y) + pResiduals->asDouble(x, y));
			}
		}
	}

	//-----------------------------------------------------
	pRegression->Fmt_Name("%s.%s [%s]", Parameters("POINTS")->asShapes()->Get_Name(), Parameters("FIELD")->asString(), _TL("Regression"));
	pPrediction->Fmt_Name("%s.%s [%s]", Parameters("POINTS")->asShapes()->Get_Name(), Parameters("FIELD")->asString(), _TL("Prediction"));

	if( Parameters("RESIDUALS")->asGrid() )
	{
		pResiduals->Fmt_Name("%s.%s [%s]", Parameters("POINTS")->asShapes()->Get_Name(), Parameters("FIELD")->asString(), _TL("Residuals"));
	}
//.........这里部分代码省略.........
开发者ID:johanvdw,项目名称:SAGA-GIS-git-mirror,代码行数:101,代码来源:kriging_regression.cpp

示例15: Parameters

//---------------------------------------------------------
bool CHugget_02::On_Execute(void)
{
	int				iStep, nSteps;
	double			sTime, dTime, PrimProd, cHumify, cCarbon,
					C_Leav, C_Bran, C_Stem, C_Root, C_Litt, C_Humu, C_Coal,
					P_Leav, P_Bran, P_Stem, P_Root,
					K_Leav_Litt, K_Bran_Litt, K_Stem_Litt,
					K_Root_Humu, K_Litt_Humu, K_Humu_Coal, K_Coal_Envi,
					d_Leav_Litt, d_Bran_Litt, d_Stem_Litt,
					d_Root_Humu, d_Litt_Humu, d_Humu_Coal, d_Coal_Envi;
	CSG_Table_Record	*pRecord;
	CSG_Table			*pTable;

	//-----------------------------------------------------
	sTime	= Parameters("TIME_SPAN")		->asDouble();
	dTime	= Parameters("TIME_STEP")		->asDouble();
	nSteps	= (int)(sTime / dTime);

	PrimProd	= Parameters("PRIMPROD")	->asDouble();
	cHumify		= Parameters("CHUMIFY")		->asDouble();
	cCarbon		= Parameters("CCARBON")		->asDouble();

	P_Leav		= Parameters("P_LEAV")		->asDouble();
	P_Bran		= Parameters("P_BRAN")		->asDouble();
	P_Stem		= Parameters("P_STEM")		->asDouble();
	P_Root		= Parameters("P_ROOT")		->asDouble();

	K_Leav_Litt	= Parameters("K_LEAV_LITT")	->asDouble();
	K_Bran_Litt	= Parameters("K_BRAN_LITT")	->asDouble();
	K_Stem_Litt	= Parameters("K_STEM_LITT")	->asDouble();
	K_Root_Humu	= Parameters("K_ROOT_HUMU")	->asDouble();
	K_Litt_Humu	= Parameters("K_LITT_HUMU")	->asDouble();
	K_Humu_Coal	= Parameters("K_HUMU_COAL")	->asDouble();
	K_Coal_Envi	= Parameters("K_COAL_ENVI")	->asDouble();

	pTable		= Parameters("TABLE")		->asTable();
	pTable->Destroy();
	pTable->Set_Name(_TL("Carbon Cycle Simulation"));
	pTable->Add_Field("STEP"	, SG_DATATYPE_Int);
	pTable->Add_Field("TIME"	, SG_DATATYPE_Double);
	pTable->Add_Field("LEAVES"	, SG_DATATYPE_Double);
	pTable->Add_Field("BRANCHES", SG_DATATYPE_Double);
	pTable->Add_Field("STEMS"	, SG_DATATYPE_Double);
	pTable->Add_Field("ROOTS"	, SG_DATATYPE_Double);
	pTable->Add_Field("LITTER"	, SG_DATATYPE_Double);
	pTable->Add_Field("HUMUS"	, SG_DATATYPE_Double);
	pTable->Add_Field("CHARCOAL", SG_DATATYPE_Double);

	//-----------------------------------------------------
	C_Leav		= 0.0;
	C_Bran		= 0.0;
	C_Stem		= 0.0;
	C_Root		= 0.0;
	C_Litt		= 0.0;
	C_Humu		= 0.0;
	C_Coal		= 0.0;

	//-----------------------------------------------------
	for(iStep=0; iStep<nSteps && Set_Progress(iStep, nSteps); iStep++)
	{
		WRITE_RECORD;

		d_Leav_Litt	= K_Leav_Litt * C_Leav;
		d_Bran_Litt	= K_Bran_Litt * C_Bran;
		d_Stem_Litt	= K_Stem_Litt * C_Stem;
		d_Root_Humu	= K_Root_Humu * C_Root;
		d_Litt_Humu	= K_Litt_Humu * C_Litt;
		d_Humu_Coal	= K_Humu_Coal * C_Humu;
		d_Coal_Envi	= K_Coal_Envi * C_Coal;

		C_Leav	= C_Leav + dTime * (-d_Leav_Litt + P_Leav * PrimProd);
		C_Bran	= C_Bran + dTime * (-d_Bran_Litt + P_Bran * PrimProd);
		C_Stem	= C_Stem + dTime * (-d_Stem_Litt + P_Stem * PrimProd);
		C_Root	= C_Root + dTime * (-d_Root_Humu + P_Root * PrimProd);
		C_Litt	= C_Litt + dTime * (-d_Litt_Humu + d_Leav_Litt + d_Bran_Litt + d_Stem_Litt);
		C_Humu	= C_Humu + dTime * (-d_Humu_Coal + cHumify * (d_Root_Humu + d_Litt_Humu));
		C_Coal	= C_Coal + dTime * (-d_Coal_Envi + cCarbon * (d_Humu_Coal));
	}

	WRITE_RECORD;

	//-----------------------------------------------------
	return( true );
}
开发者ID:Fooway,项目名称:SAGA-GIS-git-mirror,代码行数:85,代码来源:Hugget_02.cpp


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