//--------------------------------------------------------- double CSG_Table_DBase::asDouble(int iField) { char *s; double Result = 0; if( bOpen && iField >= 0 && iField < nFields ) { if( FieldDesc[iField].Type == DBF_FT_NUMERIC ) { s = (char *)SG_Calloc(FieldDesc[iField].Width + 1, sizeof(char)); memcpy(s, Record + FieldOffset[iField], FieldDesc[iField].Width); Result = atof(s); SG_Free(s); } else if( FieldDesc[iField].Type == DBF_FT_DATE ) { s = (char *)SG_Calloc(FieldDesc[iField].Width + 1, sizeof(char)); memcpy(s, Record + FieldOffset[iField], FieldDesc[iField].Width); int d = atoi(s + 6); s[6] = '\0'; if( d < 1 ) d = 1; else if( d > 31 ) d = 31; int m = atoi(s + 4); s[4] = '\0'; if( m < 1 ) m = 1; else if( m > 12 ) m = 12; int y = atoi(s); Result = 10000 * y + 100 * m + 1 * d; SG_Free(s); } } return( Result ); }
//--------------------------------------------------------- bool CSG_PointCloud::_Inc_Array(void) { if( m_nFields > 0 && m_Array_Points.Set_Array(m_nRecords + 1, (void **)&m_Points) ) { m_Points[m_nRecords++] = m_Cursor = (char *)SG_Calloc(m_nPointBytes, sizeof(char)); return( true ); } return( false ); }
size_t CSG_File::Read(CSG_String &Buffer, size_t Size) const { if( m_pStream ) { char *b = (char *)SG_Calloc(Size + 1, sizeof(char)); int i = fread(b, sizeof(char), Size, m_pStream); Buffer = b; SG_Free(b); return( i ); } return( 0 ); }
//--------------------------------------------------------- int CSG_Table_DBase::asInt(int iField) { char *s; int Result = 0; if( bOpen && iField >= 0 && iField < nFields ) { if( FieldDesc[iField].Type == DBF_FT_NUMERIC ) { s = (char *)SG_Calloc(FieldDesc[iField].Width + 1, sizeof(char)); memcpy(s, Record + FieldOffset[iField], FieldDesc[iField].Width); Result = atoi(s); SG_Free(s); } } return( Result ); }
//--------------------------------------------------------- bool CTable_PCA::Get_Fields(void) { CSG_Parameters *pFields = Parameters("FIELDS")->asParameters(); m_Features = (int *)SG_Calloc(pFields->Get_Count(), sizeof(int)); m_nFeatures = 0; for(int iFeature=0; iFeature<pFields->Get_Count(); iFeature++) { if( pFields->Get_Parameter(iFeature)->asBool() ) { CSG_String s(pFields->Get_Parameter(iFeature)->Get_Identifier()); m_Features[m_nFeatures++] = s.asInt(); } } return( m_nFeatures > 1 ); }
//--------------------------------------------------------- bool COpenCV_NNet::On_Execute(void) { //------------------------------------------------- bool b_updateWeights, b_noInputScale, b_noOutputScale, b_NoData; int i_matType, i_layers, i_maxIter, i_neurons, i_areasClassId, i_trainFeatTotalCount, *i_outputFeatureIdxs, i_outputFeatureCount, i_Grid, x, y, i_evalOut, i_winner; double d_alpha, d_beta, d_eps; DATA_TYPE e_dataType; TRAINING_METHOD e_trainMet; ACTIVATION_FUNCTION e_actFunc; CSG_Table *t_Weights, *t_Indices, *t_TrainInput, *t_EvalInput, *t_EvalOutput; CSG_Parameter_Grid_List *gl_TrainInputs; CSG_Grid *g_EvalOutput, *g_EvalOutputCert; CSG_Shapes *s_TrainInputAreas; CSG_Parameters *p_TrainFeatures; TSG_Point p; CvMat *mat_Weights, *mat_Indices, **mat_data, *mat_neuralLayers, mat_layerSizesSub, *mat_EvalInput, *mat_EvalOutput; // todo: mat_indices to respect input indices, mat_weights for initialization CvANN_MLP_TrainParams tp_trainParams; CvANN_MLP model; b_updateWeights = Parameters("UPDATE_WEIGHTS" )->asBool(); b_noInputScale = Parameters("NO_INPUT_SCALE" )->asBool(); b_noOutputScale = Parameters("NO_OUTPUT_SCALE" )->asBool(); i_layers = Parameters("NNET_LAYER" )->asInt(); i_neurons = Parameters("NNET_NEURONS" )->asInt(); i_maxIter = Parameters("MAX_ITER" )->asInt(); i_areasClassId = Parameters("TRAIN_INPUT_AREAS_CLASS_FIELD" )->asInt(); e_dataType = (DATA_TYPE)Parameters("DATA_TYPE" )->asInt(); e_trainMet = (TRAINING_METHOD)Parameters("TRAINING_METHOD" )->asInt(); e_actFunc = (ACTIVATION_FUNCTION)Parameters("ACTIVATION_FUNCTION" )->asInt(); d_alpha = Parameters("ALPHA" )->asDouble(); d_beta = Parameters("BETA" )->asDouble(); d_eps = Parameters("EPSILON" )->asDouble(); t_Weights = Parameters("WEIGHTS" )->asTable(); t_Indices = Parameters("INDICES" )->asTable(); t_TrainInput = Parameters("TRAIN_INPUT_TABLE" )->asTable(); t_EvalInput = Parameters("EVAL_INPUT_TABLE" )->asTable(); t_EvalOutput = Parameters("EVAL_OUTPUT_TABLE" )->asTable(); p_TrainFeatures = Parameters("TRAIN_FEATURES_TABLE" )->asParameters(); gl_TrainInputs = Parameters("TRAIN_INPUT_GRIDS" )->asGridList(); g_EvalOutput = Parameters("EVAL_OUTPUT_GRID_CLASSES" )->asGrid(); g_EvalOutputCert = Parameters("EVAL_OUTPUT_GRID_CERTAINTY" )->asGrid(); s_TrainInputAreas = Parameters("TRAIN_INPUT_AREAS" )->asShapes(); // Fixed matrix type (TODO: Analyze what to do for other types of data (i.e. images)) i_matType = CV_32FC1; //------------------------------------------------- if (e_dataType == TABLE) { // We are working with TABLE data if( t_TrainInput->Get_Count() == 0 || p_TrainFeatures->Get_Count() == 0 ) { Error_Set(_TL("Select an input table and at least one output feature!")); return( false ); } // Count the total number of available features i_trainFeatTotalCount = t_TrainInput->Get_Field_Count(); // Count the number of selected output features i_outputFeatureIdxs = (int *)SG_Calloc(i_trainFeatTotalCount, sizeof(int)); i_outputFeatureCount = 0; for(int i=0; i<p_TrainFeatures->Get_Count(); i++) { if( p_TrainFeatures->Get_Parameter(i)->asBool() ) { i_outputFeatureIdxs[i_outputFeatureCount++] = CSG_String(p_TrainFeatures->Get_Parameter(i)->Get_Identifier()).asInt(); } } // Update the number of training features i_trainFeatTotalCount = i_trainFeatTotalCount-i_outputFeatureCount; if( i_outputFeatureCount <= 0 ) { Error_Set(_TL("Select at least one output feature!")); return( false ); } // Now convert the input and output training data into a OpenCV matrix objects mat_data = GetTrainAndOutputMatrix(t_TrainInput, i_matType, i_outputFeatureIdxs, i_outputFeatureCount); } else { // TODO: Add some grid validation logic i_trainFeatTotalCount = gl_TrainInputs->Get_Count(); i_outputFeatureCount = s_TrainInputAreas->Get_Count(); // Convert the data from the grid into the matrix from mat_data = GetTrainAndOutputMatrix(gl_TrainInputs, i_matType, s_TrainInputAreas, i_areasClassId, g_EvalOutput, g_EvalOutputCert); } //------------------------------------------------- // Add two additional layer to the network topology (0-th layer for input and the last as the output) i_layers = i_layers + 2; mat_neuralLayers = cvCreateMat(i_layers, 1, CV_32SC1); cvGetRows(mat_neuralLayers, &mat_layerSizesSub, 0, i_layers); //Setting the number of neurons on each layer for (int i = 0; i < i_layers; i++) { if (i == 0) { // The first layer needs the same size (number of nerons) as the number of columns in the training data cvSet1D(&mat_layerSizesSub, i, cvScalar(i_trainFeatTotalCount)); } else if (i == i_layers-1) { // The last layer needs the same size (number of neurons) as the number of output columns cvSet1D(&mat_layerSizesSub, i, cvScalar(i_outputFeatureCount)); } else { // On every other layer set the layer size selected by the user cvSet1D(&mat_layerSizesSub, i, cvScalar(i_neurons)); } } //------------------------------------------------- // Create the training params object tp_trainParams = CvANN_MLP_TrainParams(); tp_trainParams.term_crit = cvTermCriteria(CV_TERMCRIT_ITER + CV_TERMCRIT_EPS, i_maxIter, d_eps); // Check which training method was selected and set corresponding params if(e_trainMet == RPROP) { // Set all RPROP specific params tp_trainParams.train_method = CvANN_MLP_TrainParams::RPROP; tp_trainParams.rp_dw0 = Parameters("RP_DW0" )->asDouble(); tp_trainParams.rp_dw_plus = Parameters("RP_DW_PLUS" )->asDouble(); tp_trainParams.rp_dw_minus = Parameters("RP_DW_MINUS" )->asDouble(); tp_trainParams.rp_dw_min = Parameters("RP_DW_MIN" )->asDouble(); tp_trainParams.rp_dw_max = Parameters("RP_DW_MAX" )->asDouble(); } else { // Set all BPROP specific params tp_trainParams.train_method = CvANN_MLP_TrainParams::BACKPROP; tp_trainParams.bp_dw_scale = Parameters("BP_DW_SCALE" )->asDouble(); tp_trainParams.bp_moment_scale = Parameters("BP_MOMENT_SCALE" )->asInt(); } //------------------------------------------------- // Create the model (depending on the activation function) if(e_actFunc == SIGMOID) { model.create(mat_neuralLayers); } else { model.create(mat_neuralLayers, CvANN_MLP::GAUSSIAN, d_alpha, d_beta); } //------------------------------------------------- // Now train the network // TODO: Integrate init weights and indicies for record selection // mat_Weights = GetMatrix(t_Weights, i_matType); // mat_Indices = GetMatrix(t_Indices, i_matType); //model.train(mat_TrainInput, mat_TrainOutput, NULL, NULL, tp_trainParams); model.train(mat_data[0], mat_data[1], NULL, NULL, tp_trainParams); //------------------------------------------------- // Predict data if (e_dataType == TABLE) { // Get the eavaluation/test matrix from the eval table mat_EvalInput = GetEvalMatrix(t_EvalInput, i_matType); } else { // Train and eval data overlap in grid mode mat_EvalInput = GetEvalMatrix(gl_TrainInputs, i_matType); } // Prepare output matrix mat_EvalOutput = cvCreateMat(mat_EvalInput->rows, i_outputFeatureCount, i_matType); // Start prediction model.predict(mat_EvalInput, mat_EvalOutput); Message_Add(_TL("Successfully trained the network and predicted the values. Here comes the output.")); //------------------------------------------------- // Save and print results if (e_dataType == TABLE) { // DEBUG -> Save results to output table and print results for (int i = 0; i < i_outputFeatureCount; i++) { t_EvalOutput->Add_Field(CSG_String(t_TrainInput->Get_Field_Name(i_outputFeatureIdxs[i])), SG_DATATYPE_Float); } for (int i = 0; i < mat_EvalOutput->rows; i++) { CSG_Table_Record* tr_record = t_EvalOutput->Add_Record(); for (int j = 0; j < i_outputFeatureCount; j++) { float f_targetValue = mat_EvalOutput->data.fl[i*i_outputFeatureCount+j]; tr_record->Set_Value(j, f_targetValue); } } } else { // Fill the output table output for (int i = 0; i < i_outputFeatureCount; i++) { // TODO: Get the class name t_EvalOutput->Add_Field(CSG_String::Format(SG_T("CLASS_%d"), i), SG_DATATYPE_Float); } for (int i = 0; i < mat_EvalOutput->rows; i++) { CSG_Table_Record* tr_record = t_EvalOutput->Add_Record(); for (int j = 0; j < i_outputFeatureCount; j++) { float f_targetValue = mat_EvalOutput->data.fl[i*i_outputFeatureCount+j]; tr_record->Set_Value(j, f_targetValue); } } i_evalOut = 0; // Fill the output grid for(y=0, p.y=Get_YMin(); y<Get_NY() && Set_Progress(y); y++, p.y+=Get_Cellsize()) { for(x=0, p.x=Get_XMin(); x<Get_NX(); x++, p.x+=Get_Cellsize()) { for(i_Grid=0, b_NoData=false; i_Grid<gl_TrainInputs->Get_Count() && !b_NoData; i_Grid++) { // If there is one grid that has no data in this point p, then set the no data flag if( gl_TrainInputs->asGrid(i_Grid)->is_NoData(x, y) ) { b_NoData = true; } } if (!b_NoData) { // We have data in all grids, so this is a point that was predicted // Get the winner class for this point and set it to the output grid float f_targetValue = 0; for (int j = 0; j < i_outputFeatureCount; j++) { if (mat_EvalOutput->data.fl[i_evalOut*i_outputFeatureCount+j] > f_targetValue) { // The current value is higher than the last one, so lets memorize the current class f_targetValue = mat_EvalOutput->data.fl[i_evalOut*i_outputFeatureCount+j]; i_winner = j; } } // Now finally set the values to the grids g_EvalOutput->Set_Value(x, y, i_winner); g_EvalOutputCert->Set_Value(x, y, f_targetValue); i_evalOut++; } } } } return( true ); }
//--------------------------------------------------------- bool CSTL_Export::On_Execute(void) { bool bBinary; int zField; float v[3]; CSG_String File; CSG_File Stream; CSG_TIN *pTIN; pTIN = Parameters("TIN") ->asTIN(); File = Parameters("FILE") ->asString(); zField = Parameters("ZFIELD") ->asInt(); bBinary = Parameters("BINARY") ->asInt() == 1; if( !Stream.Open(File, SG_FILE_W, bBinary) ) { return( false ); } //----------------------------------------------------- if( bBinary ) { char *sHeader = (char *)SG_Calloc(80, sizeof(char)); DWORD nFacets = pTIN->Get_Triangle_Count(); WORD nBytes = 0; Stream.Write(sHeader , sizeof(char), 80); Stream.Write(&nFacets, sizeof(DWORD)); SG_Free(sHeader); //------------------------------------------------- for(int iTriangle=0; iTriangle<pTIN->Get_Triangle_Count(); iTriangle++) { CSG_TIN_Triangle *pTriangle = pTIN->Get_Triangle(iTriangle); Get_Normal(pTriangle, zField, v); Stream.Write(v, sizeof(float), 3); // facet normal for(int iNode=0; iNode<3; iNode++) { CSG_TIN_Node *pNode = pTriangle->Get_Node(iNode); v[0] = (float)pNode->Get_X(); v[1] = (float)pNode->Get_Y(); v[2] = (float)pNode->asDouble(zField); Stream.Write(v, sizeof(float), 3); } Stream.Write(&nBytes, sizeof(WORD)); } } //----------------------------------------------------- else // ASCII { Stream.Printf(SG_T("solid %s\n"), SG_File_Get_Name(File, false).c_str()); for(int iTriangle=0; iTriangle<pTIN->Get_Triangle_Count(); iTriangle++) { CSG_TIN_Triangle *pTriangle = pTIN->Get_Triangle(iTriangle); Get_Normal(pTriangle, zField, v); Stream.Printf(SG_T(" facet normal %.4f %.4f %.4f\n"), v[0], v[1], v[2]); Stream.Printf(SG_T(" outer loop\n")); for(int iNode=0; iNode<3; iNode++) { CSG_TIN_Node *pNode = pTriangle->Get_Node(iNode); v[0] = (float)pNode->Get_X(); v[1] = (float)pNode->Get_Y(); v[2] = (float)pNode->asDouble(zField); Stream.Printf(SG_T(" vertex %.4f %.4f %.4f\n"), v[0], v[1], v[2]); } Stream.Printf(SG_T(" endloop\n")); Stream.Printf(SG_T(" endfacet\n")); } Stream.Printf(SG_T("endsolid %s\n"), SG_File_Get_Name(File, false).c_str()); } return( true ); }
//--------------------------------------------------------- bool CGW_Multi_Regression_Grid::On_Execute(void) { int i; //----------------------------------------------------- CSG_Parameter_Grid_List *pPredictors = Parameters("PREDICTORS")->asGridList(); if( !Initialize(Parameters("POINTS")->asShapes(), Parameters("DEPENDENT")->asInt(), pPredictors) ) { Finalize(); return( false ); } //----------------------------------------------------- CSG_Grid Quality; m_dimModel = *Get_System(); if( Parameters("RESOLUTION")->asInt() == 1 && Parameters("RESOLUTION_VAL")->asDouble() > Get_Cellsize() ) { CSG_Rect r(Get_System()->Get_Extent()); r.Inflate(0.5 * Parameters("RESOLUTION_VAL")->asDouble(), false); m_dimModel.Assign(Parameters("RESOLUTION_VAL")->asDouble(), r); Quality.Create(m_dimModel); m_pQuality = &Quality; } else { m_pQuality = Parameters("QUALITY")->asGrid(); } //----------------------------------------------------- Process_Set_Text(_TL("upsetting model domain")); 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++) { if( m_dimModel.Get_Cellsize() > Get_Cellsize() ) // scaling { m_pPredictors[i] = SG_Create_Grid(m_dimModel); m_pPredictors[i] ->Assign(pPredictors->asGrid(i), GRID_INTERPOLATION_NearestNeighbour); // GRID_INTERPOLATION_Mean_Cells } else { m_pPredictors[i] = pPredictors->asGrid(i); } m_pModel [i] = SG_Create_Grid(m_dimModel); 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_dimModel); m_pModel[m_nPredictors] ->Set_Name(_TL("Intercept")); //----------------------------------------------------- Process_Set_Text(_TL("model creation")); bool bResult = Get_Model(); //----------------------------------------------------- if( m_dimModel.Get_Cellsize() > Get_Cellsize() ) // scaling { for(i=0; i<m_nPredictors; i++) { delete(m_pPredictors[i]); m_pPredictors[i] = pPredictors->asGrid(i); } } //----------------------------------------------------- if( bResult ) { Process_Set_Text(_TL("model application")); 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); Finalize(); return( bResult ); }
//--------------------------------------------------------- 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 ); }
//--------------------------------------------------------- bool CSG_Grid_Radius::Create(int maxRadius) { Destroy(); //----------------------------------------------------- if( maxRadius > 0 && maxRadius != m_maxRadius ) { int x, y, i, n; double d; m_maxRadius = maxRadius; m_nPoints_R = (int *)SG_Calloc(m_maxRadius + 1, sizeof(int)); for(y=-m_maxRadius; y<=m_maxRadius; y++) { for(x=-m_maxRadius; x<=m_maxRadius; x++) { if( (d = M_GET_LENGTH(x, y)) <= m_maxRadius ) { m_nPoints++; m_nPoints_R[(int)d]++; } } } //------------------------------------------------- if( m_nPoints > 0 ) { m_Points = (TSG_Grid_Radius *)SG_Calloc(m_nPoints , sizeof(TSG_Grid_Radius )); m_Points_R = (TSG_Grid_Radius **)SG_Calloc(m_maxRadius + 1, sizeof(TSG_Grid_Radius *)); for(i=0, n=0; i<=m_maxRadius; i++) { m_Points_R [i] = m_Points + n; n += m_nPoints_R[i]; m_nPoints_R[i] = 0; } //--------------------------------------------- for(y=-m_maxRadius; y<=m_maxRadius; y++) { for(x=-m_maxRadius; x<=m_maxRadius; x++) { if( (d = M_GET_LENGTH(x, y)) <= m_maxRadius ) { i = (int)d; n = m_nPoints_R[i]++; m_Points_R[i][n].x = x; m_Points_R[i][n].y = y; m_Points_R[i][n].d = d; } } } return( true ); } } //----------------------------------------------------- Destroy(); return( false ); }
//--------------------------------------------------------- bool CGW_Multi_Regression::On_Execute(void) { int i; //----------------------------------------------------- m_pPoints = Parameters("POINTS") ->asShapes(); m_iDependent = Parameters("DEPENDENT") ->asInt(); m_Radius = Parameters("RANGE") ->asInt() == 0 ? Parameters("RADIUS") ->asDouble() : 0.0; m_Mode = Parameters("MODE") ->asInt(); m_nPoints_Max = Parameters("NPOINTS") ->asInt() == 0 ? Parameters("MAXPOINTS")->asInt() : 0; m_nPoints_Min = Parameters("MINPOINTS") ->asInt(); m_Weighting.Set_Parameters(Parameters("WEIGHTING")->asParameters()); //----------------------------------------------------- if( !Get_Predictors() ) { Finalize(); return( false ); } if( (m_nPoints_Max > 0 || m_Radius > 0.0) && !m_Search.Create(m_pPoints, -1) ) { Finalize(); return( false ); } //----------------------------------------------------- m_pQuality = NULL; m_pIntercept = NULL; m_pSlopes = (CSG_Grid **)SG_Calloc(m_nPredictors, sizeof(CSG_Grid *)); switch( Parameters("TARGET")->asInt() ) { case 0: // user defined... if( m_Grid_Target.Init_User(m_pPoints->Get_Extent()) && Dlg_Parameters("USER") ) { m_pQuality = m_Grid_Target.Get_User(SG_T("QUALITY" )); m_pIntercept = m_Grid_Target.Get_User(SG_T("INTERCEPT")); for(i=0; i<m_nPredictors; i++) { m_pSlopes[i] = m_Grid_Target.Get_User(SG_Get_String(i, 0)); } } break; case 1: // grid... if( Dlg_Parameters("GRID") ) { m_pQuality = m_Grid_Target.Get_Grid(SG_T("QUALITY" )); m_pIntercept = m_Grid_Target.Get_Grid(SG_T("INTERCEPT")); for(i=0; i<m_nPredictors; i++) { m_pSlopes[i] = m_Grid_Target.Get_Grid(SG_Get_String(i, 0)); } } break; } if( m_pQuality == NULL ) { Finalize(); return( false ); } m_pQuality ->Set_Name(CSG_String::Format(SG_T("%s (%s)"), m_pPoints->Get_Name(), _TL("GWR Quality"))); m_pIntercept->Set_Name(CSG_String::Format(SG_T("%s (%s)"), m_pPoints->Get_Name(), _TL("GWR Intercept"))); for(i=0; i<m_nPredictors; i++) { m_pSlopes[i]->Set_Name(CSG_String::Format(SG_T("%s (%s)"), m_pPoints->Get_Name(), m_pPoints->Get_Field_Name(m_iPredictor[i]))); } //----------------------------------------------------- int nPoints_Max = m_nPoints_Max > 0 ? m_nPoints_Max : m_pPoints->Get_Count(); m_y.Create(1 + m_nPredictors, nPoints_Max); m_z.Create(nPoints_Max); m_w.Create(nPoints_Max); //----------------------------------------------------- for(int y=0; y<m_pIntercept->Get_NY() && Set_Progress(y, m_pIntercept->Get_NY()); y++) { for(int x=0; x<m_pIntercept->Get_NX(); x++) { if( !Get_Regression(x, y) ) { m_pQuality ->Set_NoData(x, y); m_pIntercept->Set_NoData(x, y); for(i=0; i<m_nPredictors; i++) { m_pSlopes[i]->Set_NoData(x, y); } } } } //----------------------------------------------------- Finalize(); return( true ); }