4 点ポイントから外接ポリゴンを作成する方法

 2016/9/1 (木)    

Public Function PointToPolygon(ByRef pFClass As IFeatureClass, ByRef pFLayer As IFeatureLayer2) As IPolygon
 
  '------ ポイントデータからITopologicalOperator::Convex Hullで外接ポリゴンを作成する -------------
 
  Dim pFeature As IFeature
  Dim pFCursor As IFeatureCursor
  Dim pPointColl As IPointCollection
 
  Set pFCursor = pFClass.Search(Nothing, True)
  Set pFeature = pFCursor.NextFeature
  Set pPointColl = New Polygon
 
  Do While Not pFeature Is Nothing
    pPointColl.AddPoint pFeature.Shape
    Set pFeature = pFCursor.NextFeature
 
  Loop
 
 
  Dim pGeometryColl As IGeometryCollection
  Dim pTopoOperator As ITopologicalOperator
 
  Set pGeometryColl = pPointColl
  Set pTopoOperator = pGeometryColl
 
 
  Dim pGeoDataset As IGeoDataset
  Dim pPolygon As IPolygon
 
  Set pGeoDataset = pFLayer
  Set pPolygon = New Polygon
  Set pPolygon.SpatialReference = pGeoDataset.SpatialReference
 
  pTopoOperator.Simplify  'SimplifyしないとIPolygonにセットできない
  Set pPolygon = pTopoOperator.ConvexHull
 
  Set PointToPolygon = pPolygon
 
End Function

Copyright© WINGFIELD since1981 , 2018 All Rights Reserved.