Following the submission of the last part of our 2019 grant
work, here's a report detailing what was undertaken and
achieved thanks to these two funding grants:
Profile and optimise the QGIS vector rendering code
One of the most critical and important functions in the
QGIS application is rendering of vector map layers. QGIS has
an extremely powerful and flexible vector symbology engine,
capable of some mind blowing cartography and visual effects.
For efficient use on both the desktop and server, users
require that QGIS rendering is as fast as it possibly can
be!
During this grant project, we conducted in-depth research
into code "hot spots" and inefficiencies in the QGIS
rendering code using a number of code profiling tools. This
work resulted in many optimisations, including:
While the focus of this work was on the vector
rendering code, some of the optimisations implemented have
resulted in dramatic improvements across other parts of
QGIS also (such as certain Processing algorithms).
These optimisations were made available in the QGIS
3.10.0 release, with selected low-risk optimisations also
being backported to the QGIS 3.4 LTR series.
"Rebalance" the labeling engine and fix poor automatic
label placement choices
While QGIS has a powerful engine sitting behind its
automatic label placement, the labeling results generated by
this engine were often unpredictable and frustrating for
users. Labels were frequently positioned over other
features, and regardless of how heavily users tweaked the
various label settings it could be impossible to avoid these
unwanted labels. Furthermore, the settings for controlling
individual layer label and feature obstacle priorities
generally had no discernible effect on the actual placement
of labels on the map.
During this work project we commenced by safe guarding
the existing label placement logic with a series of new
carefully designed unit tests covering a range of different
label placement situations. We then used these reference
tests as a guide and re-worked the label placement engine
logic. Now, labels will never be placed over features from a
layer with a a higher obstacle weight when compared to the
label's priority.
This logic dramatically simplifies the effect of labeling
settings for users, avoiding the complexities and bugs which
were present in the older approach.
In order to avoid disrupting existing projects, the new
labeling logic is only used for newly created projects in
QGIS 3.12 and later. We added a mechanism to allow users to
manually upgrade existing projects to the newer logic, via
the project's label settings dialog.
Lastly, we used this opportunity to invest some
much-needed time in modernising and cleaning up the labeling
engine code, to help make it easier to understand and
maintain in future.
Nyall