Hello,

I need to scale a polygon from python code.

An extract of source code is the following :

           for feat in iter:
              geom = feat.geometry()
              rect = geom.boundingBox()

              x1 = rect.xMinimum()
              y1 = rect.yMinimum()

              x2 = rect.xMaximum()
              y2 = rect.yMinimum()

              xc = (x2 + x1) / 2.0
              yc = (y2 + y1) / 2.0

                elem = geom.asPolygon()

                fat = float(scale) / 100.

                for i in range(geom.exportToWkt().count(',')):

                            vertex = geom.vertexAt(i)

                            x,y = vertex.x(),
vertex.y()

                            xR, yR = x-xc , y-yc
                            xS, yS = xR*fat, yR*fat

                             xT, yT = xS + xc, yS + yc

                             geom.moveVertex(xT, yT, i)


Because the polygon do not change, sure I miss something, to save the
modified element, also if the layer is in editing.

Someone could help me to understand what I wrong ?


Thank you

Roberto
_______________________________________________
Qgis-developer mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/qgis-developer

Reply via email to