Skip to content

Commit dc156c8

Browse files
committed
Fix #12154 - select by location not working when A covers B
The combination of touches+overlaps+contains is not enough if input layer (where selection should be done) is completely within selection layer. I have reintroduced "intersects" predicate and made it default. The processing toolbox has an improved (fixed?) version but fTools were not adapted at the same time
1 parent eaeff19 commit dc156c8

File tree

2 files changed

+41
-24
lines changed

2 files changed

+41
-24
lines changed

python/plugins/fTools/tools/doSelectByLocation.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ class Dialog(QDialog, Ui_Dialog):
3838
TOUCH = 1
3939
OVERLAP = 2
4040
WITHIN = 4
41+
INTERSECT = 8
4142

4243
def __init__(self, iface):
4344
QDialog.__init__(self, iface.mainWindow())
@@ -92,7 +93,9 @@ def _poly_lines_op(geomA,geomB):
9293
if geomA.disjoint(geomB):
9394
return False
9495
intersects = False
95-
if self.opFlags & self.TOUCH:
96+
if self.opFlags & self.INTERSECT:
97+
intersects |= geomA.intersects(geomB)
98+
if not intersects and (self.opFlags & self.TOUCH):
9699
intersects |= geomA.touches(geomB)
97100
if not intersects and (self.opFlags & self.OVERLAP):
98101
if geomB.type() == QGis.Line or geomA.type() == QGis.Line:
@@ -116,6 +119,8 @@ def _sp_operator():
116119
self.opFlags |= self.OVERLAP
117120
if self.chkContains.checkState() == Qt.Checked:
118121
self.opFlags |= self.WITHIN
122+
if self.chkIntersects.checkState() == Qt.Checked:
123+
self.opFlags |= self.INTERSECT
119124

120125
sp_operator = _sp_operator()
121126

python/plugins/fTools/tools/frmSelectByLocation.ui

Lines changed: 35 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
<rect>
77
<x>0</x>
88
<y>0</y>
9-
<width>423</width>
10-
<height>308</height>
9+
<width>534</width>
10+
<height>321</height>
1111
</rect>
1212
</property>
1313
<property name="sizePolicy">
@@ -19,20 +19,20 @@
1919
<property name="minimumSize">
2020
<size>
2121
<width>0</width>
22-
<height>308</height>
22+
<height>321</height>
2323
</size>
2424
</property>
2525
<property name="maximumSize">
2626
<size>
2727
<width>16777215</width>
28-
<height>308</height>
28+
<height>321</height>
2929
</size>
3030
</property>
3131
<property name="windowTitle">
3232
<string>Select by location</string>
3333
</property>
34-
<layout class="QGridLayout" name="gridLayout">
35-
<item row="0" column="0">
34+
<layout class="QVBoxLayout" name="verticalLayout">
35+
<item>
3636
<layout class="QVBoxLayout" name="verticalLayout_2">
3737
<item>
3838
<widget class="QLabel" name="label_3">
@@ -46,7 +46,7 @@
4646
</item>
4747
</layout>
4848
</item>
49-
<item row="1" column="0">
49+
<item>
5050
<layout class="QVBoxLayout" name="verticalLayout_3">
5151
<item>
5252
<widget class="QLabel" name="label_4">
@@ -60,44 +60,48 @@
6060
</item>
6161
</layout>
6262
</item>
63-
<item row="2" column="0">
64-
<widget class="QCheckBox" name="chkTouches">
63+
<item>
64+
<widget class="QCheckBox" name="chkIntersects">
6565
<property name="text">
66-
<string>Include input features that touch the selection features</string>
66+
<string>Include input features that insersect the selection features</string>
6767
</property>
6868
<property name="checked">
6969
<bool>true</bool>
7070
</property>
7171
</widget>
7272
</item>
73-
<item row="3" column="0">
73+
<item>
74+
<widget class="QCheckBox" name="chkTouches">
75+
<property name="text">
76+
<string>Include input features that touch the selection features</string>
77+
</property>
78+
</widget>
79+
</item>
80+
<item>
7481
<widget class="QCheckBox" name="chkOverlaps">
7582
<property name="text">
7683
<string>Include input features that overlap/cross the selection features</string>
7784
</property>
78-
<property name="checked">
79-
<bool>true</bool>
80-
</property>
8185
</widget>
8286
</item>
83-
<item row="4" column="0">
87+
<item>
8488
<widget class="QCheckBox" name="chkContains">
8589
<property name="text">
8690
<string>Include input features completely within the selection features</string>
8791
</property>
88-
<property name="checked">
89-
<bool>true</bool>
90-
</property>
9192
</widget>
9293
</item>
93-
<item row="5" column="0">
94+
<item>
9495
<widget class="QCheckBox" name="chkSelected">
9596
<property name="text">
9697
<string>Only selected features</string>
9798
</property>
9899
</widget>
99100
</item>
100-
<item row="7" column="0">
101+
<item>
102+
<widget class="QComboBox" name="cmbModify"/>
103+
</item>
104+
<item>
101105
<layout class="QHBoxLayout" name="horizontalLayout_2">
102106
<item>
103107
<widget class="QProgressBar" name="progressBar">
@@ -124,11 +128,19 @@
124128
</item>
125129
</layout>
126130
</item>
127-
<item row="6" column="0">
128-
<widget class="QComboBox" name="cmbModify"/>
129-
</item>
130131
</layout>
131132
</widget>
133+
<tabstops>
134+
<tabstop>inPolygon</tabstop>
135+
<tabstop>inPoint</tabstop>
136+
<tabstop>chkIntersects</tabstop>
137+
<tabstop>chkTouches</tabstop>
138+
<tabstop>chkOverlaps</tabstop>
139+
<tabstop>chkContains</tabstop>
140+
<tabstop>chkSelected</tabstop>
141+
<tabstop>cmbModify</tabstop>
142+
<tabstop>buttonBox</tabstop>
143+
</tabstops>
132144
<resources/>
133145
<connections>
134146
<connection>

0 commit comments

Comments
 (0)