Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[processing] Remove ParamaterGeometryPredicate from SpatialJoin algor…
…ithm
  • Loading branch information
arnaud-morvan committed Dec 12, 2016
1 parent 65a4e97 commit 955563f
Showing 1 changed file with 14 additions and 21 deletions.
35 changes: 14 additions & 21 deletions python/plugins/processing/algs/qgis/SpatialJoin.py
Expand Up @@ -37,7 +37,6 @@

from processing.core.GeoAlgorithm import GeoAlgorithm
from processing.core.parameters import ParameterVector
from processing.core.parameters import ParameterGeometryPredicate
from processing.core.parameters import ParameterNumber
from processing.core.parameters import ParameterSelection
from processing.core.parameters import ParameterString
Expand All @@ -64,6 +63,15 @@ def defineCharacteristics(self):
self.name, self.i18n_name = self.trAlgorithm('Join attributes by location')
self.group, self.i18n_group = self.trAlgorithm('Vector general tools')

self.predicates = (
('intersects', self.tr('intersects')),
('contains', self.tr('contains')),
('equals', self.tr('equals')),
('touches', self.tr('touches')),
('overlaps', self.tr('overlaps')),
('within', self.tr('within')),
('crosses', self.tr('crosses')))

self.summarys = [
self.tr('Take attributes of the first located feature'),
self.tr('Take summary of intersecting features')
Expand All @@ -78,12 +86,10 @@ def defineCharacteristics(self):
self.tr('Target vector layer')))
self.addParameter(ParameterVector(self.JOIN,
self.tr('Join vector layer')))
predicates = list(ParameterGeometryPredicate.predicates)
predicates.remove('disjoint')
self.addParameter(ParameterGeometryPredicate(self.PREDICATE,
self.tr('Geometric predicate'),
left=self.TARGET, right=self.JOIN,
enabledPredicates=predicates))
self.addParameter(ParameterSelection(self.PREDICATE,
self.tr('Geometric predicate'),
self.predicates,
multiple=True))
self.addParameter(ParameterNumber(self.PRECISION,
self.tr('Precision'),
0.0, None, 0.0))
Expand Down Expand Up @@ -174,20 +180,7 @@ def processAlgorithm(self, progress):

res = False
for predicate in predicates:
if predicate == 'intersects':
res = inGeom.intersects(inGeomB)
elif predicate == 'contains':
res = inGeom.contains(inGeomB)
elif predicate == 'equals':
res = inGeom.equals(inGeomB)
elif predicate == 'touches':
res = inGeom.touches(inGeomB)
elif predicate == 'overlaps':
res = inGeom.overlaps(inGeomB)
elif predicate == 'within':
res = inGeom.within(inGeomB)
elif predicate == 'crosses':
res = inGeom.crosses(inGeomB)
res= getattr(inGeom, predicate)(inGeomB)
if res:
break

Expand Down

0 comments on commit 955563f

Please sign in to comment.