• Arc Engiene读取文档的属性


    image

    设计界面

    创建类

    image

    代码如下

    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
    }
    } image
  • 相关阅读:
    [JavaWeb基础] 001.简单的JavaWeb代码和Tomcat配置部署
    [程序员短壁纸]2015年05月
    [注]什么是用户?估计90%人不知道
    [注]排行榜相关知识
    [注]微信公众号的运营推广总结方案(持续更新)
    [注]6W运营法则教你盘活社区内容运营
    [注]一条牛B的游戏推送要具备哪些条件?
    [微信营销企划之路]001.环境搭建(XAMPP+WeiPHP)
    [Python基础]005.语法(4)
    Java多线程设计模式
  • 原文地址:https://www.cnblogs.com/shangguanjinwen/p/3967277.html
Copyright © 2020-2023  润新知