[QGIS-Developer] pyqgis QgsGeometrySnapper does not snap to a source created inside a function
Gabriel De Luca
pablogabrieldeluca at gmail.com
Thu Oct 19 05:46:21 PDT 2023
Hello all,
I am working with the QgsGeometrySnapper pyqgis class, and have a problem
to snap to a reference layer which is created inside a function (and
returned by it).
The code shared at [1] prints:
result = <QgsGeometry: Polygon ((0.10000000000000001 -0.10000000000000001,
10.09999999999999964 0, 9.90000000000000036 10.09999999999999964, 0 10,
0.10000000000000001 -0.10000000000000001))>
Which means that the geomPolygon was not snapped to the reference layer.
But, if uncomment the line 41, which adds the reference layer to the
project, the code prints:
result = <QgsGeometry: Polygon ((0 0, 10 0, 10 10, 0 10, 0 0))>
So, for some reason, adding the reference layer to the project makes the
snapper to work.
I want to ask you if you know why is this happening. Maybe I need to add
something to make it work consistently.
Regards,
Gabriel
[1] https://pastebin.com/raw/Y9v51ZMq
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20231019/0690540a/attachment.htm>
More information about the QGIS-Developer
mailing list