0

I am trying to create an SLD style that will allow polygons (in the same <FeatureTypeStyle>, but as separate or the same Symbolizers) to 'patch' compose themselves, which is to say, when one polygon with say 0.5 opacity is placed over another polygon (again, in the same FeatureTypeStyle) with 0.5 opacity, it will 'replace' the part of the 'destination' polygon (the polygon that was drawn first) with the 'source' polygon (the polygon that was drawn second), maintaining the same 0.5 opacity.

There are some vendor options for composition modes here, as well as a way to specify a new 'composite-base', i.e. 'destination', here, but you can only specify a new 'composite-base' on a FeatureTypeStyle level, not on a Symbolizer based level (which may be necessary for goal (2) below). Does anyone know how to do this or if it is possible on a Rule based level, or any possible workarounds (ideally, that are entirely SLD based, even if using GeoServer extensions or vendor options)?

To further clarify, there are two goals I am trying to accomplish:

  1. A way to composite Symbolizers, so that both the color and opacity of the 'source' overwrite the color and opacity of the 'destination'. i.e. (The dark orange shape is a separate FeatureTypeStyle/style/layer, the yellow, green, purple, and light red shapes are all seperate Symbolizers within the same FeatureTypeStyle/style/layer)

Correct example (note how the yellow and pink shapes replace the green and purple shapes without increasing the opacity of the layer, but when they overlap the dark orange shape, the opacity increases):

Correct example

Incorrect example (current behavior):

Incorrect example

  1. If necessary, way to composite a Symbolizer with itself, so that if two features within the same layer/symbolizer overlap, they behave as in (1), with the subsequent feature overwriting both the color and opacity of the previous feature. (Both yellow shapes are two features in the same layer and FeatureTypeStyle Symbolizer.)

Correct example:

Correct example

Incorrect example (Opacity of the overlapping features increases. This is wrong):

Incorrect example

1 Answer 1

0

I've never actually tried this but the manual says (my emphasis):

Both compositing and blending can be specified in SLD by adding the following VendorOption to either the end of a Symbolizer or FeatureTypeStyle:

So it should be possible to handle per rule composition by adding the vendor option to the Symbolizer rather than the FeatureTypeStyle.

1
  • I've edited the question to make things a bit clearer, and add some examples. For example (2) (which depends on example (1) working), I thought I would need to be able to add the "composite-base" vendor option to Symbolizers, but the the manual says "For FeatureTypeStyles an additional vendor option can be added to control compositing groups: <VendorOption name="composite-base">true</VendorOption> This will tell the rendering engine to use that FeatureTypeStyle as the destination, and will compose all subsequent FeatureTypeStyle/Layers on top of it, until another base is found. "
    – John
    Sep 6, 2022 at 21:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.