SDEWorkspace に新規フィーチャクラスの作成

Public Sub subCreateFeatureClass()
    Dim pWSFactory As IWorkspaceFactory
    Set pWSFactory = New SdeWorkspaceFactory
    
    'SDE接続情報
    Dim Server As String
    Dim Instance As String
    Dim Database As String
    Dim User As String
    Dim Password As String
    Dim Version As String
    
    Server = ""
    Instance = "5151"
    Database = ""
    User = ""
    Password = ""
    Version = "SDE.DEFAULT"
    
    
    Dim pPropertySet As IPropertySet
    Set pPropertySet = New PropertySet
    With pPropertySet
        .SetProperty "SERVER", Server
        .SetProperty "INSTANCE", Instance
        .SetProperty "DATABASE", Database
        .SetProperty "USER", User
        .SetProperty "PASSWORD", Password
        .SetProperty "VERSION", Version
    End With
    
    Dim pFWorkspace As IFeatureWorkspace
    Set pFWorkspace = pWSFactory.Open(pPropertySet, Application.hWnd)
    
    
    'Fieldsの作成
    
    '空間参照の定義
    Dim pSR As ISpatialReference
    Set pSR = New UnknownCoordinateSystem
    pSR.SetDomain 0, 21474.83645, 0, 21474.83645
    pSR.SetFalseOriginAndUnits 0, 0, 100000
    
    'ジオメトリの定義
    Dim pGeometryDef As IGeometryDefEdit
    Set pGeometryDef = New GeometryDef
    pGeometryDef.GeometryType = esriGeometryPolygon
    Set pGeometryDef.SpatialReference = pSR
    pGeometryDef.GridCount = 1
    pGeometryDef.GridSize(0) = 10
    pGeometryDef.AvgNumPoints = 2
    pGeometryDef.HasM = False
    pGeometryDef.HasZ = False
    
    'Fieldの追加(ジオメトリ)
    Dim pField1 As IFieldEdit
    Set pField1 = New Field
    pField1.Name = "Shape"
    pField1.Type = esriFieldTypeGeometry
    Set pField1.GeometryDef = pGeometryDef  '先にFieldTypeを設定する必要あり
    
    'Fieldの追加(その他)
    Dim pField2 As IFieldEdit
    Set pField2 = New Field
    pField2.Name = "aaa"
    pField2.Type = esriFieldTypeDouble
    pField2.Length = 16
    
    'Fieldのコレクションを作成
    Dim pFields As IFieldsEdit
    Set pFields = New Fields
    pFields.AddField pField1
    pFields.AddField pField2
    
    'フィーチャクラスの作成
    Dim pFeatureClass As IFeatureClass
    Set pFeatureClass = pFWorkspace.CreateFeatureClass("test", pFields, Nothing, Nothing, esriFTSimple, "Shape", "")
    
    MsgBox "フィーチャクラスを作成しました"

End Sub