@@ -143,19 +143,19 @@ def rectangles(self, sink, source, width, height, rotation, feedback):
143
143
angle = feat [rotation ]
144
144
if not w or not h or not angle :
145
145
feedback .pushInfo (QCoreApplication .translate ('RectanglesOvalsDiamondsVariable' , 'Feature {} has empty '
146
- 'width, height or angle. '
147
- 'Skipping…' ).format (feat .id () )))
146
+ 'width, height or angle. '
147
+ 'Skipping…' ).format (feat .id ()))
148
148
continue
149
149
150
- xOffset = w / 2.0
151
- yOffset = h / 2.0
152
- phi = angle * math .pi / 180
150
+ xOffset = w / 2.0
151
+ yOffset = h / 2.0
152
+ phi = angle * math .pi / 180
153
153
154
- point = feat .geometry ().asPoint ()
155
- x = point .x ()
156
- y = point .y ()
157
- points = [(- xOffset , - yOffset ), (- xOffset , yOffset ), (xOffset , yOffset ), (xOffset , - yOffset )]
158
- polygon = [[QgsPointXY (i [0 ] * math .cos (phi ) + i [1 ] * math .sin (phi ) + x ,
154
+ point = feat .geometry ().asPoint ()
155
+ x = point .x ()
156
+ y = point .y ()
157
+ points = [(- xOffset , - yOffset ), (- xOffset , yOffset ), (xOffset , yOffset ), (xOffset , - yOffset )]
158
+ polygon = [[QgsPointXY (i [0 ] * math .cos (phi ) + i [1 ] * math .sin (phi ) + x ,
159
159
- i [0 ] * math .sin (phi ) + i [1 ] * math .cos (phi ) + y ) for i in points ]]
160
160
161
161
ft .setGeometry (QgsGeometry .fromPolygonXY (polygon ))
@@ -171,22 +171,22 @@ def rectangles(self, sink, source, width, height, rotation, feedback):
171
171
if not feat .hasGeometry ():
172
172
continue
173
173
174
- w = feat [width ]
175
- h = feat [height ]
174
+ w = feat [width ]
175
+ h = feat [height ]
176
176
if not w or not h :
177
177
feedback .pushInfo (QCoreApplication .translate ('RectanglesOvalsDiamondsVariable' , 'Feature {} has empty '
178
- 'width or height. '
179
- 'Skipping…' ).format (feat .id ()))
178
+ 'width or height. '
179
+ 'Skipping…' ).format (feat .id ()))
180
180
continue
181
181
182
- xOffset = w / 2.0
183
- yOffset = h / 2.0
182
+ xOffset = w / 2.0
183
+ yOffset = h / 2.0
184
184
185
- point = feat .geometry ().asPoint ()
186
- x = point .x ()
187
- y = point .y ()
188
- points = [(- xOffset , - yOffset ), (- xOffset , yOffset ), (xOffset , yOffset ), (xOffset , - yOffset )]
189
- polygon = [[QgsPointXY (i [0 ] + x , i [1 ] + y ) for i in points ]]
185
+ point = feat .geometry ().asPoint ()
186
+ x = point .x ()
187
+ y = point .y ()
188
+ points = [(- xOffset , - yOffset ), (- xOffset , yOffset ), (xOffset , yOffset ), (xOffset , - yOffset )]
189
+ polygon = [[QgsPointXY (i [0 ] + x , i [1 ] + y ) for i in points ]]
190
190
191
191
ft .setGeometry (QgsGeometry .fromPolygonXY (polygon ))
192
192
ft .setAttributes (feat .attributes ())
@@ -195,10 +195,10 @@ def rectangles(self, sink, source, width, height, rotation, feedback):
195
195
feedback .setProgress (int (current * total ))
196
196
197
197
def diamonds (self , sink , source , width , height , rotation , feedback ):
198
- features = source .getFeatures ()
199
- ft = QgsFeature ()
198
+ features = source .getFeatures ()
199
+ ft = QgsFeature ()
200
200
201
- total = 100.0 / source .featureCount () if source .featureCount () else 0
201
+ total = 100.0 / source .featureCount () if source .featureCount () else 0
202
202
if rotation >= 0 :
203
203
for current , feat in enumerate (features ):
204
204
if feedback .isCanceled ():
@@ -207,24 +207,24 @@ def diamonds(self, sink, source, width, height, rotation, feedback):
207
207
if not feat .hasGeometry ():
208
208
continue
209
209
210
- w = feat [width ]
211
- h = feat [height ]
212
- angle = feat [rotation ]
210
+ w = feat [width ]
211
+ h = feat [height ]
212
+ angle = feat [rotation ]
213
213
if not w or not h or not angle :
214
214
feedback .pushInfo (QCoreApplication .translate ('RectanglesOvalsDiamondsVariable' , 'Feature {} has empty '
215
- 'width, height or angle. '
216
- 'Skipping…' ).format (feat .id ()))
215
+ 'width, height or angle. '
216
+ 'Skipping…' ).format (feat .id ()))
217
217
continue
218
218
219
- xOffset = w / 2.0
220
- yOffset = h / 2.0
221
- phi = angle * math .pi / 180
219
+ xOffset = w / 2.0
220
+ yOffset = h / 2.0
221
+ phi = angle * math .pi / 180
222
222
223
- point = feat .geometry ().asPoint ()
224
- x = point .x ()
225
- y = point .y ()
226
- points = [(0.0 , - yOffset ), (- xOffset , 0.0 ), (0.0 , yOffset ), (xOffset , 0.0 )]
227
- polygon = [[QgsPointXY (i [0 ] * math .cos (phi ) + i [1 ] * math .sin (phi ) + x ,
223
+ point = feat .geometry ().asPoint ()
224
+ x = point .x ()
225
+ y = point .y ()
226
+ points = [(0.0 , - yOffset ), (- xOffset , 0.0 ), (0.0 , yOffset ), (xOffset , 0.0 )]
227
+ polygon = [[QgsPointXY (i [0 ] * math .cos (phi ) + i [1 ] * math .sin (phi ) + x ,
228
228
- i [0 ] * math .sin (phi ) + i [1 ] * math .cos (phi ) + y ) for i in points ]]
229
229
230
230
ft .setGeometry (QgsGeometry .fromPolygonXY (polygon ))
@@ -239,33 +239,33 @@ def diamonds(self, sink, source, width, height, rotation, feedback):
239
239
if not feat .hasGeometry ():
240
240
continue
241
241
242
- w = feat [width ]
243
- h = feat [height ]
242
+ w = feat [width ]
243
+ h = feat [height ]
244
244
if not w or not h :
245
245
feedback .pushInfo (QCoreApplication .translate ('RectanglesOvalsDiamondsVariable' , 'Feature {} has empty '
246
- 'width or height. '
247
- 'Skipping…' ).format (feat .id ()))
246
+ 'width or height. '
247
+ 'Skipping…' ).format (feat .id ()))
248
248
continue
249
249
250
- xOffset = w / 2.0
251
- yOffset = h / 2.0
250
+ xOffset = w / 2.0
251
+ yOffset = h / 2.0
252
252
253
- point = feat .geometry ().asPoint ()
254
- x = point .x ()
255
- y = point .y ()
256
- points = [(0.0 , - yOffset ), (- xOffset , 0.0 ), (0.0 , yOffset ), (xOffset , 0.0 )]
257
- polygon = [[QgsPointXY (i [0 ] + x , i [1 ] + y ) for i in points ]]
253
+ point = feat .geometry ().asPoint ()
254
+ x = point .x ()
255
+ y = point .y ()
256
+ points = [(0.0 , - yOffset ), (- xOffset , 0.0 ), (0.0 , yOffset ), (xOffset , 0.0 )]
257
+ polygon = [[QgsPointXY (i [0 ] + x , i [1 ] + y ) for i in points ]]
258
258
259
259
ft .setGeometry (QgsGeometry .fromPolygonXY (polygon ))
260
260
ft .setAttributes (feat .attributes ())
261
261
sink .addFeature (ft , QgsFeatureSink .FastInsert )
262
262
feedback .setProgress (int (current * total ))
263
263
264
264
def ovals (self , sink , source , width , height , rotation , segments , feedback ):
265
- features = source .getFeatures ()
266
- ft = QgsFeature ()
265
+ features = source .getFeatures ()
266
+ ft = QgsFeature ()
267
267
268
- total = 100.0 / source .featureCount () if source .featureCount () else 0
268
+ total = 100.0 / source .featureCount () if source .featureCount () else 0
269
269
if rotation >= 0 :
270
270
for current , feat in enumerate (features ):
271
271
if feedback .isCanceled ():
@@ -274,26 +274,26 @@ def ovals(self, sink, source, width, height, rotation, segments, feedback):
274
274
if not feat .hasGeometry ():
275
275
continue
276
276
277
- w = feat [width ]
278
- h = feat [height ]
279
- angle = feat [rotation ]
277
+ w = feat [width ]
278
+ h = feat [height ]
279
+ angle = feat [rotation ]
280
280
if not w or not h or not angle :
281
281
feedback .pushInfo (QCoreApplication .translate ('RectanglesOvalsDiamondsVariable' , 'Feature {} has empty '
282
- 'width, height or angle. '
283
- 'Skipping…' ).format (feat .id ()))
282
+ 'width, height or angle. '
283
+ 'Skipping…' ).format (feat .id ()))
284
284
continue
285
285
286
- xOffset = w / 2.0
287
- yOffset = h / 2.0
288
- phi = angle * math .pi / 180
286
+ xOffset = w / 2.0
287
+ yOffset = h / 2.0
288
+ phi = angle * math .pi / 180
289
289
290
- point = feat .geometry ().asPoint ()
291
- x = point .x ()
292
- y = point .y ()
293
- points = []
290
+ point = feat .geometry ().asPoint ()
291
+ x = point .x ()
292
+ y = point .y ()
293
+ points = []
294
294
for t in [(2 * math .pi ) / segments * i for i in range (segments )]:
295
295
points .append ((xOffset * math .cos (t ), yOffset * math .sin (t )))
296
- polygon = [[QgsPointXY (i [0 ] * math .cos (phi ) + i [1 ] * math .sin (phi ) + x ,
296
+ polygon = [[QgsPointXY (i [0 ] * math .cos (phi ) + i [1 ] * math .sin (phi ) + x ,
297
297
- i [0 ] * math .sin (phi ) + i [1 ] * math .cos (phi ) + y ) for i in points ]]
298
298
299
299
ft .setGeometry (QgsGeometry .fromPolygonXY (polygon ))
@@ -308,24 +308,24 @@ def ovals(self, sink, source, width, height, rotation, segments, feedback):
308
308
if not feat .hasGeometry ():
309
309
continue
310
310
311
- w = feat [width ]
312
- h = feat [height ]
311
+ w = feat [width ]
312
+ h = feat [height ]
313
313
if not w or not h :
314
314
feedback .pushInfo (QCoreApplication .translate ('RectanglesOvalsDiamondsVariable' , 'Feature {} has empty '
315
- 'width or height. '
316
- 'Skipping…' ).format (feat .id ()))
315
+ 'width or height. '
316
+ 'Skipping…' ).format (feat .id ()))
317
317
continue
318
318
319
- xOffset = w / 2.0
320
- yOffset = h / 2.0
319
+ xOffset = w / 2.0
320
+ yOffset = h / 2.0
321
321
322
- point = feat .geometry ().asPoint ()
323
- x = point .x ()
324
- y = point .y ()
325
- points = []
322
+ point = feat .geometry ().asPoint ()
323
+ x = point .x ()
324
+ y = point .y ()
325
+ points = []
326
326
for t in [(2 * math .pi ) / segments * i for i in range (segments )]:
327
327
points .append ((xOffset * math .cos (t ), yOffset * math .sin (t )))
328
- polygon = [[QgsPointXY (i [0 ] + x , i [1 ] + y ) for i in points ]]
328
+ polygon = [[QgsPointXY (i [0 ] + x , i [1 ] + y ) for i in points ]]
329
329
330
330
ft .setGeometry (QgsGeometry .fromPolygonXY (polygon ))
331
331
ft .setAttributes (feat .attributes ())
0 commit comments