Bug report #13695

Extents (Print Composer): Data defined override not working

Added by Paul Kanelli almost 5 years ago. Updated almost 5 years ago.

Status:Closed
Priority:High
Assignee:-
Category:Map Composer/Printing
Affected QGIS version:master Regression?:No
Operating System:Windows 7 Easy fix?:No
Pull Request or Patch supplied:No Resolution:
Crashes QGIS or corrupts data:No Copied to github as #:21725

Description

In the print composer (QGIS 2.12) the data defined override for 'Extents' is ignored.

@
X min:
xmin(geometry(getFeature('layer', 'gid', 1)))

Y min:
ymin(geometry(getFeature('layer', 'gid', 1)))

X max:
xmax(geometry(getFeature('layer', 'gid', 1)))

Y max
ymax(geometry(getFeature('layer', 'gid', 1)))@

There is also no 'Output preview' in the 'Expression string builder'. Everything works fine in QGIS 2.10

map_canvas.jpg (138 KB) Paul Kanelli, 2015-10-29 07:46 AM

composer_1_A0_Portrait.jpg (196 KB) Paul Kanelli, 2015-10-29 07:46 AM

composer_2_A1_Landscape.jpg (215 KB) Paul Kanelli, 2015-10-29 07:46 AM

Associated revisions

Revision dddd0434
Added by Nyall Dawson almost 5 years ago

Fix FilterExpression feature requests will ignore expression if
using virtual fields or other complex filters

refs #13695

Revision c445ac1e
Added by Nyall Dawson almost 5 years ago

Fix expression get_feature function was not fetching feature's
geometry

Fix #13695

Revision 3c11a5d7
Added by Nyall Dawson almost 5 years ago

Fix FilterExpression feature requests will ignore expression if
using virtual fields or other complex filters

refs #13695

(cherry-picked from dddd043491deefe1e4c9606a87a771d22736ff05)

Revision 15f59aed
Added by Nyall Dawson almost 5 years ago

Fix expression get_feature function was not fetching feature's
geometry

Fix #13695

(cherry-picked from c445ac1eef0a2f94d1e334b1439d593e706f1395)

History

#1 Updated by Nyall Dawson almost 5 years ago

That expression looks very odd. What are you trying to do?

#3 Updated by Nyall Dawson almost 5 years ago

So you have a single feature in the 'layer' table which dictates the extent for all your atlas pages?

#4 Updated by Paul Kanelli almost 5 years ago

It's just an example. The name of my layer is "sheet_lines". Every feature (rectangles in portrait and/or landscape format) represents a composer page.

#5 Updated by Nyall Dawson almost 5 years ago

I'm still confused as to why you aren't just directly setting "controlled by atlas" on your map and letting it automatically set the map extent.

This expression:

xmin(geometry(getFeature('layer', 'gid', 1)))

Will always return the same number. It will just get the first feature from 'layer' with a 'gid' of 1 and return the min x coordinate of it.

Any chance you could share a project/sample data which demonstrates this issue?

#6 Updated by Paul Kanelli almost 5 years ago

I haven't testet if "controlled by atlas" can handle different paper formats and orientations (see attachment). However QGIS 2.12 fails data defined override for 'Extents'. It's working in QGIS 2.10.

#7 Updated by Harrissou Santanna almost 5 years ago

Maybe, you are looking for something like this?

Indeed, there's an issue. But I wonder if it isn't with get_feature function in 2.12. using a formule in the "data defined override" for extent, without get_feature, works :
Case WHEN @layout_pageheight>@layout_pagewidth then 437000 else 437500 end changes the X min value according to the orientation of the composition page.

To test the issue with get_feature, on the same data, I use the "Select by expression tool" with:
- attribute(getFeature('commune','insee','49080'),'gid') > "gid" in 2.8.3 : retrieves 77 features, what is expected
- attribute(get_feature('commune','insee','49080'),'gid') > "gid" in 2.12 and master : retrieves ALL the features in the table

#8 Updated by Nyall Dawson almost 5 years ago

  • Status changed from Open to Closed

Also available in: Atom PDF