Arc Engiene读取文档的属性

Arc Engiene读取文档的属性

设计界面

创建类

Arc Engiene读取文档的属性

代码如下

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

using ESRI.ArcGIS.Controls;

using System.Data;

using ESRI.ArcGIS.Carto;

using ESRI.ArcGIS.Geodatabase;

using ESRI.ArcGIS.Geometry;



namespace test

{

public class DataHelper

{

#region 读取mapControl属性表

public static DataTable GetAttribute(AxMapControl axMapControl)

{

int layerCount = axMapControl.Map.LayerCount;



// IFeature pFeature;

string fieldName=string.Empty;

int fieldCount;

bool firstThroght=true;

DataTable dataTable = new DataTable();

//循环图层得到每一层的数据

for (int l = 0; l < layerCount; l++)

{

IFeatureLayer pFeatureLayer = axMapControl.Map.get_Layer(l) as IFeatureLayer;

IFeatureClass pFeatureClass = pFeatureLayer.FeatureClass;

fieldCount = pFeatureClass.Fields.FieldCount;

int featureCount = pFeatureClass.FeatureCount(new QueryFilterClass());

if (firstThroght)

{

for (int i = 0; i < fieldCount; i++)

{

string fieldHeadName = pFeatureClass.Fields.get_Field(i).AliasName;

dataTable.Columns.Add(fieldHeadName);



}

firstThroght = false;

}

//判断feature的类型

int indexofShape = pFeatureClass.FindField("Shape");

ESRI.ArcGIS.Geometry.esriGeometryType pFeatureClassShapeType = pFeatureClass.ShapeType;

for (int i = 0; i < featureCount; i++)

{

DataRow dataRow = dataTable.NewRow();

for (int j = 0; j < fieldCount; j++)

{

if (j == indexofShape)

{

//Geometroy.shapetype转换

switch (pFeatureClassShapeType)

{

case esriGeometryType.esriGeometryPoint:

fieldName = "Point";

break;

case esriGeometryType.esriGeometryPolyline:

fieldName = "Polyline";

break;

case esriGeometryType.esriGeometryPolygon:

fieldName = "Polygon";

break;

default:

break;

}

// fieldName = pFeatureClass.GetFeature(i).get_Value(j).ToString();

//dataTable.Columns.Add(fieldName);



dataRow[j] = fieldName;

}

else

{

//添加非shape字段到表中

fieldName = pFeatureClass.GetFeature(i).get_Value(j).ToString();

//dataTable.Columns.Add(fieldName);



dataRow[j] = fieldName;

}



//dataTable[i][j] = fieldName;

}

dataTable.Rows.Add(dataRow);



}

}

return dataTable;

}

#endregion

}

}
Arc Engiene读取文档的属性
上一篇:用WebCollector爬取站点的图片


下一篇:Cracking the coding interview--Q2.4