码迷,mamicode.com
首页 > 其他好文 > 详细

Arc Engiene读取文档的属性

时间:2014-09-11 22:14:52      阅读:177      评论:0      收藏:0      [点我收藏+]

标签:style   blog   http   io   os   ar   for   数据   2014   

bubuko.com,布布扣

设计界面

创建类

bubuko.com,布布扣

代码如下

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
}
} bubuko.com,布布扣

Arc Engiene读取文档的属性

标签:style   blog   http   io   os   ar   for   数据   2014   

原文地址:http://www.cnblogs.com/shangguanjinwen/p/3967277.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!