免费视频|新人指南|投诉删帖|广告合作|地信网APP下载

查看: 1828|回复: 2
收起左侧

技术资料:SearchWithin 和 SelectByRegion 方法的使用:

[复制链接]

2072

主题

100000万

铜板

363

好友

地信专家组

每一次的分离都是为了下一次的相聚

Rank: 14Rank: 14Rank: 14Rank: 14

积分
17612

精华勋章宣传勋章爱心勋章组织勋章地信元老灌水勋章荣誉会员勋章活跃勋章贡献勋章

发表于 2009-11-15 19:28 | 显示全部楼层 |阅读模式
技术资料:SearchWithin 和 SelectByRegion 方法的使用:
下列代码演示了SearchWithin 和 SelectByRegion 方法的使用。
Private Sub cmdQuit_Click()
End
End Sub

Private Sub Command1_Click()
Dim ftr As Feature
Dim ftrs As Features
If Map1.Layers.Item("regions").Selection.Count = 0 Then
MsgBox "Select a yellow region 1st"
Exit Sub
End If
Set ftr = Map1.Layers.Item("regions").Selection.Item(1)
'SearchType: SearchType is miSearchTypeCentroidWithin, miSearchTypePartiallyWithin, or miSearchTypeEntirelyWithin.
Set ftrs = Map1.Layers.Item("pieces").SearchWithinFeature(ftr, miSearchTypePartiallyWithin)
Map1.Layers.Item("pieces").Selection.Add ftrs
Map1.Layers.Item("regions").Selection.ClearSelection
MsgBox ftrs.Count
End Sub

Private Sub Command2_Click()
Dim ftr As Feature
Dim ftrs As Features
Dim lyr As Layer
If Map1.Layers.Item("regions").Selection.Count = 0 Then
MsgBox "Select a yellow region 1st"
Exit Sub
End If
Set lyr = Map1.Layers.Item("regions")
Set ftr = lyr.Selection.Item(1)
'A feature is considered to be within "within" the region if and only if its centroid is within the radius. If more control is needed over selection criteria, use the Layer object's SearchWithinFeature method.
Map1.Layers.Item("pieces").Selection.SelectByRegion lyr, ftr.FeatureID, miSelectionNew
Map1.Layers.Item("regions").Selection.ClearSelection
MsgBox Map1.Layers.Item("pieces").Selection.Count
End Sub

Private Sub Form_Load()
'Add the layer
Map1.Layers.RemoveAll
Map1.Layers.Add App.Path & "\regions.tab"
Map1.Layers.Add App.Path & "\pieces.tab"
Map1.CurrentTool = miSelectTool
'make the map look nice for the sample data
Map1.DisplayCoordSys = Map1.NumericCoordSys
Map1.Title.Visible = False
Map1.Bounds = Map1.Layers.Item("regions").Bounds
End Sub

2

主题

3万

铜板

7

好友

钻石会员

Rank: 26Rank: 26Rank: 26Rank: 26Rank: 26Rank: 26Rank: 26

积分
5715
发表于 2021-12-19 14:52 | 显示全部楼层
谢谢分享
回复

使用道具 举报

0

主题

2万

铜板

1

好友

资深会员

Rank: 18Rank: 18Rank: 18Rank: 18Rank: 18

积分
3421
发表于 2022-1-4 09:43 | 显示全部楼层
这么复杂叱
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

在线客服
快速回复 返回顶部 返回列表