文档详情

AE开发之属性表.doc

发布:2017-06-13约9.39千字共6页下载文档
文本预览下载声明
using ESRI.ArcGIS.Geodatabase; using System.Data; using ESRI.ArcGIS.Carto; using ESRI.ArcGIS.Geometry; using ESRI.ArcGIS.DataSourcesFile; using ESRI.ArcGIS.Controls; namespace GISExercise { class AttributeTable { ILayer pLayer; string tableName; IGeoFeatureLayer pGeoFeatureLayer; public System.Data.DataTable AttributeTable1(ILayer pLayer, string tableName) { //根据选择的图层创建空DataTable System.Data.DataTable pDataTable = CreateDataTableByLayer(pLayer, tableName); pDataTable.TableName = pLayer.Name; //取得图层类型 string shapeType = getShapeType(pLayer); //创建DataTable的行对象 DataRow pDataRow = null; //从ILayer查询到ITable ITable pTable = pLayer as ITable; ICursor pCursor = pTable.Search(null, false); //取得ITable中的行信息 IRow pRow = pCursor.NextRow(); int n = 0; while (pRow != null) { //新建DataTable的行对象 pDataRow = pDataTable.NewRow(); for (int i = 0; i pRow.Fields.FieldCount; i++) { //如果字段类型为esriFieldTypeGeometry,则根据图层类型设置字段值 if (pRow.Fields.get_Field(i).Type == esriFieldType.esriFieldTypeGeometry) { pDataRow[i] = shapeType; } //当图层类型为Anotation时,要素类中会有esriFieldTypeBlob类型的数据, //其存储的是标注内容,如此情况需将对应的字段值设置为Element else if (pRow.Fields.get_Field(i).Type == esriFieldType.esriFieldTypeBlob) { pDataRow[i] = Element; } else { pDataRow[i] = pRow.get_Value(i); } } //添加DataRow到DataTable pDataTable.Rows.Add(pDataRow); pDataRow = null;
显示全部
相似文档