//--------------------------------------------------------- void CD8_Flow_Analysis::Get_Basins(void) { Process_Set_Text(_TL("Drainage Basins")); for(int y=0; y<Get_NY() && Set_Progress(y); y++) { for(int x=0; x<Get_NX(); x++) { Get_Basin(x, y); } } //----------------------------------------------------- CSG_Shapes *pBasins = Parameters("BASINS")->asShapes(); if( pBasins ) { bool bResult; SG_RUN_MODULE(bResult, "shapes_grid", 6, pModule->Get_Parameters()->Set_Parameter(SG_T("GRID") , m_pBasins) && pModule->Get_Parameters()->Set_Parameter(SG_T("POLYGONS"), pBasins) ) pBasins->Set_Name(_TL("Drainage Basins")); } }
//--------------------------------------------------------- bool COGR_Export_KML::On_Execute(void) { CSG_String File_Name, Driver_Name = "KML"; CSG_Shapes *pShapes, Shapes; pShapes = Parameters("SHAPES")->asShapes(); File_Name = Parameters("FILE" )->asString(); //----------------------------------------------------- if( pShapes->Get_Projection().Get_Type() == SG_PROJ_TYPE_CS_Undefined ) { Message_Add(_TL("layer uses undefined coordinate system, assuming geographic coordinates")); } else if( pShapes->Get_Projection().Get_Type() != SG_PROJ_TYPE_CS_Geographic ) { Message_Add(CSG_String::Format(SG_T("\n%s (%s: %s)\n"), _TL("re-projection to geographic coordinates"), _TL("original"), pShapes->Get_Projection().Get_Name().c_str()), false); bool bResult; SG_RUN_MODULE(bResult, "pj_proj4", 2, pModule->Get_Parameters()->Set_Parameter(SG_T("SOURCE"), pShapes) && pModule->Get_Parameters()->Set_Parameter(SG_T("TARGET"), &Shapes) && pModule->Get_Parameters()->Set_Parameter(SG_T("CRS_PROJ4"), SG_T("+proj=longlat +ellps=WGS84 +datum=WGS84")) ); if( bResult ) { pShapes = &Shapes; Message_Add(CSG_String::Format(SG_T("\n%s: %s\n"), _TL("re-projection"), _TL("success")), false); } else { Message_Add(CSG_String::Format(SG_T("\n%s: %s\n"), _TL("re-projection"), _TL("failed")), false); } } //----------------------------------------------------- CSG_OGR_DataSource DataSource; if( DataSource.Create(File_Name, Driver_Name) == false ) { Message_Add(_TL("could not create KML file")); } else if( DataSource.Write(pShapes, Driver_Name) ) { return( true ); } return( false ); }