コード例 #1
0
//---------------------------------------------------------
bool CSG_Module_Interactive_Base::Execute_Position(CSG_Point ptWorld, TSG_Module_Interactive_Mode Mode, int Keys)
{
	bool	bResult	= false;

	if( m_pModule && !m_pModule->m_bExecutes )
	{
		m_pModule->m_bExecutes		= true;
		m_pModule->m_bError_Ignore	= false;

		m_Point_Last				= m_Point;
		m_Point						= ptWorld;

		m_Keys						= Keys;

		bResult						= On_Execute_Position(m_Point, Mode);

		m_Keys						= 0;

		m_pModule->_Synchronize_DataObjects();

		m_pModule->m_bExecutes		= false;

		SG_UI_Process_Set_Okay();
	}

	return( bResult );
}
コード例 #2
0
//---------------------------------------------------------
bool CSG_Module_Interactive_Base::Execute_Finish(void)
{
	bool	bResult	= false;

	if( m_pModule && !m_pModule->m_bExecutes )
	{
		m_pModule->m_bExecutes		= true;
		m_pModule->m_bError_Ignore	= false;

		bResult						= On_Execute_Finish();

		m_pModule->_Synchronize_DataObjects();

		m_pModule->m_bExecutes		= false;

		SG_UI_Process_Set_Okay();
	}

	return( bResult );
}
コード例 #3
0
//---------------------------------------------------------
bool CSG_Module_Interactive_Base::Execute_Keyboard(int Character, int Keys)
{
	bool	bResult	= false;

	if( m_pModule && !m_pModule->m_bExecutes )
	{
		m_pModule->m_bExecutes		= true;
		m_pModule->m_bError_Ignore	= false;

		m_Keys						= Keys;

		bResult						= On_Execute_Keyboard(Character);

		m_Keys						= 0;

		m_pModule->_Synchronize_DataObjects();

		m_pModule->m_bExecutes		= false;

		SG_UI_Process_Set_Okay();
	}

	return( bResult );
}
コード例 #4
0
//---------------------------------------------------------
bool CPoint_Zonal_Multi_Grid_Regression::On_Execute(void)
{
	//-----------------------------------------------------
	CSG_Shapes	*pPoints		= Parameters("POINTS"    )->asShapes();
	CSG_Shapes	*pZones			= Parameters("ZONES"     )->asShapes();
	CSG_Grid	*pRegression	= Parameters("REGRESSION")->asGrid  ();

	pRegression->Assign_NoData();

	CSG_Grid	Regression(*Get_System(), SG_DATATYPE_Float);

	SG_UI_Progress_Lock(true);	// suppress dialogs from popping up

	for(int i=0; i<pZones->Get_Count() && Process_Get_Okay(); i++)
	{
		CSG_Shape_Polygon	*pZone	= (CSG_Shape_Polygon *)pZones->Get_Shape(i);

		//-------------------------------------------------
		// select all points located in current zone polygon

		bool	bResult;

		CSG_Shapes Zone(SHAPE_TYPE_Polygon);	Zone.Add_Shape(pZone);

		SG_RUN_TOOL(bResult, "shapes_tools", 5,	// select points by location
			   SG_TOOL_PARAMETER_SET("LOCATIONS", &Zone)
			&& SG_TOOL_PARAMETER_SET("SHAPES"   , pPoints)
		);

		if( !bResult )
		{
			SG_UI_Process_Set_Okay();	// don't stop overall work flow, if tool execution failed for current zone
		}
		else if( pPoints->Get_Selection_Count() > 0 )
		{
			//---------------------------------------------
			// copy selected points to a new (temporary) points layer

			CSG_Shapes	Selection;

			SG_RUN_TOOL(bResult, "shapes_tools", 6,	// copy selected points to a new layer
				   SG_TOOL_PARAMETER_SET("INPUT" , pPoints)
				&& SG_TOOL_PARAMETER_SET("OUTPUT", &Selection)
			);

			pPoints->asShapes()->Select();	// unselect everything from original points layer

			//---------------------------------------------
			// perform the regression analysis, regression grid for zone is temporary

			SG_RUN_TOOL(bResult, "statistics_regression", 1,	// multiple linear regression for points and predictor grids
				   SG_TOOL_PARAMETER_SET("PREDICTORS", Parameters("PREDICTORS"))
				&& SG_TOOL_PARAMETER_SET("REGRESSION", &Regression             )
				&& SG_TOOL_PARAMETER_SET("POINTS"    , &Selection              )
				&& SG_TOOL_PARAMETER_SET("ATTRIBUTE" , Parameters("ATTRIBUTE" ))
				&& 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"   ))
			);

			//---------------------------------------------
			// use zone polygon as mask for copying zonal regression result to final regression grid

			if( !bResult )
			{
				SG_UI_Process_Set_Okay();	// don't stop overall work flow, if tool execution failed for current zone
			}
			else
			{
				#pragma omp parallel for	// speed up using multiple processors
				for(int y=0; y<Get_NY(); y++)
				{
					for(int x=0; x<Get_NX(); x++)
					{
						if( !Regression.is_NoData(x, y) && pZone->Contains(Get_System()->Get_Grid_to_World(x, y)) )
						{
							pRegression->Set_Value(x, y, Regression.asDouble(x, y));
						}
					}
				}
			}
		}
	}

	//-----------------------------------------------------
	SG_UI_Progress_Lock(false);

	//-----------------------------------------------------
	Set_Residuals(pPoints, pRegression);

	//-----------------------------------------------------
	return( true );
}