001    //$HeadURL: svn+ssh://rbezema@svn.wald.intevation.org/deegree/base/branches/2.2_testing/src/org/deegree/ogcwebservices/wcs/describecoverage/SpatialDomain.java $
002    /*----------------    FILE HEADER  ------------------------------------------
003    
004     This file is part of deegree.
005     Copyright (C) 2001-2008 by:
006     EXSE, Department of Geography, University of Bonn
007     http://www.giub.uni-bonn.de/deegree/
008     lat/lon GmbH
009     http://www.lat-lon.de
010    
011     This library is free software; you can redistribute it and/or
012     modify it under the terms of the GNU Lesser General Public
013     License as published by the Free Software Foundation; either
014     version 2.1 of the License, or (at your option) any later version.
015    
016     This library is distributed in the hope that it will be useful,
017     but WITHOUT ANY WARRANTY; without even the implied warranty of
018     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
019     Lesser General Public License for more details.
020    
021     You should have received a copy of the GNU Lesser General Public
022     License along with this library; if not, write to the Free Software
023     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
024    
025     Contact:
026    
027     Andreas Poth
028     lat/lon GmbH
029     Aennchenstr. 19
030     53115 Bonn
031     Germany
032     E-Mail: poth@lat-lon.de
033    
034     Prof. Dr. Klaus Greve
035     Department of Geography
036     University of Bonn
037     Meckenheimer Allee 166
038     53115 Bonn
039     Germany
040     E-Mail: greve@giub.uni-bonn.de
041    
042     
043     ---------------------------------------------------------------------------*/
044    package org.deegree.ogcwebservices.wcs.describecoverage;
045    
046    import org.deegree.model.spatialschema.Envelope;
047    import org.deegree.model.spatialschema.EnvelopeImpl;
048    import org.deegree.model.spatialschema.Surface;
049    import org.deegree.model.spatialschema.SurfaceImpl;
050    import org.deegree.ogcwebservices.wcs.WCSException;
051    
052    /**
053     * @version $Revision: 9345 $
054     * @author <a href="mailto:poth@lat-lon.de">Andreas Poth</a>
055     * @author last edited by: $Author: apoth $
056     * 
057     * @version 1.0. $Revision: 9345 $, $Date: 2007-12-27 17:22:25 +0100 (Do, 27 Dez 2007) $
058     * 
059     * @since 2.0
060     */
061    
062    public class SpatialDomain implements Cloneable {
063    
064        private Envelope[] envelops = null;
065    
066        private Object[] grid = new Object[0];
067    
068        private Surface[] surface = new Surface[0];
069    
070        
071        /**
072         * @param envelops
073         */
074        public SpatialDomain(Envelope[] envelops) throws WCSException {
075            setEnvelops(envelops);
076        }
077        
078        /**
079         * @param envelops
080         * @param surface
081         */
082        public SpatialDomain(Envelope[] envelops, Surface[] surface) throws WCSException {
083            setEnvelops(envelops);
084            setSurface(surface);
085        }
086        
087        /**
088         * @param envelops
089         * @param grid
090         */
091        public SpatialDomain(Envelope[] envelops, Object[] grid) throws WCSException {
092            setEnvelops(envelops);
093            setGrid(grid);
094        }
095        
096        /**
097         * @param envelops
098         * @param grid
099         */
100        public SpatialDomain(Envelope[] envelops, Surface[] surface, Object[] grid) 
101                            throws WCSException {
102            setEnvelops(envelops);
103            setGrid(grid);
104            setSurface(surface);
105        }
106    
107        /**
108         * @return Returns the envelops.
109         * 
110         */
111        public Envelope[] getEnvelops() {
112            return envelops;
113        }
114    
115        /**
116         * @param envelops The envelops to set.
117         * 
118         */
119        public void setEnvelops(Envelope[] envelops) throws WCSException {
120            if (envelops == null) {
121                throw new WCSException("At least one envelop must be defined for "
122                    + "a SpatialDomain!");
123            }
124            this.envelops = envelops;
125        }
126    
127        /**
128         * @return Returns the grid.
129         * 
130         */
131        public Object[] getGrid() {
132            return grid;
133        }
134    
135        /**
136         * @param grid The grid to set.
137         * 
138         */
139        public void setGrid(Object[] grid) {
140            if (grid == null) {
141                grid = new Object[0];
142            }
143            this.grid = grid;
144        }
145    
146        /**
147         * @return Returns the surface.
148         * 
149         */
150        public Surface[] getSurface() {
151            return surface;
152        }
153    
154        /**
155         * @param surface The surface to set.
156         * 
157         */
158        public void setSurface(Surface[] surface) {
159            if (surface == null) {
160                surface = new Surface[0];
161            }
162            this.surface = surface;
163        }
164    
165        
166        /**
167         * @see java.lang.Object#clone()
168         */
169        public Object clone() {
170            try {
171                Envelope[] env = new Envelope[envelops.length];
172                for (int i = 0; i < env.length; i++) {
173                    env[i] = (Envelope)((EnvelopeImpl)envelops[i]).clone();
174                }
175                
176                Surface[] surf = new Surface[surface.length];
177                for (int i = 0; i < surf.length; i++) {
178                    surf[i] = (Surface)((SurfaceImpl)surface[i]).clone();
179                }
180                return new SpatialDomain( env, surf, grid );
181            } catch(Exception e) {
182                e.printStackTrace();
183            }
184            return null;
185        }
186    
187    }