001    // $HeadURL: svn+ssh://jwilden@svn.wald.intevation.org/deegree/base/branches/2.5_testing/src/org/deegree/ogcwebservices/LonLatEnvelope.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;
038    
039    import java.io.Serializable;
040    
041    import org.deegree.datatypes.time.TimePosition;
042    import org.deegree.framework.util.StringTools;
043    import org.deegree.model.spatialschema.Envelope;
044    import org.deegree.model.spatialschema.GeometryFactory;
045    import org.deegree.model.spatialschema.Point;
046    
047    /**
048     * @version $Revision: 18195 $
049     * @author <a href="mailto:poth@lat-lon.de">Andreas Poth</a>
050     * @author last edited by: $Author: mschneider $
051     *
052     * @version 1.0. $Revision: 18195 $, $Date: 2009-06-18 17:55:39 +0200 (Do, 18 Jun 2009) $
053     *
054     * @since 2.0
055     */
056    
057    public class LonLatEnvelope implements Cloneable, Serializable {
058    
059        private static final long serialVersionUID = 6225897903182806919L;
060    
061        private Point min = null;
062    
063        private Point max = null;
064    
065        private TimePosition[] timePositions = new TimePosition[0];
066    
067        //private String srs = "urn:ogc:def:crs:OGC:1.3:CRS84";
068        private String srs = "WGS84(DD)";
069    
070        /**
071         * @param min
072         * @param max
073         */
074        public LonLatEnvelope( Point min, Point max ) {
075            this.min = min;
076            this.max = max;
077        }
078    
079        /**
080         * @param min
081         * @param max
082         * @param srs
083         */
084        public LonLatEnvelope( Point min, Point max, String srs ) {
085            this.min = min;
086            this.max = max;
087            this.srs = srs;
088        }
089    
090        /**
091         * @param min
092         * @param max
093         * @param timePositions
094         * @param srs
095         */
096        public LonLatEnvelope( Point min, Point max, TimePosition[] timePositions, String srs ) {
097            this.min = min;
098            this.max = max;
099            this.timePositions = timePositions;
100            this.srs = srs;
101        }
102    
103        /**
104         * @param minx
105         * @param miny
106         * @param maxx
107         * @param maxy
108         */
109        public LonLatEnvelope( double minx, double miny, double maxx, double maxy ) {
110            this.min = GeometryFactory.createPoint( minx, miny, null );
111            this.max = GeometryFactory.createPoint( maxx, maxy, null );
112        }
113    
114        /**
115         * @param envelope
116         */
117        public LonLatEnvelope( Envelope envelope ) {
118            this.min = GeometryFactory.createPoint( envelope.getMin().getX(), envelope.getMin().getY(), null );
119            this.max = GeometryFactory.createPoint( envelope.getMax().getX(), envelope.getMax().getY(), null );
120        }
121    
122        /**
123         * @return Returns the max.
124         */
125        public Point getMax() {
126            return max;
127        }
128    
129        /**
130         * @param max
131         *            The max to set.
132         */
133        public void setMax( Point max ) {
134            this.max = max;
135        }
136    
137        /**
138         * @return Returns the min.
139         */
140        public Point getMin() {
141            return min;
142        }
143    
144        /**
145         * @param min
146         *            The min to set.
147         */
148        public void setMin( Point min ) {
149            this.min = min;
150        }
151    
152        /**
153         * @return Returns the srs.
154         */
155        public String getSrs() {
156            return srs;
157        }
158    
159        /**
160         * @param srs
161         *            The srs to set.
162         */
163        public void setSrs( String srs ) {
164            this.srs = srs;
165        }
166    
167        /**
168         * @return Returns the timePositions.
169         */
170        public TimePosition[] getTimePositions() {
171            return timePositions;
172        }
173    
174        /**
175         * @param timePositions
176         *            The timePositions to set.
177         */
178        public void setTimePositions( TimePosition[] timePositions ) {
179            if ( timePositions == null ) {
180                timePositions = new TimePosition[0];
181            }
182            this.timePositions = timePositions;
183        }
184    
185        public Object clone() {
186            TimePosition[] timePositions_ = new TimePosition[timePositions.length];
187            for ( int i = 0; i < timePositions_.length; i++ ) {
188                timePositions_[i] = (TimePosition) timePositions[i].clone();
189            }
190    
191            return new LonLatEnvelope( min, max, timePositions_, new String( srs ) );
192        }
193    
194        public String toString() {
195            return StringTools.concat( 200, "min: ", min, " max: ", max );
196        }
197    }