| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1476 人关注过本帖
标题:求助!VB + ArcGIS Engine 基于空间属性查询代码中的一部分
只看楼主 加入收藏
暮悲
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2016-10-14
结帖率:100%
收藏
已结贴  问题点数:18 回复次数:1 
求助!VB + ArcGIS Engine 基于空间属性查询代码中的一部分
跪求! 真的想了好久都想不出
跪求!
跪求!如何对类模块IInfoList进行编辑,使类模块clsQueryByPolygon中的查询结果输出到Form1中的ListBox,或者能够在不需要类模块IInfoList的情况下将类模块clsQueryByPolygon的查询结果输出到Form1中的ListBox

以下是类模块clsQueryByPolygon中的代码
图片附件: 游客没有浏览图片的权限,请 登录注册


程序代码:
Option Explicit
'要实现的接口
Implements ITool
Implements ICommand
Implements IInfoList
'成员的私有变量
Private m_pCursor As IPictureDisp
Private MapControl As MapControl
Private pListBox As ListBox
Private pColor As IColor
Private pFillSymbol As ISimpleFillSymbol
Private pLineSymbol As ISimpleLineSymbol
Private pMarkSymbol As ISimpleMarkerSymbol
Private pSymbol As ISymbol

Private Sub Class_Initialize()
'加载光标资源
Set m_pCursor = LoadResPicture("IDENTIFY", vbResCursor)

End Sub

Private Property Get ICommand_Bitmap() As esriSystem.OLE_HANDLE

End Property

Private Property Get ICommand_Caption() As String

End Property

Private Property Get ICommand_Category() As String

End Property

Private Property Get ICommand_Checked() As Boolean

End Property

Private Property Get ICommand_Enabled() As Boolean

End Property

Private Property Get Icommand_HelpContextID() As Long

End Property

Private Property Get ICommand_HelpFile() As String

End Property

Private Property Get ICommand_Message() As String

End Property

Private Property Get ICommand_Name() As String

End Property

Private Sub ICommand_OnClick()

End Sub

Private Sub Icommand_OnCreate(ByVal hook As Object)
'获得操作的MapControl对象
Set MapControl = hook
'创建点、线、面符号,用于高亮显示被选中的要素
Set pColor = New RgbColor

pColor.RGB = RGB(0, 0, 225)
Set pFillSymbol = New SimpleFillSymbol
With pFillSymbol
.Color = pColor
.Style = esriSFSDiagonalCross
End With

pColor.RGB = RGB(225, 0, 225)
Set pLineSymbol = New SimpleLineSymbol
With pLineSymbol
.Color = pColor
.Style = esriSLSDash
.Width = 2
End With

pColor.RGB = RGB(0, 225, 225)
Set pMarkSymbol = New SimpleMarkerSymbol
With pMarkSymbol
.Color = pColor
.Style = esriSMSCircle
.Size = 5
End With

End Sub

Private Property Get ICommand_Tooltip() As String

End Property

Private Property Set IInfoList_ListBox(RHS As ListBox)

Set pListBox = RHS

End Property

Private Property Get ITool_Cursor() As esriSystem.OLE_HANDLE

ITool_Cursor = m_pCursor

End Property

Private Function ITool_Deactivate() As Boolean

End Function

Private Function ITool_OnContextMenu(ByVal x As Long, ByVal y As Long) As Boolean

End Function

Private Sub ITool_OnDblClick()

End Sub

Private Sub ITool_OnKeyDown(ByVal keyCode As Long, ByVal shift As Long)

End Sub

Private Sub ITool_OnKeyUp(ByVal keyCode As Long, ByVal shift As Long)

End Sub

Private Sub ITool_OnMouseDown(ByVal button As Long, ByVal shift As Long, ByVal x As Long, ByVal y As Long)
'当发生MapControl的MouseDown事件时,开始查找地物并查询属性
Dim i As Integer, Count As Integer, idx As Integer
Dim pPolygon As esriGeometry.Polygon
Dim pFeature As IFeature
Dim pSpatialFilter As ISpatialFilter
Dim pFeaturelayer As IFeatureLayer
Dim pFeatureCursor As IFeatureCursor
Dim pFeatureSelection As IFeatureSelection
'创建点查询的“面”
Set pPolygon = MapControl.TrackPolygon
Set pSpatialFilter = New SpatialFilter
With pSpatialFilter = New SpatialFilter
Set .Geometry = pPolygon
.SpatialRel = esriSpatialRelIntersects
End With

pListBox.Clear
Count = MapControl.LayerCount

For i = 0 To Count - 1 '遍历所有图层进行查询

Set pFeatureCursor = MapControl.Layer(i)
pSpatialFilter.GeometryField = pFeaturelayer.FeatureClass.ShapeFieldName
Set pFeatureCursor = pFeaturelayer.Search(pSpatialFilter, False)
Set pFeature = pFeatureCursor.NextFeature

If Not pFeature Is Nothing Then
idx = pFeature.Fields.FindField("名称")
If idx < 0 Then idx = 0 '如果没有名称字段,则使用第一个字段
End If

While Not pFeature Is Nothing
pListBox.AddItem pFeature.Value(idx)
Set pFeature = pFeatureCursor.NextFeature
Wend

Set pFeatureSelection = pFeaturelayer
'定义选中要素的符号
If pFeaturelayer.FeatureClass.ShapeType = esriGeometryPoint Or pFeaturelayer.FeatureClass.ShapeType = esriGeometryMultipoint Then
Set pSymbol = pMarkSymbol
ElseIf pFeaturelayer.FeatureClass.ShapeType = esriGeometryPolygon Then
Set pSymbol = pFillSymbol
ElseIf pFeaturelayer.FeatureClass.ShapeType = esriGeometryPolyline Then
Set pSymbol = pLineSymbol
End If

pFeatureSelection.SelectFeatures pSpatialFilter, esriSelectionResultNew, False
pFeatureSelection.SetSelectionSymbol = True
Set pFeatureSelection.SelectionSymbol = pSymbol

Next
'刷新地图上的选择集
MapControl.ActiveView.PartialRefresh esriViewGeoSelection, Nothing, Nothing
'End 一次操作到此完成
End Sub

Private Sub ITool_OnMouseMove(ByVal button As Long, ByVal shift As Long, ByVal x As Long, ByVal y As Long)

End Sub

Private Sub ITool_OnMouseUp(ByVal button As Long, ByVal shift As Long, ByVal x As Long, ByVal y As Long)

End Sub

Private Sub ITool_Refresh(ByVal hdc As esriSystem.OLE_HANDLE)

End Sub


[此贴子已经被作者于2016-10-14 23:37编辑过]

搜索更多相关主题的帖子: 空间 如何 
2016-10-14 23:36
pengzhanggui
Rank: 5Rank: 5
等 级:职业侠客
威 望:8
帖 子:161
专家分:344
注 册:2015-7-20
收藏
得分:18 
IInfoList,这个是别人封装好的吧

来找我试试看
2016-10-15 10:48
快速回复:求助!VB + ArcGIS Engine 基于空间属性查询代码中的一部分
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.023458 second(s), 10 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved