001: /* Copyright (c) 2001 - 2007 TOPP - www.openplans.org. All rights reserved.
002: * This code is licensed under the GPL 2.0 license, availible at the root
003: * application directory.
004: */
005: package org.vfny.geoserver.wms.requests;
006:
007: import java.util.Map;
008:
009: import org.geotools.feature.FeatureType;
010: import org.geotools.styling.Rule;
011: import org.geotools.styling.Style;
012: import org.vfny.geoserver.wms.servlets.WMService;
013:
014: /**
015: * Holds the parsed parameters for a GetLegendGraphic WMS request.
016: *
017: * <p>
018: * The GET parameters of the GetLegendGraphic operation are defined as follows
019: * (from SLD 1.0 spec, ch.12):<br>
020: * <pre>
021: * <table>
022: * <tr><td><b>Parameter</b></td><td><b>Required</b></td><td><b>Description</b></td></tr>
023: * <tr><td>VERSION </td><td>Required </td><td>Version as required by OGC interfaces.</td></tr>
024: * <tr><td>REQUEST </td><td>Required </td><td>Value must be GetLegendRequest . </td></tr>
025: * <tr><td>LAYER </td><td>Required </td><td>Layer for which to produce legend graphic. </td></tr>
026: * <tr><td>STYLE </td><td>Optional </td><td>Style of layer for which to produce legend graphic. If not present, the default style is selected. The style may be any valid style available for a layer, including non-SLD internally-defined styles.</td></tr>
027: * <tr><td>FEATURETYPE </td><td>Optional </td><td>Feature type for which to produce the legend graphic. This is not needed if the layer has only a single feature type. </td></tr>
028: * <tr><td>RULE </td><td>Optional </td><td>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.</td></tr>
029: * <tr><td>SCALE </td><td>Optional </td><td>In the case that a RULE is not specified for a style, this parameter may assist the server in selecting a more appropriate representative graphic by eliminating internal rules that are outof- scope. This value is a standardized scale denominator, defined in Section 10.2</td></tr>
030: * <tr><td>SLD </td><td>Optional </td><td>This parameter specifies a reference to an external SLD document. It works in the same way as the SLD= parameter of the WMS GetMap operation. </td></tr>
031: * <tr><td>SLD_BODY </td><td>Optional </td><td>This parameter allows an SLD document to be included directly in an HTTP-GET request. It works in the same way as the SLD_BODY= parameter of the WMS GetMap operation.</td></tr>
032: * <tr><td>FORMAT </td><td>Required </td><td>This gives the MIME type of the file format in which to return the legend graphic. Allowed values are the same as for the FORMAT= parameter of the WMS GetMap request. </td></tr>
033: * <tr><td>WIDTH </td><td>Optional </td><td>This gives a hint for the width of the returned graphic in pixels. Vector-graphics can use this value as a hint for the level of detail to include. </td></tr>
034: * <tr><td>HEIGHT </td><td>Optional </td><td>This gives a hint for the height of the returned graphic in pixels. </td></tr>
035: * <tr><td>EXCEPTIONS </td><td>Optional </td><td>This gives the MIME type of the format in which to return exceptions. Allowed values are the same as for the EXCEPTIONS= parameter of the WMS GetMap request.</td></tr>
036: * <tr><td>TRANSPARENT </td><td>Optional </td><td><code>true</code> if the legend image background should be transparent. Defaults to <code>false</code>.</td></tr>
037: * </table>
038: * </pre>
039: * </p>
040: *
041: * <p>
042: * The GetLegendGraphic operation itself is optional for an SLD-enabled WMS. It
043: * provides a general mechanism for acquiring legend symbols, beyond the
044: * LegendURL reference of WMS Capabilities. Servers supporting the
045: * GetLegendGraphic call might code LegendURL references as GetLegendGraphic
046: * for interface consistency. Vendorspecific parameters may be added to
047: * GetLegendGraphic requests and all of the usual OGC-interface options and
048: * rules apply. No XML-POST method for GetLegendGraphic is presently defined.
049: * </p>
050: *
051: * @author Gabriel Roldan, Axios Engineering
052: * @version $Id: GetLegendGraphicRequest.java 7728 2007-11-09 01:53:31Z groldan $
053: */
054: public class GetLegendGraphicRequest extends WMSRequest {
055: /** DOCUMENT ME! */
056: public static final String SLD_VERSION = "1.0.0";
057:
058: /**
059: * default legend graphic width, in pixels, to apply if no WIDTH parameter
060: * was passed
061: */
062: public static final int DEFAULT_WIDTH = 20;
063:
064: /**
065: * default legend graphic height, in pixels, to apply if no WIDTH parameter
066: * was passed
067: */
068: public static final int DEFAULT_HEIGHT = 20;
069:
070: /**
071: * The default image format in which to produce a legend graphic. Not
072: * really used when performing user requests, since FORMAT is a mandatory
073: * parameter, but by now serves as a default for expressing LegendURL
074: * layer attribute in GetCapabilities.
075: */
076: public static final String DEFAULT_FORMAT = "image/png";
077:
078: /** The featuretype of the requested LAYER */
079: private FeatureType layer;
080:
081: /**
082: * The Style object for styling the legend graphic, or layer's default if
083: * not provided. This style can be aquired by evaluating the STYLE
084: * parameter, which provides one of the layer's named styles, the SLD
085: * parameter, which provides a URL for an external SLD document, or the
086: * SLD_BODY parameter, which provides the SLD body in the request body.
087: */
088: private Style style;
089:
090: /**
091: * should hold FEATURETYPE parameter value, though not used by now, since
092: * GeoServer WMS still does not supports nested layers and layers has only
093: * a single feature type. This should change in the future.
094: */
095: private String featureType;
096:
097: /** holds RULE parameter value, or <code>null</code> if not provided */
098: private Rule rule;
099:
100: /**
101: * holds the standarized scale denominator passed as the SCALE parameter
102: * value, or <code>-1.0</code> if not provided
103: */
104: private double scale = -1d;
105:
106: /**
107: * the mime type of the file format in which to return the legend graphic,
108: * as requested by the FORMAT request parameter value.
109: */
110: private String format;
111:
112: /**
113: * the width in pixels of the returned graphic, or
114: * <code>DEFAULT_WIDTH</code> if not provided
115: */
116: private int width = DEFAULT_WIDTH;
117:
118: /**
119: * the height in pixels of the returned graphic, or
120: * <code>DEFAULT_HEIGHT</code> if not provided
121: */
122: private int height = DEFAULT_HEIGHT;
123:
124: /** mime type of the format in which to return exceptions information. */
125: private String exceptionsFormat = GetMapRequest.SE_XML;
126:
127: /** holds the geoserver-specific getLegendGraphic options for controlling
128: * things like the label font, label font style, label font antialiasing, etc.
129: */
130: private Map legendOptions;
131:
132: /**
133: * Whether the legend graphic background shall be transparent or not.
134: */
135: private boolean transparent;
136:
137: /**
138: * Creates a new GetLegendGraphicRequest object.
139: * @param service The service that will handle the request
140: */
141: public GetLegendGraphicRequest(WMService service) {
142: super ("GetLegendGraphic", service);
143: }
144:
145: /**
146: * DOCUMENT ME!
147: *
148: * @return DOCUMENT ME!
149: */
150: public String getExceptionsFormat() {
151: return exceptionsFormat;
152: }
153:
154: /**
155: * DOCUMENT ME!
156: *
157: * @param exceptionsFormat DOCUMENT ME!
158: */
159: public void setExceptionsFormat(String exceptionsFormat) {
160: this .exceptionsFormat = exceptionsFormat;
161: }
162:
163: /**
164: * DOCUMENT ME!
165: *
166: * @return DOCUMENT ME!
167: */
168: public String getFeatureType() {
169: return featureType;
170: }
171:
172: /**
173: * DOCUMENT ME!
174: *
175: * @param featureType DOCUMENT ME!
176: */
177: public void setFeatureType(String featureType) {
178: this .featureType = featureType;
179: }
180:
181: /**
182: * DOCUMENT ME!
183: *
184: * @return DOCUMENT ME!
185: */
186: public String getFormat() {
187: return format;
188: }
189:
190: /**
191: * DOCUMENT ME!
192: *
193: * @param format DOCUMENT ME!
194: */
195: public void setFormat(String format) {
196: this .format = format;
197: }
198:
199: /**
200: * DOCUMENT ME!
201: *
202: * @return DOCUMENT ME!
203: */
204: public int getHeight() {
205: return height;
206: }
207:
208: /**
209: * DOCUMENT ME!
210: *
211: * @param height DOCUMENT ME!
212: */
213: public void setHeight(int height) {
214: this .height = height;
215: }
216:
217: /**
218: * DOCUMENT ME!
219: *
220: * @return DOCUMENT ME!
221: */
222: public FeatureType getLayer() {
223: return layer;
224: }
225:
226: /**
227: * DOCUMENT ME!
228: *
229: * @param layer DOCUMENT ME!
230: */
231: public void setLayer(FeatureType layer) {
232: this .layer = layer;
233: }
234:
235: /**
236: * DOCUMENT ME!
237: *
238: * @return DOCUMENT ME!
239: */
240: public Rule getRule() {
241: return rule;
242: }
243:
244: /**
245: * DOCUMENT ME!
246: *
247: * @param rule DOCUMENT ME!
248: */
249: public void setRule(Rule rule) {
250: this .rule = rule;
251: }
252:
253: /**
254: * DOCUMENT ME!
255: *
256: * @return DOCUMENT ME!
257: */
258: public double getScale() {
259: return scale;
260: }
261:
262: /**
263: * DOCUMENT ME!
264: *
265: * @param scale DOCUMENT ME!
266: */
267: public void setScale(double scale) {
268: this .scale = scale;
269: }
270:
271: /**
272: * DOCUMENT ME!
273: *
274: * @return DOCUMENT ME!
275: */
276: public Style getStyle() {
277: return style;
278: }
279:
280: /**
281: * DOCUMENT ME!
282: *
283: * @param style DOCUMENT ME!
284: */
285: public void setStyle(Style style) {
286: this .style = style;
287: }
288:
289: /**
290: * DOCUMENT ME!
291: *
292: * @return DOCUMENT ME!
293: */
294: public int getWidth() {
295: return width;
296: }
297:
298: /**
299: * DOCUMENT ME!
300: *
301: * @param width DOCUMENT ME!
302: */
303: public void setWidth(int width) {
304: this .width = width;
305: }
306:
307: public Map getLegendOptions() {
308: return legendOptions;
309: }
310:
311: public void setLegendOptions(Map legendOptions) {
312: this .legendOptions = legendOptions;
313: }
314:
315: /**
316: * Sets the value of the background transparency flag depending on the value
317: * of the <code>TRANSPARENT</code> request parameter.
318: *
319: * @param transparentBackground
320: * whether the legend graphic background shall be transparent or
321: * not
322: */
323: public void setTransparent(boolean transparentBackground) {
324: this .transparent = transparentBackground;
325: }
326:
327: /**
328: * Returns the value of the optional request parameter
329: * <code>TRANSPARENT</code>, which might be either the literal
330: * <code>true</code> or <code>false</code> and specifies if the
331: * background of the legend graphic to return shall be transparent or not.
332: * <p>
333: * If the <code>TRANSPARENT</code> parameter is not specified, this
334: * property defaults to <code>false</code>.
335: * </p>
336: *
337: * @return whether the legend graphic background shall be transparent or not
338: */
339: public boolean isTransparent() {
340: return transparent;
341: }
342: }
|