[Geoserver-devel] Adding layergroups support to WMS GetLegendGraphic

Hello to everybody,

I have prepared a little patch to the GeoServer WMS GetLegendGraphic service to add layergroups support.

LayerGroups are supported in the following manner:

  • just use a layergroup name, instead of a layer name, in the LAYER parameter to get a legend for the group
  • if STYLE is not specified, the default style is used for all the layers of the group
  • if STYLE is specified it could be:
  • a single value, used for all the group layers
  • a comma separated list to specify styles for any single layer of the group (if less styles than layers are specified the last style will be used for the remaining layers)
  • a comma separated list with empty values to use specific styles for some layers and default for the ones left empty (for example you can specify style1,style3 to use the default style for the second layer)
  • the RULE parameter is used similarly to STYLE to specify rules for some or all the styles

If you think it would be good to include this feature in GeoServer and someone has the time to review the patch, it can be found here:

https://github.com/mbarto/geoserver/commit/1152196c232046711627a7d30fb0034e577ca02e

Some thoughts on how this patch could be furtherly improved:

  • with the patch applied it would be trivial to add support for multiple layers (also if they are not part of a layergroup); would it be useful to anyone?
  • maybe for layergroups a layername label could be added alongside the icon to distinguish each single layer (similarly to what is done with rules)

Any suggestion is welcome.

Thanks for the attention,
Mauro Bartolomeoli

I have prepared a little patch to the GeoServer WMS GetLegendGraphic
service to add layergroups support.

LayerGroups are supported in the following manner:
- just use a layergroup name, instead of a layer name, in the LAYER
parameter to get a legend for the group
- if STYLE is not specified, the default style is used for all the
layers of the group
- if STYLE is specified it could be:
   * a single value, used for all the group layers
   * a comma separated list to specify styles for any single layer of
the group (if less styles than layers are specified the last style
will be used for the remaining layers)
   * a comma separated list with empty values to use specific styles
for some layers and default for the ones left empty (for example you
can specify style1,style3 to use the default style for the second layer)
  - the RULE parameter is used similarly to STYLE to specify rules for
some or all the styles

Interesting. Can I assume that is to make it possible to create
multi-tieds legends for layer groups? Got an example image?

Notice: This email and any attachments are confidential. If received in error please destroy and immediately notify us. Do not copy or disclose the contents.

What do you mean with multi-tied legend? My purpose was to have a flexible schema, where you can use a layer group with its default style, but also to choose styles for every single layer. Is this what you were talking about, or something different?

Thanks,
Mauro

Il giorno 25/nov/2012 22:40, “Phil Scadden” <p.scadden@anonymised.com> ha scritto:

I have prepared a little patch to the GeoServer WMS GetLegendGraphic
service to add layergroups support.

LayerGroups are supported in the following manner:

  • just use a layergroup name, instead of a layer name, in the LAYER
    parameter to get a legend for the group
  • if STYLE is not specified, the default style is used for all the
    layers of the group
  • if STYLE is specified it could be:
  • a single value, used for all the group layers
  • a comma separated list to specify styles for any single layer of
    the group (if less styles than layers are specified the last style
    will be used for the remaining layers)
  • a comma separated list with empty values to use specific styles
    for some layers and default for the ones left empty (for example you
    can specify style1,style3 to use the default style for the second layer)
  • the RULE parameter is used similarly to STYLE to specify rules for
    some or all the styles

Interesting. Can I assume that is to make it possible to create
multi-tieds legends for layer groups? Got an example image?

Notice: This email and any attachments are confidential. If received in error please destroy and immediately notify us. Do not copy or disclose the contents.


Monitor your physical, virtual and cloud infrastructure from a single
web console. Get in-depth insight into apps, servers, databases, vmware,
SAP, cloud infrastructure, etc. Download 30-day Free Trial.
Pricing starts from $795 for 25 servers or applications!
http://p.sf.net/sfu/zoho_dev2dev_nov


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

Some examples of usages, with related output:

Default styles:
http://localhost:8080/geoserver/wms?REQUEST=GetLegendGraphic&VERSION=1.0.0&FORMAT=image/png&WIDTH=20&HEIGHT=20&LAYER=tasmania

