-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
PAL line label placement does not consider map rotation #20037
Comments
Author Name: Sandro Santilli (@strk)
|
Author Name: Sandro Santilli (@strk) Am I reading the code correctly that the PAL library does all its work in geographical units rather than device units ? |
Author Name: Sandro Santilli (@strk) Debugging prints confirm, pal::LabelPosition getX(), getY(), getWidth() and getHeight() all return map (geographical) units, not device (pixels). |
Author Name: Sandro Santilli (@strk) And, when rotation is active, the height and the width are wrong. |
Author Name: Sandro Santilli (@strk) QgsPalLayerSettings::calculateLabelSize is the earlier point of failure I've found for today. Maybe we could add another function to QgsMapToPixel to transform sizes... (rotation would not affect them, nor translation but only scale, isn't that correct?) |
Author Name: Sandro Santilli (@strk) @dakarto: am I right that candidate label boxes are NOT stored as rotated, when being parallel to lines ? // save the rect in src/core/qgspallabeling.cpp, where label alpha (angle) is not taken in consideration |
Author Name: Sandro Santilli (@strk) Some support for map rotation in labels rendering is been pushed here: Larry your review is welcome. I had the impression a refactoring of the labeling system would be useful (like to work in pixel space rather than in geographical units space, for the sake of collision prevention, and to pass the whole map QTransform to correctly convert from one space to the other) -- the commits in the PR do not attempt to do any refactoring. |
Author Name: Larry Shaffer (Larry Shaffer) Hi Sandro, Correct me if I am wrong (have not had time to review your map rotation committed changes), but unless the features are pre-rotated and (optionally) clipped prior to going into the labeling engine (right before PAL registration), it will be a major refactoring to support map rotation. Are the features not being pre-rotated? Note: the engine works with temporary duplicates of the geometries. I think refactoring the engine output (and calculations) to be relative to pixel space might not gain anything here, plus PAL library works with map units, and the map scale is passed in. So, it would also require a refactoring of the PAL library as well. I think working only in map units is the correct approach to the labeling engine, then convert to output device units/resolution during output rendering. However, I have not before considered doing everything at output resolution pixel dimensions as a means of simplifying the engine. You may want to ask Martin Dobias what he thinks about such an approach. |
Author Name: Sandro Santilli (@strk) The vectors are not pre-rotated by the provider, but the MapSetting's matrix (QgsMapToPixel) would be able to both rotate and scale to the output coordinate space. Why do you think working in map units is the correct approach to the labeling engine ? After all labels are configured in output device terms (size, collision). Where should I look at to pre-rotate them for the PAL registration ? |
Author Name: Sandro Santilli (@strk) Label placement (for horizontal and parallel) is supported as of commit 917cee0
|
Author Name: Sandro Santilli (@strk) Reopening to try the pre-rotation approach.
|
Author Name: Sandro Santilli (@strk) It looks like there's no function to rotate a QgsGeometry right now, so this won't be as simple as I was hoping for. |
Author Name: Sandro Santilli (@strk) GEOS does not have a rotation method either. The enhancement was requested over 10 months ago: |
Author Name: Sandro Santilli (@strk) Another problem with the pre-rotation approach is that the current PAL code is full of places where the current QgsMapToPixel is used to transform map points to device points (for label placement). All such pieces of code would need to use a modified QgsMapToPixel so that the rotation portion of it is removed. To make things worst some code snippets use the QgsMapToPixel registered in the QgsMapSettings (mMapSettings) and others in the QgsRenderingContext (context). I'm not sure anymore if pre-rotating is any better than building on the path already taking of further considering the rotation component of the already-used QgsMapToPixel... One contribution in that direction arrived recently: #1750 |
Author Name: Sandro Santilli (@strk)
Original Redmine Issue: 11814
Affected QGIS version: master
Redmine category:labelling
Assignee: Sandro Santilli
Labels placement for lines does not properly consider map rotation.
With "horizontal" placement all labels are horizontal, which is nice, but placement is somewhat offsetted from the expected one.
With "parallel" placement the labels are parallel to the pre-rotated lines, so stop being parallel once lines are rotated.
I'm happy to look at it but would need help by Larry
The text was updated successfully, but these errors were encountered: