//--------------------------------------------------------- bool CWKSP_Project::_Compatibility_Load_Map(CSG_File &Stream, const wxString &ProjectDir) { TSG_Rect r; CSG_String sLine, sName; CWKSP_Base_Item *pItem; CWKSP_Map *pMap; while( Stream.Read_Line(sLine) && sLine.Cmp(MAP_ENTRY_BEGIN) && sLine.Cmp(MAP_ENTRIES_END) ); if( !sLine.Cmp(MAP_ENTRY_BEGIN) && Stream.Read_Line(sLine) ) { if( SG_SSCANF(sLine, SG_T("%lf %lf %lf %lf"), &r.xMin, &r.xMax, &r.yMin, &r.yMax) == 4 ) { pMap = NULL; while( Stream.Read_Line(sLine) && sLine.Cmp(MAP_ENTRY_END) ) { if( !sLine.Cmp(MAP_ENTRY_NAME) ) { Stream.Read_Line(sName); } else { sLine = Get_FilePath_Absolute(ProjectDir, sLine.w_str()).wc_str(); if( (pItem = _Get_byFileName(sLine.c_str())) != NULL && ( pItem->Get_Type() == WKSP_ITEM_Grid || pItem->Get_Type() == WKSP_ITEM_Grids || pItem->Get_Type() == WKSP_ITEM_TIN || pItem->Get_Type() == WKSP_ITEM_PointCloud || pItem->Get_Type() == WKSP_ITEM_Shapes) ) { if( pMap == NULL ) { pMap = new CWKSP_Map; } g_pMaps->Add((CWKSP_Layer *)pItem, pMap); } } } if( pMap ) { if( sName.Length() > 0 ) { pMap->Get_Parameter("NAME")->Set_Value(sName); pMap->Parameters_Changed(); } pMap->Set_Extent(r, true); pMap->View_Show(true); } } return( true ); } return( false ); }
//--------------------------------------------------------- bool CWKSP_Project::_Load_Map(CSG_MetaData &Entry, const wxString &ProjectDir) { TSG_Rect Extent; if( !Entry.Cmp_Name("MAP") || !Entry.Get_Child("XMIN") || !Entry.Get_Child("XMIN")->Get_Content().asDouble(Extent.xMin) || !Entry.Get_Child("XMAX") || !Entry.Get_Child("XMAX")->Get_Content().asDouble(Extent.xMax) || !Entry.Get_Child("YMIN") || !Entry.Get_Child("YMIN")->Get_Content().asDouble(Extent.yMin) || !Entry.Get_Child("YMAX") || !Entry.Get_Child("YMAX")->Get_Content().asDouble(Extent.yMax) ) { return( false ); } //----------------------------------------------------- CSG_MetaData *pNode = Entry.Get_Child("LAYERS"); if( pNode == NULL || pNode->Get_Children_Count() <= 0 ) { return( false ); } //----------------------------------------------------- int i, n; for(i=0, n=0; i<pNode->Get_Children_Count(); i++) { if( pNode->Get_Child(i)->Cmp_Name("FILE") ) { wxString FileName(pNode->Get_Child(i)->Get_Content().w_str()); if( FileName.Find("PGSQL") != 0 ) { FileName = Get_FilePath_Absolute(ProjectDir, FileName); } CWKSP_Base_Item *pItem = _Get_byFileName(FileName); if( pItem && ( pItem->Get_Type() == WKSP_ITEM_Grid || pItem->Get_Type() == WKSP_ITEM_Grids || pItem->Get_Type() == WKSP_ITEM_TIN || pItem->Get_Type() == WKSP_ITEM_PointCloud || pItem->Get_Type() == WKSP_ITEM_Shapes) ) { n++; } } } if( n == 0 ) { return( false ); } //----------------------------------------------------- CWKSP_Map *pMap = new CWKSP_Map; pMap->Get_Parameter("CRS_CHECK")->Set_Value(false); for(int i=0; i<pNode->Get_Children_Count(); i++) { if( pNode->Get_Child(i)->Cmp_Name("FILE") ) { wxString FileName(pNode->Get_Child(i)->Get_Content().w_str()); if( FileName.Find("PGSQL") != 0 ) { FileName = Get_FilePath_Absolute(ProjectDir, FileName); } CWKSP_Base_Item *pItem = _Get_byFileName(FileName); if( pItem && ( pItem->Get_Type() == WKSP_ITEM_Grid || pItem->Get_Type() == WKSP_ITEM_Grids || pItem->Get_Type() == WKSP_ITEM_TIN || pItem->Get_Type() == WKSP_ITEM_PointCloud || pItem->Get_Type() == WKSP_ITEM_Shapes) ) { g_pMaps->Add((CWKSP_Layer *)pItem, pMap); } } else if( pNode->Get_Child(i)->Cmp_Name("PARAMETERS") ) { if( pNode->Get_Child(i)->Cmp_Property("name", "GRATICULE") ) { pMap->Add_Graticule(pNode->Get_Child(i)); } if( pNode->Get_Child(i)->Cmp_Property("name", "BASEMAP") ) { pMap->Add_BaseMap (pNode->Get_Child(i)); } } } pMap->Get_Parameter("CRS_CHECK")->Set_Value(true); //----------------------------------------------------- if( Entry.Get_Child("PARAMETERS") && pMap->Get_Parameters()->Serialize(*Entry.Get_Child("PARAMETERS"), false) ) { pMap->Parameters_Changed(); } pMap->Set_Extent(Extent, true); pMap->View_Show(true); return( true ); }
//--------------------------------------------------------- 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 ); }