YouTube | Facebook | X(Twitter) | RSS

IProximityOperator でポリゴンとポイントの近接点を取得

2016/9/1 (木)

'IProximityOperator でポリゴンとポイントの近接点の取得
Sub GetQueryNearestPoint()
     
    Dim pPoint(3) As IPoint
    Set pPoint(0) = New Point
    Set pPoint(1) = New Point
    Set pPoint(2) = New Point
    Set pPoint(3) = New Point
     
    Dim pInPoint As IPoint
    Set pInPoint = New Point
     
    Call pPoint(0).PutCoords(0, 0)
    Call pPoint(1).PutCoords(0, 100)
    Call pPoint(2).PutCoords(100, 100)
    Call pPoint(3).PutCoords(100, 0)
    Call pInPoint.PutCoords(300, 50)
     
     
    Dim pPointCollection As IPointCollection
    Set pPointCollection = New Polygon
    Call pPointCollection.AddPoint(pPoint(0))
    Call pPointCollection.AddPoint(pPoint(1))
    Call pPointCollection.AddPoint(pPoint(2))
    Call pPointCollection.AddPoint(pPoint(3))
    Call pPointCollection.AddPoint(pPoint(0))
     
     
    Dim pProximityOperator As IProximityOperator
    Set pProximityOperator = pPointCollection
     
    '近接点の取得(ReturnNearestPoint)
    Dim pNearestPoint As IPoint
    'Set pNearestPoint = pProximityOperator.ReturnNearestPoint(pInPoint, esriNoExtension)
     
    '近接点の取得(QueryNearestPoint)
    Set pNearestPoint = New Point  '事前に空の Point オブジェクトを作成
    Call pProximityOperator.QueryNearestPoint(pInPoint, esriNoExtension, pNearestPoint)
     
    Dim dblNearestDistance As Double
    dblNearestDistance = pProximityOperator.ReturnDistance(pInPoint)
     
    Debug.Print dblNearestDistance, pNearestPoint.X, pNearestPoint.Y
 
End Sub
  • この記事を書いた人

羽田 康祐

伊達と酔狂のGISエンジニア。GIS上級技術者、Esri認定インストラクター、CompTIA CTT+ Classroom Trainer、潜水士、PADIダイブマスター、四アマ。WordPress は 2.1 からのユーザーで歴だけは長い。 代表著書『"地図リテラシー入門―地図の正しい読み方・描き方がわかる』 GIS を使った自己紹介はこちら。ESRIジャパン(株)所属、元青山学院大学非常勤講師を兼務。日本地図学会第31期常任委員。発言は個人の見解です。

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