ae开发中dataset as ifeatureclass语句什么意思

 我来答
护肤达人IT宅族
2016-09-05 · 知道合伙人互联网行家
护肤达人IT宅族
知道合伙人互联网行家
采纳数:5637 获赞数:17441
毕业于曲阜师范大学,学士学位。互联网行业2年从业经验,读过SEO相关书籍。现任爱家网SEO优化专员。

向TA提问 私信TA
展开全部
读取gdb方法
private void btn_Click(object sender, EventArgs e)
{
FolderBrowserDialog dlg = new FolderBrowserDialog();
dlg.Description = "打开GDB文件夹";
if (DialogResult.OK == dlg.ShowDialog())
{
if (Directory.Exists(dlg.SelectedPath))
{
if(dlg.SelectedPath.ToUpper().Contains(".GDB"))
{
GDBTextBox.Text = dlg.SelectedPath;
}
}
}
}
#region 直接获取FeatureClass
string filePath = GDBTextBox.Text;
FileGDBWorkspaceFactoryClass fac=new FileGDBWorkspaceFactoryClass();
IFeatureWorkspace space = (IFeatureWorkspace)fac.OpenFromFile(filePath, 0);
IFeatureClass pPointFClass = space.OpenFeatureClass("zhongxindian"); //获取FeatureClass
#endregion

#region 添加到comboBox里面、获取FeatureClass
IWorkspaceFactory m_pWorkspaceFactory = new FileGDBWorkspaceFactoryClass();
IWorkspace pWorkspace = m_pWorkspaceFactory.OpenFromFile(GDBTextBox.Text, 0);
IFeatureWorkspace m_pFeatureWorkspace = pWorkspace as IFeatureWorkspace;
IEnumDatasetName FeatureEnumDatasetName = pWorkspace.get_DatasetNames(esriDatasetType.esriDTFeatureClass);
if (FeatureEnumDatasetName == null) return;
FeatureEnumDatasetName.Reset();
IDatasetName pDatasetName = FeatureEnumDatasetName.Next();
while (pDatasetName != null)
{
tcCombox.Items.Add(pDatasetName.Name);//添加到comboBox里面
pDatasetName = FeatureEnumDatasetName.Next();
}
IFeatureClass m_pFeatureClass2=null;
private void tcCombox_SelectedIndexChanged(object sender, EventArgs e)
{
m_pFeatureClass2 = m_pFeatureWorkspace.OpenFeatureClass(tcCombox.Text);//comboBox里选择图层,获取FeatureClass
}
#endregion

#region 遍历GDB
IWorkspace pCarWorkspace = m_pWorkspaceFactory.OpenFromFile(GDBTextBox.Text, 0);
IEnumDataset FeatureEnumDataset = pCarWorkspace.get_Datasets(esriDatasetType.esriDTFeatureClass);
if (FeatureEnumDataset == null) return;
FeatureEnumDataset.Reset();
IDataset pDataset = FeatureEnumDataset.Next();
while (pDataset != null)
{
IFeatureClass fc = pDataset as IFeatureClass;//获取FeatureClass

//对FeatureClass的操作
//比如给FeatureClass添加字段、代码如下
if (pPolygonFClass.Fields.FindField("字段") > -1) return;//如果存在字段
IClass pTable = pPolygonFClass as IClass;
IFieldEdit pFieldEdit = new FieldClass();
pFieldEdit.Name_2 = "字段";
pFieldEdit.Type_2 = esriFieldType.esriFieldTypeInteger;
pTable.AddField((IField)pFieldEdit);
int countIndex = pPolygonFClass.Fields.FindField("字段");//获取字段索引

pDataset = FeatureEnumDataset.Next();
}
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式