YouTube | Facebook | Twitter  Feed

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

関連記事

  • この記事を書いた人

羽田 康祐

Esri認定インストラクター、GIS上級技術者、測量士補、潜水士。GISy / GISc とその関連分野である地理学・地図学について日々の出来事で学んだ記憶を記録するためにブログを書いています。行動原理は伊達と酔狂。好きな地形は圏谷。好きな地図投影法はパースクインカンシャル図法。呉市生まれ広島市出身。GIS を使った自己紹介はこちら

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

© 2020 WINGFIELD since1981