    001    //$HeadURL: https://svn.wald.intevation.org/svn/deegree/base/branches/2.4_testing/src/org/deegree/ogcwebservices/wcs/describecoverage/SpatialDomain.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    package org.deegree.ogcwebservices.wcs.describecoverage;
    037
    038    import org.deegree.model.spatialschema.Envelope;
    039    import org.deegree.model.spatialschema.EnvelopeImpl;
    040    import org.deegree.model.spatialschema.Surface;
    041    import org.deegree.model.spatialschema.SurfaceImpl;
    042    import org.deegree.ogcwebservices.wcs.WCSException;
    043
    044    /**
    045     * @version $Revision: 18195 $
    046     * @author <a href="mailto:poth@lat-lon.de">Andreas Poth</a>
    047     * @author last edited by: $Author: mschneider $
    048     *
    049     * @version 1.0. $Revision: 18195 $, $Date: 2009-06-18 17:55:39 +0200 (Do, 18. Jun 2009) $
    050     *
    051     * @since 2.0
    052     */
    053
    054    public class SpatialDomain implements Cloneable {
    055
    056        private Envelope[] envelops = null;
    057
    058        private Object[] grid = new Object[0];
    059
    060        private Surface[] surface = new Surface[0];
    061
    062        /**
    063         * @param envelops
    064         */
    065        public SpatialDomain( Envelope[] envelops ) throws WCSException {
    066            setEnvelops( envelops );
    067        }
    068
    069        /**
    070         * @param envelops
    071         * @param surface
    072         */
    073        public SpatialDomain( Envelope[] envelops, Surface[] surface ) throws WCSException {
    074            setEnvelops( envelops );
    075            setSurface( surface );
    076        }
    077
    078        /**
    079         * @param envelops
    080         * @param grid
    081         */
    082        public SpatialDomain( Envelope[] envelops, Object[] grid ) throws WCSException {
    083            setEnvelops( envelops );
    084            setGrid( grid );
    085        }
    086
    087        /**
    088         * @param envelops
    089         * @param grid
    090         */
    091        public SpatialDomain( Envelope[] envelops, Surface[] surface, Object[] grid ) throws WCSException {
    092            setEnvelops( envelops );
    093            setGrid( grid );
    094            setSurface( surface );
    095        }
    096
    097        /**
    098         * @return Returns the envelops.
    099         *
    100         */
    101        public Envelope[] getEnvelops() {
    102            return envelops;
    103        }
    104
    105        /**
    106         * @param envelops
    107         *            The envelops to set.
    108         *
    109         */
    110        public void setEnvelops( Envelope[] envelops )
    111                                throws WCSException {
    112            if ( envelops == null ) {
    113                throw new WCSException( "At least one envelop must be defined for " + "a SpatialDomain!" );
    114            }
    115            this.envelops = envelops;
    116        }
    117
    118        /**
    119         * @return Returns the grid.
    120         *
    121         */
    122        public Object[] getGrid() {
    123            return grid;
    124        }
    125
    126        /**
    127         * @param grid
    128         *            The grid to set.
    129         *
    130         */
    131        public void setGrid( Object[] grid ) {
    132            if ( grid == null ) {
    133                grid = new Object[0];
    134            }
    135            this.grid = grid;
    136        }
    137
    138        /**
    139         * @return Returns the surface.
    140         *
    141         */
    142        public Surface[] getSurface() {
    143            return surface;
    144        }
    145
    146        /**
    147         * @param surface
    148         *            The surface to set.
    149         *
    150         */
    151        public void setSurface( Surface[] surface ) {
    152            if ( surface == null ) {
    153                surface = new Surface[0];
    154            }
    155            this.surface = surface;
    156        }
    157
    158        /**
    159         * @see java.lang.Object#clone()
    160         */
    161        public Object clone() {
    162            try {
    163                Envelope[] env = new Envelope[envelops.length];
    164                for ( int i = 0; i < env.length; i++ ) {
    165                    env[i] = (Envelope) ( (EnvelopeImpl) envelops[i] ).clone();
    166                }
    167
    168                Surface[] surf = new Surface[surface.length];
    169                for ( int i = 0; i < surf.length; i++ ) {
    170                    surf[i] = (Surface) ( (SurfaceImpl) surface[i] ).clone();
    171                }
    172                return new SpatialDomain( env, surf, grid );
    173            } catch ( Exception e ) {
    174                e.printStackTrace();
    175            }
    176            return null;
    177        }
    178
    179    }