//--------------------------------------------------------- bool CWKSP_Project::_Compatibility_Load_Data(CSG_File &Stream, const wxString &ProjectDir) { int Type; CSG_String sLine, sPath; CWKSP_Base_Item *pItem; while( Stream.Read_Line(sLine) && sLine.Cmp(DATA_ENTRY_BEGIN) && sLine.Cmp(DATA_ENTRIES_END) ); if( !sLine.Cmp(DATA_ENTRY_BEGIN) ) { if( Stream.Read_Line(sPath) && Stream.Read_Line(sLine) && sLine.asInt(Type) ) { if( SG_File_Exists(sPath = Get_FilePath_Absolute(ProjectDir, sPath.w_str()).wc_str()) ) { if( (pItem = g_pData->Open(sPath.w_str(), Type)) != NULL ) { if( pItem->Get_Parameters() ) { pItem->Get_Parameters()->Serialize_Compatibility(Stream); _Compatibility_Data((TSG_Data_Type)Type, pItem->Get_Parameters(), ""); pItem->Parameters_Changed(); } } } } return( true ); } return( false ); }
//--------------------------------------------------------- bool CWKSP_Project::_Load_Data(CSG_MetaData &Entry, const wxString &ProjectDir, bool bLoad, const CSG_String &Version) { if( !Entry.Cmp_Name("DATASET") || !Entry("FILE") || Entry["FILE"].Get_Content().is_Empty() ) { return( false ); } TSG_Data_Object_Type Type = Entry.Cmp_Property("type", "GRID" ) ? SG_DATAOBJECT_TYPE_Grid : Entry.Cmp_Property("type", "GRIDS" ) ? SG_DATAOBJECT_TYPE_Grids : Entry.Cmp_Property("type", "TABLE" ) ? SG_DATAOBJECT_TYPE_Table : Entry.Cmp_Property("type", "SHAPES") ? SG_DATAOBJECT_TYPE_Shapes : Entry.Cmp_Property("type", "TIN" ) ? SG_DATAOBJECT_TYPE_TIN : Entry.Cmp_Property("type", "POINTS") ? SG_DATAOBJECT_TYPE_PointCloud : SG_DATAOBJECT_TYPE_Undefined; if( Type == SG_DATAOBJECT_TYPE_Undefined ) { return( false ); } //----------------------------------------------------- wxString File = Entry("FILE")->Get_Content().c_str(); if( File.Find("PGSQL") != 0 && wxFileExists(Get_FilePath_Absolute(ProjectDir, File)) ) { File = Get_FilePath_Absolute(ProjectDir, File); } //----------------------------------------------------- CWKSP_Base_Item *pItem = NULL; if( bLoad ) { if( Type == SG_DATAOBJECT_TYPE_Grid && Entry("PARAMETERS")) { for(int i=0; i<Entry["PARAMETERS"].Get_Children_Count() && !pItem; i++) { if( Entry["PARAMETERS"][i].Cmp_Property("id", "FILE_CACHE") ) { bool bCached = Entry["PARAMETERS"][i].Cmp_Content("TRUE", true); pItem = g_pData->Add(SG_Create_Grid(&File, SG_DATATYPE_Undefined, bCached)); } } } } if( !pItem ) { pItem = bLoad ? g_pData->Open(File, Type) : _Get_byFileName(File); } //----------------------------------------------------- if( !pItem || !pItem->Get_Parameters() || !Entry.Get_Child("PARAMETERS") ) { if( bLoad ) { MSG_Error_Add(wxString::Format("%s [%s]", _TL("failed to load data"), File.c_str())); } return( false ); } //----------------------------------------------------- CSG_MetaData *pEntry = Entry("PARAMETERS"); for(int i=0; i<pEntry->Get_Children_Count(); i++) { if( !pEntry->Get_Child(i)->Get_Name().CmpNoCase("DATA") && !pEntry->Get_Child(i)->Get_Content().is_Empty() && pEntry->Get_Child(i)->Get_Content().BeforeFirst(':').CmpNoCase("PGSQL") ) { wxString File(Get_FilePath_Absolute(ProjectDir, pEntry->Get_Child(i)->Get_Content().w_str())); pEntry->Get_Child(i)->Set_Content(&File); // if( SG_Compare_SAGA_Version(Version) < 0 ) { if( pEntry->Get_Child(i)->Cmp_Property("id", "OVERLAY_1") ) { pEntry->Get_Child(i)->Set_Property("id", "OVERLAY_G"); } if( pEntry->Get_Child(i)->Cmp_Property("id", "OVERLAY_2") ) { pEntry->Get_Child(i)->Set_Property("id", "OVERLAY_B"); } } } } pItem->Get_Parameters()->Serialize(*Entry.Get_Child("PARAMETERS"), false); //----------------------------------------------------- if( SG_Compare_Version(Version, "7.0.0") < 0 ) // inter-version-compatibility { CSG_Parameter *pParameter = pItem->Get_Parameter("COLORS_TYPE"); if( pParameter && Type == SG_DATAOBJECT_TYPE_Grid ) { if( pParameter->asInt() == 4 ) { pParameter->Set_Value(6); } // Shade if( pParameter->asInt() == 5 ) { pParameter->Set_Value(4); } // RGB Overlay if( pParameter->asInt() == 6 ) { pParameter->Set_Value(5); } // RGB Composite } } //----------------------------------------------------- if( Type == SG_DATAOBJECT_TYPE_Grid ) { pItem->Get_Parameter("FILE_CACHE")->Set_Value(((CWKSP_Grid *)pItem)->Get_Grid()->is_Cached()); } pItem->Parameters_Changed(); return( true ); }
//--------------------------------------------------------- bool CWKSP_Project::_Load_Data(CSG_MetaData &Entry, const wxString &ProjectDir, bool bLoad, const CSG_String &Version) { if( Entry.Get_Name().Cmp("DATASET") || !Entry.Get_Child("FILE") || Entry.Get_Child("FILE")->Get_Content().is_Empty() ) { return( false ); } TSG_Data_Object_Type Type = Entry.Cmp_Property("type", "GRID" ) ? DATAOBJECT_TYPE_Grid : Entry.Cmp_Property("type", "TABLE" ) ? DATAOBJECT_TYPE_Table : Entry.Cmp_Property("type", "SHAPES") ? DATAOBJECT_TYPE_Shapes : Entry.Cmp_Property("type", "TIN" ) ? DATAOBJECT_TYPE_TIN : Entry.Cmp_Property("type", "POINTS") ? DATAOBJECT_TYPE_PointCloud : DATAOBJECT_TYPE_Undefined; if( Type == DATAOBJECT_TYPE_Undefined ) { return( false ); } //----------------------------------------------------- wxString File = Entry.Get_Child("FILE")->Get_Content().c_str(); if( File.Find("PGSQL") != 0 && wxFileExists(Get_FilePath_Absolute(ProjectDir, File)) ) { File = Get_FilePath_Absolute(ProjectDir, File); } CWKSP_Base_Item *pItem = bLoad ? g_pData->Open(File, Type) : _Get_byFileName(File); if( !pItem || !pItem->Get_Parameters() || !Entry.Get_Child("PARAMETERS") ) { if( bLoad ) { MSG_Error_Add(wxString::Format("%s [%s]", _TL("failed to load data"), File.c_str())); } return( false ); } //----------------------------------------------------- CSG_MetaData *pEntry = Entry("PARAMETERS"); for(int i=0; i<pEntry->Get_Children_Count(); i++) { if( !pEntry->Get_Child(i)->Get_Name().CmpNoCase("DATA") && !pEntry->Get_Child(i)->Get_Content().is_Empty() && pEntry->Get_Child(i)->Get_Content().BeforeFirst(':').Cmp("PGSQL") ) { wxString File(Get_FilePath_Absolute(ProjectDir, pEntry->Get_Child(i)->Get_Content().w_str())); pEntry->Get_Child(i)->Set_Content(&File); // if( SG_Compare_SAGA_Version(Version) < 0 ) { if( pEntry->Get_Child(i)->Cmp_Property("id", "OVERLAY_1") ) { pEntry->Get_Child(i)->Set_Property("id", "OVERLAY_G"); } if( pEntry->Get_Child(i)->Cmp_Property("id", "OVERLAY_2") ) { pEntry->Get_Child(i)->Set_Property("id", "OVERLAY_B"); } } } } pItem->Get_Parameters()->Serialize(*Entry.Get_Child("PARAMETERS"), false); pItem->Parameters_Changed(); return( true ); }