当前位置:网站首页>Arcgis-engine二次开发之空间关系查询与按图形查询
Arcgis-engine二次开发之空间关系查询与按图形查询
2022-06-27 19:56:00 【房东不再养猫】
在GIS系统中,查询一般分为从图形查询属性和从属性查询图形两种类型。从图形查询属性,即指用户通过点选、拉框选择、拉圆选择、拉多边形选择等方式,选中特定图层中相应的几何实体,查询出这些几何实体对应的属性信息。从属性查询图形,即用户输入特定的属性或者空间关系的筛选条件,查出符合条件的几何实体。这两类查询在GIS系统中都有着广泛的应用。
目录
一、按空间关系查询
二、按图形查询
一、按空间关系查询
空间位置、空间关系查询是根据查询的几何形状和空间关系,对所选择的要素图层进行查询。一般的操作步骤为:选择要查询的要素图层;选择用于查询几何形状类型。根据选择的几何形状类型:点、线、矩形、圆和多边形。在图上选择或绘制用于查询的几何形状:选择空间关系;执行查询。实现思路为:首先构建一个窗体,如图所示;其中第一个设定选择类型,有四种:构造新的选择集、添加当前选择集、从当前选择及去除,从当前选择集中选择构造新的选择集。要查询的要素图层的名称,保存在CheckedListBox中:空间关系,保存在ComboBox中:设置查询图层的名称; .设置缓冲区距离。
窗体设计:
如同之前的按属性查询,这里也需要添加加载按图形查询的Load事件。
通过IFeatureLayer接口将地图图层导入我们设计的名为“GetFeatureLayerByName”的listbox中。
调用相应空间选择方法:
使用IFeatureSelection接口选择要素(对所有的被选图层进行遍历)。
按缓冲区查询:
二、按图形查询
图形查询是以用户通过鼠标操作生成的图形几何体为输入条件进行查询的查询,其查询结果为该几何体空间范围内的所有要素。常用的查询方式包括点选、线选、多边形选择、圆形选择和矩形选择等。图像查询主要使用Map类IMap接口中的方法,此外,还需要到Map类的IGraphicsContainer接口和操控图形元素中的IElement接口。使用IMap接口的SelectByShape方法。
这里我们选择AE自带的绘图工具进行图形查询:
添加按图形查询的按钮,并在其下添加相应的代码。首先清空地图选择集,以进行后续的选择操作,使用IGraphicsContainer接口获取地图中的各个图形(Graphics),使用IElement接口操作所获取第一个图形,并获取图形的几何信息,通过第一个图形来选择要素。
相应代码:
private void 按图形查询ToolStripMenuItem_Click(object sender, EventArgs e)
{
try
{
mainMapControl.Map.FeatureSelection.Clear();
IGraphicsContainer graphicsContainer = mainMapControl.Map as IGraphicsContainer;
graphicsContainer.Reset();
IElement element = graphicsContainer.Next();
IGeometry geometry = element.Geometry;
mainMapControl.Map.SelectByShape(geometry, null, false);
mainMapControl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection, null, mainMapControl.ActiveView.Extent);
}
catch (Exception ex)
{
//MessageBox.Show(ex.Message);
}
}
在ToolbarControl控件中调用一些用于绘制形状的Item,注意要在属性中绑定Buddy为主窗体“mainMapControl”
运行结果:
可以看到,与绘制图形的地方相交的地图要素都被选择上了。
本文的代码链接:链接:https://pan.baidu.com/s/1bDr63Bb3dj-pxW1x7tR6mQ
提取码:1234
边栏推荐
- Is flush stock trading software reliable?? Is it safe?
- Day 7 of "learning to go concurrent programming in 7 days" go language concurrent programming atomic atomic actual operation includes ABA problem
- Contest 2050 and Codeforces Round #718 (Div. 1 + Div. 2)
- Solve the problem that the virtual machine cannot be connected locally
- 关于davwa的SQL注入时报错:Illegal mix of collations for operation ‘UNION‘原因剖析与验证
- OpenSSL programming I: basic concepts
- gomock mockgen : unknown embedded interface
- MONTHS_ Between function use
- 微服务之服务网关
- STM32与RC522简单公交卡系统的设计
猜你喜欢
It smells good. Since I used Charles, Fiddler has been completely uninstalled by me
netERR_CONNECTION_REFUSED 解决大全
广告太「野」,吉野家「渡劫」
First knowledge of the second bullet of C language
扁平数组和JSON树的转换
MySQL数据库 实验报告(一)
这届考生,报志愿比高考更“拼命”
Crawler notes (3) -selenium and requests
Introduce you to ldbc SNB, a powerful tool for database performance and scenario testing
《7天學會Go並發編程》第7天 go語言並發編程Atomic原子實戰操作含ABA問題
随机推荐
Vue+mysql login registration case
netERR_CONNECTION_REFUSED 解决大全
"I make the world cooler" 2022 Huaqing vision R & D product launch was a complete success
Professor of Tsinghua University: software testing has gone into a misunderstanding - "code is necessary"
This set of steps for performance testing using JMeter includes two salary increases and one promotion
结构化机器学习项目(二)- 机器学习策略(2)
Basic data type and complex data type
Conversion between flat array and JSON tree
Conversation Qiao Xinyu: l'utilisateur est le gestionnaire de produits Wei Brand, zéro anxiété définit le luxe
扁平数组和JSON树的转换
Codeforces Round #716 (Div. 2)
Infiltration learning - problems encountered during SQL injection - explanation of sort=left (version(), 1) - understanding of order by followed by string
“顶流爱豆制造机”携手四个产业资本,做LP
雪糕还是雪“高”?
《7天學會Go並發編程》第7天 go語言並發編程Atomic原子實戰操作含ABA問題
解决本地连接不上虚拟机的问题
Yarn performance tuning of CDH cluster
Crawler notes (2) - parse
Vue+MySQL实现登录注册案例
【微服务】(十六)—— 分布式事务Seata