arcengine 缓冲区的创建
发布于 4 年前 作者 admin 1977 次浏览 来自 技术

缓冲区的创建

本文以面图层为例,并且把创建的缓冲区就存储在面图层中,当然也可以把创建的缓冲区另存为一个新的图层。程序运行环境(.NET+AO)    
    代码如下:
    
Private Sub ITopologicalOperator_Buffer(ByVal pFeatLyr As ESRI.ArcGIS.Carto.IFeatureLayer, ByVal distance As Double, Optional ByVal pFeatClass As ESRI.ArcGIS.Geodatabase.IFeatureClass = Nothing)
'pFeatLyr 为面图层
'distance缓冲距离
    Dim pFeatureClass As ESRI.ArcGIS.Geodatabase.IFeatureClass
    Dim pTopoOper As ESRI.ArcGIS.Geometry.ITopologicalOperator
    Dim pBufferPoly As ESRI.ArcGIS.Geometry.IPolygon
    Dim pFeatCursor As ESRI.ArcGIS.Geodatabase.IFeatureCursor
    Dim pFeature As ESRI.ArcGIS.Geodatabase.IFeature
    Try
        pFeatureClass = pFeatLyr.FeatureClass
        pFeatCursor = pFeatureClass.Search(Nothing, False)
        pFeature = pFeatCursor.NextFeature
        Do
            If Not (pFeature Is Nothing) Then
                pTopoOper = pFeature.Shape()
                pBufferPoly = pTopoOper.Buffer(distance)
                'pFeature = pFeatClass.CreateFeature
                pFeature.Shape = pBufferPoly
                pFeature.Store()
                pFeature = pFeatCursor.NextFeature()
            End If
        Loop Until (pFeature Is Nothing)
    Catch
        MsgBox(Err.Description, MsgBoxStyle.OKOnly, "错误提示")
        pFeature = Nothing
        pFeatCursor = Nothing
        pBufferPoly = Nothing
        pTopoOper = Nothing
        pFeatureClass = Nothing
        pFeatLyr = Nothing
    End Try
    pFeature = Nothing
    pFeatCursor = Nothing
    pBufferPoly = Nothing
    pTopoOper = Nothing
    pFeatureClass = Nothing
    pFeatLyr = Nothing
End Sub
赞助本站 点击广告
回到顶部