001    //$HeadURL: svn+ssh://rbezema@svn.wald.intevation.org/deegree/base/tags/2.1/src/org/deegree/model/csct/cs/Datum.java $
002    /*----------------    FILE HEADER  ------------------------------------------
003    
004     This file is part of deegree.
005     Copyright (C) 2001 by:
006     EXSE, Department of Geography, University of Bonn
007     http://www.giub.uni-bonn.de/exse/
008     lat/lon GmbH
009     http://www.lat-lon.de
010    
011     It has been implemented within SEAGIS - An OpenSource implementation of OpenGIS specification
012     (C) 2001, Institut de Recherche pour le D�veloppement (http://sourceforge.net/projects/seagis/)
013     SEAGIS Contacts:  Surveillance de l'Environnement Assist�e par Satellite
014     Institut de Recherche pour le D�veloppement / US-Espace
015     mailto:seasnet@teledetection.fr
016    
017    
018     This library is free software; you can redistribute it and/or
019     modify it under the terms of the GNU Lesser General Public
020     License as published by the Free Software Foundation; either
021     version 2.1 of the License, or (at your option) any later version.
022    
023     This library is distributed in the hope that it will be useful,
024     but WITHOUT ANY WARRANTY; without even the implied warranty of
025     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
026     Lesser General Public License for more details.
027    
028     You should have received a copy of the GNU Lesser General Public
029     License along with this library; if not, write to the Free Software
030     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
031    
032     Contact:
033    
034     Andreas Poth
035     lat/lon GmbH
036     Aennchenstr. 19
037     53115 Bonn
038     Germany
039     E-Mail: poth@lat-lon.de
040    
041     Klaus Greve
042     Department of Geography
043     University of Bonn
044     Meckenheimer Allee 166
045     53115 Bonn
046     Germany
047     E-Mail: klaus.greve@uni-bonn.de
048    
049     
050     ---------------------------------------------------------------------------*/
051    package org.deegree.model.csct.cs;
052    
053    // OpenGIS dependencies
054    import java.util.Map;
055    
056    import org.deegree.model.csct.resources.Utilities;
057    
058    /**
059     * A set of quantities from which other quantities are calculated. It may be a textual description
060     * and/or a set of parameters describing the relationship of a coordinate system to some predefined
061     * physical locations (such as center of mass) and physical directions (such as axis of spin). It
062     * can be defined as a set of real points on the earth that have coordinates. For example a datum
063     * can be thought of as a set of parameters defining completely the origin and orientation of a
064     * coordinate system with respect to the earth. The definition of the datum may also include the
065     * temporal behavior (such as the rate of change of the orientation of the coordinate axes).
066     * 
067     * @version 1.00
068     * @author OpenGIS (www.opengis.org)
069     * @author Martin Desruisseaux
070     * 
071     * @author last edited by: $Author: bezema $
072     * 
073     * @version $Revision: 6259 $, $Date: 2007-03-20 10:15:15 +0100 (Di, 20 Mär 2007) $
074     * 
075     * @see "org.opengis.cs.CS_Datum"
076     */
077    public class Datum extends Info {
078        /**
079         * Serial number for interoperability with different versions.
080         */
081        private static final long serialVersionUID = 2175857309476007487L;
082    
083        /**
084         * The datum type.
085         */
086        private final DatumType type;
087    
088        /**
089         * Construct a new datum with the specified name and datum type.
090         * 
091         * @param name
092         *            The datum name.
093         * @param type
094         *            The datum type.
095         */
096        public Datum( final String name, final DatumType type ) {
097            super( name );
098            this.type = type;
099            ensureNonNull( "type", type );
100        }
101    
102        /**
103         * Construct a new datum with the specified properties.
104         * 
105         * @param properties
106         *            The set of properties (see {@link Info}).
107         * @param type
108         *            The datum type.
109         */
110        Datum( final Map properties, final DatumType type ) {
111            super( properties );
112            this.type = type;
113            // Accept null value.
114        }
115    
116        /**
117         * Gets the type of the datum as an enumerated code.
118         * 
119         * @return the type of the datum as an enumerated code.
120         * 
121         * @see "org.opengis.cs.CS_Datum#getDatumType()"
122         */
123        public DatumType getDatumType() {
124            return type;
125        }
126    
127        /**
128         * Returns a hash value for this datum.
129         * 
130         * @return a hash value for this datum.
131         */
132        public int hashCode() {
133            int code = 37 * super.hashCode();
134            final DatumType type = getDatumType();
135            if ( type != null )
136                code += type.hashCode();
137            return code;
138        }
139    
140        /**
141         * Compares the specified object with this datum for equality.
142         * 
143         * @param object
144         * 
145         * @return
146         */
147        public boolean equals( final Object object ) {
148            if ( super.equals( object ) ) {
149                final Datum that = (Datum) object;
150                return Utilities.equals( this.type, that.type );
151            }
152            return false;
153        }
154    
155        /**
156         * Fill the part inside "[...]". Used for formatting Well Know Text (WKT).
157         * 
158         * @param buffer
159         * @return
160         */
161        String addString( final StringBuffer buffer ) {
162            buffer.append( ", " );
163            buffer.append( type.getName() );
164            return "DATUM";
165        }
166    
167    }