joelee
路人甲
路人甲
  • 注册日期2003-09-03
  • 发帖数12
  • QQ
  • 铜币176枚
  • 威望0点
  • 贡献值0点
  • 银元0个
阅读:1738回复: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-15 11:12
<P>什么数据类型导入sde?</P>
<P>shp还是其他?</P>
********************************** 喜欢有激情的生活 msn:hou.jiazte@hotmail.com 欢迎交流 **********************************
举报 回复(0) 喜欢(0)     评分
joelee
路人甲
路人甲
  • 注册日期2003-09-03
  • 发帖数12
  • QQ
  • 铜币176枚
  • 威望0点
  • 贡献值0点
  • 银元0个
2楼#
发布于:2007-08-16 19:22
<P>是的,shp文件.不好意思没说清楚.</P>
举报 回复(0) 喜欢(0)     评分
小波变换
路人甲
路人甲
  • 注册日期2007-06-20
  • 发帖数64
  • QQ
  • 铜币58枚
  • 威望0点
  • 贡献值0点
  • 银元0个
3楼#
发布于:2007-08-17 12:26
<P> '向Sde空间数据库中插入一条记录,并返回其ObjectId。</P>
<P>Public Shared Function InsertFeatureToSde(ByVal pFeatureGeometry As IGeometry, ByVal FeatureAttributes As Collection, ByVal strSDETableName As String, _<BR>                                                  Optional ByVal txtLog As System.Windows.Forms.TextBox = Nothing, _<BR>                                                  Optional ByVal Flag As Integer = -1, _<BR>                                                  Optional ByVal ds As DataSet = Nothing, _<BR>                                                  Optional ByVal pShapeFileds As Collection = Nothing) As Long<BR>            On Error GoTo errhdl</P>
<P>            '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''<BR>            Dim pFeatureClass As IFeatureClass, pFeatureCursor As IFeatureCursor, pFeatureBuffer As IFeatureBuffer, pFeatureFields As IFields, pFeatureField As IField<BR>            Dim i As Integer, m As Integer, strFieldName As String, strFieldVale As String, boolNull As Boolean = False<BR>            Dim FeatureObjectID As Long<BR>            Dim ErrSelfIntersect As Integer = 0</P>
<P>            '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''<BR>            Select Case Flag<BR>                Case -1, 2<BR>                    strSDETableName = "SDE." ; strSDETableName<BR>                    pFeatureClass = pFeatureClassCollection.Item(strSDETableName)<BR>                Case 1, 3<BR>                    pFeatureClass = pFeatureWorkspace.OpenFeatureClass(strSDETableName)<BR>            End Select<BR>            If pFeatureClass Is Nothing Then<BR>                txtLog.Text = txtLog.Text ; Trim(FeatureAttributes.Item("UCODE")) ; ".shp:" ; "Shape文件对应空间图层" ; Mid(strSDETableName, 5) ; "没有找到" ; vbCrLf<BR>                pFeatureClass = Nothing<BR>                Exit Function<BR>            End If<BR>            pFeatureCursor = pFeatureClass.Insert(True)<BR>            pFeatureBuffer = pFeatureClass.CreateFeatureBuffer<BR>            pFeatureFields = pFeatureClass.Fields</P>
<P>            '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''<BR>            Select Case Flag<BR>                Case -1, 1, 3<BR>                    For i = 0 To pFeatureFields.FieldCount - 1<BR>                        DoEvents()<BR>                        boolNull = False<BR>                        pFeatureField = pFeatureFields.Field(i)<BR>                        If pFeatureField.Type = esriFieldType.esriFieldTypeGeometry Then<BR>                            pFeatureBuffer.Value(i) = pFeatureGeometry<BR>                        Else<BR>                            strFieldName = pFeatureField.Name<BR>                            strFieldVale = FeatureAttributes.Item(strFieldName)<BR>                            If Not boolNull And Not UCase(Trim(strFieldVale)) = "NUL" Then<BR>                                If pFeatureField.Type = esriFieldType.esriFieldTypeString Then<BR>                                    If strFieldName = "MAXH" Then<BR>                                        If CDbl(Trim(strFieldVale)) <> 0 Then<BR>                                            pFeatureBuffer.Value(i) = Trim(strFieldVale)<BR>                                        End If<BR>                                    Else<BR>                                        pFeatureBuffer.Value(i) = Trim(strFieldVale)<BR>                                    End If<BR>                                End If<BR>                                If pFeatureField.Type = esriFieldType.esriFieldTypeDouble Then<BR>                                    pFeatureBuffer.Value(i) = CDbl(Trim(strFieldVale))<BR>                                End If<BR>                            End If<BR>                        End If<BR>                    Next<BR>                Case 2<BR>                    '赋FeatureBuffer图形数据<BR>                    strFieldName = pFeatureClass.ShapeFieldName<BR>                    m = pFeatureBuffer.Fields.FindField(strFieldName)<BR>                    If Not m = -1 Then<BR>                        pFeatureBuffer.Value(m) = pFeatureGeometry<BR>                    End If<BR>                    '赋FeatureBuffer属性数据<BR>                    For i = 1 To pShapeFileds.Count<BR>                        strFieldName = UCase(Trim(pShapeFileds.Item(i)))<BR>                        m = pFeatureBuffer.Fields.FindField(strFieldName)<BR>                        If Not m = -1 Then<BR>                            boolNull = False<BR>                            strFieldVale = FeatureAttributes.Item(strFieldName)<BR>                            If Not boolNull And Not UCase(Trim(strFieldVale)) = "NUL" Then<BR>                                If pFeatureBuffer.Fields.Field(m).Type = esriFieldType.esriFieldTypeString Then<BR>                                    pFeatureBuffer.Value(m) = Trim(strFieldVale)<BR>                                End If<BR>                                If pFeatureBuffer.Fields.Field(m).Type = esriFieldType.esriFieldTypeDouble Then<BR>                                    If strFieldName = "SYMBANGLE" Then<BR>                                        pFeatureBuffer.Value(m) = CDbl(Trim(strFieldVale)) + 90<BR>                                    Else<BR>                                        pFeatureBuffer.Value(m) = CDbl(Trim(strFieldVale))<BR>                                    End If<BR>                                End If<BR>                            End If<BR>                        Else<BR>                            If Not strFieldName = "NAME" Then<BR>                                txtLog.Text = txtLog.Text ; Trim(FeatureAttributes.Item("UCODE")) ; ".shp:找不到Sde空间图层属性字段" ; strFieldName ; vbCrLf<BR>                            End If<BR>                        End If<BR>                    Next<BR>                    If Not pFeatureBuffer.Fields.FindField("UCODE") = -1 Then pFeatureBuffer.Value(pFeatureBuffer.Fields.FindField("UCODE")) = Trim(FeatureAttributes.Item("UCODE"))<BR>                    If Not pFeatureBuffer.Fields.FindField("NAME") = -1 Then pFeatureBuffer.Value(pFeatureBuffer.Fields.FindField("NAME")) = Trim(FeatureAttributes.Item("NAME"))<BR>                    If Not pFeatureBuffer.Fields.FindField("NFCODE") = -1 Then pFeatureBuffer.Value(pFeatureBuffer.Fields.FindField("NFCODE")) = Trim(FeatureAttributes.Item("NFCODE"))<BR>            End Select<BR>            FeatureObjectID = pFeatureCursor.InsertFeature(pFeatureBuffer)<BR>            If Flag = 3 Then pFeatureCursor.Flush()<BR>         <BR>            Return FeatureObjectID</P>


<P>代码没有经过整理,中间可能有比较多关于业务的内容,不过关于接口方面的东东楼主还是可以参考一下</P>
********************************** 喜欢有激情的生活 msn:hou.jiazte@hotmail.com 欢迎交流 **********************************
举报 回复(0) 喜欢(0)     评分
游客

返回顶部