• C# ArcEngine 实现点击要素高亮并弹出其属性


    转自 C# ArcEngine 实现点击要素高亮并弹出其属性

    本文是模仿ArcMap里面的Identify(识别)功能,通过点击要素,使其高亮显示并弹出其属性表!本文只做了点击查询!

    ITopologicalOperator pTopo;
    IGeometry pGeometry;
    IFeature pFeature;
    IFeatureLayer pFeatureLayer; 
    IFeatureCursor pCursor;
    ISpatialFilter pFilter;
    DataTable dataTable;
    for (int i = 0; i < axMapControl1.Map.LayerCount; i++) { pPoint = new PointClass(); pPoint.PutCoords(e.mapX, e.mapY); pTopo = pPoint as ITopologicalOperator;
    double m_Radius = 1; pGeometry = pTopo.Buffer(m_Radius); if (pGeometry == null) continue;
    axMapControl1.Map.SelectByShape(pGeometry,
    null, true);//第三个参数为是否只选中一个 axMapControl1.Refresh(esriViewDrawPhase.esriViewGeoSelection, null, null); //选中要素高亮显示 pFilter = new SpatialFilterClass(); pFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects; pFilter.Geometry = pGeometry; pFeatureLayer = axMapControl1.Map.get_Layer(i) as IFeatureLayer; pCursor = pFeatureLayer.Search(pFilter, false); pFeature = pCursor.NextFeature();

    string fieldName; if (pFeature != null) { if (Application.OpenForms["otherQueryForm"] == null) { otherqueryform = new otherQueryForm(); otherqueryform.Show(); } else { Application.OpenForms["otherQueryForm"].Show(); }//这里主要控制子窗体不会重复弹出
    dataTable = new DataTable(); for (int k = 0; k < 2; k++) { if (k == 0) { dataTable.Columns.Add("属性"); } if (k == 1) { dataTable.Columns.Add(""); } } DataRow datarow; for (int j = 0; j < pFeature.Fields.FieldCount; j++) { datarow = dataTable.NewRow(); for (int m = 0; m < 2; m++) { if (m == 0) { fieldName = pFeature.Fields.get_Field(j).Name; datarow[m] = fieldName; } if (m == 1) { if (pFeature.Fields.get_Field(j).Name == "Shape") { if (pFeature.Shape.GeometryType == ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPoint) { datarow[m] = ""; } If ( pFeature.Shape.GeometryType == esriGeometryType.esriGeometryPolyline) { datarow[m] = "线"; } if (pFeature.Shape.GeometryType == ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPolygon) { datarow[m] = ""; } } else { datarow[m] = pFeature.get_Value(j).ToString(); } } } dataTable.Rows.Add(datarow); } otherqueryform.dataGridView1.DataSource = dataTable; otherqueryform.layerName_dev.Text = pFeatureLayer.Name; otherqueryform.dataGridView1.Refresh(); pFeature = null; break; } }
  • 相关阅读:
    JavaWeb(二)会话管理之细说cookie与session
    JavaWeb(一)Servlet中乱码解决与转发和重定向的区别
    JavaWeb(一)Servlet中的request与response
    JavaWeb(一)Servlet中的ServletConfig与ServletContext
    JavaWeb(一)之细说Servlet
    OOAD-设计模式(一)概述
    异常处理升级版
    MySQL优化原理
    hadoop 有那些发行版本
    centos7 安装搜狗输入法
  • 原文地址:https://www.cnblogs.com/arxive/p/6321827.html
Copyright © 2020-2023  润新知