//--------------------------------------------------------- bool CWKSP_Map_Graticule::Get_Graticule(const CSG_Rect &Extent) { bool bResult = false; m_Graticule .Create(SHAPE_TYPE_Line ); m_Coordinates.Create(SHAPE_TYPE_Point); CSG_Tool *pTool = SG_Get_Tool_Library_Manager().Get_Tool("pj_proj4", 14); if( pTool && Get_Map()->Get_Projection().is_Okay() ) { SG_UI_Msg_Lock (true); SG_UI_Progress_Lock(true); pTool->Settings_Push(); if( pTool->Set_Parameter("XMIN" , Extent.Get_XMin()) && pTool->Set_Parameter("XMAX" , Extent.Get_XMax()) && pTool->Set_Parameter("YMIN" , Extent.Get_YMin()) && pTool->Set_Parameter("YMAX" , Extent.Get_YMax()) && pTool->Set_Parameter("INTERVAL" , m_Parameters("INTERVAL")) && pTool->Set_Parameter("FIXED" , m_Parameters("FIXED")) && pTool->Set_Parameter("FITTED" , m_Parameters("FITTED")) && pTool->Set_Parameter("RESOLUTION", m_Parameters("RESOLUTION")) && pTool->Set_Parameter("GRATICULE" , &m_Graticule) && pTool->Set_Parameter("COORDS" , &m_Coordinates) && pTool->Set_Parameter("CRS_PROJ4" , Get_Map()->Get_Projection().Get_Proj4()) && pTool->On_Before_Execution() && pTool->Execute() ) { bResult = true; } pTool->Settings_Pop(); SG_UI_Msg_Lock (false); SG_UI_Progress_Lock(false); } return( bResult ); }
//--------------------------------------------------------- bool CSG_Shapes::Create(const CSG_String &File_Name) { Destroy(); SG_UI_Msg_Add(CSG_String::Format("%s: %s...", _TL("Load shapes"), File_Name.c_str()), true); //----------------------------------------------------- bool bResult = File_Name.BeforeFirst(':').Cmp("PGSQL") && SG_File_Exists(File_Name) && _Load_ESRI(File_Name); if( bResult ) { Set_File_Name(File_Name, true); } //----------------------------------------------------- else if( File_Name.BeforeFirst(':').Cmp("PGSQL") == 0 ) // database source { CSG_String s(File_Name); s = s.AfterFirst(':'); CSG_String Host (s.BeforeFirst(':')); s = s.AfterFirst(':'); CSG_String Port (s.BeforeFirst(':')); s = s.AfterFirst(':'); CSG_String DBName(s.BeforeFirst(':')); s = s.AfterFirst(':'); CSG_String Table (s.BeforeFirst(':')); CSG_Tool *pTool = SG_Get_Tool_Library_Manager().Get_Tool("db_pgsql", 0); // CGet_Connections if( pTool != NULL ) { SG_UI_ProgressAndMsg_Lock(true); //--------------------------------------------- CSG_Table Connections; CSG_String Connection = DBName + " [" + Host + ":" + Port + "]"; pTool->Settings_Push(); if( pTool->On_Before_Execution() && SG_TOOL_PARAMETER_SET("CONNECTIONS", &Connections) && pTool->Execute() ) // CGet_Connections { for(int i=0; !bResult && i<Connections.Get_Count(); i++) { if( !Connection.Cmp(Connections[i].asString(0)) ) { bResult = true; } } } pTool->Settings_Pop(); //--------------------------------------------- if( bResult && (bResult = (pTool = SG_Get_Tool_Library_Manager().Get_Tool("db_pgsql", 20)) != NULL) == true ) // CPGIS_Shapes_Load { pTool->Settings_Push(); bResult = pTool->On_Before_Execution() && SG_TOOL_PARAMETER_SET("CONNECTION", Connection) && SG_TOOL_PARAMETER_SET("TABLES" , Table) && SG_TOOL_PARAMETER_SET("SHAPES" , this) && pTool->Execute(); pTool->Settings_Pop(); } SG_UI_ProgressAndMsg_Lock(false); } } //----------------------------------------------------- if( bResult ) { Set_Modified(false); Set_Update_Flag(); SG_UI_Process_Set_Ready(); SG_UI_Msg_Add(_TL("okay"), false, SG_UI_MSG_STYLE_SUCCESS); return( true ); } for(int iShape=Get_Count()-1; iShape>=0; iShape--) // be kind, keep at least those shapes that have been loaded successfully { if( !Get_Shape(iShape)->is_Valid() ) { Del_Shape(iShape); } } if( Get_Count() <= 0 ) { Destroy(); } SG_UI_Process_Set_Ready(); SG_UI_Msg_Add(_TL("failed"), false, SG_UI_MSG_STYLE_FAILURE); return( false ); }