Immagine in linea 1

Custom style for all layers:
http://localhost:8080/geoserver/wms?REQUEST=GetLegendGraphic&VERSION=1.0.0&FORMAT=image/png&WIDTH=20&HEIGHT=20&LAYER=tasmania&STYLE=grass,polygon,line,burg

Immagine in linea 2

Custom style for some layers only:

http://localhost:8080/geoserver/wms?REQUEST=GetLegendGraphic&VERSION=1.0.0&FORMAT=image/png&WIDTH=20&HEIGHT=20&LAYER=tasmania&STYLE=grass,burg

Immagine in linea 3

Thanks,
Mauro Bartolomeoli

···

2012/11/25 Phil Scadden <p.scadden@anonymised.com>

I have prepared a little patch to the GeoServer WMS GetLegendGraphic
service to add layergroups support.

LayerGroups are supported in the following manner:

  • just use a layergroup name, instead of a layer name, in the LAYER
    parameter to get a legend for the group
  • if STYLE is not specified, the default style is used for all the
    layers of the group
  • if STYLE is specified it could be:
  • a single value, used for all the group layers
  • a comma separated list to specify styles for any single layer of
    the group (if less styles than layers are specified the last style
    will be used for the remaining layers)
  • a comma separated list with empty values to use specific styles
    for some layers and default for the ones left empty (for example you
    can specify style1,style3 to use the default style for the second layer)
  • the RULE parameter is used similarly to STYLE to specify rules for
    some or all the styles

Interesting. Can I assume that is to make it possible to create
multi-tieds legends for layer groups? Got an example image?

Notice: This email and any attachments are confidential. If received in error please destroy and immediately notify us. Do not copy or disclose the contents.


Monitor your physical, virtual and cloud infrastructure from a single
web console. Get in-depth insight into apps, servers, databases, vmware,
SAP, cloud infrastructure, etc. Download 30-day Free Trial.
Pricing starts from $795 for 25 servers or applications!
http://p.sf.net/sfu/zoho_dev2dev_nov


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

On Mon, Nov 26, 2012 at 7:48 AM, Mauro Bartolomeoli <maurobartolomeoli@anonymised.com> wrote:

Some examples of usages, with related output:

Default styles:
http://localhost:8080/geoserver/wms?REQUEST=GetLegendGraphic&VERSION=1.0.0&FORMAT=image/png&WIDTH=20&HEIGHT=20&LAYER=tasmania

Immagine in linea 1

Ah, as far as I remember the code also prints the rule titles when there is more than one rule involved,
and in this case I was kind of expecting to see the layer name on top of symbol too (and the rule name on the
right)

Cheers
Andrea

==
Our support, Your Success! Visit http://opensdi.geo-solutions.it 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


Sure. It was in my final thoughts as a possible improvement, but I am not sure on what to print exactly on top of each layer, some Name or Title taken from the style? The layer name in Geoserver? What do you think is better?

Mauro Bartolomeoli

(attachments)

tasmania1.png

···

2012/11/26 Andrea Aime <andrea.aime@anonymised.com…>

On Mon, Nov 26, 2012 at 7:48 AM, Mauro Bartolomeoli <maurobartolomeoli@anonymised.com> wrote:

Some examples of usages, with related output:

Default styles:
http://localhost:8080/geoserver/wms?REQUEST=GetLegendGraphic&VERSION=1.0.0&FORMAT=image/png&WIDTH=20&HEIGHT=20&LAYER=tasmania

Immagine in linea 1

Ah, as far as I remember the code also prints the rule titles when there is more than one rule involved,
and in this case I was kind of expecting to see the layer name on top of symbol too (and the rule name on the
right)

Cheers
Andrea

==
Our support, Your Success! Visit http://opensdi.geo-solutions.it 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


On 26/11/2012 7:30 p.m., Mauro Bartolomeoli wrote:

What do you mean with multi-tied legend? My purpose was to have a
flexible schema, where you can use a layer group with its d

Yes. I have example of group with lithology, faults, outcrop. Very
complex legend which would be nice to extract in bit and put into a js
tree structure on the client. This looks to enable such a thing with a
layer group.

Notice: This email and any attachments are confidential. If received in error please destroy and immediately notify us. Do not copy or disclose the contents.

