Skip to content

Commit b6111d2

Browse files
committed
fix 6dfedc3
1 parent 6dfedc3 commit b6111d2

File tree

1 file changed

+75
-75
lines changed

1 file changed

+75
-75
lines changed

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

+75-75
Original file line numberDiff line numberDiff line change
@@ -143,19 +143,19 @@ def rectangles(self, sink, source, width, height, rotation, feedback):
143143
angle = feat[rotation]
144144
if not w or not h or not angle:
145145
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()))
148148
continue
149149

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
153153

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,
159159
-i[0] * math.sin(phi) + i[1] * math.cos(phi) + y) for i in points]]
160160

161161
ft.setGeometry(QgsGeometry.fromPolygonXY(polygon))
@@ -171,22 +171,22 @@ def rectangles(self, sink, source, width, height, rotation, feedback):
171171
if not feat.hasGeometry():
172172
continue
173173

174-
w=feat[width]
175-
h=feat[height]
174+
w = feat[width]
175+
h = feat[height]
176176
if not w or not h:
177177
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()))
180180
continue
181181

182-
xOffset=w / 2.0
183-
yOffset=h / 2.0
182+
xOffset = w / 2.0
183+
yOffset = h / 2.0
184184

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]]
190190

191191
ft.setGeometry(QgsGeometry.fromPolygonXY(polygon))
192192
ft.setAttributes(feat.attributes())
@@ -195,10 +195,10 @@ def rectangles(self, sink, source, width, height, rotation, feedback):
195195
feedback.setProgress(int(current * total))
196196

197197
def diamonds(self, sink, source, width, height, rotation, feedback):
198-
features=source.getFeatures()
199-
ft=QgsFeature()
198+
features = source.getFeatures()
199+
ft = QgsFeature()
200200

201-
total=100.0 / source.featureCount() if source.featureCount() else 0
201+
total = 100.0 / source.featureCount() if source.featureCount() else 0
202202
if rotation >= 0:
203203
for current, feat in enumerate(features):
204204
if feedback.isCanceled():
@@ -207,24 +207,24 @@ def diamonds(self, sink, source, width, height, rotation, feedback):
207207
if not feat.hasGeometry():
208208
continue
209209

210-
w=feat[width]
211-
h=feat[height]
212-
angle=feat[rotation]
210+
w = feat[width]
211+
h = feat[height]
212+
angle = feat[rotation]
213213
if not w or not h or not angle:
214214
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()))
217217
continue
218218

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
222222

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,
228228
-i[0] * math.sin(phi) + i[1] * math.cos(phi) + y) for i in points]]
229229

230230
ft.setGeometry(QgsGeometry.fromPolygonXY(polygon))
@@ -239,33 +239,33 @@ def diamonds(self, sink, source, width, height, rotation, feedback):
239239
if not feat.hasGeometry():
240240
continue
241241

242-
w=feat[width]
243-
h=feat[height]
242+
w = feat[width]
243+
h = feat[height]
244244
if not w or not h:
245245
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()))
248248
continue
249249

250-
xOffset=w / 2.0
251-
yOffset=h / 2.0
250+
xOffset = w / 2.0
251+
yOffset = h / 2.0
252252

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]]
258258

259259
ft.setGeometry(QgsGeometry.fromPolygonXY(polygon))
260260
ft.setAttributes(feat.attributes())
261261
sink.addFeature(ft, QgsFeatureSink.FastInsert)
262262
feedback.setProgress(int(current * total))
263263

264264
def ovals(self, sink, source, width, height, rotation, segments, feedback):
265-
features=source.getFeatures()
266-
ft=QgsFeature()
265+
features = source.getFeatures()
266+
ft = QgsFeature()
267267

268-
total=100.0 / source.featureCount() if source.featureCount() else 0
268+
total = 100.0 / source.featureCount() if source.featureCount() else 0
269269
if rotation >= 0:
270270
for current, feat in enumerate(features):
271271
if feedback.isCanceled():
@@ -274,26 +274,26 @@ def ovals(self, sink, source, width, height, rotation, segments, feedback):
274274
if not feat.hasGeometry():
275275
continue
276276

277-
w=feat[width]
278-
h=feat[height]
279-
angle=feat[rotation]
277+
w = feat[width]
278+
h = feat[height]
279+
angle = feat[rotation]
280280
if not w or not h or not angle:
281281
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()))
284284
continue
285285

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
289289

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 = []
294294
for t in [(2 * math.pi) / segments * i for i in range(segments)]:
295295
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,
297297
-i[0] * math.sin(phi) + i[1] * math.cos(phi) + y) for i in points]]
298298

299299
ft.setGeometry(QgsGeometry.fromPolygonXY(polygon))
@@ -308,24 +308,24 @@ def ovals(self, sink, source, width, height, rotation, segments, feedback):
308308
if not feat.hasGeometry():
309309
continue
310310

311-
w=feat[width]
312-
h=feat[height]
311+
w = feat[width]
312+
h = feat[height]
313313
if not w or not h:
314314
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()))
317317
continue
318318

319-
xOffset=w / 2.0
320-
yOffset=h / 2.0
319+
xOffset = w / 2.0
320+
yOffset = h / 2.0
321321

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 = []
326326
for t in [(2 * math.pi) / segments * i for i in range(segments)]:
327327
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]]
329329

330330
ft.setGeometry(QgsGeometry.fromPolygonXY(polygon))
331331
ft.setAttributes(feat.attributes())

0 commit comments

Comments
 (0)