SDE要素类导出为shp格式文件

与导出到PGDB的方法相似,shapefile没有Annotation featureclass,所以用以下这一方法就够

Private Sub ExportFeatureClass(pFeatWorkspace As IFeatureWorkspace, pGeometry As IGeometry, pFCN() As String, OutputLocation As String)
     
    
Dim pFeatCLS As IFeatureClass
    
    
Dim pSelectionSet As ISelectionSet
    
Dim pExportOp As IExportOperation
    
Dim pDataset As IDataset
    
Dim pInFeatureClassName As IFeatureClassName
    
Dim pInDsName As IDatasetName
    
Dim pFeatureClassName As IFeatureClassName
    
Dim pOutDatasetName As IDatasetName
    
Dim pWorkspaceName As IWorkspaceName
    
    
Dim pProgID As String
    pProgID 
= "esriDataSourcesFile.ShapefileWorkspaceFactory"
     
    
'create new spatial filter
    Dim pSpatialFilter As ISpatialFilter
    
Dim pFilter As IQueryFilter
    
Set pSpatialFilter = New SpatialFilter
    
Set pSpatialFilter.Geometry = pGeometry
    pSpatialFilter.GeometryField 
= "SHAPE"
    pSpatialFilter.SpatialRel 
= esriSpatialRelEnum.esriSpatialRelIntersects
    
Set pFilter = pSpatialFilter
 
    
Dim j As Integer
    
For j = LBound(pFCN) To UBound(pFCN)
     
                
        
Set pFeatCLS = pFeatWorkspace.OpenFeatureClass(pFCN(j))
         
          
           
Set pSelectionSet = pFeatCLS.Select(pFilter, esriSelectionTypeIDSet, esriSelectionOption.esriSelectionOptionNormal, Nothing)

           
Set pWorkspaceName = New WorkspaceName
           pWorkspaceName.PathName 
= OutputLocation
           pWorkspaceName.WorkspaceFactoryProgID 
= pProgID

           
Set pDataset = pFeatCLS
           
Set pInFeatureClassName = pDataset.FullName
           
Set pInDsName = pInFeatureClassName

           
Set pFeatureClassName = New FeatureClassName

           
Set pOutDatasetName = pFeatureClassName
           
'    pOutDatasetName.Name = pFeatCls.AliasName & "_exp"
           Dim position As Integer
           position 
= InStr(pFeatCLS.AliasName, ".")
           
          
If position > 0 Then
           pOutDatasetName.Name 
= Right(pFeatCLS.AliasName, Len(pFeatCLS.AliasName) - position)
         
          
Else
            pOutDatasetName.Name 
= pFeatCLS.AliasName
          
End If
          
        
'   pOutDatasetName.Name = pFeatCls.AliasName
           Set pOutDatasetName.WorkspaceName = pWorkspaceName


           
Set pExportOp = New ExportOperation

           pExportOp.ExportFeatureClass pInDsName, 
Nothing, pSelectionSet, Nothing, pOutDatasetName, 0
          
              
       
        
Set pFeatCLS = Nothing
          
       
    
Next j
       
    
    
'Dispose
    Set pFeatCLS = Nothing
    
Set pSpatialFilter = Nothing
    
Set pFilter = Nothing
    
Set pSelectionSet = Nothing
    
Set pExportOp = Nothing
    
Set pDataset = Nothing
    
Set pInFeatureClassName = Nothing
    
Set pInDsName = Nothing
    
Set pFeatureClassName = Nothing
    
Set pOutDatasetName = Nothing
    
Set pWorkspaceName = Nothing
    
    
End Sub

 

posted on 2009-04-03 10:55  炜升  阅读(761)  评论(0编辑  收藏  举报