Ok. I think it could be used to enable that.

Mauro Bartolomeoli

Il giorno 27/nov/2012 04:53, “Phil Scadden” <p.scadden@anonymised.com> ha scritto:

On 26/11/2012 7:30 p.m., Mauro Bartolomeoli wrote:

What do you mean with multi-tied legend? My purpose was to have a
flexible schema, where you can use a layer group with its d

Yes. I have example of group with lithology, faults, outcrop. Very
complex legend which would be nice to extract in bit and put into a js
tree structure on the client. This looks to enable such a thing with a
layer group.

Notice: This email and any attachments are confidential. If received in error please destroy and immediately notify us. Do not copy or disclose the contents.


Monitor your physical, virtual and cloud infrastructure from a single
web console. Get in-depth insight into apps, servers, databases, vmware,
SAP, cloud infrastructure, etc. Download 30-day Free Trial.
Pricing starts from $795 for 25 servers or applications!
http://p.sf.net/sfu/zoho_dev2dev_nov


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

Hi again everybody ,
I’m going to complete my patch to support WMS GetLegendGraphics on layer groups, adding a label on top of each layer of the group with the name of the layer.

Here an example of output (for the tasmania layergroup with default style):

(attachments)

tasmania.png

···

Immagine in linea 1

Currently I’m choosing using this criteria to choose the label:

  • the Layer Title (if defined)

  • the Layer Name otherwise

Does it seem a good choice?

I would like to submit the patch for the community to review as soon as it is ready, so what’s my best option: to open a JIRA issue with the patch attached, to submit a pull request (maybe this could be done AFTER the review?) or to post a link to the commits on my fork of GeoServer?

Thanks in advance,
Mauro Bartolomeoli

Ciao Mauro,
I would go for JIRA + Pull request.

Regards,
Simone Giannecchini

(attachments)

tasmania.png

···

Immagine in linea 1

Currently I’m choosing using this criteria to choose the label:

  • the Layer Title (if defined)

  • the Layer Name otherwise

Does it seem a good choice?

I would like to submit the patch for the community to review as soon as it is ready, so what’s my best option: to open a JIRA issue with the patch attached, to submit a pull request (maybe this could be done AFTER the review?) or to post a link to the commits on my fork of GeoServer?

Thanks in advance,
Mauro Bartolomeoli

Just done: http://jira.codehaus.org/browse/GEOS-5524

Thank you,
Mauro Bartolomeoli

(attachments)

tasmania.png

···

2013/1/2 Simone Giannecchini <simone.giannecchini@anonymised.com>

Ciao Mauro,
I would go for JIRA + Pull request.

Regards,
Simone Giannecchini

==
Our support, Your Success! Visit http://opensdi.geo-solutions.it for more information.

Ing. Simone Giannecchini
@simogeo
Founder/Director

GeoSolutions S.A.S.
Via Poggio alle Viti 1187
55054 Massarosa (LU)
Italy
phone: +39 0584 962313
fax: +39 0584 1660272

mob: +39 333 8128928

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


On Wed, Jan 2, 2013 at 3:26 PM, Mauro Bartolomeoli <maurobartolomeoli@anonymised.com> wrote:

Hi again everybody ,
I’m going to complete my patch to support WMS GetLegendGraphics on layer groups, adding a label on top of each layer of the group with the name of the layer.

Here an example of output (for the tasmania layergroup with default style):


Master Java SE, Java EE, Eclipse, Spring, Hibernate, JavaScript, jQuery
and much more. Keep your Java skills current with LearnJavaNow -
200+ hours of step-by-step video tutorials by Java experts.
SALE $49.99 this month only – learn more at:
http://p.sf.net/sfu/learnmore_122612


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

Immagine in linea 1

Currently I’m choosing using this criteria to choose the label:

  • the Layer Title (if defined)

  • the Layer Name otherwise

Does it seem a good choice?

I would like to submit the patch for the community to review as soon as it is ready, so what’s my best option: to open a JIRA issue with the patch attached, to submit a pull request (maybe this could be done AFTER the review?) or to post a link to the commits on my fork of GeoServer?

Thanks in advance,
Mauro Bartolomeoli