YouTube | Facebook | X(Twitter) | RSS

レイヤからサーフェス(ISurface)の取得

2016/9/1 (木)

'レイヤからサーフェス(ISurface)の取得
Private Function GetSurfaceFromLayer(Optional sLayer, Optional OrActualLayer As ILayer) As ISurface
    Dim pLayer As ILayer
    Dim pTin As ITin
    Dim pRLayer As IRasterLayer
    Dim pTLayer As ITinLayer
    Dim pSurf As IRasterSurface
    Dim pBands As IRasterBandCollection
    Dim sName As String
On Error GoTo GetSurfaceFromLayer_ERR
'   get the layer:
    If OrActualLayer Is Nothing Then
        Set pLayer = GetLayer(sLayer)
    Else
        Set pLayer = OrActualLayer
    End If
    If pLayer Is Nothing Then Exit Function
    If TypeOf pLayer Is IRasterLayer Then
        Set pRLayer = pLayer
        Dim p3DProp As I3DProperties
        Dim pLE As ILayerExtensions
        Set pLE = pLayer
         
        Dim i As Integer
         
    '   look for 3D properties of layer:
        For i = 0 To pLE.ExtensionCount - 1
            If TypeOf pLE.Extension(i) Is I3DProperties Then
                Set p3DProp = pLE.Extension(i)
                Exit For
            End If
        Next
 
    '   look first for base surface of layer:
        Set pSurf = p3DProp.BaseSurface
         
    '   if not found, try first band of raster:
        If pSurf Is Nothing Then
            If Not pRLayer.Raster Is Nothing Then
                Set pSurf = New RasterSurface
                Set pBands = pRLayer.Raster
                pSurf.RasterBand = pBands.Item(0)
                sName = pLayer.Name
            End If
        Else
        End If
         
        Set GetSurfaceFromLayer = pSurf
         
    ElseIf TypeOf pLayer Is ITinLayer Then
    '   get the surface off the tin layer:
        Set pTLayer = pLayer
        Set GetSurfaceFromLayer = pTLayer.Dataset
    Else
     
    End If
 
    Exit Function
     
GetSurfaceFromLayer_ERR:
    Debug.Print "GetSurfaceFromLayer_ERR: " & vbCrLf & Err.Description
    Debug.Assert 0
End Function
  • この記事を書いた人

羽田 康祐

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

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