您的位置:首页 > 其它

打开coverage中的属性表

2013-09-26 08:35 393 查看
不经意间看到,兴许对打开info表可供参考,便粘过来。上为错误代码,下面为修正的

 

 

 

我用Ifeatureworkspace.opentable 无法实现coverage下属性表的打开,是不是因为coverage的属性表是存放在info文件夹中,所以打开失败,该如何做?我的代码如下:

Public Function OpenTableFromFile(sPath As String, sTableName As String) As ITable

' This function returns an ITable interface pointer from an INFO or DBF file. it will give an

' automation error if table type is not a dbf table or info table

On Error GoTo ERH

Dim pTable As ITable

Dim pWSFact As IWorkspaceFactory

Dim pFeatWork As IFeatureWorkspace

' choice of workspace factory depends if table is INFO or DBF

Dim sSplit() As String

sSplit = Split(sTableName, ".")

If UBound(sSplit) = LBound(sSplit) Then ' no dots in name, assume info table

Set pWSFact = New ArcInfoWorkspaceFactory

Else

If sSplit(1) = "dbf" Then

Set pWSFact = New ShapefileWorkspaceFactory

Else 'not dbf assume info table

Set pWSFact = New ArcInfoWorkspaceFactory

End If

End If

If pWSFact.IsWorkspace(sPath) Then

Set pFeatWork = pWSFact.OpenFromFile(sPath, 0)

Set pTable = pFeatWork.OpenTable(sTableName)

End If

' Return the table pointer

Set OpenTableFromFile = pTable

Exit Function

ERH:

MsgBox "Failed in opening table from file " & Err.Description

End Function

 

问题已解决,把代码贴出来吧:

Public Function GetTable(pGxObject As IGxObject) As ITable

'Use name objects because they are faster than opening objects

'Coverage featureclasses will return null

On Error GoTo err:

Dim pDatasetName As IDatasetName

Dim pDSType As esriDatasetType

Dim pname As IName

'Check for QI

Dim pArcInfoTable As IArcInfoTable

Set pname = pGxObject.InternalObjectName

If TypeOf pname Is IDatasetName Then

Set pDatasetName = pname

pDSType = pDatasetName.Type

If pDSType = esriDTTable Or pDSType = esriDTFeatureClass Then

Set GetTable = pname.Open

Set pT = GetTable

Exit Function

End If

End If

Exit Function

err:

If err.Number = 13 Then

Resume Next

End If

End Function

 
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  属性表 INFO表 Coverage