Bug report #15672

@map_extent_width and @map_extent_height seem buggy

Added by Johannes Kroeger about 4 years ago. Updated about 3 years ago.

Status:Closed
Priority:Normal
Assignee:Nyall Dawson
Category:Unknown
Affected QGIS version:2.16.3 Regression?:No
Operating System: Easy fix?:No
Pull Request or Patch supplied:No Resolution:
Crashes QGIS or corrupts data:No Copied to github as #:23595

Description

Trying some silly things I found "Geometry generator" of feature styling to create wrong geometries when I used @map_extent_width and @map_extent_height in it.

I ended up with the following test case.

Use this is label for some feature to see the values live updated:

'Center: ' || x( @map_extent_center ) || ' ' || y( @map_extent_center ) || '\
' ||
'Width: ' || @map_extent_width || '\
' ||
'Height: ' || @map_extent_height

If you resize the map, the Width and Height values never update while the Center works as intended.

Open the Python console and use this to manually request the map's width and height:

"Width: {} Height: {}".format(iface.mapCanvas().extent().width(),iface.mapCanvas().extent().height())

To my understand these should show the same values for the width and height.

When I move the map and print with Python again, I see the new values. The @map_extent_width and @map_extent_height in the label are not updated though.

Associated revisions

Revision c1cf896c
Added by Nyall Dawson about 4 years ago

Fix invalid values for @map_extent_width/height (fix #15672)

Revision 28fc834d
Added by Nyall Dawson about 4 years ago

Fix invalid values for @map_extent_width/height (fix #15672)

(cherry-picked from c1cf896c1a76fdac16b3e800b7e1f106f983e299)

Revision 3c43bb5e
Added by Nyall Dawson about 4 years ago

Fix invalid values for @map_extent_width/height (fix #15672)

(cherry-picked from c1cf896c1a76fdac16b3e800b7e1f106f983e299)

Revision bd5f9792
Added by Nyall Dawson about 4 years ago

Fix invalid values for @map_extent_width/height (fix #15672)

(cherry-picked from c1cf896c1a76fdac16b3e800b7e1f106f983e299)

History

#1 Updated by Johannes Kroeger about 4 years ago

When I move the map and print with Python again, I see the new values. The @map_extent_width and @map_extent_height in the label are not updated though.

Should have been

When I resize the map and print with Python again, I see the new values. The @map_extent_width and @map_extent_height in the label are not updated though.

#2 Updated by Nyall Dawson about 4 years ago

  • Status changed from Open to Feedback

Can you check iface.mapCanvas().mapSettings().extent().width() and see if the value matches?

#3 Updated by Nyall Dawson about 4 years ago

  • Assignee set to Nyall Dawson
  • Status changed from Feedback to Open

Actually I can reproduce - fix incoming

#4 Updated by Nyall Dawson about 4 years ago

  • Status changed from Open to Closed

#5 Updated by Jürgen Fischer about 3 years ago

  • Category set to Unknown

Also available in: Atom PDF