zrguang
路人甲
路人甲
  • 注册日期2004-07-15
  • 发帖数21
  • QQ
  • 铜币185枚
  • 威望0点
  • 贡献值0点
  • 银元0个
阅读:1302回复:0

把Shp数据转话成MapGis 数据

楼主#
更多 发布于:2004-07-19 11:51
<P>把Shp数据转话成MapGis 数据 </P>
<P>Public Function NewPntArea(ByRef pFeatCursor As esriCore.IFeatureCursor) As PntArea
       Dim pntAi As New PntArea
    Dim xy As New D_Dot
    Dim pntInfo  As New Pnt_Info
    Dim pntInfoStr As String
    Dim pntInfoFldIndex As Long
    
    Dim noteStr As Variant
    Dim notestring As String
    
    Dim xyz As New D_3Dot
    Dim szStr As String
    Dim fldinf As Field_Head
    
    Dim flag As Boolean
    Dim pPoint As IPoint
    Dim lres As Long
    Dim infsub As Pnt_Info_Sub
    Dim val As Variant
    Dim ATT As New MAPGISBASCOM1Lib.Record
    Dim fdName As String
    Dim fdIndex As Integer
'    pntInfo.Type = gisPNT_SUB '默认点类型为子图
'    Set infsub = pntInfo.sub
'    infsub.Angle = 0
'    infsub.Height = 0.01
'    infsub.Width = 0.01
'    infsub.subno = 35
    'Set PntInfo.sub = infsub
    
    Dim pFields As esriCore.IFields
    Set pFields = pFeatCursor.Fields
    If pFields Is Nothing Then
        Debug.Print "Failed to retrieve Fields."
    End If
    '
    ' 先建立属性表结构
    '
    Dim pField As esriCore.IField
    Dim field_name As String
    Dim field_index As Integer
    For field_index = 0 To pFields.FieldCount - 1 '属性字段
        field_name = pFields.Field(field_index).Name '取字段的名称
        
       If Not field_name = "ELEMENTINFO" Then
          Set pField = pFields.Field(field_index)
          Debug.Assert Not pField Is Nothing
          If Not pField.Type = esriCore.esriFieldTypeOID Then
             Set fldinf = MapGisField_Head(pField)
             flag = pntAi.ATT.stru.AppendField(fldinf)  '创建属性表结构
          End If
       End If
    Next field_index
    
     '将属性值写入点工作区
    Dim pFeat As IFeature
    Set pFeat = pFeatCursor.NextFeature
    Do While Not pFeat Is Nothing '要素循环
        Set pPoint = pFeat.Shape
        xy.X = pPoint.X * Vscale
        xy.Y = pPoint.Y * Vscale
        'pntai.UpdatePos lres, xy
           pntInfoStr = pFeat.value(pFeat.Fields.FindField("ELEMENTINFO"))
          
           Set pntInfo = String2PntInfo(pntInfoStr)
  
    notestring = Str1(pntInfoStr)
     Debug.Print notestring
        lres = pntAi.Append(xy, notestring, pntInfo)  '先添加一个记录'更新点坐标
        pntAi.ATT.Get 1, ATT '取得记录结构
        For field_index = 0 To ATT.Count - 1
          fdName = ATT.Item(field_index).FieldHD.FieldName
          If fdName = "ID" Then fdName = "OBJECTID"
          fdIndex = pFeat.Fields.FindField(fdName)
    '      If fdIndex > 0 Then
              ATT.value(field_index) = pFeat.value(fdIndex)
    '      End If
        Next
        pntAi.ATT.Write lres, ATT '将属性写入当前工作区记录
    
        Set pFeat = pFeatCursor.NextFeature '下一要素循环
    Loop
    
    Set NewPntArea = pntAi
    Set pntAi = Nothing
End Function</P>
<P>这样 怎么不能把属性数据导出去呢? </P>
喜欢0 评分0
游客

返回顶部