Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When using map_get() in expressions referencing multiple maps in print composer, map does not refresh automatically #27828

Open
qgib opened this issue Oct 3, 2018 · 1 comment
Labels
Bug Either a bug report, or a bug fix. Let's hope for the latter! Print Layouts Related to QGIS Print Layouts, Atlas or Reporting frameworks

Comments

@qgib
Copy link
Contributor

qgib commented Oct 3, 2018

Author Name: Robert Carey (Robert Carey)
Original Redmine Issue: 20006
Affected QGIS version: 3.2.3
Redmine category:map_composer/printing


When exporting from a Layout with inset maps, these is unexpected behaviour concerning the use of the map_get function. The expression functions correctly if the map is refreshed before being exported to PDF, but if exported before this point (such as when using an atlas or the QGIS API), the refresh does not occur. This can be demonstrated in the below scenario (my current issue).

I have a map consisting of a walking routes. A layout has been created with atlas enabled to create maps for each route. I have included an inset map which overlaps the main map area, but which moves to a different position around the map if the inset map intersects the geometry. I was able to do this using map_get location to calculate the map extent of the main map, and move the X and Y positions of the inset map if they overlapped.

A simple example would be as follows (changing the X position of the INSET map):

@case WHEN
--checks if the inset map intersect the walking route
intersects(
--geometry 1: creating a bounding box square from the bottom left corner to 40.5% of the maps width which represents the position of the inset map
bounds(make_line(
point_n( map_get( item_variables( 'FULLMAP' ), 'map_extent' ) ,1)
,make_point(X(point_n(map_get( item_variables( 'FULLMAP' ), 'map_extent' ) ,1))+(0.405map_get( item_variables( 'FULLMAP' ), 'map_extent_width' ))
,Y(point_n(map_get( item_variables( 'FULLMAP' ), 'map_extent' ) ,1))+ (0.405
map_get( item_variables( 'FULLMAP' ), 'map_extent_width' )))
))
--intersecting with map geometry which is the same between both maps, controlled by the atlas filter query
, @atlas_geometry ) = 0 --when the route does not intersect the inset map
THEN '100' --map is visible
ELSE '0' --map is not visible
END@

In the above example, viewing the atlas pages individually, I can see the inset map overlapping the geometry of the main map, which is unexpected. However, if I open the position expression for the inset map without changing it, the map refreshes and the map moves outside the map bounds as expected. Similarly, pressing F5 allows the position to change as expected.

My issue is that when exporting an atlas, or using the API to perform this function, there appears to be no way to force this refresh. I have included an example QGZ project and shapefile containing 5 routes. This is the x and y positions of the inset map are dictated by the extent and geometry of the full map. The map is also dynamically landscape/portrait. Preview the atlas and notice the inset map begins overlapping the feature. Refreshing the layout with F5 moves the inset map to its correct position.


@qgib qgib added Bug Either a bug report, or a bug fix. Let's hope for the latter! Print Layouts Related to QGIS Print Layouts, Atlas or Reporting frameworks labels May 25, 2019
@Pedro-Murteira
Copy link

Still valid on QGIS 3.22.3.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Either a bug report, or a bug fix. Let's hope for the latter! Print Layouts Related to QGIS Print Layouts, Atlas or Reporting frameworks
Projects
None yet
Development

No branches or pull requests

2 participants