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
Also export rule based labelling in SLD. Follows up to ticket #8925 #5226
Conversation
That should have been fixed a couple of months back - can you point me to where the issue is? |
src/core/qgsrulebasedlabeling.cpp
Outdated
QgsRuleBasedLabeling::RuleList rules = mRootRule->children(); | ||
for ( RuleList::const_iterator it = rules.constBegin(); it != rules.constEnd(); ++it ) | ||
{ | ||
Rule *rule = *it; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generic input, this can be simplified to:
const QgsRuleBasedLabeling::RuleList rules = mRootRule->children();
for ( Rule *rule : rules )
{
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, fixing it
src/core/qgsvectorlayerlabeling.h
Outdated
* @param parent | ||
* @param settings | ||
* @param props | ||
*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you remove all those empty @param
and @brief
(and document the ones that are important for this implementation)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding doc for all of them
For @nyalldawson, here we go. See here for a comment talking about min scale denominator, but a variable called minScale: However in qgspallabeling there are similarly named variables with the opposite meaning, mimuminScale is the actual minimum scale (not denominator), but expressed as the denominator: |
@m-kuhn feedback applied :-) |
@m-kuhn @nyalldawson pull request updated, conflict removed, build is green. Anything else that needs to be done before merge? :-) |
@m-kuhn @nyalldawson is this ok for you? I was thinking: should/do we have some sld output tests? I only can think of some tests to have a set of qml files, load them as style and then save them as sld and check schema validity (I think that is most important). Do we already have a test which does some schema validity? If so I'm happy to try to add an output test ( if I find the docs/marks on how to do/run those :-) ) |
@rduivenvoorde I've prepared tests in python for every change made, they start with a qml and/or a in memory setup, generate SLD, and perform checks on the tags. However, they are not testing schema validity, and they will not be schema valid as the outputs use in some places "VendorOption" which is an element that GeoTools/GeoServer introduced many years ago, but it's not part of the standard. Generation of VendorOption was already in the code base before I started working on the fixes, but of course I added more along the way (especially in text symbolizer) to make sure the style is as close as possible when imported in software based on GeoTools. I guess that a strictly compliant SLD could be generated, add an option in the UI and pass it along as a hint in the SLD generation chain, of course that would significantly degrade what you can actually export (you'd lose most of the point symbols, parametric SVGs, good part of the text symbolizer, and a few other options along the way). |
Oh no, more conflicts to solve. If I take the time to solve them will someone merge it? :-) |
Sure, please go ahead. |
@aaime can you have a look at this please? And ping me, I'll promiss I'm make it merged then |
@rduivenvoorde @elpaso conflict fixed, all green :-) |
src/core/qgsrulebasedlabeling.cpp
Outdated
|
||
void QgsRuleBasedLabeling::toSld( QDomNode &parent, const QgsStringMap &props ) const | ||
{ | ||
if ( mRootRule == nullptr ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe just ( !mRootRule )
, nullptr
has the boolean value of false.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh ok, was not aware, fixed it.
Just one note, grepping the codebase seems that equality/inequality comparisons against nullptr
are rather common:
~/devel/qgis$ git grep -i "== nullptr" | wc -l
44
~/devel/qgis$ git grep -i "!= nullptr" | wc -l
89
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
well, not really:
ale@littlestar:~/dev/QGIS$ git grep -i "== nullptr" | grep -v astyle| wc -l
6
ale@littlestar:~/dev/QGIS$ git grep -i "!= nullptr" | grep -v astyle| wc -l
29
btw, there is not such a big difference, I just find it semantically clearer.
@aaime looks good to me, just a minor change request from my side. |
@elpaso nope, there is some docs already: it is just working better now... pull :-) |
note that this doc is rather about rule-based rendering and not labeling. Anyway, i'm not sure we need to go to these details in the docs (nice that all works now) but as a new feature it might be worth mentioning in the changelog, hence [feature] tag... |
@aaime thanks for your patience! |
Awesome, thanks for merging :) |
Description
This pull request adds export of SLD for rule based labels.
While I was at it, found an issue with min/max scale denominator exports. While in the QgsMapLayer mMinScale is a min scale denominator, in labelling the min scale is a minimum scale expressed as its denominator (but the meaning is the opposite, a small scale denominator makes for a large scale!), so I fixed the export of those in labelling as well.
Checklist
fixes #11111
in the commit message next to the description[FEATURE]
in the commit message[needs-docs]
in the commit message and containt sufficient information in the commit message to be documentedscripts/prepare-commit.sh
script before each commit