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.global;
006:
007: import org.geoserver.wfs.WFS;
008: import org.vfny.geoserver.global.dto.ServiceDTO;
009: import org.vfny.geoserver.global.dto.WMSDTO;
010:
011: import java.util.Collections;
012: import java.util.Map;
013:
014: /**
015: * WMS
016: *
017: * <p>
018: * Represents the GeoServer information required to configure an instance of
019: * the WMS Server. This class holds the currently used configuration and is
020: * instantiated initially by the GeoServerPlugIn at start-up, but may be
021: * modified by the Configuration Interface during runtime. Such modifications
022: * come from the GeoServer Object in the SessionContext.
023: * </p>
024: *
025: * <p>
026: * WMS wms = new WMS(dto); System.out.println(wms.getName() + wms.WMS_VERSION);
027: * System.out.println(wms.getAbstract());
028: * </p>
029: *
030: * @author Gabriel Rold???n
031: * @version $Id: WMS.java 7731 2007-11-10 02:52:30Z groldan $
032: */
033: public class WMS extends Service {
034: /** WMS version spec implemented */
035: private static final String WMS_VERSION = "1.1.1";
036:
037: /** WMS spec specifies this fixed service name */
038: private static final String FIXED_SERVICE_NAME = "OGC:WMS";
039:
040: /** list of WMS Exception Formats */
041: private static final String[] EXCEPTION_FORMATS = { "application/vnd.ogc.se_xml", //DJB: these arent actually supported!!
042: //"application/vnd.ogc.se_inimage",
043: // "application/vnd.ogc.se_blank"
044: };
045: public static final String WEB_CONTAINER_KEY = "WMS";
046:
047: /** svg Renderer to use **/
048: private String svgRenderer;
049:
050: /** svg anitalias or not **/
051: private boolean svgAntiAlias;
052:
053: /** rendering interpolation or not **/
054: private Map baseMapLayers;
055: private Map baseMapStyles;
056: private Map baseMapEnvelopes;
057: private String allowInterpolation;
058: private WFS wfs;
059:
060: /**
061: * WMS constructor.
062: *
063: * <p>
064: * Stores the data specified in the WMSDTO object in this WMS Object for
065: * GeoServer to use.
066: * </p>
067: *
068: * @param config The data intended for GeoServer to use.
069: */
070: public WMS(WMSDTO config) {
071: super (config.getService());
072: setId("wms");
073: svgRenderer = config.getSvgRenderer();
074: svgAntiAlias = config.getSvgAntiAlias();
075: allowInterpolation = config.getAllowInterpolation();
076: baseMapLayers = config.getBaseMapLayers();
077: baseMapStyles = config.getBaseMapStyles();
078: baseMapEnvelopes = config.getBaseMapEnvelopes();
079: }
080:
081: /**
082: * Creates the WMS service by getting the WMSDTO object from the
083: * config and calling {@link #WMS(WMSDTO)}.
084: *
085: * @param config
086: * @param data
087: * @param geoServer
088: * @throws ConfigurationException
089: */
090: public WMS(Config config, Data data, GeoServer geoServer, WFS wfs)
091: throws ConfigurationException {
092: this (config.getWms());
093: setData(data);
094: setGeoServer(geoServer);
095: this .wfs = wfs;
096: }
097:
098: /**
099: * Quick hack to fix geot-770, need a full class rewrite otherwise and
100: * we are too near release to do that
101: * @return
102: */
103: public WFS getWFS() {
104: return wfs;
105: }
106:
107: /**
108: * load purpose.
109: * <p>
110: * loads a new instance of data into this object.
111: * </p>
112: * @param config
113: */
114: public void load(WMSDTO config) {
115: super .load(config.getService());
116: svgRenderer = config.getSvgRenderer();
117: svgAntiAlias = config.getSvgAntiAlias();
118: allowInterpolation = config.getAllowInterpolation();
119: baseMapLayers = config.getBaseMapLayers();
120: baseMapStyles = config.getBaseMapStyles();
121: baseMapEnvelopes = config.getBaseMapEnvelopes();
122: }
123:
124: /**
125: * WMS constructor.
126: *
127: * <p>
128: * Package constructor intended for default use by GeoServer
129: * </p>
130: *
131: * @see GeoServer#GeoServer()
132: */
133: WMS() {
134: super (new ServiceDTO());
135: setId("wms");
136: }
137:
138: /**
139: * Implement toDTO.
140: *
141: * <p>
142: * Package method used by GeoServer. This method may return references, and
143: * does not clone, so extreme caution sould be used when traversing the
144: * results.
145: * </p>
146: *
147: * @return WMSDTO An instance of the data this class represents. Please see
148: * Caution Above.
149: *
150: * @see org.vfny.geoserver.global.GlobalLayerSupertype#toDTO()
151: * @see WMSDTO
152: */
153: public Object toDTO() {
154: WMSDTO w = new WMSDTO();
155: w.setService((ServiceDTO) super .toDTO());
156: w.setSvgRenderer(svgRenderer);
157: w.setSvgAntiAlias(svgAntiAlias);
158: w.setAllowInterpolation(allowInterpolation);
159: w.setBaseMapLayers(baseMapLayers);
160: w.setBaseMapStyles(baseMapStyles);
161: w.setBaseMapEnvelopes(baseMapEnvelopes);
162:
163: return w;
164: }
165:
166: /**
167: * getExceptionFormats purpose.
168: *
169: * <p>
170: * Returns a static list of Exception Formats in as Strings
171: * </p>
172: *
173: * @return String[] a static list of Exception Formats
174: */
175: public String[] getExceptionFormats() {
176: return EXCEPTION_FORMATS;
177: }
178:
179: /**
180: * overrides getName() to return the fixed service name as specified by OGC
181: * WMS 1.1 spec
182: *
183: * @return static service name.
184: */
185: public String getName() {
186: return FIXED_SERVICE_NAME;
187: }
188:
189: /**
190: * Returns the version of this WMS Instance.
191: *
192: * @return static version name
193: */
194: public static String getVersion() {
195: return WMS_VERSION;
196: }
197:
198: /**
199: * Informs the user that this WMS supports SLD. We don't currently
200: * handle sld, still needs to be rolled in from geotools, so this now
201: * must be false.
202: *
203: * //djb: we support it now
204: *
205: * @return false
206: */
207: public boolean supportsSLD() {
208: return true; //djb: we support it now
209: }
210:
211: /**
212: * Informs the user that this WMS supports User Layers
213: *
214: * @return false
215: */
216: public boolean supportsUserLayer() {
217: return true; //djb we support this partially - we support inlinefeatures. Soon we'll support remote wfs
218: }
219:
220: /**
221: * Informs the user that this WMS supports User Styles
222: *
223: * @return false
224: */
225: public boolean supportsUserStyle() {
226: return true; //djb: we support this now!
227: }
228:
229: /**
230: * Informs the user that this WMS supports Remote WFS.
231: *
232: * @return false
233: */
234: public boolean supportsRemoteWFS() {
235: return false; //djb: hopefully this will change soon.
236: }
237:
238: /**
239: * @return the id of the SVG renderer being used by the wms.
240: */
241: public String getSvgRenderer() {
242: return svgRenderer;
243: }
244:
245: /**
246: * Sets the id of the SVG renderer being used by the wms.
247: */
248: public void setSvgRenderer(String svgRenderer) {
249: this .svgRenderer = svgRenderer;
250: }
251:
252: /**
253: * @return Flag indicating wether the svg renderer should anti-alias or not.
254: */
255: public boolean isSvgAntiAlias() {
256: return svgAntiAlias;
257: }
258:
259: /**
260: * Sets the Flag indicating wether the svg renderer should anti-alias or not.
261: */
262: public void setSvgAntiAlias(boolean svgAntiAlias) {
263: this .svgAntiAlias = svgAntiAlias;
264: }
265:
266: /**
267: * @return Flag indicating wether the renderer should interpolate or not.
268: */
269: public String getAllowInterpolation() {
270: return allowInterpolation;
271: }
272:
273: /**
274: * Sets the Flag indicating wether the renderer should interpolate or not.
275: */
276: public void setAllowInterpolation(String allowInterpolation) {
277: this .allowInterpolation = allowInterpolation;
278: }
279:
280: public Map getBaseMapLayers() {
281: return baseMapLayers != null ? baseMapLayers
282: : Collections.EMPTY_MAP;
283: }
284:
285: public void setBaseMapLayers(Map layers) {
286: baseMapLayers = layers;
287: }
288:
289: public Map getBaseMapStyles() {
290: return baseMapStyles != null ? baseMapStyles
291: : Collections.EMPTY_MAP;
292: }
293:
294: public void setBaseMapStyles(Map styles) {
295: baseMapStyles = styles;
296: }
297:
298: public Map getBaseMapEnvelopes() {
299: return baseMapEnvelopes != null ? baseMapEnvelopes
300: : Collections.EMPTY_MAP;
301: }
302:
303: public void getBaseMapEnvelopes(Map envelopes) {
304: baseMapEnvelopes = envelopes;
305: }
306: }
|