zoukankan      html  css  js  c++  java
  • 我的需求

    如何进行空间查询

    本例实现的是在一个图层上画一个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

  • 相关阅读:
    2021.01.28 Rating赛 解题/补题报告
    2021.01.23 Rating赛 补题&解题报告
    ACM 实验室2020.11.08天梯赛练习*5
    6. Python 基础 dict 字典 查找方法 set() 集合 公共方法
    5. python 基础 list [] 列表 tuple () 元组
    4. python 操作字符串 字符串的一些方法
    3. python基础 转化字符类型 循环
    2. python 数据类型 格式化
    1. Python是编译性语言解释性语言 pyCharm 配置
    科二 教育教学知识与能力4
  • 原文地址:https://www.cnblogs.com/zhangjun1130/p/1394755.html
Copyright © 2011-2022 走看看