The style is pretty weird, probably the first time I see one with raster
symbolizers and two colormaps
against the same source raster (seen multiple with rendering
transformations, but that's another story)

The same map could be obtained fusing them into a single raster symbolizer,
but it seems like you're trying to
separate them for legend generation purposes. As you noticed, it won't
work, the raster legend generation code
only supports one raster symbolizer:
https://github.com/geoserver/geoserver/blob/aa1e49d0023e60e529182a6e45a1f2119d67dd05/src/wms/src/main/java/org/geoserver/wms/legendgraphic/RasterLayerLegendHelper.java#L44

If it's something you actually need, I'd warmly suggest working on a PR to
change the legend generation code,
it's unlikely that someone else might sponsor such work. See:
https://github.com/geoserver/geoserver/blob/master/CONTRIBUTING.md

Best regards
Andrea

On Fri, Dec 11, 2020 at 12:37 PM Davide Battista <davide.batti...@gmail.com>
wrote:

> Dear All,
>
> I have a 2-Rule SLD file, to be applied to a raster (see below).
>
> The style is well applied in the GetMap request, but not in the
> GetLegendGraphic one.
>
> In fact, only the first rule is rendered, but not the second one.
>
> This is against what have been reported in the documentation:
>
> https://docs.geoserver.org/stable/en/user/services/wms/get_legend_graphic/index.html
>
> RULE - Optional - Rule of style to produce legend graphic for, if
> applicable.
>                   In the case that a style has multiple rules but no
> specific rule is selected,
>                   then the map server is obligated to produce a graphic
> that is representative
>                   of all of the rules of the style.
>
> If I request a GetLegendGraphic with:
>
>     ...&rule=Data (the first rule, it works)
>     ...&rule=Flags (the second rule, it works)
>
> but I'm not able to retrieve the legend formed by the full rules list.
>
> ---------------------------------------
>
> to workaround this issue I've tried to have 2 RasterSymbolizer in the same
> Rule.
>
> It fails, with the error message:
>
>     "Unable to create a legend for this style, we need exactly 1
> Symbolizer"
>
>
> while in the documentation is reported: (
> https://docs.geoserver.org/latest/en/user/styling/sld/reference/rules.html
> )
>
>     "A rule combines a filter with any number of symbolizers."
>
> and
>
>     "<RasterSymbolizer>    0..N    Specifies styling for raster data."
>
> ---------------------------------------
>
> Thanks in advance
>
>
> Davide Battista
>
> ---------------------------------------
>
> <?xml version="1.0" ?>
> <sld:StyledLayerDescriptor version="1.0.0" xmlns="
> http://www.opengis.net/sld"; xmlns:gml="http://www.opengis.net/gml";
> xmlns:ogc="http://www.opengis.net/ogc"; xmlns:sld="
> http://www.opengis.net/sld";>
>   <sld:UserLayer>
>     <sld:LayerFeatureConstraints>
>       <sld:FeatureTypeConstraint/>
>     </sld:LayerFeatureConstraints>
>     <sld:UserStyle>
>       <sld:Name>Drought Intensity (Annual) - Cropland</sld:Name>
>       <sld:Title/>
>       <sld:FeatureTypeStyle>
>         <sld:Name/>
>         <sld:Rule>
>           <sld:Name>Data</sld:Name>
>           <sld:RasterSymbolizer>
>             <sld:Geometry>
>               <ogc:PropertyName>grid</ogc:PropertyName>
>             </sld:Geometry>
>             <sld:Opacity>1</sld:Opacity>
>             <sld:ColorMap type="intervals">
>               <sld:ColorMapEntry color="#c00000" label=" &lt;25 (Extreme)"
> opacity="1.0" quantity="0.25"/>
>               <sld:ColorMapEntry color="#ca6664" label=" 25 - 35 (Severe)"
> opacity="1.0" quantity="0.35"/>
>               <sld:ColorMapEntry color="#ffff30" label=" 35 - 38
> (Moderate)" opacity="1.0" quantity="0.38"/>
>               <sld:ColorMapEntry color="#e2efda" label=" 38 - 42 (Mild)"
> opacity="1.0" quantity="0.42"/>
>               <sld:ColorMapEntry color="#aad08e" label=" &gt;=42 (None)"
> opacity="1.0" quantity="251"/>
>             </sld:ColorMap>
>           </sld:RasterSymbolizer>
>         </sld:Rule>
>         <sld:Rule>
>           <sld:Name>Flags</sld:Name>
>           <sld:RasterSymbolizer>
>             <sld:Geometry>
>               <ogc:PropertyName>grid</ogc:PropertyName>
>             </sld:Geometry>
>             <sld:Opacity>1</sld:Opacity>
>             <sld:ColorMap type="values">
>          <!-- <sld:ColorMapEntry color="#ffffff" label=" off season"
> opacity="1.0" quantity="251"/> -->
>               <sld:ColorMapEntry color="#000000" label=" insufficient
> data" opacity="1.0" quantity="252"/>
>               <sld:ColorMapEntry color="#666666" label=" no season"
> opacity="1.0" quantity="253"/>
>               <sld:ColorMapEntry color="#cccccc" label=" no cropland"
> opacity="1.0" quantity="254"/>
>          <!-- <sld:ColorMapEntry color="#ffffff" label=" water"
> opacity="0.0" quantity="255"/> -->
>             </sld:ColorMap>
>           </sld:RasterSymbolizer>
>         </sld:Rule>
>       </sld:FeatureTypeStyle>
>     </sld:UserStyle>
>   </sld:UserLayer>
> </sld:StyledLayerDescriptor>
>
> ---------------------------------------
> _______________________________________________
> Geoserver-users mailing list
>
> Please make sure you read the following two resources before posting to
> this list:
> - Earning your support instead of buying it, but Ian Turton:
> http://www.ianturton.com/talks/foss4g.html#/
> - The GeoServer user list posting guidelines:
> http://geoserver.org/comm/userlist-guidelines.html
>
> If you want to request a feature or an improvement, also see this:
> https://github.com/geoserver/geoserver/wiki/Successfully-requesting-and-integrating-new-features-and-improvements-in-GeoServer
>
>
> Geoserver-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/geoserver-users
>


-- 

Regards, Andrea Aime

== GeoServer Professional Services from the experts! Visit
http://goo.gl/it488V for more information. == Ing. Andrea Aime @geowolf
Technical Lead GeoSolutions S.A.S. Via di Montramito 3/A 55054 Massarosa
(LU) phone: +39 0584 962313 fax: +39 0584 1660272 mob: +39 339 8844549
http://www.geo-solutions.it http://twitter.com/geosolutions_it
------------------------------------------------------- *Con riferimento
alla normativa sul trattamento dei dati personali (Reg. UE 2016/679 -
Regolamento generale sulla protezione dei dati “GDPR”), si precisa che ogni
circostanza inerente alla presente email (il suo contenuto, gli eventuali
allegati, etc.) è un dato la cui conoscenza è riservata al/i solo/i
destinatario/i indicati dallo scrivente. Se il messaggio Le è giunto per
errore, è tenuta/o a cancellarlo, ogni altra operazione è illecita. Le
sarei comunque grato se potesse darmene notizia. This email is intended
only for the person or entity to which it is addressed and may contain
information that is privileged, confidential or otherwise protected from
disclosure. We remind that - as provided by European Regulation 2016/679
“GDPR” - copying, dissemination or use of this e-mail or the information
herein by anyone other than the intended recipient is prohibited. If you
have received this email by mistake, please notify us immediately by
telephone or e-mail.*
_______________________________________________
Geoserver-users mailing list

Please make sure you read the following two resources before posting to this 
list:
- Earning your support instead of buying it, but Ian Turton: 
http://www.ianturton.com/talks/foss4g.html#/
- The GeoServer user list posting guidelines: 
http://geoserver.org/comm/userlist-guidelines.html

If you want to request a feature or an improvement, also see this: 
https://github.com/geoserver/geoserver/wiki/Successfully-requesting-and-integrating-new-features-and-improvements-in-GeoServer


Geoserver-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-users

Reply via email to