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

Andrea Giudiceandrea andreaerdna at libero.it
Thu Feb 11 11:13:03 PST 2021


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


More information about the QGIS-Developer mailing list