关闭

AE+C#将E00数据导入到ArcSDE中去

标签: ArcGISesric#
1170人阅读 评论(0) 收藏 举报
分类:

介绍两种AE+C#E00数据导入到ArcSDE中去的方法。

首先,需要将AE的互操作扩展的授权加上,我们在VS2010中新建一个WinFrom工程,引入一个License Control,设置如下图

 

然后,需要增加一个连接SDE数据库的方法

 

 

 

       publicstaticIPropertySet getPropertySet()

 

       {

 

           IPropertySet Propset = newPropertySetClass();

 

           try

 

           {

 

                Propset.SetProperty(“SERVER, “esri-2003);

 

                Propset.SetProperty(“INSTANCE, “port:5151);

 

                Propset.SetProperty(“USER, “sde);

 

                Propset.SetProperty(“PASSWORD, “sde);

 

                Propset.SetProperty(“DATABASE, “orcl);

 

                Propset.SetProperty(“VERSION, “SDE.DEFAULT);

 

 

 

                returnPropset;

 

           }

 

           catch (Exception ex)

 

           {

 

                stringmsg = ex.Message;

 

                returnPropset;

 

           }

 

       }

 

 

 

 

 

方法一:通过GP调用FeatureClassToGeodatabase组件实现E00数据导入到ArcSDE中。

 

       ///<summary>

 

       ///

 

       ///</summary>

 

       ///<param name=”e00path”></param>

 

       ///<param name=”sdePath”>不带图层名称</param>

 

       publicstaticvoid e00FeatureClassToGeodatabase(string e00path, string sdePath)

 

       {

 

           ESRI.ArcGIS.ConversionTools.FeatureClassToGeodatabase featureClassToGeodatabase= newFeatureClassToGeodatabase();

 

           featureClassToGeodatabase.Output_Geodatabase = sdePath;

 

           featureClassToGeodatabase.Input_Features = e00path;

 

           Geoprocessor geoprocessor = newGeoprocessor();

 

           geoprocessor.OverwriteOutput = true;

 

           try

 

           {

 

               geoprocessor.Execute(featureClassToGeodatabase, null);

 

                stringmess = null;

 

                for (int k = 0; k < geoprocessor.MessageCount; k++)

 

                {

 

                    mess +=geoprocessor.GetMessage(k) +
;

 

                }

 

                MessageBox.Show(mess);

 

           }

 

           catch (Exception ex)

 

           {

 

                stringmess = null;

 

                for (int k = 0; k < geoprocessor.MessageCount; k++)

 

                {

 

                    mess +=geoprocessor.GetMessage(k) +
;

 

                }

 

           }

 

       }

 

 

 

 

 

 

 

方法二:通过GP调用CopyFeatures组件实现E00数据导入到ArcSDE中。

 

 

 

       ///<summary>

 

       ///

 

       ///</summary>

 

       ///<param name=”e00Path”></param>

 

       ///<param name=”sdePath”>带图层名称</param>

 

       publicstaticvoid e00CopyFeaturesToSDE(string e00Path, stringsdePath)

 

       {

 

           IVariantArray parameters = newVarArrayClass();

 

           parameters.Add(e00Path);

 

           parameters.Add(sdePath);

 

           Geoprocessor geoprocessor = newGeoprocessor();

 

           geoprocessor.OverwriteOutput = true;

 

           try

 

           {

 

                geoprocessor.Execute(“CopyFeatures, parameters, null);

 

 

 

                stringmess = null;

 

                for (int k = 0; k < geoprocessor.MessageCount; k++)

 

                {

 

 

 

                    mess +=geoprocessor.GetMessage(k) +
;

 

 

 

                }

 

           }

 

           catch (Exception ex)

 

           {

 

                stringmess = null;

 

                for (int k = 0; k < geoprocessor.MessageCount; k++)

 

                {

 

                    mess +=geoprocessor.GetMessage(k) +
;

 

                }

 

           }

 

       }

 

 

 

 

 

然后在窗体上增加一个按钮Button1,增加Click事件

 

 

 

       privatevoid button1_Click(object sender, EventArgs e)

 

       {

 

           string path = @”C:est;

 

           string sdeName = @”test.sde;

 

           string sdePath = path + “\ + sdeName;

 

           if (File.Exists(sdePath))

 

           {

 

                File.Delete(sdePath);

 

           }

 

           IWorkspaceFactory workspaceFactory = newSdeWorkspaceFactoryClass();

 

           IWorkspaceName workspaceName =workspaceFactory.Create(path, sdeName, getPropertySet(), 0);

 

 

 

           //方法一通过FeatureClassToGeodatabase        

 

           e00FeatureClassToGeodatabase(@”C: estcontinent.e00CONTINENT_point, sdePath);

 

           //方法二通过 CopyFeatures          

 

           e00CopyFeaturesToSDE(@”C: estcontinent.e00CONTINENT_arc, sdePath + @”CONTINENT_arc);

 

       }

 

 

 

以上两种方式将E00数据导入到ArcSDE管理的数据库中去。

 

0
0

猜你在找
【套餐】Hadoop生态系统零基础入门
【套餐】嵌入式Linux C编程基础
【套餐】2017软考系统集成项目——任铄
【套餐】Android 5.x顶级视频课程——李宁
【套餐】深度学习入门视频课程——唐宇迪
【直播】广义线性模型及其应用——李科
【直播】从0到1 区块链的概念到实践
【直播】计算机视觉原理及实战——屈教授
【直播】机器学习之凸优化——马博士
【直播】机器学习&数据挖掘7周实训--韦玮
查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:380208次
    • 积分:6625
    • 等级:
    • 排名:第3551名
    • 原创:292篇
    • 转载:3篇
    • 译文:1篇
    • 评论:36条
    最新评论