-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Check if feature is rendered before displaying its map tips #38861
Conversation
renderer.reset( vlayer->renderer()->clone() ); | ||
renderer->startRender( renderCtx, vlayer->fields() ); | ||
} | ||
|
||
QgsFeatureIterator it = vlayer->getFeatures( request ); |
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.
It's possible to optimise this request based on the renderer's visible features -- if the layer has a renderer, you can use QgsFeatureRenderer::filter to set a filter expression on the request to avoid fetching and testing some invisible features, which should speed this functionality up
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.
Indeed! I take a look. Thanks for your input Nyall 👍.
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.
@nyalldawson I think I took into account your comment. Let me know if it's not what you had in mind.
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.
Actually we also need:
request.setFilterExpression( renderer->filter( vlayer->fields() ));
in order to delegate the filter to the provider
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.
Mmm... In my use case with a graduated renderer and a SHP, the renderer->filter( vlayer->fields() )
call returns an empty string so I get an "empty" iterator from vlayer->getFeatures( request )
. So map tips are never displayed.
I can write a unit test to highlight this behavior if you want?
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.
It's not implemented for the graduated renderer -- so if filter() returns an empty string, you don't set a filter expression on the iterator. It's implemented for categorized, rule based renderers only.
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.
OK good to know. The code is now updated.
aaa272f
to
e1f1708
Compare
I'll merge this PR in the coming days if I don't have more comments in the meantime. |
e1f1708
to
8c7af16
Compare
8c7af16
to
dd6b20e
Compare
Description
Fixes #37066