mirror of
https://github.com/qgis/QGIS.git
synced 2025-11-22 00:14:55 -05:00
fix 6dfedc38
This commit is contained in:
parent
6dfedc38e9
commit
b6111d296e
@ -143,19 +143,19 @@ class RectanglesOvalsDiamondsVariable(QgisAlgorithm):
|
|||||||
angle = feat[rotation]
|
angle = feat[rotation]
|
||||||
if not w or not h or not angle:
|
if not w or not h or not angle:
|
||||||
feedback.pushInfo(QCoreApplication.translate('RectanglesOvalsDiamondsVariable', 'Feature {} has empty '
|
feedback.pushInfo(QCoreApplication.translate('RectanglesOvalsDiamondsVariable', 'Feature {} has empty '
|
||||||
'width, height or angle. '
|
'width, height or angle. '
|
||||||
'Skipping…').format(feat.id())))
|
'Skipping…').format(feat.id()))
|
||||||
continue
|
continue
|
||||||
|
|
||||||
xOffset=w / 2.0
|
xOffset = w / 2.0
|
||||||
yOffset=h / 2.0
|
yOffset = h / 2.0
|
||||||
phi=angle * math.pi / 180
|
phi = angle * math.pi / 180
|
||||||
|
|
||||||
point=feat.geometry().asPoint()
|
point = feat.geometry().asPoint()
|
||||||
x=point.x()
|
x = point.x()
|
||||||
y=point.y()
|
y = point.y()
|
||||||
points=[(-xOffset, -yOffset), (-xOffset, yOffset), (xOffset, yOffset), (xOffset, -yOffset)]
|
points = [(-xOffset, -yOffset), (-xOffset, yOffset), (xOffset, yOffset), (xOffset, -yOffset)]
|
||||||
polygon=[[QgsPointXY(i[0] * math.cos(phi) + i[1] * math.sin(phi) + x,
|
polygon = [[QgsPointXY(i[0] * math.cos(phi) + i[1] * math.sin(phi) + x,
|
||||||
-i[0] * math.sin(phi) + i[1] * math.cos(phi) + y) for i in points]]
|
-i[0] * math.sin(phi) + i[1] * math.cos(phi) + y) for i in points]]
|
||||||
|
|
||||||
ft.setGeometry(QgsGeometry.fromPolygonXY(polygon))
|
ft.setGeometry(QgsGeometry.fromPolygonXY(polygon))
|
||||||
@ -171,22 +171,22 @@ class RectanglesOvalsDiamondsVariable(QgisAlgorithm):
|
|||||||
if not feat.hasGeometry():
|
if not feat.hasGeometry():
|
||||||
continue
|
continue
|
||||||
|
|
||||||
w=feat[width]
|
w = feat[width]
|
||||||
h=feat[height]
|
h = feat[height]
|
||||||
if not w or not h:
|
if not w or not h:
|
||||||
feedback.pushInfo(QCoreApplication.translate('RectanglesOvalsDiamondsVariable', 'Feature {} has empty '
|
feedback.pushInfo(QCoreApplication.translate('RectanglesOvalsDiamondsVariable', 'Feature {} has empty '
|
||||||
'width or height. '
|
'width or height. '
|
||||||
'Skipping…').format(feat.id()))
|
'Skipping…').format(feat.id()))
|
||||||
continue
|
continue
|
||||||
|
|
||||||
xOffset=w / 2.0
|
xOffset = w / 2.0
|
||||||
yOffset=h / 2.0
|
yOffset = h / 2.0
|
||||||
|
|
||||||
point=feat.geometry().asPoint()
|
point = feat.geometry().asPoint()
|
||||||
x=point.x()
|
x = point.x()
|
||||||
y=point.y()
|
y = point.y()
|
||||||
points=[(-xOffset, -yOffset), (-xOffset, yOffset), (xOffset, yOffset), (xOffset, -yOffset)]
|
points = [(-xOffset, -yOffset), (-xOffset, yOffset), (xOffset, yOffset), (xOffset, -yOffset)]
|
||||||
polygon=[[QgsPointXY(i[0] + x, i[1] + y) for i in points]]
|
polygon = [[QgsPointXY(i[0] + x, i[1] + y) for i in points]]
|
||||||
|
|
||||||
ft.setGeometry(QgsGeometry.fromPolygonXY(polygon))
|
ft.setGeometry(QgsGeometry.fromPolygonXY(polygon))
|
||||||
ft.setAttributes(feat.attributes())
|
ft.setAttributes(feat.attributes())
|
||||||
@ -195,10 +195,10 @@ class RectanglesOvalsDiamondsVariable(QgisAlgorithm):
|
|||||||
feedback.setProgress(int(current * total))
|
feedback.setProgress(int(current * total))
|
||||||
|
|
||||||
def diamonds(self, sink, source, width, height, rotation, feedback):
|
def diamonds(self, sink, source, width, height, rotation, feedback):
|
||||||
features=source.getFeatures()
|
features = source.getFeatures()
|
||||||
ft=QgsFeature()
|
ft = QgsFeature()
|
||||||
|
|
||||||
total=100.0 / source.featureCount() if source.featureCount() else 0
|
total = 100.0 / source.featureCount() if source.featureCount() else 0
|
||||||
if rotation >= 0:
|
if rotation >= 0:
|
||||||
for current, feat in enumerate(features):
|
for current, feat in enumerate(features):
|
||||||
if feedback.isCanceled():
|
if feedback.isCanceled():
|
||||||
@ -207,24 +207,24 @@ class RectanglesOvalsDiamondsVariable(QgisAlgorithm):
|
|||||||
if not feat.hasGeometry():
|
if not feat.hasGeometry():
|
||||||
continue
|
continue
|
||||||
|
|
||||||
w=feat[width]
|
w = feat[width]
|
||||||
h=feat[height]
|
h = feat[height]
|
||||||
angle=feat[rotation]
|
angle = feat[rotation]
|
||||||
if not w or not h or not angle:
|
if not w or not h or not angle:
|
||||||
feedback.pushInfo(QCoreApplication.translate('RectanglesOvalsDiamondsVariable', 'Feature {} has empty '
|
feedback.pushInfo(QCoreApplication.translate('RectanglesOvalsDiamondsVariable', 'Feature {} has empty '
|
||||||
'width, height or angle. '
|
'width, height or angle. '
|
||||||
'Skipping…').format(feat.id()))
|
'Skipping…').format(feat.id()))
|
||||||
continue
|
continue
|
||||||
|
|
||||||
xOffset=w / 2.0
|
xOffset = w / 2.0
|
||||||
yOffset=h / 2.0
|
yOffset = h / 2.0
|
||||||
phi=angle * math.pi / 180
|
phi = angle * math.pi / 180
|
||||||
|
|
||||||
point=feat.geometry().asPoint()
|
point = feat.geometry().asPoint()
|
||||||
x=point.x()
|
x = point.x()
|
||||||
y=point.y()
|
y = point.y()
|
||||||
points=[(0.0, -yOffset), (-xOffset, 0.0), (0.0, yOffset), (xOffset, 0.0)]
|
points = [(0.0, -yOffset), (-xOffset, 0.0), (0.0, yOffset), (xOffset, 0.0)]
|
||||||
polygon=[[QgsPointXY(i[0] * math.cos(phi) + i[1] * math.sin(phi) + x,
|
polygon = [[QgsPointXY(i[0] * math.cos(phi) + i[1] * math.sin(phi) + x,
|
||||||
-i[0] * math.sin(phi) + i[1] * math.cos(phi) + y) for i in points]]
|
-i[0] * math.sin(phi) + i[1] * math.cos(phi) + y) for i in points]]
|
||||||
|
|
||||||
ft.setGeometry(QgsGeometry.fromPolygonXY(polygon))
|
ft.setGeometry(QgsGeometry.fromPolygonXY(polygon))
|
||||||
@ -239,22 +239,22 @@ class RectanglesOvalsDiamondsVariable(QgisAlgorithm):
|
|||||||
if not feat.hasGeometry():
|
if not feat.hasGeometry():
|
||||||
continue
|
continue
|
||||||
|
|
||||||
w=feat[width]
|
w = feat[width]
|
||||||
h=feat[height]
|
h = feat[height]
|
||||||
if not w or not h:
|
if not w or not h:
|
||||||
feedback.pushInfo(QCoreApplication.translate('RectanglesOvalsDiamondsVariable', 'Feature {} has empty '
|
feedback.pushInfo(QCoreApplication.translate('RectanglesOvalsDiamondsVariable', 'Feature {} has empty '
|
||||||
'width or height. '
|
'width or height. '
|
||||||
'Skipping…').format(feat.id()))
|
'Skipping…').format(feat.id()))
|
||||||
continue
|
continue
|
||||||
|
|
||||||
xOffset=w / 2.0
|
xOffset = w / 2.0
|
||||||
yOffset=h / 2.0
|
yOffset = h / 2.0
|
||||||
|
|
||||||
point=feat.geometry().asPoint()
|
point = feat.geometry().asPoint()
|
||||||
x=point.x()
|
x = point.x()
|
||||||
y=point.y()
|
y = point.y()
|
||||||
points=[(0.0, -yOffset), (-xOffset, 0.0), (0.0, yOffset), (xOffset, 0.0)]
|
points = [(0.0, -yOffset), (-xOffset, 0.0), (0.0, yOffset), (xOffset, 0.0)]
|
||||||
polygon=[[QgsPointXY(i[0] + x, i[1] + y) for i in points]]
|
polygon = [[QgsPointXY(i[0] + x, i[1] + y) for i in points]]
|
||||||
|
|
||||||
ft.setGeometry(QgsGeometry.fromPolygonXY(polygon))
|
ft.setGeometry(QgsGeometry.fromPolygonXY(polygon))
|
||||||
ft.setAttributes(feat.attributes())
|
ft.setAttributes(feat.attributes())
|
||||||
@ -262,10 +262,10 @@ class RectanglesOvalsDiamondsVariable(QgisAlgorithm):
|
|||||||
feedback.setProgress(int(current * total))
|
feedback.setProgress(int(current * total))
|
||||||
|
|
||||||
def ovals(self, sink, source, width, height, rotation, segments, feedback):
|
def ovals(self, sink, source, width, height, rotation, segments, feedback):
|
||||||
features=source.getFeatures()
|
features = source.getFeatures()
|
||||||
ft=QgsFeature()
|
ft = QgsFeature()
|
||||||
|
|
||||||
total=100.0 / source.featureCount() if source.featureCount() else 0
|
total = 100.0 / source.featureCount() if source.featureCount() else 0
|
||||||
if rotation >= 0:
|
if rotation >= 0:
|
||||||
for current, feat in enumerate(features):
|
for current, feat in enumerate(features):
|
||||||
if feedback.isCanceled():
|
if feedback.isCanceled():
|
||||||
@ -274,26 +274,26 @@ class RectanglesOvalsDiamondsVariable(QgisAlgorithm):
|
|||||||
if not feat.hasGeometry():
|
if not feat.hasGeometry():
|
||||||
continue
|
continue
|
||||||
|
|
||||||
w=feat[width]
|
w = feat[width]
|
||||||
h=feat[height]
|
h = feat[height]
|
||||||
angle=feat[rotation]
|
angle = feat[rotation]
|
||||||
if not w or not h or not angle:
|
if not w or not h or not angle:
|
||||||
feedback.pushInfo(QCoreApplication.translate('RectanglesOvalsDiamondsVariable', 'Feature {} has empty '
|
feedback.pushInfo(QCoreApplication.translate('RectanglesOvalsDiamondsVariable', 'Feature {} has empty '
|
||||||
'width, height or angle. '
|
'width, height or angle. '
|
||||||
'Skipping…').format(feat.id()))
|
'Skipping…').format(feat.id()))
|
||||||
continue
|
continue
|
||||||
|
|
||||||
xOffset=w / 2.0
|
xOffset = w / 2.0
|
||||||
yOffset=h / 2.0
|
yOffset = h / 2.0
|
||||||
phi=angle * math.pi / 180
|
phi = angle * math.pi / 180
|
||||||
|
|
||||||
point=feat.geometry().asPoint()
|
point = feat.geometry().asPoint()
|
||||||
x=point.x()
|
x = point.x()
|
||||||
y=point.y()
|
y = point.y()
|
||||||
points=[]
|
points = []
|
||||||
for t in [(2 * math.pi) / segments * i for i in range(segments)]:
|
for t in [(2 * math.pi) / segments * i for i in range(segments)]:
|
||||||
points.append((xOffset * math.cos(t), yOffset * math.sin(t)))
|
points.append((xOffset * math.cos(t), yOffset * math.sin(t)))
|
||||||
polygon=[[QgsPointXY(i[0] * math.cos(phi) + i[1] * math.sin(phi) + x,
|
polygon = [[QgsPointXY(i[0] * math.cos(phi) + i[1] * math.sin(phi) + x,
|
||||||
-i[0] * math.sin(phi) + i[1] * math.cos(phi) + y) for i in points]]
|
-i[0] * math.sin(phi) + i[1] * math.cos(phi) + y) for i in points]]
|
||||||
|
|
||||||
ft.setGeometry(QgsGeometry.fromPolygonXY(polygon))
|
ft.setGeometry(QgsGeometry.fromPolygonXY(polygon))
|
||||||
@ -308,24 +308,24 @@ class RectanglesOvalsDiamondsVariable(QgisAlgorithm):
|
|||||||
if not feat.hasGeometry():
|
if not feat.hasGeometry():
|
||||||
continue
|
continue
|
||||||
|
|
||||||
w=feat[width]
|
w = feat[width]
|
||||||
h=feat[height]
|
h = feat[height]
|
||||||
if not w or not h:
|
if not w or not h:
|
||||||
feedback.pushInfo(QCoreApplication.translate('RectanglesOvalsDiamondsVariable', 'Feature {} has empty '
|
feedback.pushInfo(QCoreApplication.translate('RectanglesOvalsDiamondsVariable', 'Feature {} has empty '
|
||||||
'width or height. '
|
'width or height. '
|
||||||
'Skipping…').format(feat.id()))
|
'Skipping…').format(feat.id()))
|
||||||
continue
|
continue
|
||||||
|
|
||||||
xOffset=w / 2.0
|
xOffset = w / 2.0
|
||||||
yOffset=h / 2.0
|
yOffset = h / 2.0
|
||||||
|
|
||||||
point=feat.geometry().asPoint()
|
point = feat.geometry().asPoint()
|
||||||
x=point.x()
|
x = point.x()
|
||||||
y=point.y()
|
y = point.y()
|
||||||
points=[]
|
points = []
|
||||||
for t in [(2 * math.pi) / segments * i for i in range(segments)]:
|
for t in [(2 * math.pi) / segments * i for i in range(segments)]:
|
||||||
points.append((xOffset * math.cos(t), yOffset * math.sin(t)))
|
points.append((xOffset * math.cos(t), yOffset * math.sin(t)))
|
||||||
polygon=[[QgsPointXY(i[0] + x, i[1] + y) for i in points]]
|
polygon = [[QgsPointXY(i[0] + x, i[1] + y) for i in points]]
|
||||||
|
|
||||||
ft.setGeometry(QgsGeometry.fromPolygonXY(polygon))
|
ft.setGeometry(QgsGeometry.fromPolygonXY(polygon))
|
||||||
ft.setAttributes(feat.attributes())
|
ft.setAttributes(feat.attributes())
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user