On the road to improve QGIS SLD export
today we would like to introduce some recent work we have done in QGIS to improve SLD export. Our GeoServer Technical Lead Andrea Aime, has been working along with others at the FOSS4G 2016 code sprint to fix some of the SLD 1.1 export issues, improving the compatibility of GeoServer to reproduce the style in the process.
The first fix regarded rotations, gaps and alpha values, which used to be expressed using a <ogc:Filter> instead of a normal OGC “expression”, or plain value. This broke standard compatibility and made GeoServer unable to interpret the corresponding values, for reference, here is a before/after comparison
The second issue fixed was about units of measures. QGIS allows to use different units of measure for the various sizes/widths/height values, however, the default one is “on screen mm”, and was exporting the values un-modified, with a non standard attribute at the very top reporting the unit being in millimiters. The SE specification on the other hand only supports “on screen pixel”, “on ground meter”, “on ground feet”. The change here was to remove the extraneous attribute, and rescale all values to from on screen mm to on screen pixels, e.g., a value of “10” mm would translate to 36 pixels and results in visual size preservation in SLD based tools.
One subsequent fix modified the SLD export to account for scale base visibility not only in rule based symbols, but in all common types. After all, nobody wants the server to display millions of points or roads at very small scales.
Subsequently, we noticed that GeoTools/GeoServer could not handle the way font based symbols were exported by QGIS, and this time, since QGIS export was indeed valid, we implemented support for the index based mark syntax in GeoServer.
<se:OnlineResource xlink:type="simple" xlink:href="ttf://Webdings"/>
Map in GeoServer
Moreover, we noticed that QGIS exports a number of “well known” marks that are not actually well known. In the interest of maximizing the ability to see symbol on the other side, Jonathan Moules implemented several of the missing symbols on the GeoServer end:
Map In GeoServer
Currently still in progress we have parametric SVG support, that allows QGIS to change some aspects of a SVG file on the fly (fill, stroke, stroke widths and opacity levels) as well as a minimal implementation of text symbolizer export (currently completely missing). Here is a show comparing plain and parametric SVG display based on the same QGIS :
In terms of availability for you to try out:
- Most of the QGIS changes are already available on the 2.16.3 release
- The parametric SVG export one is still in the work, as well as the basic text symbolizer one
- The external mark fixes will be available in GeoServer 2.9.2 (to be released)
- The extra marks support will likely land in time for GeoServer 2.9.3 and GeoServer 2.10 RC1
We would like to thank the entire team involved in the changes:
- Andrea Aime, for the QGIS SLD export changes as well as some of the GeoTools/GeoServer
- Alessandro Pasotti and Matthias Kuhn for reviewing and merging the pull requests against QGIS
- Richard Duivenvoorde for the networking and support (as well as Jody Garnett for some personal introductions)
- Jonathan Moules for adding support for several QGIS extra symbols into GeoTools
- Last but not least, to René-Luc D’Hont for backporting the QGIS changes onto the 2.16.x series (available in 2.16.3) and 2.14.x series too (available in 2.14.7)
It is eventually worth to point out that more work will be needed to fully support the seamless integration between GeoServer and QGIS. We are going to invest on this ourselves but if you are interested in funding this effort, stay tuned since we will launch some sort or crowdfunding initiative to support this effort.