Esempio n. 1
0
void wxGxArchiveFolder::LoadChildren(void)
{
	if(m_bIsChildrenLoaded)
		return;
    char **papszItems = CPLReadDir(m_sPath);
    if(papszItems == NULL)
        return;

    char **papszFileList = NULL;
    //remove unused items
    for(int i = CSLCount(papszItems) - 1; i >= 0; i-- )
    {
        if( wxGISEQUAL(papszItems[i],".") || wxGISEQUAL(papszItems[i],"..") )
            continue;
        CPLString szFileName = m_sPath;
        szFileName += "/";
        szFileName += papszItems[i];

        VSIStatBufL BufL;
        int ret = VSIStatL(szFileName, &BufL);
        if(ret == 0)
        {
            if(VSI_ISDIR(BufL.st_mode))
            {
		        wxString sCharset(wxT("cp-866"));
		        wxGISAppConfig oConfig = GetConfig();
                if(oConfig.IsOk())
			        sCharset = oConfig.Read(enumGISHKCU, wxString(wxT("wxGISCommon/zip/charset")), sCharset);
                wxString sFileName(papszItems[i], wxCSConv(sCharset));
				GetArchiveFolder(this, sFileName, szFileName);
            }
            else
            {
                papszFileList = CSLAddString( papszFileList, szFileName );
            }
        }
    }
    CSLDestroy( papszItems );

    //load names
    wxGxCatalog *pCatalog = wxDynamicCast(GetGxCatalog(), wxGxCatalog);

	if(pCatalog)
    {
        wxArrayLong ChildrenIds;
        pCatalog->CreateChildren(this, papszFileList, ChildrenIds);
        for(size_t i = 0; i < ChildrenIds.GetCount(); ++i)
            pCatalog->ObjectAdded(ChildrenIds[i]);
	}

    CSLDestroy( papszFileList );

	m_bIsChildrenLoaded = true;
}
Esempio n. 2
0
void wxGxOpenFileGDB::FillMetadata(bool bForce)
{
    if (m_bIsMetadataFilled && !bForce)
        return;
    m_bIsMetadataFilled = true;

    wxGISDataset* pDSet = GetDatasetFast();
    if (NULL == pDSet)
    {
        return;
    }

    VSIStatBufL BufL;
    wxULongLong nSize(0);
    wxDateTime dt(1,wxDateTime::Jan, 1900);
    int ret = VSIStatL(m_sPath, &BufL);
    if (ret == 0)
    {
        //nSize += BufL.st_size;
        //dt = wxDateTime(BufL.st_mtime);

        if (VSI_ISDIR(BufL.st_mode))
        {
            char **papszItems = CPLReadDir(wxGxObjectContainer::GetPath());
            if (papszItems && CSLCount(papszItems) > 0)
            {
                for (int i = 0; papszItems[i] != NULL; ++i)
                {
                    if (wxGISEQUAL(papszItems[i], ".") || wxGISEQUAL(papszItems[i], ".."))
                        continue;
                    CPLString szFullPathFrom = CPLFormFilename(wxGxObjectContainer::GetPath(), papszItems[i], NULL);

                    ret = VSIStatL(szFullPathFrom, &BufL);
                    if (ret == 0)
                    {
                        nSize += BufL.st_size;
                        wxDateTime dtt(BufL.st_mtime);
                        if (dtt > dt)
                            dt = dtt;
                    }
                }
            }
            CSLDestroy(papszItems);
        }
    }


    m_nSize = nSize;
    m_dtMod = dt;

    wsDELETE(pDSet);
}
Esempio n. 3
0
bool wxGxWebConnectionFactory::GetChildren(wxGxObject* pParent, char** &pFileNames, wxArrayLong & pChildrenIds)
{
    wxGxCatalogBase* pCatalog = GetGxCatalog();
    for(int i = CSLCount(pFileNames) - 1; i >= 0; i-- )
    {
        CPLString szExt = CPLGetExtension(pFileNames[i]);
		if(wxGISEQUAL(szExt, "wconn"))
		{
            if( m_bHasDriver )
            {
    			wxGxObject* pObj = GetGxObject(pParent, GetConvName(pFileNames[i]), pFileNames[i]); 
                if(pObj)
                    pChildrenIds.Add(pObj->GetId());
            }
            pFileNames = CSLRemoveStrings( pFileNames, i, 1, NULL );
		}
    }
	return true;
}
bool wxGxLocalDBFactory::GetChildren(wxGxObject* pParent, char** &pFileNames, wxArrayLong & pChildrenIds)
{
    wxGxCatalogBase* pCatalog = GetGxCatalog();
    bool bCheckNames = CSLCount(pFileNames) < CHECK_DUBLES_MAX_COUNT;
    for(int i = CSLCount(pFileNames) - 1; i >= 0; i-- )
    {
        VSIStatBufL BufL;
        int ret = VSIStatL(pFileNames[i], &BufL);
        if(ret == 0)
        {
            if (VSI_ISDIR(BufL.st_mode) && wxGISEQUAL(CPLGetExtension(pFileNames[i]), "gdb"))
            {
                wxGxObject* pObj = GetGxObject(pParent, wxString(CPLGetFilename(pFileNames[i]), wxConvUTF8), pFileNames[i], enumContGDBFolder, bCheckNames);
                if(pObj)
                    pChildrenIds.Add(pObj->GetId());
                pFileNames = CSLRemoveStrings( pFileNames, i, 1, NULL );
            }
            //TODO: mdb, sqlite, db extensions
        }
    }
    return true;
}
Esempio n. 5
0
bool wxGxPrjFactory::GetChildren(wxGxObject* pParent, char** &pFileNames, wxArrayLong & pChildrenIds)
{
    bool bCheckNames = CSLCount(pFileNames) < CHECK_DUBLES_MAX_COUNT;
    for(int i = CSLCount(pFileNames) - 1; i >= 0; i-- )
    {
        CPLString szExt = CPLGetExtension(pFileNames[i]);

        wxGxObject* pGxObj = NULL;
 
        if(wxGISEQUAL(szExt, "prj"))
        {
            bool bAdd = true;
            for(int j = 0; prj_notadd_exts[j] != NULL; ++j )
            {
                if(CPLCheckForFile((char*)CPLResetExtension(pFileNames[i], prj_notadd_exts[j]), NULL))
                {
                    bAdd = false;
                    break;
                }
            }

            if(bAdd)
            {
                pGxObj = GetGxObject(pParent, GetConvName(pFileNames[i]), pFileNames[i], enumESRIPrjFile, bCheckNames);
            }

            pFileNames = CSLRemoveStrings( pFileNames, i, 1, NULL );
        }
        else if(wxGISEQUAL(szExt, "qpj"))
        {
            bool bAdd = true;
            for(int j = 0; prj_notadd_exts[j] != NULL; ++j )
            {
                if(CPLCheckForFile((char*)CPLResetExtension(pFileNames[i], prj_notadd_exts[j]), NULL))
                {
                    bAdd = false;
                    break;
                }
            }

            if(bAdd)
            {
                pGxObj = GetGxObject(pParent, GetConvName(pFileNames[i]), pFileNames[i], enumQPJfile, bCheckNames);
            }

            pFileNames = CSLRemoveStrings( pFileNames, i, 1, NULL );
        }
        else if(wxGISEQUAL(szExt, "spr"))
        {
            pGxObj = GetGxObject(pParent, GetConvName(pFileNames[i]), pFileNames[i], enumSPRfile, bCheckNames);

            pFileNames = CSLRemoveStrings( pFileNames, i, 1, NULL );
        }

        if(pGxObj)
        {
            pChildrenIds.Add(pGxObj->GetId());
            pGxObj = NULL;
        }
    }
	return true;
}
wxGxObject* wxGxMapInfoFactoryUI::GetGxObject(wxGxObject* pParent, const wxString &soName, const CPLString &szPath, wxGISEnumVectorDatasetType type, bool bCheckNames)
{
    if(!m_bHasDriver)
        return NULL;

    if(bCheckNames && IsNameExist(pParent, soName))
    {
        return NULL;
    }

    switch(type)
    {
    case enumVecMapinfoTab:
        {
            CPLString sTestPath;
            wxGxObject *pCompoundObjectPart = NULL;
            wxGxObjectContainer* pParentCont = wxDynamicCast(pParent, wxGxObjectContainer);

            for (int j = 0; mi_filter_exts[j] != NULL; ++j)
            {
                sTestPath = (char*)CPLResetExtension(szPath, mi_filter_exts[j]);

                wxGxObjectList::const_iterator iter;
                for (iter = pParentCont->GetChildren().begin(); iter != pParentCont->GetChildren().end(); ++iter)
                {
                    wxGxObject *current = *iter;
                    if (wxGISEQUAL(current->GetPath(), sTestPath))
                    {
                        current->Destroy();
                        break;
                    }
                }
            }

            if(!m_SmallTabIcon.IsOk())
                m_SmallTabIcon = wxIcon(mi_dset_16_xpm);
            if(!m_LargeTabIcon.IsOk())
                m_LargeTabIcon = wxIcon(mi_dset_48_xpm);

            return wxStaticCast(new wxGxFeatureDatasetUI(type, pParent, soName, szPath, m_LargeTabIcon, m_SmallTabIcon), wxGxObject);
        }
    case enumVecMapinfoMif:
        if(!m_SmallMifIcon.IsOk())
            m_SmallMifIcon = wxIcon(md_dset_16_xpm);
        if(!m_LargeMifIcon.IsOk())
            m_LargeMifIcon = wxIcon(md_dset_48_xpm);
        return wxStaticCast(new wxGxFeatureDatasetUI(type, pParent, soName, szPath, m_LargeMifIcon, m_SmallMifIcon), wxGxObject);
    case enumVecMAX + 1:
        if(!m_SmallTabTIcon.IsOk())
            m_SmallTabTIcon = wxIcon(table_tab_16_xpm);
        if(!m_LargeTabTIcon.IsOk())
            m_LargeTabTIcon = wxIcon(table_tab_48_xpm);
        return wxStaticCast(new wxGxTableDatasetUI(enumTableMapinfoTab, pParent, soName, szPath, m_LargeTabTIcon, m_SmallTabTIcon), wxGxObject);
    case enumVecMAX + 2:
        if(!m_SmallTabTIcon.IsOk())
            m_SmallTabTIcon = wxIcon(table_tab_16_xpm);
        if(!m_LargeTabTIcon.IsOk())
            m_LargeTabTIcon = wxIcon(table_tab_48_xpm);
        return wxStaticCast(new wxGxTableDatasetUI(enumTableMapinfoMif, pParent, soName, szPath, m_LargeTabTIcon, m_SmallTabTIcon), wxGxObject);
    default:
        return NULL;
    }
}
bool wxGxRasterFactory::GetChildren(wxGxObject* pParent, char** &pFileNames, wxArrayLong & pChildrenIds)
{
    bool bCheckNames = CSLCount(pFileNames) < CHECK_DUBLES_MAX_COUNT;
    for(int i = CSLCount(pFileNames) - 1; i >= 0; i-- )
    {
        wxGxObject* pGxObj = NULL;
        CPLString szExt = CPLGetExtension(pFileNames[i]);
        CPLString szPath;
        bool bContinue(false);

        unsigned int j;
        for(j = 0; j < sizeof(raster_exts) / sizeof(raster_exts[0]); ++j)
        {
            if(wxGISEQUAL(szExt, raster_exts[j].sExt) )
		    {
                if(raster_exts[j].bAvailable)
                {
                    CPLString szPath(pFileNames[i]);
                    pGxObj = GetGxObject(pParent, GetConvName(szPath), szPath, raster_exts[j].eType, bCheckNames);
                    if(pGxObj != NULL)
                        pChildrenIds.Add(pGxObj->GetId());
                }
                pFileNames = CSLRemoveStrings( pFileNames, i, 1, NULL );
                bContinue = true;
                break;
		    }
        }

        if(bContinue)
            continue;


        if(wxGISEQUAL(szExt, "prj"))
        {
			if(pFileNames)
			{
                unsigned int j;
                for(j = 0; j < sizeof(raster_exts) / sizeof(raster_exts[0]); ++j)
                {
    				szPath = (char*)CPLResetExtension(pFileNames[i], raster_exts[j].sExt);
	    			if(CPLCheckForFile((char*)szPath.c_str(), NULL))
                    {
		    			pFileNames = CSLRemoveStrings( pFileNames, i, 1, NULL );
                        bContinue = true;
                        break;
                    }
                }
            }
        }

        if(bContinue)
            continue;
        
        for( j = 0; raster_add_exts[j] != NULL; ++j )
        {
            if(wxGISEQUAL(szExt, raster_add_exts[j]))
            {
                pFileNames = CSLRemoveStrings( pFileNames, i, 1, NULL );
                break;
            }
        }
    }
	return true;
}