001    //$$HeadURL: svn+ssh://jwilden@svn.wald.intevation.org/deegree/base/branches/2.5_testing/src/org/deegree/ogcwebservices/wpvs/configuration/WPVSDeegreeParams.java $$
002    /*----------------------------------------------------------------------------
003     This file is part of deegree, http://deegree.org/
004     Copyright (C) 2001-2009 by:
005     Department of Geography, University of Bonn
006     and
007     lat/lon GmbH
008    
009     This library is free software; you can redistribute it and/or modify it under
010     the terms of the GNU Lesser General Public License as published by the Free
011     Software Foundation; either version 2.1 of the License, or (at your option)
012     any later version.
013     This library is distributed in the hope that it will be useful, but WITHOUT
014     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
015     FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
016     details.
017     You should have received a copy of the GNU Lesser General Public License
018     along with this library; if not, write to the Free Software Foundation, Inc.,
019     59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
020    
021     Contact information:
022    
023     lat/lon GmbH
024     Aennchenstr. 19, 53177 Bonn
025     Germany
026     http://lat-lon.de/
027    
028     Department of Geography, University of Bonn
029     Prof. Dr. Klaus Greve
030     Postfach 1147, 53001 Bonn
031     Germany
032     http://www.geographie.uni-bonn.de/deegree/
033    
034     e-mail: info@deegree.org
035     ----------------------------------------------------------------------------*/
036    
037    package org.deegree.ogcwebservices.wpvs.configuration;
038    
039    import java.awt.image.BufferedImage;
040    import java.io.IOException;
041    import java.net.MalformedURLException;
042    import java.net.URL;
043    import java.util.Map;
044    
045    import org.deegree.enterprise.DeegreeParams;
046    import org.deegree.framework.log.ILogger;
047    import org.deegree.framework.log.LoggerFactory;
048    import org.deegree.framework.util.ImageUtils;
049    import org.deegree.model.metadata.iso19115.OnlineResource;
050    
051    /**
052     * 
053     * 
054     * @author <a href="mailto:mays@lat-lon.de">Judit Mays</a>
055     * @author last edited by: $Author: rbezema $
056     * 
057     *         $Revision: 19665 $, $Date: 2009-09-16 10:11:29 +0200 (Mi, 16 Sep 2009) $
058     * 
059     */
060    public class WPVSDeegreeParams extends DeegreeParams {
061    
062        /**
063         *
064         */
065        private static final long serialVersionUID = 4480667559177855009L;
066    
067        private static final ILogger LOG = LoggerFactory.getLogger( WPVSDeegreeParams.class );
068    
069        private String copyright; // copyright is either text-string or url-string
070    
071        // the configured copyrightImage to paint over the GetView response
072        private BufferedImage copyrightImage = null;
073    
074        private float viewQuality = 0.95f;
075    
076        private int maxLifeTime = 3600;
077    
078        private final Map<String, URL> backgroundMap;
079    
080        private final boolean isWatermarked;
081    
082        private final int maxViewWidth;
083    
084        private final int maxViewHeight;
085    
086        private final boolean requestQualityPreferred;
087    
088        private double maximumFarClippingPlane;
089    
090        private String defaultSplitter;
091    
092        private double minimalTerrainHeight;
093    
094        private final double minimalWCS_DGMResolution;
095    
096        private double extendRequestPercentage;
097    
098        private double nearClippingPlane;
099    
100        private final int maxTextureDimension;
101    
102        private int quadMergeCount;
103    
104        private final boolean antialiasingEnabled;
105    
106        /**
107         * 
108         * 
109         * @param defaultOnlineResource
110         * @param cacheSize
111         * @param requestTimeLimit
112         * @param characterSet
113         * @param copyright
114         * @param watermarked
115         * @param maxLifeTime
116         * @param viewQuality
117         * @param backgroundMap
118         *            a <code>Map</code> for background images. This Map contains image names as keys and image URL as
119         *            values
120         * @param maxWidth
121         * @param maxHeight
122         * @param requestQualityPreferred
123         * @param maximumFarClippingPlane
124         *            to which extend the request can set a farclippingplane
125         * @param nearClippingPlane
126         *            of the viewport
127         * @param defaultSplitter
128         *            What kind of splitter to use if the GetView request has no field named "splitter"
129         * @param minimalTerrainHeight
130         *            the minimalheight of a terrain if no dgm is found.
131         * @param minimalWCS_DGMResolution
132         *            the configured minimal resolution of a wcs dgm
133         * @param extendRequestPercentage
134         *            the percentage to which wcs/wms request should be extended.
135         * @param maxTextureDimension
136         *            the maximums request size of the textures
137         * @param quadMergeCount
138         *            a value for the quadtree-splitter to tell at which amount the leaves should be merged.
139         * @param antialiasingEnabled
140         *            true if the scene should be rendered with antialiasing.
141         */
142        public WPVSDeegreeParams( OnlineResource defaultOnlineResource, int cacheSize, int requestTimeLimit,
143                                  String characterSet, String copyright, boolean watermarked, int maxLifeTime,
144                                  float viewQuality, Map<String, URL> backgroundMap, int maxWidth, int maxHeight,
145                                  boolean requestQualityPreferred, double maximumFarClippingPlane,
146                                  double nearClippingPlane, String defaultSplitter, double minimalTerrainHeight,
147                                  double minimalWCS_DGMResolution, double extendRequestPercentage, int maxTextureDimension,
148                                  int quadMergeCount, boolean antialiasingEnabled ) {
149    
150            super( defaultOnlineResource, cacheSize, requestTimeLimit, characterSet );
151    
152            this.copyright = copyright;
153            this.maxLifeTime = maxLifeTime;
154            this.viewQuality = viewQuality;
155            this.backgroundMap = backgroundMap;
156            this.isWatermarked = watermarked;
157            this.maxViewWidth = maxWidth;
158            this.maxViewHeight = maxHeight;
159            this.requestQualityPreferred = requestQualityPreferred;
160            this.maximumFarClippingPlane = maximumFarClippingPlane;
161            this.nearClippingPlane = nearClippingPlane;
162            this.minimalWCS_DGMResolution = minimalWCS_DGMResolution;
163            this.defaultSplitter = defaultSplitter.toUpperCase();
164            if ( !( "QUAD".equals( defaultSplitter ) || "BBOX".equals( defaultSplitter ) ) ) {
165                LOG.logWarning( "The configured defaultSplitter does not exist, setting to QUAD" );
166                this.defaultSplitter = "QUAD";
167            }
168    
169            if ( copyright != null && !"".equals( copyright.trim() ) ) {
170                try {
171                    copyrightImage = ImageUtils.loadImage( new URL( this.copyright ).getFile() );
172                } catch ( MalformedURLException murle ) {
173                    // The Copyright is a String.
174                } catch ( IOException ioe ) {
175                    // The Copyright is a String.
176                }
177            }
178            this.minimalTerrainHeight = minimalTerrainHeight;
179            this.extendRequestPercentage = extendRequestPercentage;
180            this.maxTextureDimension = maxTextureDimension;
181            if ( quadMergeCount < 0 ) {
182                quadMergeCount = 0;
183            }
184            this.quadMergeCount = quadMergeCount;
185            this.antialiasingEnabled = antialiasingEnabled;
186        }
187    
188        /**
189         * @return Returns the copyright.
190         */
191        public String getCopyright() {
192            return copyright;
193        }
194    
195        /**
196         * @return Returns the maxLifeTime.
197         */
198        public int getMaxLifeTime() {
199            return maxLifeTime;
200        }
201    
202        /**
203         * @return Returns the viewQuality.
204         */
205        public float getViewQuality() {
206            return viewQuality;
207        }
208    
209        /**
210         * @return the configured different backgroundimages
211         */
212        public Map<String, URL> getBackgroundMap() {
213            return backgroundMap;
214        }
215    
216        /**
217         * @return true if the image should be watermarked (with an image or text)
218         */
219        public boolean isWatermarked() {
220            return isWatermarked;
221        }
222    
223        /**
224         * @return maximum value of the width of a request
225         */
226        public int getMaxViewWidth() {
227            return maxViewWidth;
228        }
229    
230        /**
231         * @return maximum value of the height of a request
232         */
233        public int getMaxViewHeight() {
234            return maxViewHeight;
235        }
236    
237        /**
238         * @return true if the splitter should use hight quality (lot of request quads) or false otherwise.
239         */
240        public boolean isRequestQualityPreferred() {
241            return requestQualityPreferred;
242        }
243    
244        /**
245         * @return the maximumFarClippingPlane which a user can request.
246         */
247        public double getMaximumFarClippingPlane() {
248            return maximumFarClippingPlane;
249        }
250    
251        /**
252         * @return the copyrightImage as a BufferedImage.
253         */
254        public BufferedImage getCopyrightImage() {
255            return copyrightImage;
256        }
257    
258        /**
259         * @return the defaultSplitter.
260         */
261        public String getDefaultSplitter() {
262            return defaultSplitter;
263        }
264    
265        /**
266         * @return the minimalTerrainHeight which is used as zValue of a terrain if no dgm is found (configured) for a
267         *         request. The default value is 0d.
268         */
269        public double getMinimalTerrainHeight() {
270            return minimalTerrainHeight;
271        }
272    
273        /**
274         * @return the minimalWCS_DGMResolution.
275         */
276        public double getMinimalWCS_DGMResolution() {
277            return minimalWCS_DGMResolution;
278        }
279    
280        /**
281         * @return the percentage to which wcs-request should be extended
282         */
283        public double getExtendRequestPercentage() {
284            return extendRequestPercentage;
285        }
286    
287        /**
288         * @return the configured nearclipping plane.
289         */
290        public double getNearClippingPlane() {
291            return nearClippingPlane;
292        }
293    
294        /**
295         * @return the maxim dimension of a requested Texture.
296         */
297        public final int getMaxTextureDimension() {
298            return maxTextureDimension;
299        }
300    
301        /**
302         * @return the number of leaves a quadtree-splitter can have before it starts merging leaves together.
303         */
304        public final int getQuadMergeCount() {
305            return quadMergeCount;
306        }
307    
308        /**
309         * @return true if the scene should be rendered antialiased.
310         */
311        public boolean isAntialiasingEnabled() {
312            return antialiasingEnabled;
313        }
314    }