//--------------------------------------------------------- bool CExercise_10::On_Execute(void) { bool bAlive; int x, y, i; CSG_Colors Colors; //----------------------------------------------------- // General initialisations... m_pLife = Parameters("RESULT")->asGrid(); m_nColors = Parameters("COLORS")->asInt(); Colors.Set_Count(m_nColors + 1); Colors.Set_Ramp(SG_GET_RGB(127, 127, 127), SG_GET_RGB(0, 0, 0)); Colors.Set_Color(0, SG_GET_RGB(255, 255, 255)); DataObject_Set_Colors(m_pLife, Colors); //----------------------------------------------------- // Initialise life's world... if( Parameters("REFRESH")->asBool() ) { srand((unsigned)time(NULL)); for(y=0; y<Get_NY(); y++) { for(x=0; x<Get_NX(); x++) { m_pLife->Set_Value(x, y, rand() > RAND_MAX / 2 ? 0 : 1); } } } //----------------------------------------------------- // Execution... m_pTemp = SG_Create_Grid(m_pLife, SG_DATATYPE_Byte); for(i=1, bAlive=true; bAlive && Process_Get_Okay(true); i++) { Process_Set_Text(CSG_String::Format(SG_T("%d %s"), i, _TL("Life Cycle"))); if( (bAlive = Next_Step()) == false ) { Message_Add(CSG_String::Format(SG_T("%s %d %s\n"), _TL("Dead after"), i, _TL("Life Cycles"))); } } delete(m_pTemp); //----------------------------------------------------- // Finish... return( true ); }
//--------------------------------------------------------- bool CMine_Sweeper::MakeBoard(int level) { int i, x, y; CSG_Colors Colors; switch( level ) { case 0: Mine_NX = 8; Mine_NY = 8; N_Mines=10; break; case 1: Mine_NX = 16; Mine_NY = 16; N_Mines=40; break; case 2: Mine_NX = 30; Mine_NY = 16; N_Mines=99; break; } pInput = SG_Create_Grid(SG_DATATYPE_Int,SPRITE_SIZE*Mine_NX, SPRITE_SIZE*Mine_NY); pInput->Set_Name(_TL("Mine Sweeper")); Parameters("GRID")->Set_Value(pInput); //----------------------------------------------------- CSG_Parameter *pLUT = DataObject_Get_Parameter(pInput, "LUT"); if( pLUT && pLUT->asTable() ) { pLUT->asTable()->Del_Records(); for(i=0; i<16; i++) { CSG_Table_Record *pRecord = pLUT->asTable()->Add_Record(); pRecord->Set_Value(0, SG_GET_RGB(mine_res_color[i*3], mine_res_color[i*3+1], mine_res_color[i*3+2])); pRecord->Set_Value(3, i); } DataObject_Set_Parameter(pInput, pLUT); DataObject_Set_Parameter(pInput, "COLORS_TYPE", 1); // Color Classification Type: Lookup Table } Colors.Set_Count(16); for ( i=0;i<16; i++) { Colors.Set_Color(i, SG_GET_RGB(mine_res_color[i*3], mine_res_color[i*3+1], mine_res_color[i*3+2])); } DataObject_Set_Colors(pInput, Colors); DataObject_Update(pInput, 0.0, 15.0, true); //----------------------------------------------------- for( y = 0; y < Mine_NY; y++) for( x = 0; x < Mine_NX; x++) { SetSprite(x,y,SPRITE_CLOSE); } pInput->Set_Value(0, 0); return true; }
//--------------------------------------------------------- void CVisibility_BASE::Initialize(CSG_Grid *pVisibility, int iMethod) { CSG_Colors Colors; switch( iMethod ) { case 0: // Visibility pVisibility->Assign(0.0); Colors.Set_Count(2); Colors.Set_Ramp(SG_GET_RGB(0, 0, 0), SG_GET_RGB(255, 255, 255)); break; case 1: // Shade pVisibility->Assign(M_PI_090); pVisibility->Set_Unit(_TL("radians")); Colors.Set_Ramp(SG_GET_RGB(255, 255, 255), SG_GET_RGB(0, 0, 0)); break; case 2: // Distance pVisibility->Assign_NoData(); Colors.Set_Ramp(SG_GET_RGB(255, 255, 191), SG_GET_RGB(0, 95, 0)); break; case 3: // Size pVisibility->Assign_NoData(); pVisibility->Set_Unit(_TL("radians")); Colors.Set_Ramp(SG_GET_RGB(0, 95, 0), SG_GET_RGB(255, 255, 191)); break; } SG_UI_DataObject_Colors_Set(pVisibility, &Colors); return; }
//--------------------------------------------------------- int CDecision_Tree::Get_Class(CSG_Parameters *pDecision, CSG_Table *pTable) { CSG_String ID_Root = pDecision->Get_Identifier(); if( !ID_Root.Cmp(SG_T("ROOT")) ) ID_Root.Clear(); for(int Child=0; Child<=1; Child++) { CSG_String ID = ID_Root + (Child == 0 ? SG_T("A") : SG_T("B")); if( pDecision->Get_Parameter(ID + SG_T("|NODE"))->asBool() ) { Get_Class(pDecision->Get_Parameter(ID)->asParameters(), pTable); } else { CSG_Table_Record *pRecord = pTable->Add_Record(); pRecord->Set_Value(0, SG_GET_RGB(rand() * 255.0 / RAND_MAX, rand() * 255.0 / RAND_MAX, rand() * 255.0 / RAND_MAX)); pRecord->Set_Value(1, pDecision->Get_Parameter(ID + SG_T("|NAME"))->asString()); pRecord->Set_Value(2, pDecision->Get_Parameter(ID + SG_T("|NAME"))->asString()); pRecord->Set_Value(3, Get_Class(ID)); pRecord->Set_Value(4, Get_Class(ID)); } } return( pTable->Get_Count() ); }
//--------------------------------------------------------- inline void CGrid_3D_Image::_Draw_Pixel(int x, int y, double z, BYTE r, BYTE g, BYTE b) { if( m_pRGB->is_InGrid(x, y, false) && (m_pRGB_Z->is_NoData(x, y) || z > m_pRGB_Z->asDouble(x, y)) ) { m_pRGB_Z ->Set_Value(x, y, z); m_pRGB ->Set_Value(x, y, SG_GET_RGB(r, g, b)); } }
//--------------------------------------------------------- int CSG_3DView_Canvas::_Dim_Color(int Color, double dim) { if( dim <= 0.0 ) { return( 0 ); } if( dim != 1.0 ) { int r = (int)(dim * SG_GET_R(Color)); if( r > 255 ) r = 255; int g = (int)(dim * SG_GET_G(Color)); if( g > 255 ) g = 255; int b = (int)(dim * SG_GET_B(Color)); if( b > 255 ) b = 255; Color = SG_GET_RGB(r, g, b); } return( Color ); }
//--------------------------------------------------------- void CGrid_Cluster_Analysis::Save_LUT(CSG_Grid *pCluster) { CSG_Parameter *pLUT = DataObject_Get_Parameter(pCluster, "LUT"); if( pLUT && pLUT->asTable() ) { CSG_Parameter_Grid_List *pGrids = Parameters("GRIDS")->asGridList(); CSG_Table &Statistics = *Parameters("STATISTICS")->asTable(); bool bRGB = pGrids->Get_Count() >= 3 && Parameters("RGB_COLORS")->asBool(); for(int iCluster=0; iCluster<Statistics.Get_Count(); iCluster++) { CSG_Table_Record *pClass = pLUT->asTable()->Get_Record(iCluster); if( !pClass ) { (pClass = pLUT->asTable()->Add_Record())->Set_Value(0, SG_Color_Get_Random()); } pClass->Set_Value(1, CSG_String::Format("%s %d", _TL("Cluster"), iCluster + 1)); pClass->Set_Value(2, ""); pClass->Set_Value(3, iCluster + 1); pClass->Set_Value(4, iCluster + 1); if( bRGB ) { #define SET_COLOR_COMPONENT(c, i) c = (int)(127 + (Statistics[iCluster].asDouble(3 + i) - pGrids->asGrid(i)->Get_Mean()) * 127 / pGrids->asGrid(i)->Get_StdDev()); if( c < 0 ) c = 0; else if( c > 255 ) c = 255; int r; SET_COLOR_COMPONENT(r, 2); int g; SET_COLOR_COMPONENT(g, 1); int b; SET_COLOR_COMPONENT(b, 0); pClass->Set_Value(0, SG_GET_RGB(r, g, b)); } } pLUT->asTable()->Set_Record_Count(Statistics.Get_Count()); DataObject_Set_Parameter(pCluster, pLUT); DataObject_Set_Parameter(pCluster, "COLORS_TYPE", 1); // Color Classification Type: Lookup Table } }
//--------------------------------------------------------- void CSG_3DView_Canvas::_Draw_Box(void) { if( !m_bBox ) { return; } int color = SG_GET_RGB(SG_GET_R(m_bgColor) + 128, SG_GET_G(m_bgColor) + 128, SG_GET_B(m_bgColor) + 128); TSG_Point_Z p[2][4], Buffer; Buffer.x = 0.01 * (m_Data_Max.x - m_Data_Min.x); Buffer.y = 0.01 * (m_Data_Max.y - m_Data_Min.y); Buffer.z = 0.01 * (m_Data_Max.z - m_Data_Min.z); for(int i=0; i<2; i++) { p[i][0].x = m_Data_Min.x - Buffer.x; p[i][0].y = m_Data_Min.y - Buffer.y; p[i][1].x = m_Data_Max.x + Buffer.x; p[i][1].y = m_Data_Min.y - Buffer.y; p[i][2].x = m_Data_Max.x + Buffer.x; p[i][2].y = m_Data_Max.y + Buffer.y; p[i][3].x = m_Data_Min.x - Buffer.x; p[i][3].y = m_Data_Max.y + Buffer.y; p[i][0].z = p[i][1].z = p[i][2].z = p[i][3].z = i == 0 ? m_Data_Min.z - Buffer.z : m_Data_Max.z + Buffer.z; for(int j=0; j<4; j++) { m_Projector.Get_Projection(p[i][j]); } Draw_Line(p[i][0], p[i][1], color); Draw_Line(p[i][1], p[i][2], color); Draw_Line(p[i][2], p[i][3], color); Draw_Line(p[i][3], p[i][0], color); } Draw_Line(p[0][0], p[1][0], color); Draw_Line(p[0][1], p[1][1], color); Draw_Line(p[0][2], p[1][2], color); Draw_Line(p[0][3], p[1][3], color); }
//--------------------------------------------------------- bool CGrid_CVA::On_Execute(void) { //----------------------------------------------------- CSG_Parameter_Grid_List *pA = Parameters("A")->asGridList(); CSG_Parameter_Grid_List *pB = Parameters("B")->asGridList(); CSG_Parameter_Grid_List *pC = Parameters("C")->asGridList(); if( pA->Get_Grid_Count() != pB->Get_Grid_Count() ) { Error_Set(_TL("number of initial and final state grids differs")); return( false ); } if( pA->Get_Grid_Count() == 0 ) { Error_Set(_TL("no grids in list")); return( false ); } //----------------------------------------------------- int n = pA->Get_Grid_Count(); bool bAngle = Parameters("ANGLE")->asBool() && n == 2; bool bC_Out = Parameters("C_OUT")->asBool(); CSG_Grid *pDist = Parameters("DIST")->asGrid(); CSG_Grid *pDir = Parameters("DIR" )->asGrid(); //----------------------------------------------------- pC->Del_Items(); if( bC_Out ) { for(int i=0; i<n; i++) { CSG_Grid *pGrid = SG_Create_Grid(Get_System()); pGrid->Fmt_Name("%s %01d", _TL("Change Vector"), i + 1); pC->Add_Item(pGrid); } } //----------------------------------------------------- CSG_Parameter *pLUT; CSG_Colors Colors; Colors.Set_Count(100); Colors.Set_Ramp(SG_GET_RGB(255, 255, 255), SG_GET_RGB( 0, 127, 127), 0, Colors.Get_Count() / 2); Colors.Set_Ramp(SG_GET_RGB( 0, 127, 127), SG_GET_RGB(255, 0, 0), Colors.Get_Count() / 2, Colors.Get_Count()); DataObject_Set_Colors(pDist, Colors); if( (pLUT = DataObject_Get_Parameter(pDir, "LUT")) == NULL || pLUT->asTable() == NULL || bAngle ) { Colors.Set_Default(100); Colors.Set_Ramp_Brighness(255, 0, 0, Colors.Get_Count() / 2); Colors.Set_Ramp_Brighness( 0, 255, Colors.Get_Count() / 2, Colors.Get_Count()); DataObject_Set_Colors(pDir, Colors); DataObject_Set_Parameter(pDir, "COLORS_TYPE", 2); } else { pLUT->asTable()->Del_Records(); for(int i=0, nClasses=(int)pow(2.0, n); i<nClasses; i++) { CSG_String s; for(int j=0; j<n; j++) { s += i & (int)pow(2.0, j) ? '+' : '-'; } CSG_Table_Record *pClass = pLUT->asTable()->Add_Record(); pClass->Set_Value(1, s); pClass->Set_Value(3, i); pClass->Set_Value(4, i); } Colors.Set_Count(pLUT->asTable()->Get_Count()); Colors.Random(); for(int c=0; c<pLUT->asTable()->Get_Count(); c++) { pLUT->asTable()->Get_Record(c)->Set_Value(0, Colors.Get_Color(c)); } DataObject_Set_Parameter(pDir, pLUT); DataObject_Set_Parameter(pDir, "COLORS_TYPE", 1); // Color Classification Type: Lookup Table } //----------------------------------------------------- for(int y=0; y<Get_NY() && Set_Progress(y); y++) { #pragma omp parallel for for(int x=0; x<Get_NX(); x++) { bool bOkay; int i, j; double d; CSG_Vector v(n); for(i=0, bOkay=true; i<n && bOkay; i++) { if( pA->Get_Grid(i)->is_NoData(x, y) || pB->Get_Grid(i)->is_NoData(x, y) ) { bOkay = false; } else { v[i] = pB->Get_Grid(i)->asDouble(x, y) - pA->Get_Grid(i)->asDouble(x, y); } } //--------------------------------------------- if( bOkay ) { if( bAngle ) { d = atan2(v[0], v[1]); } else for(i=0, j=1, d=0.0; i<n; i++, j*=2) { if( v[i] >= 0.0 ) { d += j; } } pDist->Set_Value(x, y, v.Get_Length()); pDir ->Set_Value(x, y, d); for(i=0; i<n && bC_Out; i++) { pC->Get_Grid(i)->Set_Value(x, y, v[i]); } } //--------------------------------------------- else { pDist->Set_NoData(x, y); pDir ->Set_NoData(x, y); for(i=0; i<n && bC_Out; i++) { pC->Get_Grid(i)->Set_NoData(x, y); } } } } return( true ); }
bool CSHALSTAB::On_Execute(void) { double fCmin = Parameters("fCmin")->asDouble(); double fDmin = Parameters("fDmin")->asDouble(); double fEmin = Parameters("fEmin")->asDouble(); double fFmin = Parameters("fFmin")->asDouble(); double fJmin = Parameters("fJmin")->asDouble(); double fCmax = Parameters("fCmax")->asDouble(); double fDmax = Parameters("fDmax")->asDouble(); double fEmax = Parameters("fEmax")->asDouble(); double fFmax = Parameters("fFmax")->asDouble(); double fJmax = Parameters("fJmax")->asDouble(); double fK = Parameters("fK")->asInt(); double grav = 9.81; CSG_Grid *pA, *pB, *pCmin, *pDmin, *pEmin, *pFmin, *pG, *pH, *pJmin, *pCmax, *pDmax, *pEmax, *pFmax, *pJmax; pA = Parameters("A" )->asGrid(); //slope pB = Parameters("B" )->asGrid(); //flow accumulation pCmin = Parameters("Cmin" )->asGrid(); //density pDmin = Parameters("Dmin" )->asGrid(); //conductivity pEmin = Parameters("Emin" )->asGrid(); //depth pFmin = Parameters("Fmin" )->asGrid(); //friction pCmax = Parameters("Cmax" )->asGrid(); //density pDmax = Parameters("Dmax" )->asGrid(); //conductivity pEmax = Parameters("Emax" )->asGrid(); //depth pFmax = Parameters("Fmax" )->asGrid(); //friction pG = Parameters("G" )->asGrid(); //output critical recharge pH = Parameters("H" )->asGrid(); //optional output classified grid pJmin = Parameters("Jmin" )->asGrid(); //bulk cohesion pJmax = Parameters("Jmax" )->asGrid(); //bulk cohesion for(int y=0; y<Get_NY() && Set_Progress(y); y++) { #pragma omp parallel for for(int x=0; x<Get_NX(); x++) { double a, b, c, d, e, f, g, j, l; double cmin, dmin, emin, fmin, jmin; double cmax, dmax, emax, fmax, jmax; double cc, dd, ee, ff, jj; int cperc, dperc, eperc, fperc, jperc; int rand_int, k, n; a = pA->asDouble(x, y); b = pB->asDouble(x, y); //Abfrage ob Raster oder Globalwerte: cmin = pCmin ? pCmin->asDouble(x, y) : fCmin; dmin = pDmin ? pDmin->asDouble(x, y) : fDmin; emin = pEmin ? pEmin->asDouble(x, y) : fEmin; fmin = pFmin ? pFmin->asDouble(x, y) : fFmin; jmin = pJmin ? pJmin->asDouble(x, y) : fJmin; cmax = pCmax ? pCmax->asDouble(x, y) : fCmax; dmax = pDmax ? pDmax->asDouble(x, y) : fDmax; emax = pEmax ? pEmax->asDouble(x, y) : fEmax; fmax = pFmax ? pFmax->asDouble(x, y) : fFmax; jmax = pJmax ? pJmax->asDouble(x, y) : fJmax; k = fK; if (pA->is_NoData(x, y) || pB->is_NoData(x, y)) { pG->Set_NoData(x, y); if (pH) pH->Set_Value(x, y, CR_NODATA); } else if ((pCmin || pCmax || pDmin || pDmax || pEmin || pEmax || pFmin || pFmax || pJmin || pJmax) && (pCmin && pCmax->is_NoData(x, y) || pDmin && pDmax->is_NoData(x, y) || pEmin && pEmax->is_NoData(x, y) || pFmin && pFmax->is_NoData(x, y) || pJmin && pJmax->is_NoData(x, y))) { pG->Set_NoData(x, y); if (pH) pH->Set_Value(x, y, CR_NODATA); } else { cperc = ((cmax - cmin) / cmax) * 100; //calculate parameter range %: density if (cperc > 0) { n = 0; cc = 0; while ( n < k) //loop through specified random number iterations: { rand_int = rand() % cperc + 0; //calculate random percentage c = ((cmax/100) * rand_int) + cmin; //calculate value cc = cc + c; //sum n = n + 1; } c = cc / n; // calculate mean from random values } else { c = cmax; } dperc = ((dmax - dmin) / dmax) * 100; if (dperc > 0) { n = 0; dd = 0; while ( n < k) { rand_int = rand() % dperc + 0; d = ((dmax/100) * rand_int) + dmin; dd = dd + d; n = n + 1; } d = dd / n; } else { d = dmax; } eperc = ((emax - emin) / emax) * 100; if (eperc > 0) { n = 0; ee = 0; while ( n < k) { rand_int = rand() % eperc + 0; e = ((emax/100) * rand_int) + emin; ee = ee + e; n = n + 1; } e = ee / n; } else { e = emax; } fperc = ((fmax - fmin) / fmax) * 100; if (fperc > 0) { n = 0; ff = 0; while ( n < k) { rand_int = rand() % fperc + 0; f = ((fmax/100) * rand_int) + fmin; ff = ff + f; n = n + 1; } f = ff / n; } else { f = fmax; } jperc = ((jmax - jmin) / jmax) * 100; if (jperc > 0) { n = 0; jj = 0; while ( n < k) { rand_int = rand() % jperc + 0; j = ((jmax/100) * rand_int) + jmin; jj = jj + j; n = n + 1; } j = jj / n; } else { j = jmax; } l = j/((e/cos(a))*c*grav); //calculate dimensionless cohesion //g = ((((sin(a) * (d*24*e)) * c)/(b/pB->Get_Cellsize())) * (1-(tan(a)/tan(f/57.2958)))) *1000; //cohesionless SHALSTAB calculation g = ((((sin(a) * (d*24*e)) * c)/(b/pB->Get_Cellsize())) * (1-((sin(a) - l)/(cos(a)*tan(f/57.2958))))) *1000; //SHALSTAB calculation //if ((tan(a) > (tan(f/57.2958) * (1-(1/c))))) //general stability criterion if (tan(a) > ((tan(f/57.2958) * (1-(1/c)))+(j/cos(a)))) { if (g > 0) //critical recharge pG->Set_Value(x, y, g); else pG->Set_Value(x, y, 0); //unconditionally unstable = 0 } //else if (tan(a) <= (tan(f/57.2958) * (1-(1/c)))) else if (tan(a) <= ((tan(f/57.2958) * (1-(1/c)))+(l/cos(a)))) { pG->Set_NoData(x, y); //unconditionally stable = nodata } if (pH) //calculate optional classified grid { //if ((tan(a) > (tan(f/57.2958) * (1-(1/c))))) if (tan(a) > ((tan(f/57.2958) * (1-(1/c)))+(l/cos(a)))) { if (g <= 0) pH->Set_Value(x, y, CR_UNSTABLE); else if ((g > 0) && (g <= 50)) pH->Set_Value(x, y, CR_0_TO_50); else if ((g > 50) && (g <= 100)) pH->Set_Value(x, y, CR_50_TO_100); else if ((g > 100) && (g <= 200)) pH->Set_Value(x, y, CR_100_TO_200); else if ((g > 200) && (g <= 400)) pH->Set_Value(x, y, CR_200_TO_400); else if (g > 400) pH->Set_Value(x, y, CR_GR_400); } //else if (tan(a) <= (tan(f/57.2958) * (1-(1/c)))) else if (tan(a) <= ((tan(f/57.2958) * (1-(1/c)))+(l/cos(a)))) { pH->Set_Value(x, y, CR_STABLE); } } } } } //----------------------------------------------------- CSG_Parameters P; if( DataObject_Get_Parameters(pH, P) && P("COLORS_TYPE") && P("LUT") ) { int CR_Colors[CR_COUNT] = { SG_GET_RGB(255, 255, 255), // CR_NODATA SG_GET_RGB(255, 0, 0), // CR_UNSTAB SG_GET_RGB(255, 128, 64), // CR_0-50 SG_GET_RGB(255, 255, 0), // CR_50-100 SG_GET_RGB( 0, 255, 0), // CR_100-200 SG_GET_RGB(128, 255, 255), // CR_200-400 SG_GET_RGB( 0, 0, 255), // CR_>400 SG_GET_RGB(128, 128, 128), // CR_STABLE }; //------------------------------------------------- CSG_Strings Name, Desc; Name += _TL("No data"); Desc += _TL(""); Name += _TL("Uncond. unstable"); Desc += _TL(""); Name += _TL("0-50 mm/day"); Desc += _TL(""); Name += _TL("50-100 mm/day"); Desc += _TL(""); Name += _TL("100-200 mm/day"); Desc += _TL(""); Name += _TL("200-400 mm/day"); Desc += _TL(""); Name += _TL(">400 mm/day"); Desc += _TL(""); Name += _TL("Uncond. stable"); Desc += _TL(""); //------------------------------------------------- CSG_Table *pTable = P("LUT")->asTable(); pTable->Del_Records(); for(int i=0; i<CR_COUNT; i++) { CSG_Table_Record *pRecord = pTable->Add_Record(); pRecord->Set_Value(0, CR_Colors[i]); pRecord->Set_Value(1, Name[i].c_str()); pRecord->Set_Value(2, Desc[i].c_str()); pRecord->Set_Value(3, i); pRecord->Set_Value(4, i); } P("COLORS_TYPE")->Set_Value(1); // Color Classification Type: Lookup Table DataObject_Set_Parameters(pH, P); } return( true ); }
//--------------------------------------------------------- CGrid_Aspect_Slope_Map::~CGrid_Aspect_Slope_Map(void) {} /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- long LUT_COLOR[25] = { SG_GET_RGB(153, 153, 153), SG_GET_RGB(147, 166, 89), SG_GET_RGB(102, 153, 102), SG_GET_RGB(102, 153, 136), SG_GET_RGB( 89, 89, 166), SG_GET_RGB(128, 108, 147), SG_GET_RGB(166, 89, 89), SG_GET_RGB(166, 134, 89), SG_GET_RGB(166, 166, 89), SG_GET_RGB(172, 217, 38), SG_GET_RGB( 77, 179, 77), SG_GET_RGB( 73, 182, 146), SG_GET_RGB( 51, 51, 204), SG_GET_RGB(128, 89, 166), SG_GET_RGB(217, 38, 38), SG_GET_RGB(217, 142, 38),
//--------------------------------------------------------- CWKSP_Map_Graticule::CWKSP_Map_Graticule(CSG_MetaData *pEntry) { m_bShow = true; //----------------------------------------------------- CSG_Parameter *pNode, *pNode_1; m_Parameters.Set_Name ("GRATICULE"); m_Parameters.Set_Identifier("GRATICULE"); //----------------------------------------------------- pNode = m_Parameters.Add_Node(NULL, "NODE_GENERAL" ,_TL("General") , _TL("")); m_Parameters.Add_String( pNode , "NAME" , _TL("Name"), _TL(""), _TL("Graticule") ); pNode_1 = m_Parameters.Add_Choice( pNode , "INTERVAL" , _TL("Interval"), _TL(""), CSG_String::Format(SG_T("%s|%s|"), _TL("fixed interval"), _TL("fitted interval") ), 1 ); m_Parameters.Add_Value( pNode_1 , "FIXED" , _TL("Fixed Interval (Degree)"), _TL(""), PARAMETER_TYPE_Double, 5.0, 0.0, true, 20.0 ); m_Parameters.Add_Value( pNode_1 , "FITTED" , _TL("Number of Intervals"), _TL(""), PARAMETER_TYPE_Int, 5, 1, true ); m_Parameters.Add_Value( pNode , "RESOLUTION" , _TL("Minimum Resolution (Degree)"), _TL(""), PARAMETER_TYPE_Double, 0.5, 0.0, true ); //----------------------------------------------------- pNode_1 = m_Parameters.Add_Value( pNode , "SHOW_ALWAYS" , _TL("Show at all scales"), _TL(""), PARAMETER_TYPE_Bool, true ); m_Parameters.Add_Range( pNode_1 , "SHOW_RANGE" , _TL("Scale Range"), _TL("only show within scale range; values are given as extent measured in map units"), 100.0, 1000.0, 0.0, true ); //----------------------------------------------------- pNode = m_Parameters.Add_Node(NULL, "NODE_DISPLAY" ,_TL("Display") , _TL("")); m_Parameters.Add_Value( pNode , "COLOR" , _TL("Color"), _TL(""), PARAMETER_TYPE_Color, SG_COLOR_GREY ); m_Parameters.Add_Value( pNode , "SIZE" , _TL("Size"), _TL(""), PARAMETER_TYPE_Int, 0, 0, true ); m_Parameters.Add_Value( pNode , "TRANSPARENCY", _TL("Transparency [%]"), _TL(""), PARAMETER_TYPE_Double, 0.0, 0.0, true, 100.0, true ); m_Parameters.Add_Choice( pNode , "LINE_STYLE" , _TL("Line Style"), _TL(""), CSG_String::Format(SG_T("%s|%s|%s|%s|%s|%s|%s|%s|%s|%s|%s|"), _TL("Solid style"), _TL("Dotted style"), _TL("Long dashed style"), _TL("Short dashed style"), _TL("Dot and dash style"), _TL("Backward diagonal hatch"), _TL("Cross-diagonal hatch"), _TL("Forward diagonal hatch"), _TL("Cross hatch"), _TL("Horizontal hatch"), _TL("Vertical hatch") // _TL("Use the stipple bitmap") // _TL("Use the user dashes") // _TL("No pen is used") ), 4 ); //----------------------------------------------------- pNode_1 = m_Parameters.Add_Value( pNode , "LABEL" , _TL("Label"), _TL(""), PARAMETER_TYPE_Bool, true ); m_Parameters.Add_Font( pNode_1 , "LABEL_FONT" , _TL("Font"), _TL("") ); m_Parameters.Add_Value( pNode_1 , "LABEL_SIZE" , _TL("Size"), _TL("Font size given as percentage of map size."), PARAMETER_TYPE_Double, 2, 0.0, true, 10.0, true ); m_Parameters.Add_Choice( pNode_1 , "LABEL_EFFECT", _TL("Boundary Effect"), _TL(""), CSG_String::Format(SG_T("%s|%s|%s|%s|%s|%s|%s|%s|%s|%s|"), _TL("none"), _TL("full frame"), _TL("top"), _TL("top left"), _TL("left"), _TL("bottom left"), _TL("bottom"), _TL("bottom right"), _TL("right"), _TL("top right") ), 1 ); m_Parameters.Add_Value( pNode_1 , "LABEL_EFFCOL", _TL("Boundary Effect Color"), _TL(""), PARAMETER_TYPE_Color, SG_GET_RGB(255, 255, 255) ); //----------------------------------------------------- if( pEntry ) { Load(*pEntry); } }
//--------------------------------------------------------- bool CGrid_Classify_Supervised::Set_Classification(CSG_Classifier_Supervised &Classifier) { //----------------------------------------------------- CSG_Grid *pClasses = Parameters("CLASSES")->asGrid(); //----------------------------------------------------- CSG_Parameter *pLUT = DataObject_Get_Parameter(pClasses, "LUT"); if( pLUT && pLUT->asTable() ) { CSG_Parameter_Grid_List *pGrids = Parameters("GRIDS")->asGridList(); bool bRGB = pGrids->Get_Count() >= 3 && Parameters("RGB_COLORS")->asBool(); for(int iClass=0; iClass<Classifier.Get_Class_Count(); iClass++) { CSG_Table_Record *pClass = pLUT->asTable()->Get_Record(iClass); if( !pClass ) { (pClass = pLUT->asTable()->Add_Record())->Set_Value(0, SG_Color_Get_Random()); } pClass->Set_Value(1, Classifier.Get_Class_ID(iClass).c_str()); pClass->Set_Value(2, ""); pClass->Set_Value(3, iClass + 1); pClass->Set_Value(4, iClass + 1); if( bRGB ) { #define SET_COLOR_COMPONENT(c, i) c = (int)(127 + (Classifier.Get_Class_Mean(iClass, i) - pGrids->asGrid(i)->Get_Mean()) * 127 / pGrids->asGrid(i)->Get_StdDev()); if( c < 0 ) c = 0; else if( c > 255 ) c = 255; int r; SET_COLOR_COMPONENT(r, 2); int g; SET_COLOR_COMPONENT(g, 1); int b; SET_COLOR_COMPONENT(b, 0); pClass->Set_Value(0, SG_GET_RGB(r, g, b)); } } pLUT->asTable()->Set_Record_Count(Classifier.Get_Class_Count()); DataObject_Set_Parameter(pClasses, pLUT); DataObject_Set_Parameter(pClasses, "COLORS_TYPE", 1); // Color Classification Type: Lookup Table } pClasses->Set_Name(CSG_String::Format("%s [%s]", _TL("Classification"), CSG_Classifier_Supervised::Get_Name_of_Method(Parameters("METHOD")->asInt()).c_str())); //----------------------------------------------------- CSG_Grid *pQuality = Parameters("QUALITY")->asGrid(); if( pQuality ) { DataObject_Set_Colors(pQuality, 11, SG_COLORS_YELLOW_GREEN); pQuality->Set_Name(CSG_String::Format("%s [%s]", _TL("Classification Quality"), CSG_Classifier_Supervised::Get_Name_of_Quality(Parameters("METHOD")->asInt()).c_str())); } //----------------------------------------------------- return( true ); }
//--------------------------------------------------------- void CWKSP_Shapes_Point::On_Create_Parameters(void) { CWKSP_Shapes::On_Create_Parameters(); BrushList_Add( m_Parameters("NODE_DISPLAY") , "DISPLAY_BRUSH" , _TL("Fill Style"), _TL("") ); m_Parameters.Add_Value( m_Parameters("NODE_DISPLAY") , "OUTLINE" , _TL("Outline"), _TL(""), PARAMETER_TYPE_Bool, true ); m_Parameters.Add_Value( m_Parameters("OUTLINE") , "OUTLINE_COLOR" , _TL("Color"), _TL(""), PARAMETER_TYPE_Color, SG_GET_RGB(0, 0, 0) ); m_Parameters.Add_Value( m_Parameters("OUTLINE") , "OUTLINE_SIZE" , _TL("Size"), _TL(""), PARAMETER_TYPE_Int, 0, 0, true ); m_Parameters.Add_Choice( m_Parameters("NODE_DISPLAY") , "DISPLAY_SYMBOL_TYPE" , _TL("Symbol Type"), _TL(""), CSG_String::Format(SG_T("%s|%s|%s|%s|%s|%s|%s|%s|%s|%s|%s|%s|%s|%s|"), _TL("circle"), _TL("square"), _TL("rhombus"), _TL("triangle (up)"), _TL("triangle (down)"), _TL("circle with square"), _TL("circle with rhombus"), _TL("circle with triangle (up)"), _TL("circle with triangle (down)"), _TL("circle in square"), _TL("circle in rhombus"), _TL("circle in triangle (up)"), _TL("circle in triangle (down)"), _TL("image") ), 0 ); m_Parameters.Add_FilePath( m_Parameters("DISPLAY_SYMBOL_TYPE") , "DISPLAY_SYMBOL_IMAGE" , _TL("Symbol Image"), _TL(""), CSG_String::Format( SG_T("%s|*.bmp;*.ico;*.gif;*.jpg;*.jif;*.jpeg;*.pcx;*.png;*.pnm;*.tif;*.tiff;*.xpm|") SG_T("%s (*.bmp)|*.bmp|") SG_T("%s (*.jpg)|*.jpg;*.jif;*.jpeg|") SG_T("%s (*.png)|*.png|") SG_T("%s (*.pcx)|*.pcx|") SG_T("%s (*.xpm)|*.xpm|") SG_T("%s (*.tif)|*.tif;*.tiff|") SG_T("%s (*.gif)|*.gif|") SG_T("%s|*.*"), _TL("Image Files"), _TL("Windows or OS/2 Bitmap"), _TL("JPEG - JFIF Compliant"), _TL("Portable Network Graphics"), _TL("Zsoft Paintbrush"), _TL("X11 Pixel Map"), _TL("Tagged Image File Format"), _TL("CompuServe Graphics Interchange"), _TL("All Files") ) ); //----------------------------------------------------- // Label... AttributeList_Add( m_Parameters("LABEL_ATTRIB") , "LABEL_ANGLE_ATTRIB" , _TL("Rotation by Attribute"), _TL("") ); m_Parameters.Add_Value( m_Parameters("LABEL_ANGLE_ATTRIB"), "LABEL_ANGLE" , _TL("Default Rotation"), _TL("rotation clockwise in degree"), PARAMETER_TYPE_Double, 0.0, -360.0, true, 360.0, true ); m_Parameters.Add_Choice( m_Parameters("LABEL_ATTRIB") , "LABEL_ALIGN_X" , _TL("Horizontal Align"), _TL(""), CSG_String::Format(SG_T("%s|%s|%s|"), _TL("left"), _TL("center"), _TL("right") ), 1 ); m_Parameters.Add_Choice( m_Parameters("LABEL_ATTRIB") , "LABEL_ALIGN_Y" , _TL("Vertical Align"), _TL(""), CSG_String::Format(SG_T("%s|%s|%s|"), _TL("top"), _TL("center"), _TL("bottom") ), 0 ); //----------------------------------------------------- // Size... m_Parameters.Add_Choice( m_Parameters("NODE_SIZE") , "SIZE_TYPE" , _TL("Size relates to..."), _TL(""), CSG_String::Format(SG_T("%s|%s|"), _TL("Screen"), _TL("Map Units") ), 0 ); AttributeList_Add( m_Parameters("NODE_SIZE") , "SIZE_ATTRIB" , _TL("Attribute"), _TL("") ); m_Parameters.Add_Choice( m_Parameters("SIZE_ATTRIB") , "SIZE_SCALE" , _TL("Attribute Values"), _TL(""), CSG_String::Format(SG_T("%s|%s|"), _TL("no scaling"), _TL("scale to size range") ), 1 ); m_Parameters.Add_Range( m_Parameters("SIZE_ATTRIB") , "SIZE_RANGE" , _TL("Size Range"), _TL(""), 2, 10, 0, true ); m_Parameters.Add_Value( m_Parameters("SIZE_ATTRIB") , "SIZE_DEFAULT" , _TL("Default Size"), _TL(""), PARAMETER_TYPE_Double, 5, 0, true ); //----------------------------------------------------- // Edit... m_Parameters.Add_Value( m_Parameters("NODE_SELECTION") , "SEL_COLOR_FILL" , _TL("Fill Color"), _TL(""), PARAMETER_TYPE_Color, SG_GET_RGB(255, 255, 0) ); }
//--------------------------------------------------------- bool CPC_Cluster_Analysis::On_Execute(void) { int nCluster; long nElements; double SP; CSG_Parameters Parms; m_bUpdateView = false; //----------------------------------------------------- nCluster = Parameters("NCLUSTER")->asInt(); pInput = Parameters("PC_IN") ->asPointCloud(); pResult = Parameters("PC_OUT") ->asPointCloud(); if( SG_UI_Get_Window_Main() ) m_bUpdateView = Parameters("UPDATEVIEW")->asBool(); //------------------------------------------------- m_Features = (int *)Parameters("FIELDS")->asPointer(); m_nFeatures = Parameters("FIELDS")->asInt (); if( !m_Features || m_nFeatures <= 0 ) { Error_Set(_TL("no features in selection")); return( false ); } //----------------------------------------------------- pResult->Create(pInput); pResult->Set_Name(CSG_String::Format(SG_T("%s_cluster"), pInput->Get_Name())); pResult->Add_Field(SG_T("CLUSTER"), SG_DATATYPE_Int); DataObject_Update(pResult); pResult->Set_NoData_Value(-1.0); clustField = pResult->Get_Field_Count() - 1; //----------------------------------------------------- Process_Set_Text(_TL("Initializing ...")); for( int i=0; i<m_nFeatures; i++ ) vValues.push_back( std::vector<double>() ); for( int i=0; i<pInput->Get_Record_Count() && SG_UI_Process_Set_Progress(i, pInput->Get_Record_Count()); i++ ) { pResult->Add_Point(pInput->Get_X(i), pInput->Get_Y(i), pInput->Get_Z(i)); for( int j=0; j<pInput->Get_Attribute_Count(); j++ ) pResult->Set_Attribute(i, j, pInput->Get_Attribute(i, j)); pResult->Set_NoData(i, clustField); bool bNoData = false; for( int j=0; j<m_nFeatures; j++) { if( pInput->is_NoData(i, m_Features[j]) ) { bNoData = true; break; } } if( !bNoData ) { for( int j=0; j<m_nFeatures; j++ ) { if( Parameters("NORMALISE")->asBool() ) vValues.at(j).push_back( (pInput->Get_Value(i, m_Features[j]) - pInput->Get_Mean(m_Features[j])) / pInput->Get_StdDev(m_Features[j]) ); else vValues.at(j).push_back(pInput->Get_Value(i, m_Features[j])); } } else { for( int j=0; j<m_nFeatures; j++ ) { vValues.at(j).push_back(pInput->Get_NoData_Value()); } } } if( m_bUpdateView ) { if( DataObject_Get_Parameters(pResult, Parms) && Parms("COLORS_TYPE") && Parms("METRIC_ATTRIB") && Parms("METRIC_COLORS") && Parms("METRIC_ZRANGE") ) { Parms("COLORS_TYPE") ->Set_Value(2); // graduated color Parms("METRIC_COLORS")->asColors() ->Set_Count(nCluster); Parms("METRIC_ATTRIB") ->Set_Value(clustField); Parms("METRIC_ZRANGE")->asRange() ->Set_Range(0, nCluster); } DataObject_Set_Parameters(pResult, Parms); DataObject_Update(pResult, SG_UI_DATAOBJECT_SHOW_LAST_MAP); } nMembers = (int *)SG_Malloc(nCluster * sizeof(int)); Variances = (double *)SG_Malloc(nCluster * sizeof(double)); Centroids = (double **)SG_Malloc(nCluster * sizeof(double *)); for( int i=0; i<nCluster; i++ ) { Centroids[i] = (double *)SG_Malloc(m_nFeatures * sizeof(double)); } //------------------------------------------------- nElements = pInput->Get_Point_Count(); switch( Parameters("METHOD")->asInt() ) { case 0: SP = MinimumDistance (nElements, nCluster); break; case 1: SP = HillClimbing (nElements, nCluster); break; case 2: SP = MinimumDistance (nElements, nCluster); nElements = pInput->Get_Point_Count(); // may have been diminished because of no data values... SP = HillClimbing (nElements, nCluster); break; } //------------------------------------------------- if( Parameters("NORMALISE")->asBool() ) { int iv = 0; for( int i=0; i<m_nFeatures; i++ ) { for( int j=0; j<nCluster; j++ ) { Centroids[j][iv] = sqrt(pInput->Get_Variance(m_Features[i])) * Centroids[j][iv] + pInput->Get_Mean(m_Features[i]); } iv++; } } Write_Result(Parameters("STATISTICS")->asTable(), nElements, nCluster, SP); //------------------------------------------------- if( DataObject_Get_Parameters(pResult, Parms) && Parms("COLORS_TYPE") && Parms("LUT") && Parms("LUT_ATTRIB") ) { CSG_Table_Record *pClass; CSG_Table *pLUT = Parms("LUT")->asTable(); for( int i=0; i<nCluster; i++ ) { if( (pClass = pLUT->Get_Record(i)) == NULL ) { pClass = pLUT->Add_Record(); pClass->Set_Value(0, SG_GET_RGB(rand() * 255.0 / RAND_MAX, rand() * 255.0 / RAND_MAX, rand() * 255.0 / RAND_MAX)); } pClass->Set_Value(1, CSG_String::Format(SG_T("%s %d"), _TL("Class"), i)); pClass->Set_Value(2, CSG_String::Format(SG_T("%s %d"), _TL("Class"), i)); pClass->Set_Value(3, i); pClass->Set_Value(4, i); } while( pLUT->Get_Record_Count() > nCluster ) { pLUT->Del_Record(pLUT->Get_Record_Count() - 1); } Parms("COLORS_TYPE") ->Set_Value(1); // Color Classification Type: Lookup Table Parms("LUT_ATTRIB") ->Set_Value(clustField); DataObject_Set_Parameters(pResult, Parms); } //------------------------------------------------- for( int i=0; i<nCluster; i++ ) { SG_Free(Centroids[i]); } SG_Free(Centroids); SG_Free(Variances); SG_Free(nMembers); vValues.clear(); return( true ); }
//--------------------------------------------------------- int Get_Color_asInt(wxColour Color) { return( SG_GET_RGB(Color.Red(), Color.Green(), Color.Blue()) ); }
//--------------------------------------------------------- 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() ) { cntInvalid++; continue; } } pPoints->Add_Point(point.GetX(), point.GetY(), point.GetZ()); if( iField[VAR_T] > 0 ) pPoints->Set_Value(iPoint, iField[VAR_T], point.GetTime()); if( iField[VAR_i] > 0 ) pPoints->Set_Value(iPoint, iField[VAR_i], point.GetIntensity()); if( iField[VAR_a] > 0 ) pPoints->Set_Value(iPoint, iField[VAR_a], point.GetScanAngleRank()); if( iField[VAR_r] > 0 ) pPoints->Set_Value(iPoint, iField[VAR_r], point.GetReturnNumber()); if( iField[VAR_c] > 0 ) pPoints->Set_Value(iPoint, iField[VAR_c], point.GetClassification()); if( iField[VAR_u] > 0 ) pPoints->Set_Value(iPoint, iField[VAR_u], point.GetUserData()); if( iField[VAR_n] > 0 ) pPoints->Set_Value(iPoint, iField[VAR_n], point.GetNumberOfReturns()); if( iField[VAR_R] > 0 ) pPoints->Set_Value(iPoint, iField[VAR_R], point.GetColor().GetRed()); if( iField[VAR_G] > 0 ) pPoints->Set_Value(iPoint, iField[VAR_G], point.GetColor().GetGreen()); if( iField[VAR_B] > 0 ) pPoints->Set_Value(iPoint, iField[VAR_B], point.GetColor().GetBlue()); if( iField[VAR_e] > 0 ) pPoints->Set_Value(iPoint, iField[VAR_e], point.GetFlightLineEdge()); if( iField[VAR_d] > 0 ) pPoints->Set_Value(iPoint, iField[VAR_d], point.GetScanDirection()); if( iField[VAR_p] > 0 ) pPoints->Set_Value(iPoint, iField[VAR_p], point.GetPointSourceID()); if( iField[VAR_C] > 0 ) { double r, g, b; r = point.GetColor().GetRed(); g = point.GetColor().GetGreen(); b = point.GetColor().GetBlue(); if (RGBrange == 0) // 16 bit { r = r / 65535 * 255; g = g / 65535 * 255; b = b / 65535 * 255; } pPoints->Set_Value(iPoint, iField[VAR_C], SG_GET_RGB(r, g, b)); } iPoint++; } } catch(std::exception &e) { SG_UI_Msg_Add_Error(CSG_String::Format(_TL("LAS reader exception: %s"), e.what())); ifs.close(); return( false ); } catch(...) { SG_UI_Msg_Add_Error(CSG_String::Format(_TL("Unknown LAS reader exception!"))); ifs.close(); return( false ); } ifs.close(); pPointsList->Add_Item(pPoints); DataObject_Add(pPoints); //----------------------------------------------------- CSG_Parameters sParms; DataObject_Get_Parameters(pPoints, sParms); if (sParms("METRIC_ATTRIB") && sParms("COLORS_TYPE") && sParms("METRIC_COLORS") && sParms("METRIC_ZRANGE") && sParms("DISPLAY_VALUE_AGGREGATE")) { sParms("DISPLAY_VALUE_AGGREGATE")->Set_Value(3); // highest z sParms("COLORS_TYPE")->Set_Value(2); // graduated color sParms("METRIC_COLORS")->asColors()->Set_Count(255); // number of colors sParms("METRIC_ATTRIB")->Set_Value(2); // z attrib sParms("METRIC_ZRANGE")->asRange()->Set_Range(pPoints->Get_Minimum(2),pPoints->Get_Maximum(2)); } DataObject_Set_Parameters(pPoints, sParms); SG_UI_Msg_Add(_TL("okay"), false); } //----------------------------------------------------- if( bValidity && cntInvalid > 0 ) SG_UI_Msg_Add(CSG_String::Format(_TL("WARNING: %d invalid points skipped!"), cntInvalid), true); return( true ); }
struct SClass { int ID, Color; CSG_String Name; int nPoints; double Sand[8], Clay[8]; }; //--------------------------------------------------------- const struct SClass Classes[12] = { { 1, SG_GET_RGB(000, 000, 255), _TL("Clay"), 6, { 0, 0, 20, 45, 45, 0 }, { 100, 60, 40, 40, 55, 100 } }, { 2, SG_GET_RGB(000, 200, 255), _TL("Silty Clay"), 4, { 0, 0, 20, 0 }, { 100, 60, 40, 40 } }, { 3, SG_GET_RGB(000, 200, 200), _TL("Silty Clay-Loam"), 5, { 0, 0, 20, 20, 0 }, { 40, 27, 27, 40, 40 } }, { 4, SG_GET_RGB(200, 000, 255), _TL("Sandy Clay"), 4, { 45, 45, 65, 45 }, { 55, 35, 35, 55 } }, {
//--------------------------------------------------------- bool CSADO_SolarRadiation::Initialise(void) { int x, y; Process_Set_Text(_TL("initialising...")); //----------------------------------------------------- CSG_Colors c(100, SG_COLORS_YELLOW_RED, true); c.Set_Ramp(SG_GET_RGB( 0, 0, 64), SG_GET_RGB(255, 159, 0), 0, 50); c.Set_Ramp(SG_GET_RGB(255, 159, 0), SG_GET_RGB(255, 255, 255), 50, 99); if( m_pSumDirect ) { m_pSumDirect->Assign(0.0); m_pSumDirect->Set_Unit(_TL("Joule")); DataObject_Set_Colors(m_pSumDirect, c); if( m_bUpdateDirect ) { m_TmpDirect.Create(*Get_System(), SG_DATATYPE_Float); DataObject_Update(m_pSumDirect, true); } } if( m_pSumDiffus ) { m_pSumDiffus->Assign(0.0); m_pSumDiffus->Set_Unit(_TL("Joule")); DataObject_Set_Colors(m_pSumDiffus, c); if( m_bUpdateDiffus ) { m_TmpDiffus.Create(*Get_System(), SG_DATATYPE_Float); DataObject_Update(m_pSumDiffus, true); } } if( m_pSumTotal ) { m_pSumTotal ->Assign(0.0); m_pSumTotal ->Set_Unit(_TL("Joule")); DataObject_Set_Colors(m_pSumTotal , c); if( m_bUpdateTotal ) { m_TmpTotal.Create(*Get_System(), SG_DATATYPE_Float); DataObject_Update(m_pSumTotal , true); } } //----------------------------------------------------- Process_Set_Text(_TL("initialising gradient...")); m_Shade .Create(*Get_System(), SG_DATATYPE_Byte); m_Slope .Create(*Get_System(), SG_DATATYPE_Float); m_Aspect.Create(*Get_System(), SG_DATATYPE_Float); for(y=0; y<Get_NY() && Set_Progress(y); y++) { for(x=0; x<Get_NX(); x++) { double s, a; if( m_pDEM->Get_Gradient(x, y, s, a) ) { m_Slope .Set_Value(x, y, s); m_Aspect.Set_Value(x, y, a); } else { m_Slope .Set_NoData(x, y); m_Aspect.Set_NoData(x, y); } } } //----------------------------------------------------- if( m_bBending ) { Process_Set_Text(_TL("initialising planetary bending...")); CSG_Grid *pLat = Parameters("GRD_LAT")->asGrid(), *pLon = Parameters("GRD_LON")->asGrid(); m_Lat .Create(*Get_System(), SG_DATATYPE_Float); m_Lon .Create(*Get_System(), SG_DATATYPE_Float); m_Decline .Create(*Get_System(), SG_DATATYPE_Float); m_Azimuth .Create(*Get_System(), SG_DATATYPE_Float); if( pLat || pLon ) { if( pLat ) { m_Lat = *pLat; m_Lat *= M_DEG_TO_RAD; } if( pLon ) { m_Lon = *pLon; m_Lon *= M_DEG_TO_RAD; } } //------------------------------------------------- else { double d, dx, dy, dxA, dyA; d = M_DEG_TO_RAD / (Parameters("RADIUS")->asDouble() * M_PI / 180.0); switch( Parameters("LON_OFFSET")->asInt() ) { case 0: dxA = Get_System()->Get_Extent().Get_XMin(); break; // left case 1: dxA = Get_System()->Get_Extent().Get_XCenter(); break; // center case 2: dxA = Get_System()->Get_Extent().Get_XMax(); break; // right case 3: dxA = Parameters("LON_REF_USER")->asDouble(); break; // user defined coordinate } switch( Parameters("LAT_OFFSET")->asInt() ) { case 0: dyA = Get_System()->Get_Extent().Get_YMin(); break; // bottom case 1: dyA = Get_System()->Get_Extent().Get_YCenter(); break; // center case 2: dyA = Get_System()->Get_Extent().Get_YMax(); break; // top case 3: dyA = Parameters("LAT_REF_USER")->asDouble(); break; // user defined coordinate } dxA = d * (Get_XMin() - dxA); dyA = d * (Get_YMin() - dyA) + m_Latitude; d *= Get_Cellsize(); for(y=0, dy=dyA; y<Get_NY() && Set_Progress(y); y++, dy+=d) { for(x=0, dx=dxA; x<Get_NX(); x++, dx+=d) { m_Lat.Set_Value(x, y, dy); m_Lon.Set_Value(x, y, dx); } } } } //----------------------------------------------------- return( true ); }
//--------------------------------------------------------- bool CGrid_Import::On_Execute(void) { bool bTransform; int x, y, yy, Method; double ax, ay, dx, dy, rx, ry, xMin, yMin, Cellsize; CSG_Colors Colors; CSG_String fImage, fWorld, Name; CSG_Grid *pImage; CSG_File Stream; wxImage Image; wxImageHistogram Histogram; //----------------------------------------------------- fImage = Parameters("FILE") ->asString(); Method = Parameters("METHOD") ->asInt(); Name = SG_File_Get_Name(fImage, false); //----------------------------------------------------- wxImageHandler *pImgHandler = NULL; if( !SG_UI_Get_Window_Main() ) { CSG_String fName = SG_File_Get_Name(fImage, true); if( SG_File_Cmp_Extension(fName, SG_T("jpg")) ) pImgHandler = new wxJPEGHandler; else if( SG_File_Cmp_Extension(fName, SG_T("pcx")) ) pImgHandler = new wxPCXHandler; else if( SG_File_Cmp_Extension(fName, SG_T("tif")) ) pImgHandler = new wxTIFFHandler; else if( SG_File_Cmp_Extension(fName, SG_T("gif")) ) pImgHandler = new wxGIFHandler; else if( SG_File_Cmp_Extension(fName, SG_T("pnm")) ) pImgHandler = new wxPNMHandler; else if( SG_File_Cmp_Extension(fName, SG_T("xpm")) ) pImgHandler = new wxXPMHandler; #ifdef _SAGA_MSW else if( SG_File_Cmp_Extension(fName, SG_T("bmp")) ) pImgHandler = new wxBMPHandler; #endif else // if( SG_File_Cmp_Extension(fName, SG_T("png")) ) pImgHandler = new wxPNGHandler; wxImage::AddHandler(pImgHandler); } if( !Image.LoadFile(fImage.c_str()) ) { return( false ); } //----------------------------------------------------- if( SG_File_Cmp_Extension(fImage, SG_T("bmp")) ) { fWorld = SG_File_Make_Path(NULL, fImage, SG_T("bpw")); } else if( SG_File_Cmp_Extension(fImage, SG_T("jpg")) ) { fWorld = SG_File_Make_Path(NULL, fImage, SG_T("jgw")); } else if( SG_File_Cmp_Extension(fImage, SG_T("png")) ) { fWorld = SG_File_Make_Path(NULL, fImage, SG_T("pgw")); } else if( SG_File_Cmp_Extension(fImage, SG_T("tif")) ) { fWorld = SG_File_Make_Path(NULL, fImage, SG_T("tfw")); } else { fWorld = SG_File_Make_Path(NULL, fImage, SG_T("world")); } bTransform = false; xMin = 0.0; yMin = 0.0; Cellsize = 1.0; if( Stream.Open(fWorld, SG_FILE_R, false) && fscanf(Stream.Get_Stream(), "%lf %lf %lf %lf %lf %lf ", &dx, &ry, &rx, &dy, &ax, &ay) == 6 ) { if( dx != -dy || rx != 0.0 || ry != 0.0 ) { bTransform = true; } else { xMin = ax; yMin = ay + dy * (Image.GetHeight() - 1); Cellsize = dx; } } //----------------------------------------------------- // color look-up table... if( Method == 0 && (yy = Image.ComputeHistogram(Histogram)) <= 256 ) { Colors.Set_Count(yy); for(wxImageHistogram::iterator i=Histogram.begin(); i!=Histogram.end(); ++i) { Colors.Set_Color(i->second.index, SG_GET_R(i->first), SG_GET_G(i->first), SG_GET_B(i->first)); } pImage = SG_Create_Grid(yy <= 2 ? SG_DATATYPE_Bit : SG_DATATYPE_Byte, Image.GetWidth(), Image.GetHeight(), Cellsize, xMin, yMin); for(y=0; y<pImage->Get_NY() && Set_Progress(y, pImage->Get_NY()); y++) { yy = bTransform ? y : pImage->Get_NY() - 1 - y; for(x=0; x<pImage->Get_NX(); x++) { pImage->Set_Value(x, y, Histogram[SG_GET_RGB(Image.GetRed(x, yy), Image.GetGreen(x, yy), Image.GetBlue(x, yy))].index); } } if( bTransform ) { Set_Transformation(&pImage, ax, ay, dx, dy, rx, ry); } pImage->Set_Name(Name); pImage->Get_Projection().Load(SG_File_Make_Path(NULL, fImage, SG_T("prj"))); Parameters("OUT_GRID")->Set_Value(pImage); DataObject_Set_Colors(pImage, Colors); DataObject_Update(pImage, 0, Colors.Get_Count() - 1); } //----------------------------------------------------- else // true color... { pImage = SG_Create_Grid(SG_DATATYPE_Int, Image.GetWidth(), Image.GetHeight(), Cellsize, xMin, yMin); pImage ->Set_Name(Name); for(y=0; y<pImage->Get_NY() && Set_Progress(y, pImage->Get_NY()); y++) { yy = bTransform ? y : pImage->Get_NY() - 1 - y; for(x=0; x<pImage->Get_NX(); x++) { pImage->Set_Value(x, y, SG_GET_RGB(Image.GetRed(x, yy), Image.GetGreen(x, yy), Image.GetBlue(x, yy))); } } if( bTransform ) { Set_Transformation(&pImage, ax, ay, dx, dy, rx, ry); } //------------------------------------------------- if( Method != 1 ) // true color... { pImage->Get_Projection().Load(fImage, SG_PROJ_FMT_WKT); pImage->Set_Name(Name); pImage->Get_Projection().Load(SG_File_Make_Path(NULL, fImage, SG_T("prj"))); Parameters("OUT_GRID")->Set_Value(pImage); DataObject_Set_Colors(pImage, 100, SG_COLORS_BLACK_WHITE); DataObject_Set_Parameter(pImage, "COLORS_TYPE", 6); // Color Classification Type: RGB } //------------------------------------------------- else // split channels... { CSG_Grid *pR, *pG, *pB; pR = SG_Create_Grid(pImage->Get_System(), SG_DATATYPE_Byte); pG = SG_Create_Grid(pImage->Get_System(), SG_DATATYPE_Byte); pB = SG_Create_Grid(pImage->Get_System(), SG_DATATYPE_Byte); for(y=0; y<pImage->Get_NY() && Set_Progress(y, pImage->Get_NY()); y++) { for(x=0; x<pImage->Get_NX(); x++) { pR->Set_Value(x, y, SG_GET_R(pImage->asInt(x, y))); pG->Set_Value(x, y, SG_GET_G(pImage->asInt(x, y))); pB->Set_Value(x, y, SG_GET_B(pImage->asInt(x, y))); } } pR->Get_Projection().Load(fImage, SG_PROJ_FMT_WKT); pG->Get_Projection().Load(fImage, SG_PROJ_FMT_WKT); pB->Get_Projection().Load(fImage, SG_PROJ_FMT_WKT); pR->Set_Name(CSG_String::Format(SG_T("%s [R]"), Name.c_str())); pG->Set_Name(CSG_String::Format(SG_T("%s [G]"), Name.c_str())); pB->Set_Name(CSG_String::Format(SG_T("%s [B]"), Name.c_str())); pR->Get_Projection().Load(SG_File_Make_Path(NULL, fImage, SG_T("prj"))); pG->Get_Projection().Load(SG_File_Make_Path(NULL, fImage, SG_T("prj"))); pB->Get_Projection().Load(SG_File_Make_Path(NULL, fImage, SG_T("prj"))); Parameters("OUT_RED") ->Set_Value(pR); Parameters("OUT_GREEN") ->Set_Value(pG); Parameters("OUT_BLUE") ->Set_Value(pB); DataObject_Set_Colors(pR, 100, SG_COLORS_BLACK_RED); DataObject_Set_Colors(pG, 100, SG_COLORS_BLACK_GREEN); DataObject_Set_Colors(pB, 100, SG_COLORS_BLACK_BLUE); } } //----------------------------------------------------- if( !SG_UI_Get_Window_Main() && pImgHandler != NULL) { wxImage::RemoveHandler(pImgHandler->GetName()); } //----------------------------------------------------- return( true ); }
//--------------------------------------------------------- bool CWKSP_Map_Graticule::Draw(CWKSP_Map_DC &dc_Map) { if( !Get_Graticule(dc_Map.m_rWorld) || m_Graticule.Get_Count() <= 0 ) { return( false ); } if( !m_Parameters("SHOW_ALWAYS")->asBool() ) { CSG_Parameter_Range *pRange = m_Parameters("SHOW_RANGE")->asRange(); double dRange = dc_Map.m_rWorld.Get_XRange() > dc_Map.m_rWorld.Get_YRange() ? dc_Map.m_rWorld.Get_XRange() : dc_Map.m_rWorld.Get_YRange(); if( dRange < pRange->Get_LoVal() || pRange->Get_HiVal() < dRange ) { return( false ); } } //----------------------------------------------------- CWKSP_Map_DC *pDC = m_Parameters("TRANSPARENCY")->asDouble() > 0.0 ? new CWKSP_Map_DC(dc_Map.m_rWorld, dc_Map.m_rDC, dc_Map.m_Scale, SG_GET_RGB(255, 255, 255)) : NULL; CWKSP_Map_DC &dc = pDC ? *pDC : dc_Map; //----------------------------------------------------- wxPen Pen(m_Parameters("COLOR")->asColor(), m_Parameters("SIZE")->asInt()); switch( m_Parameters("LINE_STYLE")->asInt() ) { default: case 0: Pen.SetStyle(wxPENSTYLE_SOLID ); break; // Solid style. case 1: Pen.SetStyle(wxPENSTYLE_DOT ); break; // Dotted style. case 2: Pen.SetStyle(wxPENSTYLE_LONG_DASH ); break; // Long dashed style. case 3: Pen.SetStyle(wxPENSTYLE_SHORT_DASH ); break; // Short dashed style. case 4: Pen.SetStyle(wxPENSTYLE_DOT_DASH ); break; // Dot and dash style. case 5: Pen.SetStyle(wxPENSTYLE_BDIAGONAL_HATCH ); break; // Backward diagonal hatch. case 6: Pen.SetStyle(wxPENSTYLE_CROSSDIAG_HATCH ); break; // Cross-diagonal hatch. case 7: Pen.SetStyle(wxPENSTYLE_FDIAGONAL_HATCH ); break; // Forward diagonal hatch. case 8: Pen.SetStyle(wxPENSTYLE_CROSS_HATCH ); break; // Cross hatch. case 9: Pen.SetStyle(wxPENSTYLE_HORIZONTAL_HATCH); break; // Horizontal hatch. case 10: Pen.SetStyle(wxPENSTYLE_VERTICAL_HATCH ); break; // Vertical hatch. // case 11: Pen.SetStyle(wxPENSTYLE_STIPPLE ); break; // Use the stipple bitmap. // case 12: Pen.SetStyle(wxPENSTYLE_USER_DASH ); break; // Use the user dashes: see wxPen::SetDashes. // case 13: Pen.SetStyle(wxPENSTYLE_TRANSPARENT ); break; // No pen is used. } dc.dc.SetPen(Pen); //----------------------------------------------------- for(int iLine=0; iLine<m_Graticule.Get_Count(); iLine++) { CSG_Shape *pLine = m_Graticule.Get_Shape(iLine); for(int iPart=0; iPart<pLine->Get_Part_Count(); iPart++) { if( pLine->Get_Point_Count(iPart) > 1 ) { TSG_Point_Int B, A = dc.World2DC(pLine->Get_Point(0, iPart)); for(int iPoint=1; iPoint<pLine->Get_Point_Count(iPart); iPoint++) { B = A; A = dc.World2DC(pLine->Get_Point(iPoint, iPart)); dc.dc.DrawLine(A.x, A.y, B.x, B.y); } } } } //----------------------------------------------------- if( m_Parameters("LABEL")->asBool() ) { int Size = (int)(0.5 + 0.01 * m_Parameters("LABEL_SIZE")->asDouble() * ( dc.m_rDC.GetWidth() < dc.m_rDC.GetHeight() ? dc.m_rDC.GetWidth() : dc.m_rDC.GetHeight() ) ); if( Size > 2 ) { int Effect; wxColour Effect_Color = Get_Color_asWX(m_Parameters("LABEL_EFFCOL")->asInt()); wxFont Font = Get_Font(m_Parameters("LABEL_FONT")); Font.SetPointSize(Size); dc.dc.SetFont(Font); dc.dc.SetTextForeground(m_Parameters("LABEL_FONT")->asColor()); switch( m_Parameters("LABEL_EFFECT")->asInt() ) { default: Effect = TEXTEFFECT_NONE; break; case 1: Effect = TEXTEFFECT_FRAME; break; case 2: Effect = TEXTEFFECT_TOP; break; case 3: Effect = TEXTEFFECT_TOPLEFT; break; case 4: Effect = TEXTEFFECT_LEFT; break; case 5: Effect = TEXTEFFECT_BOTTOMLEFT; break; case 6: Effect = TEXTEFFECT_BOTTOM; break; case 7: Effect = TEXTEFFECT_BOTTOMRIGHT; break; case 8: Effect = TEXTEFFECT_RIGHT; break; case 9: Effect = TEXTEFFECT_TOPRIGHT; break; } for(int iPoint=0; iPoint<m_Coordinates.Get_Count(); iPoint++) { CSG_Shape *pPoint = m_Coordinates.Get_Shape(iPoint); TSG_Point_Int p(dc.World2DC(pPoint->Get_Point(0))); wxString Type(pPoint->asString(0)); int Align = !Type.Cmp("LAT_MIN") ? TEXTALIGN_CENTERLEFT : !Type.Cmp("LAT_MAX") ? TEXTALIGN_CENTERRIGHT : !Type.Cmp("LON_MIN") ? TEXTALIGN_BOTTOMCENTER : !Type.Cmp("LON_MAX") ? TEXTALIGN_TOPCENTER : TEXTALIGN_CENTER; Draw_Text(dc.dc, Align, p.x, p.y, 0.0, pPoint->asString(1), Effect, Effect_Color); } } } //----------------------------------------------------- if( pDC ) { dc_Map.Draw_DC(dc, m_Parameters("TRANSPARENCY")->asDouble() / 100.0); delete(pDC); } return( true ); }
//--------------------------------------------------------- bool CGrid_RGB_Composite::On_Execute(void) { double rMin, rRange, gMin, gRange, bMin, bRange, aMin, aRange; //----------------------------------------------------- CSG_Grid *pR = _Get_Grid(Parameters("R_GRID")->asGrid(), Parameters("R_METHOD")->asInt(), Parameters("R_RANGE")->asRange(), Parameters("R_PERCTL")->asRange(), Parameters("R_STDDEV")->asDouble(), rMin, rRange); CSG_Grid *pG = _Get_Grid(Parameters("G_GRID")->asGrid(), Parameters("G_METHOD")->asInt(), Parameters("G_RANGE")->asRange(), Parameters("G_PERCTL")->asRange(), Parameters("G_STDDEV")->asDouble(), gMin, gRange); CSG_Grid *pB = _Get_Grid(Parameters("B_GRID")->asGrid(), Parameters("B_METHOD")->asInt(), Parameters("B_RANGE")->asRange(), Parameters("B_PERCTL")->asRange(), Parameters("B_STDDEV")->asDouble(), bMin, bRange); CSG_Grid *pA = _Get_Grid(Parameters("A_GRID")->asGrid(), Parameters("A_METHOD")->asInt(), Parameters("A_RANGE")->asRange(), Parameters("A_PERCTL")->asRange(), Parameters("A_STDDEV")->asDouble(), aMin, aRange); //----------------------------------------------------- CSG_Grid *pRGB = Parameters("RGB")->asGrid(); pRGB->Create(pRGB->Get_System(), SG_DATATYPE_Int); pRGB->Set_Name(_TL("Composite")); CSG_String s; s += CSG_String(_TL("Red" )) + ": " + pR->Get_Name() + "\n"; s += CSG_String(_TL("Green")) + ": " + pG->Get_Name() + "\n"; s += CSG_String(_TL("Blue" )) + ": " + pB->Get_Name() + "\n"; if( pA ) { s += CSG_String(_TL("Alpha")) + ": " + pA->Get_Name() + "\n"; } pRGB->Set_Description(s); DataObject_Set_Colors (pRGB, 100, SG_COLORS_BLACK_WHITE); DataObject_Set_Parameter(pRGB, "COLORS_TYPE", 5); // Color Classification Type: RGB Coded Values //----------------------------------------------------- for(int y=0; y<Get_NY() && Set_Progress(y); y++) { #pragma omp parallel for for(int x=0; x<Get_NX(); x++) { if( pR->is_NoData(x, y) || pG->is_NoData(x, y) || pB->is_NoData(x, y) || (pA && pA->is_NoData(x, y)) ) { pRGB->Set_NoData(x, y); } else { int r = (int)(rRange * (pR->asDouble(x, y) - rMin)); if( r > 255 ) r = 255; else if( r < 0 ) r = 0; int g = (int)(gRange * (pG->asDouble(x, y) - gMin)); if( g > 255 ) g = 255; else if( g < 0 ) g = 0; int b = (int)(bRange * (pB->asDouble(x, y) - bMin)); if( b > 255 ) b = 255; else if( b < 0 ) b = 0; if( pA ) { int a = (int)(aRange * (pA->asDouble(x, y) - aMin)); if( a > 255 ) a = 255; else if( a < 0 ) a = 0; pRGB->Set_Value(x, y, SG_GET_RGBA(r, g, b, a)); } else { pRGB->Set_Value(x, y, SG_GET_RGB (r, g, b)); } } } } return( true ); }
//--------------------------------------------------------- CWKSP_Map_Manager::CWKSP_Map_Manager(void) { g_pMaps = this; //----------------------------------------------------- CSG_Parameter *pNode, *pNode_1; //----------------------------------------------------- pNode = m_Parameters.Add_Node(NULL, "NODE_DEFAULTS", _TL("Defaults for New Maps"), _TL("")); m_Parameters.Add_Value( pNode , "GOTO_NEWLAYER" , _TL("Zoom to added layer"), _TL(""), PARAMETER_TYPE_Bool, true ); m_Parameters.Add_Value( pNode , "SCALE_BAR" , _TL("Show Scale Bar"), _TL(""), PARAMETER_TYPE_Bool, true ); //----------------------------------------------------- pNode_1 = m_Parameters.Add_Node(pNode, "NODE_FRAME", _TL("Frame"), _TL("")); m_Parameters.Add_Value( pNode_1 , "FRAME_SHOW" , _TL("Show"), _TL(""), PARAMETER_TYPE_Bool, true ); m_Parameters.Add_Value( pNode_1 , "FRAME_WIDTH" , _TL("Width"), _TL(""), PARAMETER_TYPE_Int, 17, 5, true ); //----------------------------------------------------- pNode = m_Parameters.Add_Node(NULL, "NODE_CLIPBOARD", _TL("Clipboard"), _TL("")); m_Parameters.Add_Value( pNode , "CLIP_NX" , _TL("Width"), _TL(""), PARAMETER_TYPE_Int, 400, 10, true ); m_Parameters.Add_Value( pNode , "CLIP_NY" , _TL("Height"), _TL(""), PARAMETER_TYPE_Int, 400, 10, true ); m_Parameters.Add_Value( pNode , "CLIP_FRAME" , _TL("Frame Width"), _TL(""), PARAMETER_TYPE_Int, 17, 0, true ); //----------------------------------------------------- pNode_1 = m_Parameters.Add_Node(pNode, "NODE_CLIP_LEGEND", _TL("Legend"), _TL("")); m_Parameters.Add_Value( pNode_1 , "CLIP_LEGEND_SCALE", _TL("Scale"), _TL(""), PARAMETER_TYPE_Double, 2.0, 1.0, true ); m_Parameters.Add_Value( pNode_1 , "CLIP_LEGEND_FRAME", _TL("Frame Width"), _TL(""), PARAMETER_TYPE_Int, 10, 0, true ); m_Parameters.Add_Value( pNode_1 , "CLIP_LEGEND_COLOR", _TL("Border Color"), _TL(""), PARAMETER_TYPE_Color, SG_GET_RGB(0, 0, 0) ); //----------------------------------------------------- pNode = m_Parameters.Add_Node(NULL, "NODE_THUMBNAILS", _TL("Thumbnails"), _TL("")); m_Parameters.Add_Value( pNode , "THUMBNAIL_SIZE" , _TL("Thumbnail Size"), _TL(""), PARAMETER_TYPE_Int, 75, 10, true ); m_Parameters.Add_Value( pNode , "THUMBNAIL_SELCOLOR" , _TL("Selection Color"), _TL(""), PARAMETER_TYPE_Color, Get_Color_asInt(SYS_Get_Color(wxSYS_COLOUR_BTNSHADOW)) ); //----------------------------------------------------- CONFIG_Read("/MAPS", &m_Parameters); }
_TL("Silty Clay-Loam"), _TL("Sandy Clay"), _TL("Sandy Clay-Loam"), _TL("Clay-Loam"), _TL("Silt"), _TL("Silt-Loam"), _TL("Loam"), _TL("Sand"), _TL("Loamy Sand"), _TL("Sandy Loam") }; //--------------------------------------------------------- long TEXTURE_COLOR[12] = { SG_GET_RGB(000, 000, 255), // clay SG_GET_RGB(000, 200, 255), // silty clay SG_GET_RGB(000, 200, 200), // silty clay-loam SG_GET_RGB(200, 000, 255), // sandy clay SG_GET_RGB(200, 200, 200), // sandy clay-loam SG_GET_RGB(127, 127, 200), // clay-loam SG_GET_RGB(000, 255, 000), // silt SG_GET_RGB(127, 255, 127), // silt-loam SG_GET_RGB(127, 127, 127), // loam SG_GET_RGB(255, 000, 000), // sand SG_GET_RGB(255, 000, 127), // loamy sand SG_GET_RGB(200, 127, 127) // sandy loam }; ///////////////////////////////////////////////////////////
//--------------------------------------------------------- bool CWMS_Import::Get_Map(wxHTTP *pServer, const CSG_String &Directory, CWMS_Capabilities &Cap) { bool bResult = false; int i, n; CSG_Rect r(Cap.m_Extent); CSG_Parameters p; //----------------------------------------------------- // if( Cap.m_MaxWidth > 2 && NX > Cap.m_MaxWidth ) NX = Cap.m_MaxWidth; // if( Cap.m_MaxHeight > 2 && NY > Cap.m_MaxHeight ) NY = Cap.m_MaxHeight; p.Add_Range (NULL , "X_RANGE" , _TL("X Range") , _TL(""), r.Get_XMin(), r.Get_XMax(), r.Get_XMin(), r.Get_XRange() > 0.0, r.Get_XMax(), r.Get_XRange() > 0.0); p.Add_Range (NULL , "Y_RANGE" , _TL("Y Range") , _TL(""), r.Get_YMin(), r.Get_YMax(), r.Get_YMin(), r.Get_YRange() > 0.0, r.Get_YMax(), r.Get_YRange() > 0.0); p.Add_Value (NULL , "CELLSIZE", _TL("Cellsize") , _TL(""), PARAMETER_TYPE_Double, r.Get_XRange() / 2001.0, 0.0, true); p.Add_Choice(NULL , "FORMAT" , _TL("Format") , _TL(""), Cap.m_Formats); p.Add_Choice(NULL , "PROJ" , _TL("Projections"), _TL(""), Cap.m_Projections); CSG_Parameter *pNode = p("FORMAT"); for(i=0; i<pNode->asChoice()->Get_Count(); i++) { CSG_String s(pNode->asChoice()->Get_Item(i)); if( !s.CmpNoCase(SG_T("image/png")) ) pNode->Set_Value(i); } for(i=0; i<Cap.m_Layers_Name.Get_Count(); i++) { p.Add_Value(NULL, Cap.m_Layers_Name[i], Cap.m_Layers_Title[i], "", PARAMETER_TYPE_Bool, false); } //----------------------------------------------------- if( pServer && Dlg_Parameters(&p, _TL("WMS Import")) ) { int NX, NY; double Cellsize; CSG_String Layers, Format; //------------------------------------------------- r.Assign( p("X_RANGE")->asRange()->Get_LoVal(), p("Y_RANGE")->asRange()->Get_LoVal(), p("X_RANGE")->asRange()->Get_HiVal(), p("Y_RANGE")->asRange()->Get_HiVal() ); Cellsize = p("CELLSIZE") ->asDouble(); NX = 1 + (int)(r.Get_XRange() / Cellsize); NY = 1 + (int)(r.Get_YRange() / Cellsize); //------------------------------------------------- Layers.Clear(); for(i=0, n=0; i<Cap.m_Layers_Name.Get_Count(); i++) { if( p(Cap.m_Layers_Name[i])->asBool() ) { if( n++ > 0 ) Layers += ","; Layers += Cap.m_Layers_Name[i]; } } if( n == 0 ) { return( false ); } //------------------------------------------------- wxBitmapType tFormat; Format = p("FORMAT")->asString(); if( Format.Contains(SG_T("image/gif" )) ) tFormat = wxBITMAP_TYPE_GIF ; else if( Format.Contains(SG_T("image/jpeg")) ) tFormat = wxBITMAP_TYPE_JPEG; else if( Format.Contains(SG_T("image/png" )) ) tFormat = wxBITMAP_TYPE_PNG ; else if( Format.Contains(SG_T("image/wbmp")) ) tFormat = wxBITMAP_TYPE_BMP ; else if( Format.Contains(SG_T("image/bmp" )) ) tFormat = wxBITMAP_TYPE_BMP ; else if( Format.Contains(SG_T("image/tiff")) ) tFormat = wxBITMAP_TYPE_TIF ; else if( Format.Contains(SG_T("GIF" )) ) tFormat = wxBITMAP_TYPE_GIF ; else if( Format.Contains(SG_T("JPEG" )) ) tFormat = wxBITMAP_TYPE_JPEG; else if( Format.Contains(SG_T("PNG" )) ) tFormat = wxBITMAP_TYPE_PNG ; else { return( false ); } //------------------------------------------------- CSG_String sRequest(Directory); sRequest += SG_T("?SERVICE=WMS"); sRequest += SG_T("&VERSION=") + Cap.m_Version; sRequest += SG_T("&REQUEST=GetMap"); sRequest += SG_T("&LAYERS=") + Layers; if( Cap.m_Projections.Length() > 0 ) sRequest += CSG_String(S_SRS(Cap.m_Version)) + p("PROJ")->asString(); sRequest += SG_T("&FORMAT=") + Format; sRequest += CSG_String::Format(SG_T("&WIDTH=%d&HEIGHT=%d"), NX, NY); sRequest += CSG_String::Format(SG_T("&BBOX=%f,%f,%f,%f"), r.m_rect.xMin, r.m_rect.yMin, r.m_rect.xMax, r.m_rect.yMax); Message_Add(sRequest, true); //------------------------------------------------- wxInputStream *pStream; if( (pStream = pServer->GetInputStream(sRequest.c_str())) == NULL ) { Message_Add(_TL("could not open GetMap stream")); } else { wxImage Image; if( Image.LoadFile(*pStream, tFormat) == false ) { Message_Add(_TL("could not read image")); CSG_String s = SG_T("\n"); pStream->SeekI(0, wxFromStart); while( !pStream->Eof() ) { s += (char)pStream->GetC(); } Message_Add(s); } else { CSG_Grid *pGrid = SG_Create_Grid(SG_DATATYPE_Int, Image.GetWidth(), Image.GetHeight(), Cellsize, r.m_rect.xMin, r.m_rect.yMin); for(int y=0, yy=pGrid->Get_NY()-1; y<pGrid->Get_NY() && Set_Progress(y, pGrid->Get_NY()); y++, yy--) { for(int x=0; x<pGrid->Get_NX(); x++) { pGrid->Set_Value(x, y, SG_GET_RGB(Image.GetRed(x, yy), Image.GetGreen(x, yy), Image.GetBlue(x, yy))); } } //----------------------------------------- pGrid->Set_Name(Cap.m_Title); Parameters("MAP")->Set_Value(pGrid); DataObject_Set_Colors(pGrid, 100, SG_COLORS_BLACK_WHITE); CSG_Parameters Parms; if( DataObject_Get_Parameters(pGrid, Parms) && Parms("COLORS_TYPE") ) { Parms("COLORS_TYPE")->Set_Value(3); // Color Classification Type: RGB DataObject_Set_Parameters(pGrid, Parms); } bResult = true; } delete(pStream); } } return( bResult ); }
//--------------------------------------------------------- bool CParam_Scale::On_Execute(void) { //----------------------------------------------------- bool bConstrain; int Index[6]; double zScale, Tol_Slope, Tol_Curve; CSG_Matrix Normal; //----------------------------------------------------- bConstrain = Parameters("CONSTRAIN")->asBool(); zScale = Parameters("ZSCALE" )->asDouble(); if( zScale <= 0.0 ) { zScale = 1.0; } Tol_Slope = Parameters("TOL_SLOPE")->asDouble(); Tol_Curve = Parameters("TOL_CURVE")->asDouble(); m_pDEM = Parameters("DEM" )->asGrid(); //----------------------------------------------------- CSG_Grid *pFeature = Parameters("FEATURES" )->asGrid(); CSG_Grid *pElevation = Parameters("ELEVATION")->asGrid(); CSG_Grid *pSlope = Parameters("SLOPE" )->asGrid(); CSG_Grid *pAspect = Parameters("ASPECT" )->asGrid(); CSG_Grid *pProfC = Parameters("PROFC" )->asGrid(); CSG_Grid *pPlanC = Parameters("PLANC" )->asGrid(); CSG_Grid *pLongC = Parameters("LONGC" )->asGrid(); CSG_Grid *pCrosC = Parameters("CROSC" )->asGrid(); CSG_Grid *pMiniC = Parameters("MINIC" )->asGrid(); CSG_Grid *pMaxiC = Parameters("MAXIC" )->asGrid(); //----------------------------------------------------- if( !Get_Weights() ) { return( false ); } if( !Get_Normal(Normal) ) { return( false ); } // To constrain the quadtratic through the central cell, ignore the calculations involving the // coefficient f. Since these are all in the last row and column of the matrix, simply redimension. if( !SG_Matrix_LU_Decomposition(bConstrain ? 5 : 6, Index, Normal.Get_Data()) ) { return( false ); } //----------------------------------------------------- for(int y=0; y<Get_NY() && Set_Progress(y); y++) { #pragma omp parallel for for(int x=0; x<Get_NX(); x++) { CSG_Vector Observed; double elevation, slope, aspect, profc, planc, longc, crosc, minic, maxic; if( Get_Observed(x, y, Observed, bConstrain) && SG_Matrix_LU_Solve(bConstrain ? 5 : 6, Index, Normal, Observed.Get_Data()) ) { Get_Parameters(zScale, Observed.Get_Data(), elevation, slope, aspect, profc, planc, longc, crosc, minic, maxic); GRID_SET_VALUE(pFeature , Get_Feature(slope, minic, maxic, crosc, Tol_Slope, Tol_Curve)); GRID_SET_VALUE(pElevation, elevation + m_pDEM->asDouble(x, y)); // Add central elevation back GRID_SET_VALUE(pSlope , slope); GRID_SET_VALUE(pAspect , aspect); GRID_SET_VALUE(pProfC , profc); GRID_SET_VALUE(pPlanC , planc); GRID_SET_VALUE(pLongC , longc); GRID_SET_VALUE(pCrosC , crosc); GRID_SET_VALUE(pMiniC , minic); GRID_SET_VALUE(pMaxiC , maxic); } else { GRID_SET_NODATA(pFeature); GRID_SET_NODATA(pElevation); GRID_SET_NODATA(pSlope); GRID_SET_NODATA(pAspect); GRID_SET_NODATA(pProfC); GRID_SET_NODATA(pPlanC); GRID_SET_NODATA(pLongC); GRID_SET_NODATA(pCrosC); GRID_SET_NODATA(pMiniC); GRID_SET_NODATA(pMaxiC); } } } //----------------------------------------------------- CSG_Parameter *pLUT = DataObject_Get_Parameter(pFeature, "LUT"); if( pLUT && pLUT->asTable() ) { pLUT->asTable()->Del_Records(); LUT_SET_CLASS(FLAT , _TL("Planar" ), SG_GET_RGB(180, 180, 180)); LUT_SET_CLASS(PIT , _TL("Pit" ), SG_GET_RGB( 0, 0, 0)); LUT_SET_CLASS(CHANNEL, _TL("Channel" ), SG_GET_RGB( 0, 0, 255)); LUT_SET_CLASS(PASS , _TL("Pass (saddle)"), SG_GET_RGB( 0, 255, 0)); LUT_SET_CLASS(RIDGE , _TL("Ridge" ), SG_GET_RGB(255, 255, 0)); LUT_SET_CLASS(PEAK , _TL("Peak" ), SG_GET_RGB(255, 0, 0)); DataObject_Set_Parameter(pFeature, pLUT); DataObject_Set_Parameter(pFeature, "COLORS_TYPE", 1); // Color Classification Type: Lookup Table } //----------------------------------------------------- DataObject_Set_Colors(pSlope , 11, SG_COLORS_YELLOW_RED); DataObject_Set_Colors(pAspect, 11, SG_COLORS_ASPECT_3); DataObject_Set_Colors(pProfC , 11, SG_COLORS_RED_GREY_BLUE, true); DataObject_Set_Colors(pPlanC , 11, SG_COLORS_RED_GREY_BLUE, false); DataObject_Set_Colors(pLongC , 11, SG_COLORS_RED_GREY_BLUE, true); DataObject_Set_Colors(pCrosC , 11, SG_COLORS_RED_GREY_BLUE, true); DataObject_Set_Colors(pMiniC , 11, SG_COLORS_RED_GREY_BLUE, true); DataObject_Set_Colors(pMaxiC , 11, SG_COLORS_RED_GREY_BLUE, true); //----------------------------------------------------- return( true ); }
//--------------------------------------------------------- void CVIEW_Map_3D::Parameters_Create(void) { CSG_Parameter *pNode; m_Parameters.Create(NULL, _TL("3D-View"), _TL("")); //----------------------------------------------------- pNode = m_Parameters.Add_Grid( NULL , "DEM" , _TL("Elevation"), _TL(""), PARAMETER_INPUT ); m_Parameters.Add_Value( pNode , "DEM_RES" , _TL("Resolution"), _TL(""), PARAMETER_TYPE_Int, 100, 2, true ); m_Parameters.Add_Value( pNode , "Z_SCALE" , _TL("Exaggeration"), _TL(""), PARAMETER_TYPE_Double, 1.0 ); m_Parameters.Add_Value( pNode , "DRAW_BOX" , _TL("Bounding Box"), _TL(""), PARAMETER_TYPE_Bool, false ); //----------------------------------------------------- pNode = m_Parameters.Add_Node(NULL, "MAP", _TL("Map"), _TL("")); m_Parameters.Add_Value( pNode , "MAP_RES" , _TL("Resolution"), _TL(""), PARAMETER_TYPE_Int, 1000, 2, true ); m_Parameters.Add_Choice( pNode , "DRAPE_MODE" , _TL("Map Draping Interpolation"), _TL(""), CSG_String::Format(SG_T("%s|%s|%s|%s|%s|"), _TL("None"), _TL("Bilinear"), _TL("Inverse Distance"), _TL("Bicubic Spline"), _TL("B-Spline") ), 0 ); //----------------------------------------------------- pNode = m_Parameters.Add_Node(NULL, "ROTATION", _TL("Rotation"), _TL("")); m_Parameters.Add_Value(pNode, "ROTATION_X", _TL("X"), _TL(""), PARAMETER_TYPE_Double, 55.0, -360.0, true, 360.0, true); m_Parameters.Add_Value(pNode, "ROTATION_Y", _TL("Y"), _TL(""), PARAMETER_TYPE_Double, 0.0, -360.0, true, 360.0, true); m_Parameters.Add_Value(pNode, "ROTATION_Z", _TL("Z"), _TL(""), PARAMETER_TYPE_Double, -45.0, -360.0, true, 360.0, true); //----------------------------------------------------- pNode = m_Parameters.Add_Node(NULL, "SHIFT", _TL("Shift"), _TL("")); m_Parameters.Add_Value(pNode, "SHIFT_X", _TL("Left/Right"), _TL(""), PARAMETER_TYPE_Double, 0.0); m_Parameters.Add_Value(pNode, "SHIFT_Y", _TL("Up/Down" ), _TL(""), PARAMETER_TYPE_Double, 0.0); m_Parameters.Add_Value(pNode, "SHIFT_Z", _TL("In/Out" ), _TL(""), PARAMETER_TYPE_Double, 1500.0); //----------------------------------------------------- pNode = m_Parameters.Add_Node(NULL, "NODE_PROJECTION", _TL("Projection"), _TL("")); m_Parameters.Add_Choice( pNode , "CENTRAL" , _TL("Projection"), _TL(""), CSG_String::Format(SG_T("%s|%s|"), _TL("parallel"), _TL("central") ), 1 ); m_Parameters.Add_Value( pNode , "CENTRAL_DIST" , _TL("Perspectivic Distance"), _TL(""), PARAMETER_TYPE_Double, 1500, 1, true ); //----------------------------------------------------- pNode = m_Parameters.Add_Node(NULL, "NODE_STEREO", _TL("Anaglyph"), _TL("")); m_Parameters.Add_Value( pNode , "STEREO" , _TL("Anaglyph"), _TL(""), PARAMETER_TYPE_Bool, false ); m_Parameters.Add_Value( pNode , "STEREO_DIST" , _TL("Eye Distance [Degree]"), _TL(""), PARAMETER_TYPE_Double, 2.0, 0, true, 180, true ); //----------------------------------------------------- m_Parameters.Add_Value( NULL , "BGCOLOR" , _TL("Background Color"), _TL(""), PARAMETER_TYPE_Color, SG_GET_RGB(255, 255, 255) ); }
//--------------------------------------------------------- void CVIEW_Map_3D::_Parms_Create(void) { CSG_Parameter *pNode; m_Parameters.Create(NULL, LNG("[CAP] 3D-View"), LNG("")); //----------------------------------------------------- m_Parameters.Add_Grid( NULL , "ELEVATION" , LNG("[CAP] Elevation"), LNG(""), PARAMETER_INPUT ); //----------------------------------------------------- pNode = m_Parameters.Add_Node(NULL, "ROTATION", LNG("[CAP] Rotation"), LNG("")); m_Parameters.Add_Value( pNode , "ROTATION_X" , LNG("X"), LNG(""), PARAMETER_TYPE_Double, -45.0, -360.0, true, 360.0, true ); m_Parameters.Add_Value( pNode , "ROTATION_Y" , LNG("Y"), LNG(""), PARAMETER_TYPE_Double, 0.0, -360.0, true, 360.0, true ); m_Parameters.Add_Value( pNode , "ROTATION_Z" , LNG("Z"), LNG(""), PARAMETER_TYPE_Double, 45.0, -360.0, true, 360.0, true ); //----------------------------------------------------- pNode = m_Parameters.Add_Node(NULL, "SHIFT", LNG("[CAP] Shift"), LNG("")); m_Parameters.Add_Value( pNode , "SHIFT_X" , LNG("Left/Right"), LNG(""), PARAMETER_TYPE_Double, 0.0 ); m_Parameters.Add_Value( pNode , "SHIFT_Y" , LNG("Up/Down"), LNG(""), PARAMETER_TYPE_Double, 0.0 ); m_Parameters.Add_Value( pNode , "SHIFT_Z" , LNG("In/Out"), LNG(""), PARAMETER_TYPE_Double, 200.0 ); //----------------------------------------------------- m_Parameters.Add_Value( NULL , "EXAGGERATION" , LNG("[CAP] Exaggeration"), LNG(""), PARAMETER_TYPE_Double, 1.0 ); //----------------------------------------------------- pNode = m_Parameters.Add_Node(NULL, "NODE_PROJECTION", LNG("[CAP] Projection"), LNG("")); m_Parameters.Add_Choice( pNode , "CENTRAL" , LNG("[CAP] Projection"), LNG(""), CSG_String::Format(wxT("%s|%s|"), LNG("parallel"), LNG("central") ), 1 ); m_Parameters.Add_Value( pNode , "CENTRAL_DIST" , LNG("[CAP] Perspectivic Distance"), LNG(""), PARAMETER_TYPE_Double, 200, 1, true ); //----------------------------------------------------- pNode = m_Parameters.Add_Node(NULL, "NODE_FIGURE", LNG("[CAP] Figure"), LNG("")); m_Parameters.Add_Choice( pNode , "FIGURE" , LNG("[CAP] Figure"), LNG(""), CSG_String::Format(wxT("%s|%s|%s|%s|"), LNG("plain"), LNG("cylinder"), LNG("ball"), LNG("panorama") ), 0 ); m_Parameters.Add_Value( pNode , "FIGURE_WEIGHT" , LNG("[CAP] Weight"), LNG(""), PARAMETER_TYPE_Double, 1.0 ); //----------------------------------------------------- pNode = m_Parameters.Add_Node(NULL, "NODE_STEREO", LNG("[CAP] Anaglyph"), LNG("")); m_Parameters.Add_Value( pNode , "STEREO" , LNG("[CAP] Anaglyph"), LNG(""), PARAMETER_TYPE_Bool, 0.0 ); m_Parameters.Add_Value( pNode , "STEREO_DIST" , LNG("[CAP] Eye Distance [Degree]"), LNG(""), PARAMETER_TYPE_Double, 2.0, 0, true, 180, true ); //----------------------------------------------------- m_Parameters.Add_Value( NULL , "INTERPOLATED" , LNG("[CAP] Interpolated"), LNG(""), PARAMETER_TYPE_Bool, true ); m_Parameters.Add_Value( NULL , "BKGRD_COLOR" , LNG("[CAP] Background Color"), LNG(""), PARAMETER_TYPE_Color, SG_GET_RGB(0, 0, 0) ); m_Parameters.Add_Value( NULL , "SRC_RESOLUTION" , LNG("Resolution"), LNG(""), PARAMETER_TYPE_Int, 200, 10, true ); }
//--------------------------------------------------------- bool CTOBIA::On_Execute(void) { double fB = Parameters("fB")->asDouble(); double fC = Parameters("fC")->asDouble(); CSG_Grid *pA, *pB, *pC, *pD, *pE, *pF; pA = Parameters("A" )->asGrid(); //slope pB = Parameters("B" )->asGrid(); //aspect pC = Parameters("C" )->asGrid(); //dip grid pD = Parameters("D" )->asGrid(); //dip dir grid pE = Parameters("E" )->asGrid(); //output TOBIA classes pF = Parameters("F" )->asGrid(); //output TOBIA index for(int y=0; y<Get_NY() && Set_Progress(y); y++) { #pragma omp parallel for for(int x=0; x<Get_NX(); x++) { double a, b, c, d, e, f; a = pA->asDouble(x, y); b = pB->asDouble(x, y); //Abfrage ob Raster oder Globalwerte c = pC ? pC->asDouble(x, y) : fB; d = pC ? pD->asDouble(x, y) : fC; if (pA->is_NoData(x, y)) { pE->Set_NoData(x, y); if (pF) pF->Set_NoData(x, y); } else if ((pC || pD) && (pC->is_NoData(x, y) || (pD->is_NoData(x, y)))) { pE->Set_NoData(x, y); if (pF) pF->Set_NoData(x, y); } else { e = pow(pow((cos(d/57.2958) - cos(b)), 2) + pow((sin(d/57.2958) - sin(b)), 2), 0.5); //TOBIA-classes if (((0 <= e) && (e < 0.7654)) && ((c - (a*57.2958)) > 5)) pE->Set_Value(x, y, TO_UNDERDIP_SLOPE); else if (((0 <= e) && (e < 0.7654)) && ((-5 <= (c - (a*57.2958))) && ((c - (a*57.2958) <= 5)))) pE->Set_Value(x, y, TO_DIP_SLOPE); else if (((0 <= e) && (e < 0.7654)) && ((c - (a*57.2958)) < -5)) pE->Set_Value(x, y, TO_OVERDIP_SLOPE); else if (((1.8478 < e) && (e <= 2)) && ((c - (a*57.2958)) < -5)) pE->Set_Value(x, y, TO_STEEPENED_ESCARPMENT); else if (((1.8478 < e) && (e <= 2)) && ((-5 <= (c - (a*57.2958))) && ((c - (a*57.2958) <= 5)))) pE->Set_Value(x, y, TO_NORMAL_ESCARPMENT); else if (((1.8478 < e) && (e <= 2)) && ((c - (a*57.2958)) > 5)) pE->Set_Value(x, y, TO_SUBDUED_ESCARPMENT); else if ((0.7654 < e) && (e <= 1.8478)) pE->Set_Value(x, y, TO_ORTHOCLINAL_SLOPE); else pE->Set_NoData_Value(0); if (pF) { f = (cos((c/57.2958)) * (cos(a))) + (sin(c/57.2958) * sin(a) * ((cos((d/57.2958) - b)))); //TOBIA-index pF->Set_Value(x, y, f); } } } } //----------------------------------------------------- CSG_Parameters P; if( DataObject_Get_Parameters(pE, P) && P("COLORS_TYPE") && P("LUT") ) { int TO_Colors[TO_COUNT] = { SG_GET_RGB(255, 255, 0), // TO_UNDERDIP SG_GET_RGB(255, 128, 0), // TO_DIP SG_GET_RGB(255, 0, 0), // TO_OVERDIP SG_GET_RGB( 0, 0, 128), // TO_STEEPENED SG_GET_RGB( 0, 128, 255), // TO_NORMAL SG_GET_RGB(128, 255, 255), // TO_SUBDUED SG_GET_RGB( 0, 255, 64), // TO_ORTHOCLINAL }; //------------------------------------------------- CSG_Strings Name, Desc; Name += _TL("Underdip slope"); Desc += _TL(""); Name += _TL("Dip slope"); Desc += _TL(""); Name += _TL("Overdip slope"); Desc += _TL(""); Name += _TL("Steepened escarpment"); Desc += _TL(""); Name += _TL("Normal escarpment"); Desc += _TL(""); Name += _TL("Subdued escarpment"); Desc += _TL(""); Name += _TL("Orthoclinal slope"); Desc += _TL(""); //------------------------------------------------- CSG_Table *pTable = P("LUT")->asTable(); pTable->Del_Records(); for(int i=0; i<TO_COUNT; i++) { CSG_Table_Record *pRecord = pTable->Add_Record(); pRecord->Set_Value(0, TO_Colors[i]); pRecord->Set_Value(1, Name[i].c_str()); pRecord->Set_Value(2, Desc[i].c_str()); pRecord->Set_Value(3, i); pRecord->Set_Value(4, i); } P("COLORS_TYPE")->Set_Value(1); // Color Classification Type: Lookup Table DataObject_Set_Parameters(pE, P); } return( true ); }
struct SClass { int ID, Color; CSG_String Key, Name; int nPoints; double Sand[8], Clay[8]; }; //--------------------------------------------------------- const struct SClass Classes[12] = { { 1, SG_GET_RGB(000, 000, 255), "C" , _TL("Clay"), 6, { 0, 0, 20, 45, 45, 0 }, { 100, 60, 40, 40, 55, 100 } }, { 2, SG_GET_RGB(000, 200, 255), "SiC" , _TL("Silty Clay"), 4, { 0, 0, 20, 0 }, { 100, 60, 40, 40 } }, { 3, SG_GET_RGB(000, 200, 200), "SiCL", _TL("Silty Clay Loam"), 5, { 0, 0, 20, 20, 0 }, { 40, 27, 27, 40, 40 } }, { 4, SG_GET_RGB(200, 000, 255), "SC" , _TL("Sandy Clay"), 4, { 45, 45, 65, 45 }, { 55, 35, 35, 55 } }, {