Bug report #10338

inverted polygon symbology wrongly handles overlapping polygons

Added by Mathieu Pellerin - nIRV over 7 years ago. Updated over 7 years ago.

Affected QGIS version:master Regression?:No
Operating System: Easy fix?:No
Pull Request or Patch supplied:Yes Resolution:
Crashes QGIS or corrupts data:No Copied to github as #:18759


Right now, the inverted polygon symbology appears to add polygons using a symmetrical difference method, resulting in a mishandling of overlapping polygons.

Basically right now when polygons overlap, the overlapping area is covered by symbology (i.e. considered as having no polygon underneath it). Overlapping polygons should result in merged area that isn't filled by the inverted polygon symbology.

See attached project, easier to understand through looking at it :)

Flagging this as blocker as IMO this needs fixing before releasing the feature to the public.

inverted_polygon.zip (6.57 KB) Mathieu Pellerin - nIRV, 2014-05-23 10:34 PM


#1 Updated by Hugo Mercier over 7 years ago

No particular spatial operations are done on the polygons. They are only surrounded by a big square polygon. The 'inversion' effect is done by the rendering pipeline, through QPainter operations. It is by default using the even-odd filling rule, which explains what you see.
The other rule (non-zero winding) could resolve the issue, but if and only if we send polygons to the QPainter pipeline with consistent orientations (exterior rings always in the same orientation - cw or ccw).
(see http://en.wikipedia.org/wiki/Nonzero-rule)
An alternative would be to add a spatial operation of merging, but from what I already tested, it was very slow and too strict (what to do when geometries are invalid ?) when using GEOS-based primitives.

#2 Updated by Mathieu Pellerin - nIRV over 7 years ago

Ok. I'm pretty clueless about the mechanics of it all, but the current behavior definitely needs fixing when it comes to this specific overlapping polygon scenario.

#3 Updated by Hugo Mercier over 7 years ago

Ok, after some experiments with QPainter, it appears the filling rules won't solve this problem easily.
So I think you would have to rely on some spatial preprocessing (union).
I would prefer to have this as an option, since it requires some computations and may return blank polygons when the union is not doable (when the input polygons are invalid are when the on-the-fly simplification gives invalid polygons).

#4 Updated by Hugo Mercier over 7 years ago

  • Pull Request or Patch supplied changed from No to Yes

Fix submitted

It adds an option for the use of a spatial union

#5 Updated by Martin Dobias over 7 years ago

  • Status changed from Open to Closed

Also available in: Atom PDF