默认头像
路人甲
路人甲
  • 注册日期2003-09-03
  • 发帖数12
  • QQ
  • 铜币176枚
  • 威望0点
  • 贡献值0点
  • 银元0个
阅读:1736回复:3

arcsde数据导入请教

楼主#
更多 发布于:2007-08-14 17:50
用java对arcsde二次开发,想将数据导入到sde库中,找不到相应的方法,请教.seConntion好像没有入库的方法.谢谢
喜欢0 评分0
默认头像
路人甲
路人甲
  • 注册日期2007-06-20
  • 发帖数64
  • QQ
  • 铜币58枚
  • 威望0点
  • 贡献值0点
  • 银元0个
1楼#
发布于:2007-08-17 12:26

'向Sde空间数据库中插入一条记录,并返回其ObjectId。

Public Shared Function InsertFeatureToSde(ByVal pFeatureGeometry As IGeometry, ByVal FeatureAttributes As Collection, ByVal strSDETableName As String, _
                                                 Optional ByVal txtLog As System.Windows.Forms.TextBox = Nothing, _
                                                 Optional ByVal Flag As Integer = -1, _
                                                 Optional ByVal ds As DataSet = Nothing, _
                                                 Optional ByVal pShapeFileds As Collection = Nothing) As Long
           On Error GoTo errhdl

           '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
           Dim pFeatureClass As IFeatureClass, pFeatureCursor As IFeatureCursor, pFeatureBuffer As IFeatureBuffer, pFeatureFields As IFields, pFeatureField As IField
           Dim i As Integer, m As Integer, strFieldName As String, strFieldVale As String, boolNull As Boolean = False
           Dim FeatureObjectID As Long
           Dim ErrSelfIntersect As Integer = 0

           '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
           Select Case Flag
               Case -1, 2
                   strSDETableName = "SDE." ; strSDETableName
                   pFeatureClass = pFeatureClassCollection.Item(strSDETableName)
               Case 1, 3
                   pFeatureClass = pFeatureWorkspace.OpenFeatureClass(strSDETableName)
           End Select
           If pFeatureClass Is Nothing Then
               txtLog.Text = txtLog.Text ; Trim(FeatureAttributes.Item("UCODE")) ; ".shp:" ; "Shape文件对应空间图层" ; Mid(strSDETableName, 5) ; "没有找到" ; vbCrLf
               pFeatureClass = Nothing
               Exit Function
           End If
           pFeatureCursor = pFeatureClass.Insert(True)
           pFeatureBuffer = pFeatureClass.CreateFeatureBuffer
           pFeatureFields = pFeatureClass.Fields

           '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
           Select Case Flag
               Case -1, 1, 3
                   For i = 0 To pFeatureFields.FieldCount - 1
                       DoEvents()
                       boolNull = False
                       pFeatureField = pFeatureFields.Field(i)
                       If pFeatureField.Type = esriFieldType.esriFieldTypeGeometry Then
                           pFeatureBuffer.Value(i) = pFeatureGeometry
                       Else
                           strFieldName = pFeatureField.Name
                           strFieldVale = FeatureAttributes.Item(strFieldName)
                           If Not boolNull And Not UCase(Trim(strFieldVale)) = "NUL" Then
                               If pFeatureField.Type = esriFieldType.esriFieldTypeString Then
                                   If strFieldName = "MAXH" Then
                                       If CDbl(Trim(strFieldVale)) <> 0 Then
                                           pFeatureBuffer.Value(i) = Trim(strFieldVale)
                                       End If
                                   Else
                                       pFeatureBuffer.Value(i) = Trim(strFieldVale)
                                   End If
                               End If
                               If pFeatureField.Type = esriFieldType.esriFieldTypeDouble Then
                                   pFeatureBuffer.Value(i) = CDbl(Trim(strFieldVale))
                               End If
                           End If
                       End If
                   Next
               Case 2
                   '赋FeatureBuffer图形数据
                   strFieldName = pFeatureClass.ShapeFieldName
                   m = pFeatureBuffer.Fields.FindField(strFieldName)
                   If Not m = -1 Then
                       pFeatureBuffer.Value(m) = pFeatureGeometry
                   End If
                   '赋FeatureBuffer属性数据
                   For i = 1 To pShapeFileds.Count
                       strFieldName = UCase(Trim(pShapeFileds.Item(i)))
                       m = pFeatureBuffer.Fields.FindField(strFieldName)
                       If Not m = -1 Then
                           boolNull = False
                           strFieldVale = FeatureAttributes.Item(strFieldName)
                           If Not boolNull And Not UCase(Trim(strFieldVale)) = "NUL" Then
                               If pFeatureBuffer.Fields.Field(m).Type = esriFieldType.esriFieldTypeString Then
                                   pFeatureBuffer.Value(m) = Trim(strFieldVale)
                               End If
                               If pFeatureBuffer.Fields.Field(m).Type = esriFieldType.esriFieldTypeDouble Then
                                   If strFieldName = "SYMBANGLE" Then
                                       pFeatureBuffer.Value(m) = CDbl(Trim(strFieldVale)) + 90
                                   Else
                                       pFeatureBuffer.Value(m) = CDbl(Trim(strFieldVale))
                                   End If
                               End If
                           End If
                       Else
                           If Not strFieldName = "NAME" Then
                               txtLog.Text = txtLog.Text ; Trim(FeatureAttributes.Item("UCODE")) ; ".shp:找不到Sde空间图层属性字段" ; strFieldName ; vbCrLf
                           End If
                       End If
                   Next
                   If Not pFeatureBuffer.Fields.FindField("UCODE") = -1 Then pFeatureBuffer.Value(pFeatureBuffer.Fields.FindField("UCODE")) = Trim(FeatureAttributes.Item("UCODE"))
                   If Not pFeatureBuffer.Fields.FindField("NAME") = -1 Then pFeatureBuffer.Value(pFeatureBuffer.Fields.FindField("NAME")) = Trim(FeatureAttributes.Item("NAME"))
                   If Not pFeatureBuffer.Fields.FindField("NFCODE") = -1 Then pFeatureBuffer.Value(pFeatureBuffer.Fields.FindField("NFCODE")) = Trim(FeatureAttributes.Item("NFCODE"))
           End Select
           FeatureObjectID = pFeatureCursor.InsertFeature(pFeatureBuffer)
           If Flag = 3 Then pFeatureCursor.Flush()
       
           Return FeatureObjectID

代码没有经过整理,中间可能有比较多关于业务的内容,不过关于接口方面的东东楼主还是可以参考一下

********************************** 喜欢有激情的生活 msn:hou.jiazte@hotmail.com 欢迎交流 **********************************
举报 回复(0) 喜欢(0)     评分
默认头像
路人甲
路人甲
  • 注册日期2003-09-03
  • 发帖数12
  • QQ
  • 铜币176枚
  • 威望0点
  • 贡献值0点
  • 银元0个
2楼#
发布于:2007-08-16 19:22

是的,shp文件.不好意思没说清楚.

举报 回复(0) 喜欢(0)     评分
默认头像
路人甲
路人甲
  • 注册日期2007-06-20
  • 发帖数64
  • QQ
  • 铜币58枚
  • 威望0点
  • 贡献值0点
  • 银元0个
3楼#
发布于:2007-08-15 11:12

什么数据类型导入sde?

shp还是其他?

********************************** 喜欢有激情的生活 msn:hou.jiazte@hotmail.com 欢迎交流 **********************************
举报 回复(0) 喜欢(0)     评分
默认头像

返回顶部