-
-
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
[Improvement] Use BoundingBoxes in labeling #2852
Conversation
eb730be
to
d1cc22e
Compare
I moved the topology validation to last item to verify because "isGeosValid" is a costly method |
@@ -3944,7 +3944,7 @@ QgsGeometry* QgsPalLabeling::prepareGeometry( const QgsGeometry* geometry, QgsRe | |||
clonedGeometry.reset( geom ); | |||
} | |||
|
|||
if ( clipGeometry && !clipGeometry->contains( geom ) ) | |||
if ( clipGeometry && !clipGeometry->boundingBox().contains( geom->boundingBox() ) ) |
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.
I think this line should be left untouched. If a map is rotated then the extent geometry will be a rotated rectangle, so taking its bounding box will result in a larger extent then is actually visible. In this case we'd still need to clip. The geometryRequiresPreparation change is safe since it's already returned true if the map is rotated, but I think this second check should be left at the original version. What do you think?
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.
But this previous line covers it? no?
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.
@ahuarte47 Sorry, I don't quite understand. The changes to geometryRequiresPreparation are fine, no issue there. But we need to make sure the test before doing the actual clipping is still applied using the geometries themselves when rotation is applied. Maybe a better replacement for line 3947 would be:
if ( clipGeometry &&
( ( qgsDoubleNear( m2p.mapRotation(), 0 ) && !clipGeometry->boundingBox().contains( geom->boundingBox() ) )
|| ( !qgsDoubleNear( m2p.mapRotation(), 0 ) && !clipGeometry->contains( geom ) ) ) )
Ie if no rotation, do the optimised bounding box check, but if rotation then do the full expensive check?
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 sorry, I mixed the code in my mind, my apologies, you are right!
Thanks for your pacience :-)
1b56f2b
to
8bdb9e4
Compare
@ahuarte47 no need to apologise - I'm just happy someone is looking to speed this stuff up! |
:-) thanks to you for your work. I am working in this work. I hope in right way. |
ac91d8e
to
2809b82
Compare
Use BoundingBoxes to check faster if clipping is necessary
2809b82
to
b07bbd0
Compare
@ahuarte47 I noticed you're having issues with the indentation test - here's some tips getting this to pass: Tips to prevent and resolve:
|
Thanks @nyalldawson |
[Improvement] Use BoundingBoxes in labeling
Use BoundingBoxes to check faster if clipping is necessary.
Now it uses directly the geometries to check if clipping is necessary. There is a performance bottleneck with this.