File tree Expand file tree Collapse file tree 3 files changed +25
-29
lines changed
python/plugins/processing/algs/qgis Expand file tree Collapse file tree 3 files changed +25
-29
lines changed Original file line number Diff line number Diff line change @@ -76,26 +76,25 @@ def processAlgorithm(self, progress):
76
76
geom = QgsGeometry ()
77
77
78
78
current = 0
79
- hasIntersections = False
80
79
81
80
features = vector .features (polyLayer )
82
81
total = 100.0 / float (len (features ))
83
82
for ftPoly in features :
84
83
geom = ftPoly .geometry ()
84
+ engine = QgsGeometry .createGeometryEngine (geom .geometry ())
85
+ engine .prepareGeometry ()
86
+
85
87
attrs = ftPoly .attributes ()
86
88
87
89
count = 0
88
- hasIntersections = False
89
90
points = spatialIndex .intersects (geom .boundingBox ())
90
91
if len (points ) > 0 :
91
- hasIntersections = True
92
-
93
- if hasIntersections :
94
- for i in points :
95
- request = QgsFeatureRequest ().setFilterFid (i )
96
- ftPoint = pointLayer .getFeatures (request ).next ()
97
- tmpGeom = QgsGeometry (ftPoint .geometry ())
98
- if geom .contains (tmpGeom ):
92
+ request = QgsFeatureRequest ().setFilterFids (points )
93
+ fit = pointLayer .getFeatures (request )
94
+ ftPoint = QgsFeature ()
95
+ while fit .nextFeature (ftPoint ):
96
+ tmpGeom = ftPoint .geometry ()
97
+ if engine .contains (tmpGeom .geometry ()):
99
98
count += 1
100
99
101
100
outFeat .setGeometry (geom )
Original file line number Diff line number Diff line change @@ -80,26 +80,25 @@ def processAlgorithm(self, progress):
80
80
geom = QgsGeometry ()
81
81
82
82
current = 0
83
- hasIntersections = False
84
83
85
84
features = vector .features (polyLayer )
86
85
total = 100.0 / float (len (features ))
87
86
for ftPoly in features :
88
87
geom = ftPoly .geometry ()
88
+ engine = QgsGeometry .createGeometryEngine (geom .geometry ())
89
+ engine .prepareGeometry ()
90
+
89
91
attrs = ftPoly .attributes ()
90
92
91
93
classes = []
92
- hasIntersections = False
93
94
points = spatialIndex .intersects (geom .boundingBox ())
94
95
if len (points ) > 0 :
95
- hasIntersections = True
96
-
97
- if hasIntersections :
98
- for i in points :
99
- request = QgsFeatureRequest ().setFilterFid (i )
100
- ftPoint = pointLayer .getFeatures (request ).next ()
96
+ request = QgsFeatureRequest ().setFilterFids (points )
97
+ fit = pointLayer .getFeatures (request )
98
+ ftPoint = QgsFeature ()
99
+ while fit .nextFeature (ftPoint ):
101
100
tmpGeom = QgsGeometry (ftPoint .geometry ())
102
- if geom .contains (tmpGeom ):
101
+ if engine .contains (tmpGeom . geometry () ):
103
102
clazz = ftPoint .attributes ()[classFieldIndex ]
104
103
if clazz not in classes :
105
104
classes .append (clazz )
Original file line number Diff line number Diff line change @@ -86,27 +86,25 @@ def processAlgorithm(self, progress):
86
86
geom = QgsGeometry ()
87
87
88
88
current = 0
89
- hasIntersections = False
90
-
91
89
features = vector .features (polyLayer )
92
90
total = 100.0 / float (len (features ))
93
91
for ftPoly in features :
94
92
geom = ftPoly .geometry ()
93
+ engine = QgsGeometry .createGeometryEngine (geom .geometry ())
94
+ engine .prepareGeometry ()
95
+
95
96
attrs = ftPoly .attributes ()
96
97
97
98
count = 0
98
- hasIntersections = False
99
99
points = spatialIndex .intersects (geom .boundingBox ())
100
100
if len (points ) > 0 :
101
- hasIntersections = True
102
-
103
- if hasIntersections :
104
101
progress .setText (unicode (len (points )))
105
- for i in points :
106
- request = QgsFeatureRequest ().setFilterFid (i )
107
- ftPoint = pointLayer .getFeatures (request ).next ()
102
+ request = QgsFeatureRequest ().setFilterFids (points )
103
+ fit = pointLayer .getFeatures (request )
104
+ ftPoint = QgsFeature ()
105
+ while fit .nextFeature (ftPoint ):
108
106
tmpGeom = QgsGeometry (ftPoint .geometry ())
109
- if geom .contains (tmpGeom ):
107
+ if engine .contains (tmpGeom . geometry () ):
110
108
weight = unicode (ftPoint .attributes ()[fieldIdx ])
111
109
try :
112
110
count += float (weight )
You can’t perform that action at this time.
0 commit comments