ArcGISEngine二次开发(4):属性查询(2)
来源:互联网 发布:mac adb unauthorized 编辑:程序博客网 时间:2024/06/08 11:49
属性查询(2)
使用IGeometry接口TrackPolygon方法建立对象实现属性查询
使用ISpatialFilter接口SpatialRel属性定义Intersects取交集为查询对象
之后将查询到的(FindField方法)属性显示在新的windowsform中的listbox中显示属性字段
单击Listbox中的属性字段,地图高亮显示对应多边形
添加引用:
using System;using System.Collections.Generic;using System.Linq;using System.Text;using ESRI.ArcGIS.Carto;using ESRI.ArcGIS.SystemUI;using ESRI.ArcGIS.esriSystem;using ESRI.ArcGIS.Controls;using ESRI.ArcGIS.Geometry;using ESRI.ArcGIS.Geodatabase;using ESRI.ArcGIS.DataSourcesFile;
添加ToolTripButton,添加Click事件代码如下
ICommand spatialqueryintersect = new spatialquery();spatialqueryintersect.OnCreate(axMapControl1.Object);spatialqueryintersect.OnClick();ITool ptool = spatialqueryintersect as ITool;axMapControl1.CurrentTool = ptool;
新建windowsform窗体,并在里边添加Listbox,Modifiers属性Public,否则在其他窗体的事件代码中不能检测到该控件,事件代码如下
//定义全局变量public IMapControlDefault spaqury;//必须添加public关键字,因为要从新建的类中传来Imapcontrol对象// private void listBox1_Click(object sender, EventArgs e) { IFeatureLayer pFeatureLayer = spaqury.get_Layer(0) as IFeatureLayer; IQueryFilter pqueryfilter = new QueryFilterClass(); pqueryfilter.SubFields = "*"; pqueryfilter.WhereClause = "NAME" + "=" + "'" + this.listBox1.SelectedItem.ToString() + "'"; IFeatureCursor pfeaturecursor = pFeatureLayer.Search(pqueryfilter, false); IFeature pfeature = pfeaturecursor.NextFeature(); spaqury.FlashShape(pfeature.Shape, 3, 500, null); return; }
新建类库,手动实现Icommand,ITool 接口,定义全局变量:
IMapControlDefault m_app;
//Onclick函数设为空,因为单击Button没有立刻开始画多边形,而是在单击axmapcontrol对象以后开始画public void OnClick() { }
//传入ImapControl对象public void OnCreate(object Hook) { m_app = Hook as IMapControlDefault; }
//其他接口置为空public void OnMouseDown(int button, int shift, int x, int y) { IGeometry pGeometry = m_app.TrackPolygon(); IFeatureLayer pfeatureLayer = m_app.get_Layer(0) as IFeatureLayer; ISpatialFilter pSpatialfilter =new SpatialFilterClass(); pSpatialfilter.SubFields="*"; pSpatialfilter.GeometryField="shape";//所画图形类型 pSpatialfilter.Geometry=pGeometry; pSpatialfilter.SpatialRel=esriSpatialRelEnum.esriSpatialRelIntersects;//空间交集 IFeatureCursor pfeaturecursor = pfeatureLayer.Search(pSpatialfilter, false); IFeature pfeature = pfeaturecursor.NextFeature(); int ifname = pfeaturecursor.FindField("NAME");//属性查询字段 SpatialQueryListBox listboxwindows = new SpatialQueryListBox();//SpatialQueryListBox为新建的windowsform窗体 listboxwindows.spaqury = m_app;//该窗体中的全局变量 while (pfeature != null) { listboxwindows.listBox1.Items.Add(pfeature.get_Value(ifname).ToString()); m_app.FlashShape(pfeature.Shape, 3, 500, null); pfeature = pfeaturecursor.NextFeature(); } listboxwindows.Show(); }
阅读全文
0 0
- ArcGISEngine二次开发(4):属性查询(2)
- ArcGISEngine二次开发(2):地图制图
- ArcGISEngine二次开发(1):系统基本功能
- ArcGISEngine二次开发(5):添加矢量要素
- QGis二次开发基础 -- 根据属性查询要素
- QGis二次开发基础 -- 根据属性查询要素
- iwebshop二次开发(2)
- ArcgisEngine+c#二次开发,sde要素类进行GP操作总结
- Nginx二次开发(2)进程
- c#+arcgisengine 对属性表创…
- AutoCAD二次开发之属性操作(2) 读属性
- Revit二次开发(2):Hello World!
- weka+eclipse算法二次开发(2)
- Wowza服务器系列(2):开始二次开发
- 微信公众号二次开发(2)
- 二次开发、(CMS)
- Wps二次开发(POI)
- MasterCAM二次开发(一)
- 语义分析-哈工大编译原理第三次实验
- 关于重载new delete new[] delete[]笔记----C++学习之路
- 约束
- linux学习资源整理
- 将迭代器中元素(对象)放入数组中
- ArcGISEngine二次开发(4):属性查询(2)
- Matches(uva 11375)
- Linux命令(一)
- 人生就是不断自我颠覆——《颠覆者》读书心得
- js获取URL参数的2个方法,可以直接使用
- 2017-11-19
- Angular2搭建环境
- JDK8中的Comparable<T>接口源码分析
- 使用Xib自定义UITableViewCell