//--------------------------------------------------------- void CVisibility_BASE::Finalize(CSG_Grid *pVisibility, int iMethod) { CSG_Parameters Parameters; switch( iMethod ) { case 0: // Visibility Parameters.Add_Range(NULL, SG_T("METRIC_ZRANGE"), SG_T(""), SG_T(""), 0.0, 1.0); SG_UI_DataObject_Update(pVisibility, true, &Parameters); break; case 1: // Shade Parameters.Add_Range(NULL, SG_T("METRIC_ZRANGE"), SG_T(""), SG_T(""), 0.0, M_PI_090); SG_UI_DataObject_Update(pVisibility, true, &Parameters); break; case 2: // Distance case 3: // Size SG_UI_DataObject_Show(pVisibility, true); break; } return; }
//--------------------------------------------------------- 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 ); }
//--------------------------------------------------------- C_Kriging_Base::C_Kriging_Base(void) { CSG_Parameter *pNode; CSG_Parameters *pParameters; //----------------------------------------------------- Parameters.Add_Grid_Output( NULL , "GRID" , _TL("Grid"), _TL("") ); Parameters.Add_Grid_Output( NULL , "VARIANCE" , _TL("Variance"), _TL("") ); pNode = Parameters.Add_Shapes( NULL , "SHAPES" , _TL("Points"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Table_Field( pNode , "FIELD" , _TL("Attribute"), _TL("") ); Parameters.Add_Value( NULL , "BVARIANCE" , _TL("Create Variance Grid"), _TL(""), PARAMETER_TYPE_Bool , true ); Parameters.Add_Choice( NULL , "TARGET" , _TL("Target Grid"), _TL(""), CSG_String::Format(SG_T("%s|%s|%s|"), _TL("user defined"), _TL("grid system"), _TL("grid") ), 0 ); Parameters.Add_Choice( NULL , "MODEL" , _TL("Variogram Model"), _TL(""), CSG_String::Format(SG_T("%s|%s|%s|%s|%s|%s|"), _TL("Spherical Model"), _TL("Exponential Model"), _TL("Gaussian Model"), _TL("Linear Regression"), _TL("Exponential Regression"), _TL("Power Function Regression") ), 3 ); Parameters.Add_Value( NULL , "BLOCK" , _TL("Block Kriging"), _TL(""), PARAMETER_TYPE_Bool , false ); Parameters.Add_Value( NULL , "DBLOCK" , _TL("Block Size"), _TL(""), PARAMETER_TYPE_Double , 100.0, 0.0, true ); Parameters.Add_Value( NULL , "BLOG" , _TL("Logarithmic Transformation"), _TL(""), PARAMETER_TYPE_Bool ); Parameters.Add_Value( NULL , "NUGGET" , _TL("Nugget"), _TL(""), PARAMETER_TYPE_Double, 0.0, 0.0, true ); Parameters.Add_Value( NULL , "SILL" , _TL("Sill"), _TL(""), PARAMETER_TYPE_Double, 10.0, 0.0, true ); Parameters.Add_Value( NULL , "RANGE" , _TL("Range"), _TL(""), PARAMETER_TYPE_Double, 100.0, 0.0, true ); pNode = Parameters.Add_Node( NULL , "PARMS" , _TL("Additional Parameters"), _TL("") ); Parameters.Add_Value( pNode , "LIN_B" , _TL("Linear Regression"), _TL("Parameter B for Linear Regression:\n y = Nugget + B * x"), PARAMETER_TYPE_Double, 1.0 ); Parameters.Add_Value( pNode , "EXP_B" , _TL("Exponential Regression"), _TL("Parameter B for Exponential Regression:\n y = Nugget * e ^ (B * x)"), PARAMETER_TYPE_Double, 0.1 ); Parameters.Add_Value( pNode , "POW_A" , _TL("Power Function - A"), _TL("Parameter A for Power Function Regression:\n y = A * x ^ B"), PARAMETER_TYPE_Double, 1.0 ); Parameters.Add_Value( pNode , "POW_B" , _TL("Power Function - B"), _TL("Parameter B for Power Function Regression:\n y = A * x ^ B"), PARAMETER_TYPE_Double, 0.5 ); //----------------------------------------------------- pParameters = Add_Parameters(SG_T("USER") , _TL("User defined grid") , _TL("")); pParameters->Add_Value( NULL , "CELL_SIZE" , _TL("Grid Size"), _TL(""), PARAMETER_TYPE_Double, 100.0, 0.0, true ); pNode = pParameters->Add_Value( NULL , "FIT_EXTENT" , _TL("Fit Extent"), _TL("Automatically fits the grid to the shapes layers extent."), PARAMETER_TYPE_Bool , true ); pParameters->Add_Range( pNode , "X_EXTENT" , _TL("X-Extent"), _TL("") ); pParameters->Add_Range( pNode , "Y_EXTENT" , _TL("Y-Extent"), _TL("") ); //----------------------------------------------------- pParameters = Add_Parameters(SG_T("SYSTEM") , _TL("Choose Grid System") , _TL("")); pParameters->Add_Grid_System( NULL , "SYSTEM" , _TL("Grid System"), _TL("") ); //----------------------------------------------------- pParameters = Add_Parameters(SG_T("GRID") , _TL("Choose Grid") , _TL("")); pNode = pParameters->Add_Grid_System( NULL , "SYSTEM" , _TL("Grid System"), _TL("") ); pParameters->Add_Grid( pNode , "GRID" , _TL("Grid"), _TL(""), PARAMETER_INPUT , false ); pParameters->Add_Grid( pNode , "VARIANCE" , _TL("Variance"), _TL(""), PARAMETER_INPUT_OPTIONAL, false ); }