Bug report #11954
Atlas doesn't consider map rotation when setting scale
|Affected QGIS version:||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 #:||20162|
Steps to reproduce:
1 - Create a dataset with a long vertical line and a long horizontal line.
2 - Create a composer map with Atlas enabled.
3 - Allow Atlas to set a margin around each feature.
4 - Define a data-driven map rotation such that the vertical line is rotated 90 degrees to use up the full width of the page.
5 - Output Atlas maps.
The output shows that the map is rotated as expected, but the scale set by Atlas appears to key off of the unrotated map, so the effective margin on the item is larger than it should be.
#2 Updated by Spencer Gardner over 5 years ago
Perhaps I'm not qualified to answer, since I'm not as familiar with the code. But here are my thoughts in any case:
It is likely that resolving #11912 would probably resolve my specific use case. Depending on how #11912 is implemented it seems possible that this could still be an issue even when #11912 is resolved. If a user has the option within Composer to either A) rotate the rendered map (current functionality) or B) rotate the map canvas (#11912) then this issue could still be present for users who opt for A.
In any case it seems like it would be a good idea for Atlas to check for margins after it knows the final dimensions of the map item in composer rather than beforehand, which appears to be the current process. I haven't tested this, but as an example I suspect there would also be margin problems if a user sets a data-defined override on the width or height of the map item.
I'll try to test this sometime soon, although I'm leaving on vacation and may not get to it for a while.
#4 Updated by Ilya Zverev over 3 years ago
Encountered this issue when creating my first atlas last week. Made a column for rotating shapes, so they fit best on a paper, and found out the scale does not change, regardless of rotation.
A quick glance at the source did not give a clear impression on fixing this. Possibly a rotation should be added somewhere here: https://github.com/qgis/QGIS/blob/master/src/core/composer/qgsatlascomposition.cpp#L441 . Like g = QgsGeometry(currectGeometry()); g.rotate(map->mapRotation(), g.centroid()).