[QGIS-Developer] Inconsistent results using length(), perimeter() and area() expression functions and Identify Features map tool

Nyall Dawson nyall.dawson at gmail.com
Sun Oct 17 15:57:59 PDT 2021


On Sun, 17 Oct 2021 at 08:27, Andrea Giudiceandrea
<andreaerdna at libero.it> wrote:
>
> Hi Devs,
> I noticed that the expression functions length(), perimeter() and area()
> use the QgsGeometry length() and area() functions to calculate the
> Cartesian length of lines and perimeter and area of polygons.
>
> The Identify Features map tool uses instead the QgsAbstractGeometry
> class length() and perimeter() functions for the Cartesian length of
> lines and the perimeter of polygons and the QgsGeometry area() function
> for the Cartesian area.
>
> This leads to inconsistent results when the geometries contain
> CircularStrings or CurvePolygons.
> In this case the QgsAbstractGeometry class functions are more accurate
> then the QgsGeometry ones.
>
> Is there any reason or contraindication why not to use the
> QgsAbstractGeometry class functions also for the expression functions
> length(), perimeter() and area() and for the Identify Features map tool
> measurement of polygons area?

It's really just a historical artefact, for outdated reasons. We
should definitely change the QgsGeometry methods to use the
QgsAbstractGeometry ones. Aside from the accuracy of curved vs
segmentized representations it's likely that the native calculations
will be much faster then the QGIS representation -> GEOS
representation -> GEOS calculation trip.

Nyall


>
> Best regards.
>
> Andrea Giudiceandrea
> _______________________________________________
> 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


More information about the QGIS-Developer mailing list