zoukankan      html  css  js  c++  java
  • ArcEngine查询属性数据表

    1实现原理

            使用要素类(IFeatureClass)查询获取游标(IFeatureCursor),遍历游标装载数据到数据表(DataTable)中。

    2涉及接口

           IFeatureClass、IFeatureCursor、IQueryfilter

    3具体实现

     1 DataTable dt = new DataTable("AttributeTable");
     2 
     3 ILayer layer = this.axMapControl1.get_Layer(0);
     4 IFeatureLayer featureLayer = layer as IFeatureLayer;
     5 IFeatureClass featureClass = featureLayer.FeatureClass;
     6 
     7 for (int i = 0; i < featureClass.Fields.FieldCount; i++)
     8 {
     9     DataColumn dc = new DataColumn();
    10     dc.ColumnName = featureClass.Fields.get_Field(i).AliasName;
    11     dt.Columns.Add(dc);
    12 }
    13 
    14 IQueryFilter filter = new QueryFilterClass();
    15 filter.WhereClause = "";
    16 IFeatureCursor featureCursor = featureClass.Search(filter, false);
    17 IFeature feature = featureCursor.NextFeature();
    18 while (feature != null)
    19 {
    20     DataRow dr = dt.NewRow();
    21     for (int i = 0; i < feature.Fields.FieldCount; i++)
    22     {
    23         if (feature.Fields.get_Field(i).Type == esriFieldType.esriFieldTypeGeometry)
    24         {
    25             string geoType;
    26             switch (feature.Shape.GeometryType)
    27             {
    28                 case ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPoint:
    29                     geoType = "";
    30                     break;
    31                 case ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPolygon:
    32                     geoType = "";
    33                     break;
    34                 case ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPolyline:
    35                     geoType = "线";
    36                     break;
    37                 default:
    38                     geoType = "未知";
    39                     break;
    40             }
    41             dr[i] = geoType;
    42         }
    43         else
    44         {
    45             dr[i] = feature.get_Value(i);
    46         }
    47     }
    48     dt.Rows.Add(dr);
    49 
    50     feature = featureCursor.NextFeature();
    51 }
    52 
    53 this.dataGridView1.DataSource = dt;
  • 相关阅读:
    点语法
    第一个OC的类
    gitlab教程
    php接收post的json数组
    phpstorm10.0.2三月22号补丁原来的网址被封了
    冰点下载器在转换pdf的时候出现停止工作
    乱码问题
    有用的网址(php)
    ubuntu16.04安装mysql5.6
    MapUtils常用方法
  • 原文地址:https://www.cnblogs.com/HelsingWang/p/8945192.html
Copyright © 2011-2022 走看看