Bug report #19355

$length incorrect in expressions

Added by Gavin Fleming over 6 years ago. Updated almost 6 years ago.

Status:Closed
Priority:High
Assignee:Hugo Mercier
Category:Expressions
Affected QGIS version:3.5(master) Regression?:No
Operating System: Easy fix?:No
Pull Request or Patch supplied:No Resolution:
Crashes QGIS or corrupts data:No Copied to github as #:27183

Description

$length correctly calculates ellipsoidal length in a field calculator update, but shows planimetric length in the expression dialog and if used in expressions elsewhere, such as in labels.

test_length.gpkg - Test GPKG (96 KB) Hugo Mercier, 2019-01-30 04:04 PM

test_length.qgz (5.15 KB) Hugo Mercier, 2019-01-30 04:05 PM

qgis_length_bug.png (15.9 KB) Hugo Mercier, 2019-01-30 04:06 PM

Associated revisions

Revision 80919669
Added by Hugo Mercier almost 6 years ago

Fix $length in labels (fixes #19355)

Use the project expression scope to access project
parameters (ellipsoid and distance/area units)

Revision aaed9ffa
Added by Hugo Mercier almost 6 years ago

Fix $length in labels (fixes #19355)

Use the project expression scope to access project
parameters (ellipsoid and distance/area units)

History

#1 Updated by Borys Jurgiel almost 6 years ago

  • Operating System deleted (MacOS)
  • Priority changed from Normal to High

This bug is definitely high priority, and misleading labels can be even considered as indirect data corruption.
On every training I teach users how to deal with this long standing issue, what becomes a bit embarrassing... :)

#2 Updated by Hugo Mercier almost 6 years ago

Attached a sample project to reproduce, with one virtual field "length" with expression "$length" and labels using "$length || ' - ' || length"

#3 Updated by Hugo Mercier almost 6 years ago

  • Assignee set to Hugo Mercier

#4 Updated by Hugo Mercier almost 6 years ago

  • Status changed from Open to Closed
  • % Done changed from 0 to 100

Also available in: Atom PDF