Skip to content

Commit 955563f

Browse files
committed
[processing] Remove ParamaterGeometryPredicate from SpatialJoin algorithm
1 parent 65a4e97 commit 955563f

File tree

1 file changed

+14
-21
lines changed

1 file changed

+14
-21
lines changed

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

Lines changed: 14 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737

3838
from processing.core.GeoAlgorithm import GeoAlgorithm
3939
from processing.core.parameters import ParameterVector
40-
from processing.core.parameters import ParameterGeometryPredicate
4140
from processing.core.parameters import ParameterNumber
4241
from processing.core.parameters import ParameterSelection
4342
from processing.core.parameters import ParameterString
@@ -64,6 +63,15 @@ def defineCharacteristics(self):
6463
self.name, self.i18n_name = self.trAlgorithm('Join attributes by location')
6564
self.group, self.i18n_group = self.trAlgorithm('Vector general tools')
6665

66+
self.predicates = (
67+
('intersects', self.tr('intersects')),
68+
('contains', self.tr('contains')),
69+
('equals', self.tr('equals')),
70+
('touches', self.tr('touches')),
71+
('overlaps', self.tr('overlaps')),
72+
('within', self.tr('within')),
73+
('crosses', self.tr('crosses')))
74+
6775
self.summarys = [
6876
self.tr('Take attributes of the first located feature'),
6977
self.tr('Take summary of intersecting features')
@@ -78,12 +86,10 @@ def defineCharacteristics(self):
7886
self.tr('Target vector layer')))
7987
self.addParameter(ParameterVector(self.JOIN,
8088
self.tr('Join vector layer')))
81-
predicates = list(ParameterGeometryPredicate.predicates)
82-
predicates.remove('disjoint')
83-
self.addParameter(ParameterGeometryPredicate(self.PREDICATE,
84-
self.tr('Geometric predicate'),
85-
left=self.TARGET, right=self.JOIN,
86-
enabledPredicates=predicates))
89+
self.addParameter(ParameterSelection(self.PREDICATE,
90+
self.tr('Geometric predicate'),
91+
self.predicates,
92+
multiple=True))
8793
self.addParameter(ParameterNumber(self.PRECISION,
8894
self.tr('Precision'),
8995
0.0, None, 0.0))
@@ -174,20 +180,7 @@ def processAlgorithm(self, progress):
174180

175181
res = False
176182
for predicate in predicates:
177-
if predicate == 'intersects':
178-
res = inGeom.intersects(inGeomB)
179-
elif predicate == 'contains':
180-
res = inGeom.contains(inGeomB)
181-
elif predicate == 'equals':
182-
res = inGeom.equals(inGeomB)
183-
elif predicate == 'touches':
184-
res = inGeom.touches(inGeomB)
185-
elif predicate == 'overlaps':
186-
res = inGeom.overlaps(inGeomB)
187-
elif predicate == 'within':
188-
res = inGeom.within(inGeomB)
189-
elif predicate == 'crosses':
190-
res = inGeom.crosses(inGeomB)
183+
res= getattr(inGeom, predicate)(inGeomB)
191184
if res:
192185
break
193186

0 commit comments

Comments
 (0)