//--------------------------------------------------------- bool CSG_PointCloud::_Save(const CSG_String &File_Name) { CSG_File Stream; SG_UI_Msg_Add(CSG_String::Format(SG_T("%s: %s..."), _TL("Save point cloud"), File_Name.c_str()), true); CSG_String sFile_Name = SG_File_Make_Path(NULL, File_Name, SG_T("spc")); if( Stream.Open(sFile_Name, SG_FILE_W, true) == false ) { SG_UI_Msg_Add(_TL("failed"), false, SG_UI_MSG_STYLE_FAILURE); SG_UI_Msg_Add_Error(_TL("unable to create file.")); return( false ); } int i, iBuffer, nPointBytes = m_nPointBytes - 1; Stream.Write((void *)PC_FILE_VERSION, 6); Stream.Write(&nPointBytes , sizeof(int)); Stream.Write(&m_nFields , sizeof(int)); for(i=0; i<m_nFields; i++) { Stream.Write(&m_Field_Type[i], sizeof(TSG_Data_Type)); iBuffer = (int)m_Field_Name[i]->Length(); if( iBuffer >= 1024 - 1 ) iBuffer = 1024 - 1; Stream.Write(&iBuffer, sizeof(int)); Stream.Write((void *)m_Field_Name[i]->b_str(), sizeof(char), iBuffer); } _Set_Shape(m_Shapes_Index); for(i=0; i<Get_Count() && SG_UI_Process_Set_Progress(i, Get_Count()); i++) { Stream.Write(m_Points[i] + 1, nPointBytes); } Set_Modified(false); Set_File_Name(sFile_Name, true); Save_MetaData(File_Name); Get_Projection().Save(SG_File_Make_Path(NULL, File_Name, SG_T("prj")), SG_PROJ_FMT_WKT); SG_UI_Msg_Add(_TL("okay"), false, SG_UI_MSG_STYLE_SUCCESS); SG_UI_Process_Set_Ready(); return( true ); }
//--------------------------------------------------------- bool CSG_Shapes::Save(const CSG_String &File_Name, int Format) { SG_UI_Msg_Add(CSG_String::Format(SG_T("%s: %s..."), _TL("Save shapes"), File_Name.c_str()), true); if( _Save_ESRI(File_Name) ) { Set_Modified(false); Set_File_Name(File_Name, true); Save_MetaData(File_Name); SG_UI_Msg_Add(_TL("okay"), false, SG_UI_MSG_STYLE_SUCCESS); return( true ); } SG_UI_Msg_Add(_TL("failed"), false, SG_UI_MSG_STYLE_FAILURE); return( false ); }
bool CSG_Grid::Save(const CSG_String &File_Name, int Format, int xA, int yA, int xN, int yN) { bool bResult; CSG_String sFile_Name = SG_File_Make_Path(NULL, File_Name, SG_T("sgrd")); //----------------------------------------------------- if( xA < 0 || xA >= Get_NX() - 1 ) { xA = 0; } if( yA < 0 || yA >= Get_NY() - 1 ) { yA = 0; } if( xN > Get_NX() - xA ) { xN = Get_NX() - xA; } if( yN > Get_NY() - yA ) { yN = Get_NY() - yA; } //----------------------------------------------------- SG_UI_Msg_Add(CSG_String::Format(SG_T("%s: %s..."), LNG("[MSG] Save grid"), File_Name.c_str()), true); switch( Format ) { default: case GRID_FILE_FORMAT_Binary: // 1 - Binary bResult = _Save_Native(sFile_Name, xA, yA, xN, yN, true); break; case GRID_FILE_FORMAT_ASCII: // 2 - ASCII bResult = _Save_Native(sFile_Name, xA, yA, xN, yN, false); break; } //----------------------------------------------------- if( bResult ) { Set_Modified(false); Set_File_Name(sFile_Name); Save_MetaData(File_Name); SG_UI_Msg_Add(LNG("[MSG] okay"), false, SG_UI_MSG_STYLE_SUCCESS); } else { SG_UI_Msg_Add(LNG("[MSG] failed"), false, SG_UI_MSG_STYLE_FAILURE); SG_UI_Msg_Add_Error(LNG("[ERR] Grid file could not be saved.")); } return( bResult ); }
//--------------------------------------------------------- bool CSG_Table::Save(const CSG_String &File_Name, int Format, const SG_Char *Separator) { bool bResult; CSG_String sSeparator(Separator); SG_UI_Msg_Add(CSG_String::Format(SG_T("%s: %s..."), LNG("[MSG] Save table"), File_Name.c_str()), true); //----------------------------------------------------- if( Format <= TABLE_FILETYPE_Undefined || Format > TABLE_FILETYPE_DBase ) { if( SG_File_Cmp_Extension(File_Name, SG_T("dbf")) ) { Format = TABLE_FILETYPE_DBase; } else if( SG_File_Cmp_Extension(File_Name, SG_T("csv")) ) { Format = TABLE_FILETYPE_Text; sSeparator = ';'; } else //if( SG_File_Cmp_Extension(File_Name, SG_T("txt")) ) { Format = TABLE_FILETYPE_Text; } } switch( Format ) { case TABLE_FILETYPE_Text: bResult = _Save_Text (File_Name, true , Separator); break; case TABLE_FILETYPE_Text_NoHeadLine: bResult = _Save_Text (File_Name, false, Separator); break; case TABLE_FILETYPE_DBase: bResult = _Save_DBase(File_Name); break; } //----------------------------------------------------- if( bResult ) { Set_Modified(false); Set_Update_Flag(); Set_File_Type(Format); Set_File_Name(File_Name); Save_MetaData(File_Name); SG_UI_Msg_Add(LNG("[MSG] okay"), false, SG_UI_MSG_STYLE_SUCCESS); return( true ); } SG_UI_Msg_Add(LNG("[MSG] failed"), false, SG_UI_MSG_STYLE_FAILURE); return( false ); }