This page last changed on Apr 09, 2014 by jive.


Replace HashMaps in GetLegendGraphicsRequest with a data structure

Proposed By

Jody Garnett

Assigned to Release

The release that this proposal will be implemented for 2.6.


Choose one of: Under Discussion, In Progress, Completed, Rejected, Deferred


In looking at pull request 400 (adding external graphics to GetCapabilities and GetLegendGraphics) i.e. became obvious that more state needed to be passed from the GetLegendGraphicKvpReader to BufferedImageLegendGraphicBuilder.

Rather than add additional HashMaps I have collected what was already there and cleaned it up. This results in an API change so a proposal is required.


API Change

Prior to this proposal GetLegendGraphicRequest data structure looks like this:

class GetLegendGraphicsRequest {
  List<FeatureType> layers;
  List<Style> styles;
  List<String> rules;
  Map<Name,String> titles;
  Map<Name,String> legends; // pending
  // accessors
  List<FeatureType> getLayers();
  void setLayers( List<FeatureType> layers );
  List<Style> getStyles();
  void setStyles(List<Style> styles);
  void setStyle( Style style);

After this proposal:

class GetLegendGraphicsRequest {
  public class LegendRequest {
    Name layerName;        
    FeatureType featureType;
    String styleName;
    String title;
    String rule;
    Style style;
    LegendInfo legendInfo;
    LayerInfo layerInfo;
    LayerGroupInfo layerGroupInfo;

    LegendRequest(); // placeholder used for style
    LegendRequest(Featuretype featureType );
    // accessors

  List<LegendRequest> layers;

  // accessors
  List<LegendRequest> getLegends();
  void setStyle( Style style);

  // deprecated accessors
  List<FeatureType> getLayers();
  void setLayers( List<FeatureType> layers );
  List<Style> getStyles();
  void setStyles(List<Style> styles);


Introduction of this data structure results in both GetLegendGraphicKvpReader and BufferedImageLegendGraphicBuilder being easier to follow and document.

This is just an initial cleanup, there are opportunities for further simplification not covered by this proposal.


  • Use of a placeholder LegendRequest provided to allow for GetLegendGraphics code to preview Style
  • Single "layer" methods, such as setStyle above, were marked as unnecessary in the code. I am maintaining them as they are used in test cases.
  • The order in which GetLegendGraphicsRequest is filled in is significant (layers must be created before styles and titles are set). This is now made clear in javadocs.
  • Experimented with using a LinkedHashMap<Name,LegendRequest> but code inspection showed that this information was always accessed in order.


This section should contain feedback provided by PSC members who may have a problem with the proposal.

Backwards Compatibility

Several accessors (for style, title and similar) are no longer used and have been deprecated. Compatibility was maintained (now implemented in terms of List<LegendRequest>).


Alessio Fabiani:
Andrea Aime:
Ben Caradoc-Davies: +1
Christian Mueller:
Gabriel Roldán: +1
Jody Garnett: +1
Jukka Rahkonen:
Justin Deoliveira:
Phil Scadden:
Simone Giannecchini: +0



Document generated by Confluence on May 14, 2014 23:00