Skip to content

Commit 09035a4

Browse files
committed
[processing] Remove ParamaterGeometryPredicate from ExtractByLocation algorithm
1 parent 955563f commit 09035a4

File tree

1 file changed

+16
-18
lines changed

1 file changed

+16
-18
lines changed

python/plugins/processing/algs/qgis/ExtractByLocation.py

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
from qgis.core import QgsFeatureRequest
3030
from processing.core.GeoAlgorithm import GeoAlgorithm
3131
from processing.core.parameters import ParameterVector
32-
from processing.core.parameters import ParameterGeometryPredicate
32+
from processing.core.parameters import ParameterSelection
3333
from processing.core.parameters import ParameterNumber
3434
from processing.core.outputs import OutputVector
3535
from processing.tools import dataobjects, vector
@@ -48,13 +48,24 @@ def defineCharacteristics(self):
4848
self.group, self.i18n_group = self.trAlgorithm('Vector selection tools')
4949
self.tags = self.tr('extract,filter,location,intersects,contains,within')
5050

51+
self.predicates = (
52+
('intersects', self.tr('intersects')),
53+
('contains', self.tr('contains')),
54+
('disjoint', self.tr('disjoint')),
55+
('equals', self.tr('equals')),
56+
('touches', self.tr('touches')),
57+
('overlaps', self.tr('overlaps')),
58+
('within', self.tr('within')),
59+
('crosses', self.tr('crosses')))
60+
5161
self.addParameter(ParameterVector(self.INPUT,
5262
self.tr('Layer to select from')))
5363
self.addParameter(ParameterVector(self.INTERSECT,
5464
self.tr('Additional layer (intersection layer)')))
55-
self.addParameter(ParameterGeometryPredicate(self.PREDICATE,
56-
self.tr('Geometric predicate'),
57-
left=self.INPUT, right=self.INTERSECT))
65+
self.addParameter(ParameterSelection(self.PREDICATE,
66+
self.tr('Geometric predicate'),
67+
self.predicates,
68+
multiple=True))
5869
self.addParameter(ParameterNumber(self.PRECISION,
5970
self.tr('Precision'),
6071
0.0, None, 0.0))
@@ -98,20 +109,7 @@ def processAlgorithm(self, progress):
98109
except:
99110
pass # already removed
100111
else:
101-
if predicate == 'intersects':
102-
res = tmpGeom.intersects(geom)
103-
elif predicate == 'contains':
104-
res = tmpGeom.contains(geom)
105-
elif predicate == 'equals':
106-
res = tmpGeom.equals(geom)
107-
elif predicate == 'touches':
108-
res = tmpGeom.touches(geom)
109-
elif predicate == 'overlaps':
110-
res = tmpGeom.overlaps(geom)
111-
elif predicate == 'within':
112-
res = tmpGeom.within(geom)
113-
elif predicate == 'crosses':
114-
res = tmpGeom.crosses(geom)
112+
res = getattr(tmpGeom, predicate)(geom)
115113
if res:
116114
selectedSet.append(feat.id())
117115
break

0 commit comments

Comments
 (0)