博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
arcengine 经典代码(转) 空间查询 在一个图层上画一个polygon,根据该polygon查询出图层上与之相交的polygon并高亮显示出来...
阅读量:4322 次
发布时间:2019-06-06

本文共 1862 字,大约阅读时间需要 6 分钟。

如何进行空间查询

本例实现的是在一个图层上画一个polygon,根据该polygon查询出图层上与之相交的polygon并高亮显示出来。

要点

通过RubberPolygon类来实现接口IRubberBand接口对象,用IRubberBand.TrackNew方法在图层上画出polygon,然后定义IGeometry获得该polygon,创建ISpatialFilter接口对象实现过滤功能,通过ILayer接口实例获得IFeatureSelection接口,调用IFeatureSelection.SelectFeatures方法将结果高亮显示。

程序说明

过程UIToolControl1_MouseDown是实现模块。

代码

Option Explicit

Private Function UIToolControl1_Deactivate() As Boolean

UIToolControl1_Deactivate = True

End Function

Private Sub UIToolControl1_MouseDown(ByVal button As Long, ByVal shift As Long, _

ByVal x As Long, ByVal y As Long)

Dim pMxDoc As IMxDocument

Dim pActiveView As IActiveView

Dim pScreenDisplay As IScreenDisplay

Dim pRubberPolygon As IRubberBand

Dim pFillSymbol As ISimpleFillSymbol

Dim pRgbColor As IRgbColor

Dim pPolygon As IPolygon

Dim pGeometry As IGeometry

Dim pFeatselect As IFeatureSelection

Dim pSpatialFilter As ISpatialFilter

On Error GoTo ErrorHandler:

Set pMxDoc = ThisDocument

Set pActiveView = pMxDoc.FocusMap

'Draw Polygon

Set pScreenDisplay = pActiveView.ScreenDisplay

Set pRubberPolygon = New RubberPolygon

Set pFillSymbol = New SimpleFillSymbol

Set pRgbColor = New RgbColor

pRgbColor.NullColor = True

pFillSymbol.Color = pRgbColor

Set pPolygon = pRubberPolygon.TrackNew(pScreenDisplay, pFillSymbol)

With pScreenDisplay

.StartDrawing pScreenDisplay.hDC, esriNoScreenCache

.SetSymbol pFillSymbol

.DrawPolygon pPolygon

.FinishDrawing

End With

'set up pFilter

Set pGeometry = pPolygon

Set pSpatialFilter = New SpatialFilter

With pSpatialFilter

Set .Geometry = pGeometry

.SpatialRel = esriSpatialRelIntersects

End With

'select

Set pFeatselect = pMxDoc.FocusMap.Layer(0)

pFeatselect.SelectFeatures pSpatialFilter, esriSelectionResultNew, False

pFeatselect.SelectionSet.**

pMxDoc.ActiveView.**

Exit Sub

ErrorHandler:

MsgBox Err.Description

End Sub

转载于:https://www.cnblogs.com/xiexiaokui/archive/2008/07/25/1251698.html

你可能感兴趣的文章
PhotoView
查看>>
hdu 1735(贪心) 统计字数
查看>>
iOS 系统框架结构图
查看>>
uml系列(六)——行为图:活动&状态
查看>>
Learning Deconvolution Network for Semantic Segme小结
查看>>
Leetcode 424.替换后的最长重复字符
查看>>
第二阶段:2.商业需求文档MRD:1.M版本管理
查看>>
我爱Java系列---【单列集合和双列集合总结】
查看>>
新开始
查看>>
git - 如何从项目中删除git跟踪
查看>>
MacBook Air密码忘了,苹果电脑密码忘了怎么办
查看>>
PHP二维数组排序
查看>>
.Net Core WebApi返回的json数据,自定义日期格式
查看>>
C语言运算符表
查看>>
网络调试 adb connect
查看>>
ormlite 文档
查看>>
修改root远程ssh登录权限
查看>>
保存cookies
查看>>
iOS酷炫动画效果合集
查看>>
[CSS] Scale on Hover with Transition
查看>>