本文主要是介绍AE+C#将E00数据导入到ArcSDE中去,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
介绍两种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管理的数据库中去。
这篇关于AE+C#将E00数据导入到ArcSDE中去的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!