-
Notifications
You must be signed in to change notification settings - Fork 4
GSIP 111 GetLegendGraphicsRequest Cleanup
Replace HashMaps in GetLegendGraphicsRequest with a data structure
Jody Garnett
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.
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.
Notes:
- 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.
Several accessors (for style, title and similar) are no longer used and have been deprecated. Compatibility was maintained (now implemented in terms of List).
Alessio Fabiani: Andrea Aime: Ben Caradoc Davies: +1 Christian Mueller: Gabriel Roldan: +1 Jody Garnett: +1 Jukka Rahkonen: +0 Justin Deoliveira: Phil Scadden: Simone Giannecchini: +0
- [https://github.com/geoserver/geoserver/pull/551] Revised GetCapabilities/GetLegendGraphics Pull Request
- Email Discussion GSIP 111 email discussion
- [http://jira.codehaus.org/browse/GEOS-6425] Allow ExternalGraphics reference in WMS GetCapabilities
Previous:
- [http://jira.codehaus.org/browse/GEOS-6245] Not reporting correct style width/height in GetCaps
- [https://github.com/geoserver/geoserver/pull/349] Initial GetCapabilities/ExternalGraphics Pull Request
- [https://github.com/geoserver/geoserver/pull/400] Revised GetCapabilities/ExternalGraphics Pull Request
- Email Discussion style with pre-rendered legend discussion