qgis / QGIS

QGIS is a free, open source, cross platform (lin/win/mac) geographical information system (GIS)
https://qgis.org
GNU General Public License v2.0
10.58k stars 3k forks source link

'Control feature rendering order' should have precedence over symbol levels #42428

Open JohnProv opened 3 years ago

JohnProv commented 3 years ago

Describe the bug 'Control feature rendering order' should have precedence over symbol levels. Now it isn't possible to create a map with for example correct road outlines and have roads in the correct order (bridge over road etc.). For a detailed description and examples, see: https://gis.stackexchange.com/questions/204034/can-i-change-the-precedence-when-combining-control-feature-rendering-order-wit

How to Reproduce

  1. Download OpenStreetMap sample data (for example shapefile from http://download.geofabrik.de/)
  2. Open road-layer (shapefile) or open line-layer (Postgis / Osm2pgsql)
  3. Add a rule-based style with an outline
  4. Set symbol levels (0 and 1)
  5. -> Now the map looks correctly (outlines are merged), except bridges over roads (the z-order isn't taken into account)
  6. Check 'Control feature rendering order' and order ascending by 'layer' or 'z_order'
  7. -> The map doesn't change
  8. Delete symbol levels (set all to 0)
  9. -> Map shows bridges correctly, but outlines are not merged at for example intersections.
QGIS and OS versions QGIS version 3.18.1-Zürich QGIS code branch Release 3.18
Compiled against Qt 5.15.2 Running against Qt 5.15.2
Compiled against GDAL/OGR 3.0.4 Running against GDAL/OGR 3.0.4
Compiled against GEOS 3.8.1-CAPI-1.13.3 Running against GEOS 3.8.1-CAPI-1.13.3
Compiled against SQLite 3.35.2 Running against SQLite 3.35.2
PostgreSQL Client Version 13.2 SpatiaLite Version 4.3.0a
QWT Version 6.1.6 QScintilla2 Version 2.12.1
Compiled against PROJ 6.3.2 Running against PROJ Rel. 6.3.2, May 1st, 2020
OS Version Arch Linux

Additional context Please let me know if there are other possibilities to achieve the desired effect that I don't know.

Pedro-Murteira commented 2 years ago

This is still valid on QGIS 3.22.3.

JohnProv commented 1 year ago

The problem described in this bug isn't fixed completely with #52096. For the categorized renderer it works well, but not for the rule-based renderer. Please fix that also. See https://github.com/qgis/QGIS/pull/52096#issuecomment-1623130269

JohnProv commented 1 year ago

See the differences between categorised rendering and rule rendering below.

Categorised rendering, this looks good: Screenshot_20230711_190714

Rule rendering, this doesn't look good: Screenshot_20230711_190504

(Example: knooppunt Deil, © map data: OpenStreetMap-contributors)

joto commented 1 year ago

I had a look at the code to see why this is not working in the rule rendering. The rule based renderer reports that it doesn't support the QgsFeatureRenderer::SymbolLevels capability which makes the rendering take a completely different code path. Obviously it does support symbol levels, but the different code path implements that in a different way. I don't know whether this is just historic and the code could be joined or if there is a reason for the different paths. I'd be happy to work on that some more, but just implementing this feature a second time in the other code paths seems not like a good idea to me.

Maybe somebody with more experience with this code has an idea why these two code paths are there and what to do about it? @m-kuhn