Exemplo n.º 1
0
//---------------------------------------------------------
bool CWKSP_Project::_Save_Map(CSG_MetaData &Entry, const wxString &ProjectDir, CWKSP_Map *pMap)
{
	if( !pMap )
	{
		return( false );
	}

	CSG_MetaData	*pEntry	= Entry.Add_Child("MAP");

	pEntry->Add_Child("XMIN", pMap->Get_Extent().Get_XMin());
	pEntry->Add_Child("XMAX", pMap->Get_Extent().Get_XMax());
	pEntry->Add_Child("YMIN", pMap->Get_Extent().Get_YMin());
	pEntry->Add_Child("YMAX", pMap->Get_Extent().Get_YMax());

	pMap->Get_Parameters()->Serialize(*pEntry->Add_Child("PARAMETERS"), true);

	pEntry	= pEntry->Add_Child("LAYERS");

	for(int i=pMap->Get_Count()-1; i>=0; i--)
	{
		if( pMap->Get_Item(i)->Get_Type() == WKSP_ITEM_Map_Layer )
		{
			CSG_Data_Object	*pObject	= ((CWKSP_Map_Layer *)pMap->Get_Item(i))->Get_Layer()->Get_Object();

			if( pObject && pObject->Get_File_Name(false) && *pObject->Get_File_Name(false) )
			{
				wxString	FileName(pObject->Get_File_Name(false));

				if( FileName.Find("PGSQL") == 0 )
				{
					pEntry->Add_Child("FILE", &FileName);
				}
				else if( wxFileExists(FileName) )
				{
					pEntry->Add_Child("FILE", SG_File_Get_Path_Relative(&ProjectDir, &FileName));
				}
			}
		}

		else if( pMap->Get_Item(i)->Get_Type() == WKSP_ITEM_Map_Graticule )
		{
			((CWKSP_Map_Graticule *)pMap->Get_Item(i))->Save(*pEntry);
		}

		else if( pMap->Get_Item(i)->Get_Type() == WKSP_ITEM_Map_BaseMap )
		{
			((CWKSP_Map_BaseMap   *)pMap->Get_Item(i))->Save(*pEntry);
		}
	}

	return( true );
}
Exemplo n.º 2
0
//---------------------------------------------------------
bool CCMD_Module::_Save_Output(CSG_Parameters *pParameters)
{
    for(int j=0; j<pParameters->Get_Count(); j++)
    {
        wxString		FileName;

        CSG_Parameter	*pParameter	= pParameters->Get_Parameter(j);

        //-------------------------------------------------
        if( pParameter->is_Input() )
        {
            if( pParameter->is_DataObject() )
            {
                CSG_Data_Object	*pObject	= pParameter->asDataObject();

                if( pObject && pObject->is_Modified() && SG_File_Exists(pObject->Get_File_Name()) )
                {
                    pObject->Save(pObject->Get_File_Name());
                }
            }

            else if( pParameter->is_DataObject_List() )
            {
                for(int i=0; i<pParameter->asList()->Get_Count(); i++)
                {
                    CSG_Data_Object	*pObject	= pParameter->asList()->asDataObject(i);

                    if( pObject->is_Modified() && SG_File_Exists(pObject->Get_File_Name()) )
                    {
                        pObject->Save(pObject->Get_File_Name());
                    }
                }
            }
        }

        //-------------------------------------------------
        else if( pParameter->is_Output() &&  m_CMD.Found(_Get_ID(pParameter), &FileName) && FileName.Length() > 0 )
        {
            if( pParameter->is_DataObject() )
            {
                if( pParameter->asDataObject() )
                {
                    pParameter->asDataObject()->Save(&FileName);
                }
            }

            else if( pParameter->is_DataObject_List() )
            {
                CSG_Strings	FileNames;

                while( FileName.Length() > 0 )
                {
                    CSG_String	s(&FileName);
                    s = s.BeforeFirst(';');

                    if( s.Length() > 0 )
                    {
                        FileNames	+= s;
                        FileName	 = FileName.AfterFirst(';');
                    }
                    else
                    {
                        FileNames	+= &FileName;
                        FileName	.Clear();
                    }
                }

                int	nFileNames	= pParameter->asList()->Get_Count() <= FileNames.Get_Count() ? FileNames.Get_Count() : FileNames.Get_Count() - 1;

                for(int i=0; i<pParameter->asList()->Get_Count(); i++)
                {
                    if( i < nFileNames )
                    {
                        pParameter->asList()->asDataObject(i)->Save(FileNames[i]);
                    }
                    else
                    {
                        pParameter->asList()->asDataObject(i)->Save(CSG_String::Format(SG_T("%s_%0*d"),
                                FileNames[FileNames.Get_Count() - 1].c_str(),
                                SG_Get_Digit_Count(pParameter->asList()->Get_Count()),
                                1 + i - nFileNames
                                                                                      ));
                    }
                }
            }
        }
    }

    return( true );
}