Bug report #9791

Wrong area in composer with enabled OTF

Added by Alexander Bruy over 10 years ago. Updated about 10 years ago.

Status:Closed
Priority:High
Assignee:-
Category:Expressions
Affected QGIS version:2.2.0 Regression?:No
Operating System:all Easy fix?:No
Pull Request or Patch supplied:No Resolution:
Crashes QGIS or corrupts data:No Copied to github as #:18332

Description

Geometry functions "$area", "$perimeter" and probably others always return values in layer map units even if OTF is enabled and project units are different. In same time this functions in Field calculator returns correct result using units of the destination CRS.

To reproduce:
  1. load attached project (layer used EPSG:4326, OTF to EPSG:3857 enabled)
  2. enable editing and calculate features area using Field calculator
  3. now open composer "Test_area"
  4. enable atlas preview and navigate on features
  5. areas are in degrees instead of meters

Tested on master and 2.2.0

Associated revisions

Revision 0cb98546
Added by Nyall Dawson about 10 years ago

[composer] Fix area calculation in expressions with OTF (fix #9791)

Adds an argument to QgsExpression::replaceExpressionText to allow
passing an optional QgsDistanceArea to use during calculations.
Ensure that html and label composer items correctly specify this
argument.

History

#1 Updated by Nyall Dawson about 10 years ago

  • Status changed from Open to Closed

Also available in: Atom PDF