YouTube | Facebook | X(Twitter) | RSS

Densify の利用

2016/9/1 (木)

VBA
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
'That sub demonstrates how to use the ISegment::Densify method
Private Sub Densify()
  On Error GoTo ErrorHandler
    Dim ptCenter As IPoint, ptcfromto As IPoint
    Dim psegment As ISegment, pseg() As ILine
    Dim lout As Long, i As Long, pcarc As ICircularArc
    Dim ii As Long
      
    'Create a new closed Circular Arc segment
    Set ptCenter = New esriGeometry.Point
    ptCenter.PutCoords 0, 0
    Set ptcfromto = New esriGeometry.Point
    ptcfromto.PutCoords 10, 10
    Set pcarc = New CircularArc
    pcarc.PutCoords ptCenter, ptcfromto, ptcfromto, esriArcClockwise
    Set psegment = pcarc 'QI to ISegment
      
        If TypeOf psegment Is ICircularArc Then
        Debug.Print "CircularArc"
    ElseIf TypeOf psegment Is ILine Then
        Debug.Print "Line"
    End If
      
    'Call densify
    'cInSlots: 100, tells the method the number of input segments
    'maxDeviation: 0.1, tells the method that the segment must not further
    '                    a part from that distance from the curve
    'pcOutSegments: lout, Output parameter returning the the number of segments created
    'segments: pseg, pass in the first element of the array, that array
    '               will contain the output segments
      
    psegment.Densify 100, 0.1, lout, pseg(0)
    Debug.Print "The pseg array contains : " & lout & " segments"
    For ii = 0 To lout - 1
      Debug.Print pseg(ii).Length
    Next
      
    If TypeOf pseg(0) Is ICircularArc Then
        Debug.Print "CircularArc"
    ElseIf TypeOf pseg(0) Is ILine Then
        Debug.Print "Line"
    End If
      
  Exit Sub
ErrorHandler:
  MsgBox Err.Description
End Sub
  • この記事を書いた人

羽田 康祐

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

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

S