[Geoserver-users] Multiple Layers in GetLegendGraphic?

It looks like GetLegendGraphic only supports requesting a legend for a single layer. Could this be generalized to allow multiple layers being requested?

The use case is that in some simple clients it’s difficult to display an arbitrary-length list of images (e.g. Jasper Reports).

Hey Martin:

I am sure we could do that, we already have a bunch of options to try and pass in current scale/dpi to try and get a visual that matches what is on the screen.

The code is here:

https://github.com/geoserver/geoserver/blob/master/src/wms/src/main/java/org/geoserver/wms/GetLegendGraphicRequest.java

The important part is:

  • LAYER Required Layer for which to produce legend graphic. A layergroup can be specified, too. In this case, STYLE and RULE parameters can have multiple values (separated by commas), one for each of the group layers.

So if style and rule are already setup it should be fairly easy to allow layer to have multiple values separated by commas.

Indeed internally the code already has:

/** The featuretype(s) of the requested LAYER(s) */
private List layers=new ArrayList();

So no change to the data structure and logic should be required, just parser and test case.

  • |

Aside: As long as we are dreaming here I would love to have one that operates like GetFeatureInfo - and includes a reference GetMap complete with BBox (and thus could only show the layers / rules that end up having something on the screen.

···

On 25 September 2015 at 09:48, Martin Davis <mtnclimb@anonymised.com> wrote:

It looks like GetLegendGraphic only supports requesting a legend for a single layer. Could this be generalized to allow multiple layers being requested?

The use case is that in some simple clients it’s difficult to display an arbitrary-length list of images (e.g. Jasper Reports).



Geoserver-users mailing list
Geoserver-users@anonymised.comsts.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-users


Jody Garnett

Thanks, Jody. Good to know that it’s a relatively simple extension. Not sure if/when we’ll have time to do development on this thiough.

And the idea of a map/scale-aware GetLegendGraphic is a good one. Legends for our maps can get very long, so any way of cutting them down to size is useful.

···

On Sun, Sep 27, 2015 at 2:17 PM, Jody Garnett <jody.garnett@anonymised.com…> wrote:

Hey Martin:

I am sure we could do that, we already have a bunch of options to try and pass in current scale/dpi to try and get a visual that matches what is on the screen.

The code is here:

https://github.com/geoserver/geoserver/blob/master/src/wms/src/main/java/org/geoserver/wms/GetLegendGraphicRequest.java

The important part is:

  • LAYER Required Layer for which to produce legend graphic. A layergroup can be specified, too. In this case, STYLE and RULE parameters can have multiple values (separated by commas), one for each of the group layers.

So if style and rule are already setup it should be fairly easy to allow layer to have multiple values separated by commas.

Indeed internally the code already has:

/** The featuretype(s) of the requested LAYER(s) */
private List layers=new ArrayList();

So no change to the data structure and logic should be required, just parser and test case.

Aside: As long as we are dreaming here I would love to have one that operates like GetFeatureInfo - and includes a reference GetMap complete with BBox (and thus could only show the layers / rules that end up having something on the screen.


Jody Garnett

On 25 September 2015 at 09:48, Martin Davis <mtnclimb@anonymised.com> wrote:

It looks like GetLegendGraphic only supports requesting a legend for a single layer. Could this be generalized to allow multiple layers being requested?

The use case is that in some simple clients it’s difficult to display an arbitrary-length list of images (e.g. Jasper Reports).



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

On Fri, Sep 25, 2015 at 6:48 PM, Martin Davis <mtnclimb@anonymised.com> wrote:

It looks like GetLegendGraphic only supports requesting a legend for a
single layer. Could this be generalized to allow multiple layers being
requested?

Hi Martin,
sorry for chiming in late. The GetLegendGraphic internal code already
supports a list of layers, this feature has been added by Mauro
almost two years ago when adding supporting layer groups in
GetLegendGraphic (which is, as usual, exploded in its internal list
of layers at parsing time).

What is missing, as far as I can see, is just the code that would parse a
comma separate list of layers/styles in the request, as far as I know

Cheers
Andrea

--

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 Poggio alle Viti 1187
55054 Massarosa (LU)
Italy
phone: +39 0584 962313
fax: +39 0584 1660272
mob: +39 339 8844549

http://www.geo-solutions.it
http://twitter.com/geosolutions_it

*AVVERTENZE AI SENSI DEL D.Lgs. 196/2003*

Le informazioni contenute in questo messaggio di posta elettronica e/o
nel/i file/s allegato/i sono da considerarsi strettamente riservate. Il
loro utilizzo è consentito esclusivamente al destinatario del messaggio,
per le finalità indicate nel messaggio stesso. Qualora riceviate questo
messaggio senza esserne il destinatario, Vi preghiamo cortesemente di
darcene notizia via e-mail e di procedere alla distruzione del messaggio
stesso, cancellandolo dal Vostro sistema. Conservare il messaggio stesso,
divulgarlo anche in parte, distribuirlo ad altri soggetti, copiarlo, od
utilizzarlo per finalità diverse, costituisce comportamento contrario ai
principi dettati dal D.Lgs. 196/2003.

The information in this message and/or attachments, is intended solely for
the attention and use of the named addressee(s) and may be confidential or
proprietary in nature or covered by the provisions of privacy act
(Legislative Decree June, 30 2003, no.196 - Italy's New Data Protection
Code).Any use not in accord with its purpose, any disclosure, reproduction,
copying, distribution, or either dissemination, either whole or partial, is
strictly forbidden except previous formal approval of the named
addressee(s). If you are not the intended recipient, please contact
immediately the sender by telephone, fax or e-mail and delete the
information in this message that has been received in error. The sender
does not give any warranty or accept liability as the content, accuracy or
completeness of sent messages and accepts no responsibility for changes
made after they were sent or for other risks which arise as a result of
e-mail transmission, viruses, etc.

-------------------------------------------------------