FeatureCursorBuffer を使用したバッファー作成

投稿日:2016/9/1 (木) 更新日:

' ワークスペースの名前を作成
Dim pWorkspaceName As IWorkspaceName = New WorkspaceName
Dim factoryType As Type = Type.GetTypeFromProgID("esriDataSourcesGDB.ScratchWorkspaceFactory")
Dim pScracthWorkspaceFactory As IScratchWorkspaceFactory2 = CType(Activator.CreateInstance(factoryType), IScratchWorkspaceFactory2)
Dim pWorkspace As IWorkspace = pScracthWorkspaceFactory.CreateNewScratchWorkspace()
Dim pDataset As IDataset = CType(pWorkspace, IDataset)
 
' フィーチャクラスの名前を作成
Dim pFeatureClassName As IFeatureClassName = New FeatureClassName
With pFeatureClassName
    .FeatureType = esriFeatureType.esriFTSimple
    .ShapeFieldName = "Shape"
    .ShapeType = esriGeometryType.esriGeometryPolygon
End With
 
' データセットの名前を作成
Dim pDatasetName As IDatasetName = pFeatureClassName
With pDatasetName
    .Name = "test"
    .WorkspaceName = pDataset.FullName
End With
 
' TOC の最上位レイヤを取得
Dim pMxDocument As IMxDocument = My.ArcMap.Document
Dim pMap As IMap = pMxDocument.FocusMap
Dim pLayer As ILayer = pMap.Layer(0)
Dim pFeatureLayer As IFeatureLayer = pLayer
 
' レイヤの空間参照を取得
Dim pGeoDataset As IGeoDataset = pFeatureLayer
Dim pSpatialReference As ISpatialReference = pGeoDataset.SpatialReference
 
' レイヤのカーソルを取得
Dim pFeatureCursor As IFeatureCursor = pFeatureLayer.Search(Nothing, True)
 
' FeatureCursorBuffer オブジェクトの取得 
Dim pFeatureCursorBuffer As IFeatureCursorBuffer2 = New FeatureCursorBuffer
 
' バッファ プロセスのプロパティを設定
Dim pBufferProcessingParameter As IBufferProcessingParameter = pFeatureCursorBuffer
With pBufferProcessingParameter
    .AdjustCirclesForProjection = False
    .BufferSpatialReference = esriBufferSpatialReferenceType.esriFeatureSetOptimizedSpatialReference
    .FeatureClass = pFeatureLayer.FeatureClass
    .GenerateRings = False
    .InputHasPolygons = False
    .SaveAsGraphics = False
    .SimplifyShapes = False
    .TargetSpatialReference = esriBufferSpatialReferenceType.esriFeatureSetOptimizedSpatialReference
End With
 
' FeatureCursorBuffer のプロパティを設定
With pFeatureCursorBuffer
    .PolygonBufferType = esriBufferType.esriBufferAll
    .Dissolve = False
    .CancelTrack = Nothing
    .FeatureCursor = pFeatureCursor
    .ValueDistance = 100000
    .SpatialReference = pSpatialReference
    .Units(esriUnits.esriMeters) = esriUnits.esriMeters
    .BufferSpatialReference = pSpatialReference
    .DataFrameSpatialReference = pSpatialReference
    .TargetSpatialReference = pSpatialReference
    .Buffer(pFeatureClassName) ' バッファの実行
End With
 
Dim pFCName As IName = CType(pFeatureClassName, IName)
Dim pFeatureClass As IFeatureClass = CType(pFCName.Open(), IFeatureClass)
Dim pFeatureCursor2 As IFeatureCursor = pFeatureClass.Search(Nothing, True)
Dim pFeature As IFeature = pFeatureCursor2.NextFeature()
Dim pGeometryBag As IGeometryCollection = New GeometryBagClass
 
While Not pFeature Is Nothing
    pGeometryBag.AddGeometry(pFeature.ShapeCopy)
    pFeature = pFeatureCursor2.NextFeature()
End While

関連記事

-プログラミング, ArcGIS
-, ,

Copyright© WINGFIELD since1981 , 2018 All Rights Reserved.