[QGIS-Developer] Do QgsGeometry constGet() e constParts() return non-modifiable or modifiable reference in PyQGIS?

DelazJ delazj at gmail.com
Thu Feb 11 11:47:41 PST 2021


Hi Andrea,
Funny (?). I had the same request:
https://github.com/qgis/QGIS-Documentation/pull/6488

Regards,
Harrissou

Le jeu. 11 févr. 2021 à 20:13, Andrea Giudiceandrea <andreaerdna at libero.it>
a écrit :

> Hi all,
> is it expected that QgsGeometry constGet() and constParts() in PyQGIS
> return
> modifiable objects?
>
> In the Python Console:
>
> >>> geom=QgsGeometry.fromWkt( 'Point(16 41)' )
> >>> geom_const=geom.constGet()
> >>>
> geom_const.transform(QgsCoordinateTransform(QgsCoordinateReferenceSystem("EPSG:4326"),
> >>> QgsCoordinateReferenceSystem("EPSG:25833"), QgsProject.instance()))
>
> >>> geom_const
> <QgsPoint: Point (584102.13444570498540998 4539238.58925933390855789)>
> >>> geom
> <QgsGeometry: Point (584102.13444570498540998 4539238.58925933390855789)>
>
>
> >>> geom=QgsGeometry.fromWkt( 'MultiPoint((16 41))' )
> >>> for part in geom.constParts():
>
>
> part.transform(QgsCoordinateTransform(QgsCoordinateReferenceSystem("EPSG:4326"),
> QgsCoordinateReferenceSystem("EPSG:25833"), QgsProject.instance()))
>
> >>> geom
> <QgsGeometry: MultiPoint ((584102.13444570498540998
> 4539238.58925933390855789))>
>
>
> Regards.
>
> Andrea Giudiceandrea
>
>
>
> --
> Sent from:
> http://osgeo-org.1560.x6.nabble.com/QGIS-Developer-f4099106.html
> _______________________________________________
> QGIS-Developer mailing list
> QGIS-Developer at lists.osgeo.org
> List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20210211/305a7749/attachment.html>


More information about the QGIS-Developer mailing list