//--------------------------------------------------------- bool CGEOTRANS_Grid::On_Execute_Conversion(void) { int Interpolation; TSG_Data_Type Type; TSG_Rect Extent; CSG_Grid *pSource, *pGrid; //----------------------------------------------------- pSource = Parameters("SOURCE" )->asGrid(); Interpolation = Parameters("INTERPOLATION")->asInt(); Type = Interpolation == 0 ? pSource->Get_Type() : SG_DATATYPE_Float; //----------------------------------------------------- if( Get_Target_Extent(pSource, Extent, true) ) { m_Grid_Target.Set_User_Defined(Get_Parameters("TARGET"), Extent, pSource->Get_NY()); } if( Dlg_Parameters("TARGET") && (pGrid = m_Grid_Target.Get_Grid(Type)) != NULL ) { return( Set_Grid(pSource, pGrid, Interpolation) ); } return( false ); }
//--------------------------------------------------------- bool CGEOTRANS_Grid::On_Execute_Conversion(void) { TSG_Data_Type Type; TSG_Rect Extent; CSG_Grid *pSource, *pGrid; //----------------------------------------------------- TSG_Grid_Resampling Resampling; switch( Parameters("RESAMPLING")->asInt() ) { default: Resampling = GRID_RESAMPLING_NearestNeighbour; break; case 1: Resampling = GRID_RESAMPLING_Bilinear ; break; case 2: Resampling = GRID_RESAMPLING_BicubicSpline ; break; case 3: Resampling = GRID_RESAMPLING_BSpline ; break; } //----------------------------------------------------- pSource = Parameters("SOURCE")->asGrid(); Type = Resampling == GRID_RESAMPLING_NearestNeighbour ? pSource->Get_Type() : SG_DATATYPE_Float; //----------------------------------------------------- if( Get_Target_Extent(pSource, Extent, true) ) { m_Grid_Target.Set_User_Defined(Get_Parameters("TARGET"), Extent, pSource->Get_NY()); } if( Dlg_Parameters("TARGET") && (pGrid = m_Grid_Target.Get_Grid(Type)) != NULL ) { return( Set_Grid(pSource, pGrid, Resampling) ); } return( false ); }
//--------------------------------------------------------- bool CPROJ4_Grid::On_Execute_Conversion(void) { TSG_Data_Type Type; TSG_Rect Extent; CSG_Grid *pSource, *pGrid; CSG_Shapes *pShapes; m_Interpolation = Parameters("INTERPOLATION")->asInt(); //----------------------------------------------------- if( m_bInputList ) { CSG_Parameter_Grid_List *pSources = Parameters("SOURCE")->asGridList(); CSG_Parameter_Grid_List *pTargets = Parameters("TARGET")->asGridList(); if( pSources->Get_Count() < 1 ) { return( false ); } pSource = pSources->asGrid(0); pGrid = NULL; pShapes = NULL; Type = m_Interpolation == 0 ? pSource->Get_Type() : SG_DATATYPE_Float; switch( Parameters("TARGET_TYPE")->asInt() ) { case 0: // create new user defined grid... if( Get_Target_Extent(pSource, Extent) && m_Grid_Target.Init_User(Extent, pSource->Get_NY()) && Dlg_Parameters("GET_USER") ) { pGrid = m_Grid_Target.Get_User(Type); } break; case 1: // select grid system... if( Dlg_Parameters("<") && Get_Parameters("GET_SYSTEM")->Get_Parameter("SYSTEM")->asGrid_System()->is_Valid() ) { pGrid = SG_Create_Grid(*Get_Parameters("GET_SYSTEM")->Get_Parameter("SYSTEM")->asGrid_System(), Type); } break; case 2: // shapes... if( Dlg_Parameters("GET_SHAPES") ) { pShapes = Get_Parameters("GET_SHAPES")->Get_Parameter("SHAPES")->asShapes(); if( pShapes == DATAOBJECT_NOTSET || pShapes == DATAOBJECT_CREATE ) { Get_Parameters("GET_SHAPES")->Get_Parameter("SHAPES")->Set_Value(pShapes = SG_Create_Shapes()); } } break; } //------------------------------------------------- if( pShapes ) { Parameters("SHAPES")->Set_Value(pShapes); return( Set_Shapes(pSources, pShapes) ); } if( pGrid ) { pTargets->Del_Items(); pTargets->Add_Item(pGrid); Init_Target(pSource, pGrid); for(int i=1; i<pSources->Get_Count(); i++) { pTargets->Add_Item(SG_Create_Grid(pGrid->Get_System(), m_Interpolation == 0 ? pSources->asGrid(i)->Get_Type() : SG_DATATYPE_Float)); Init_Target(pSources->asGrid(i), pTargets->asGrid(i)); } return( Set_Grids(pSources, pTargets) ); } } //----------------------------------------------------- else { pSource = Parameters("SOURCE")->asGrid(); pGrid = NULL; pShapes = NULL; Type = m_Interpolation == 0 ? pSource->Get_Type() : SG_DATATYPE_Float; switch( Parameters("TARGET_TYPE")->asInt() ) { case 0: // create new user defined grid... if( Get_Target_Extent(pSource, Extent) && m_Grid_Target.Init_User(Extent, pSource->Get_NY()) && Dlg_Parameters("GET_USER") ) { pGrid = m_Grid_Target.Get_User(Type); } break; case 1: // select grid... if( Dlg_Parameters("GET_GRID") ) { pGrid = m_Grid_Target.Get_Grid(Type); } break; case 2: // shapes... if( Dlg_Parameters("GET_SHAPES") ) { pShapes = Get_Parameters("GET_SHAPES")->Get_Parameter("SHAPES")->asShapes(); if( pShapes == DATAOBJECT_NOTSET || pShapes == DATAOBJECT_CREATE ) { Get_Parameters("GET_SHAPES")->Get_Parameter("SHAPES")->Set_Value(pShapes = SG_Create_Shapes()); } } break; } //------------------------------------------------- if( pShapes ) { Parameters("SHAPES")->Set_Value(pShapes); return( Set_Shapes(pSource, pShapes) ); } if( pGrid ) { return( Set_Grid(pSource, pGrid) ); } } //----------------------------------------------------- return( false ); }
//--------------------------------------------------------- bool CGeoref_Grid::Get_Conversion(void) { //----------------------------------------------------- CSG_Rect Extent; CSG_Grid *pSource = Parameters("GRID")->asGrid(); //----------------------------------------------------- if( !Get_Target_Extent(Extent, true) || !m_Grid_Target.Set_User_Defined(Get_Parameters("TARGET"), Extent, pSource->Get_NY()) ) { Error_Set(_TL("failed to estimate target extent")); return( false ); } if( !Dlg_Parameters("TARGET") ) { return( false ); } //----------------------------------------------------- TSG_Grid_Resampling Resampling; switch( Parameters("RESAMPLING")->asInt() ) { default: Resampling = GRID_RESAMPLING_NearestNeighbour; break; case 1: Resampling = GRID_RESAMPLING_Bilinear; break; case 2: Resampling = GRID_RESAMPLING_BicubicSpline; break; case 3: Resampling = GRID_RESAMPLING_BSpline; break; } CSG_Grid *pReferenced = m_Grid_Target.Get_Grid(Resampling == GRID_RESAMPLING_NearestNeighbour ? pSource->Get_Type() : SG_DATATYPE_Float); if( !pReferenced ) { Error_Set(_TL("failed to initialize target grid")); return( false ); } //----------------------------------------------------- if( !Set_Grid(pSource, pReferenced, Resampling) ) { Error_Set(_TL("failed to project target grid")); return( false ); } //----------------------------------------------------- CSG_Parameters P; if( DataObject_Get_Parameters(pSource, P) ) { DataObject_Add(pReferenced); DataObject_Set_Parameters(pReferenced, P); } //----------------------------------------------------- return( true ); }