001    //$HeadURL: https://svn.wald.intevation.org/svn/deegree/base/branches/2.3_testing/src/org/deegree/model/crs/CoordinateSystem.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.model.crs;
037    
038    // OpenGIS dependencies
039    import java.net.URI;
040    
041    import org.deegree.crs.components.Unit;
042    import org.deegree.datatypes.QualifiedName;
043    
044    /**
045     * A coordinate system is a mathematical space, where the elements of the space are called positions. Each position is
046     * described by a list of numbers. The length of the list corresponds to the dimension of the coordinate system. So in a
047     * 2D coordinate system each position is described by a list containing 2 numbers. <br>
048     * <br>
049     * However, in a coordinate system, not all lists of numbers correspond to a position - some lists may be outside the
050     * domain of the coordinate system. For example, in a 2D Lat/Lon coordinate system, the list (91,91) does not correspond
051     * to a position. <br>
052     * <br>
053     * Some coordinate systems also have a mapping from the mathematical space into locations in the real world. So in a
054     * Lat/Lon coordinate system, the mathematical position (lat, long) corresponds to a location on the surface of the
055     * Earth. This mapping from the mathematical space into real-world locations is called a Datum.
056     *
057     * @version $Revision: 18195 $
058     * @author <a href="mailto:poth@lat-lon.de">Andreas Poth</a>
059     * @author last edited by: $Author: mschneider $
060     *
061     * @version 1.0. $Revision: 18195 $, $Date: 2009-06-18 17:55:39 +0200 (Do, 18. Jun 2009) $
062     *
063     * @since 2.0
064     */
065    public class CoordinateSystem extends QualifiedName {
066    
067        /**
068         *
069         */
070        private static final long serialVersionUID = -170831086069691683L;
071    
072        private org.deegree.crs.coordinatesystems.CoordinateSystem realCRS;
073    
074        private final String requestedID;
075    
076        /**
077         *
078         * @param prefix
079         *            must be not null
080         * @param localName
081         * @param namespace
082         * @deprecated use {@link #CoordinateSystem(org.deegree.crs.coordinatesystems.CoordinateSystem, String)} instead
083         */
084        @Deprecated
085        CoordinateSystem( String prefix, String localName, URI namespace ) {
086            super( prefix.toLowerCase(), localName, namespace );
087            requestedID = localName;
088        }
089    
090        /**
091         *
092         * @param name
093         * @param namespace
094         * @deprecated use {@link #CoordinateSystem(org.deegree.crs.coordinatesystems.CoordinateSystem, String)}
095         */
096        @Deprecated
097        CoordinateSystem( String name, URI namespace ) {
098            super( name, namespace );
099            requestedID = name;
100        }
101    
102        /**
103         * e.g. epgs:4326, should not be used.
104         *
105         * @param name
106         * @deprecated use CoordinateSystem(org.deegree.crs.coordinatesystems.CoordinateSystem, String)
107         */
108        @Deprecated
109        protected CoordinateSystem( String name ) {
110            super( name );
111            requestedID = name;
112        }
113    
114        /**
115         * Creates a CoordinateSystem as a wrapper to the real CRS.
116         *
117         * @param realCRS
118         */
119        CoordinateSystem( org.deegree.crs.coordinatesystems.CoordinateSystem realCRS, String requestedID ) {
120            super( realCRS.getIdentifier() );
121            this.realCRS = realCRS;
122            this.requestedID = requestedID;
123        }
124    
125        /**
126         * @param realCRS
127         *            to wrap
128         */
129        CoordinateSystem( org.deegree.crs.coordinatesystems.CoordinateSystem realCRS ) {
130            this( realCRS, realCRS.getIdentifier() );
131        }
132    
133        /**
134         * returns the name of the CRS, this method is actually mapped to {@link #getIdentifier()}
135         *
136         * @return the name of the CRS
137         * @deprecated use {@link #getIdentifier()} instead
138         */
139        @Deprecated
140        public String getName() {
141            return getIdentifier();
142        }
143    
144        /**
145         * This method returns the requested id (given in the constructor) and not the
146         * {@link org.deegree.crs.coordinatesystems.CoordinateSystem#getIdentifier()} which only returns the first
147         * configured id.
148         *
149         * @return the requested id.
150         */
151        public String getIdentifier() {
152            return requestedID;
153        }
154    
155        /**
156         * Since the crs uses a different namespace system as {@link QualifiedName} this method only returns the
157         * {@link #getIdentifier()}.
158         */
159        @Override
160        public String getPrefixedName() {
161            return getIdentifier();
162        }
163    
164        /**
165         * returns the CRSs code. In case of EPSG:4326 it will be 4326; in case of adv:DE_DHDN_3GK2_NW177 it will be
166         * DE_DHDN_3GK2_NW177
167         *
168         * @return the CRSs code
169         * @deprecated has no relevance, returns a bogus value.
170         */
171        @Deprecated
172        public String getCode() {
173            return getLocalName();
174        }
175    
176        /**
177         * returns the unit of the first axis of the encapsulated CRS
178         *
179         * @return the units of the first axis of the encapsulated CRS
180         * @deprecated this method returns the unit of the fist axis, assuming all axis have the same unit, which is not
181         *             necessarily so. It is better to use the {@link  #getAxisUnits()} and iterate over all units.
182         */
183        @Deprecated
184        public String getUnits() {
185            return realCRS.getUnits()[0].toString();
186        }
187    
188        /**
189         * @return the units of all axis.
190         */
191        public Unit[] getAxisUnits() {
192            return realCRS.getUnits();
193        }
194    
195        /**
196         * @return the dimension of the encapsulated CRS
197         */
198        public int getDimension() {
199            return realCRS.getDimension();
200        }
201    
202        /**
203         * @return the encapsulated CRS.
204         */
205        public org.deegree.crs.coordinatesystems.CoordinateSystem getCRS() {
206            return realCRS;
207        }
208    
209        @Override
210        public boolean equals( Object other ) {
211            if ( other != null && other instanceof CoordinateSystem ) {
212                final CoordinateSystem that = (CoordinateSystem) other;
213                return this.realCRS.equals( that.realCRS );
214            }
215            return false;
216        }
217    }