001: //$HeadURL: $
002: /*---------------- FILE HEADER ------------------------------------------
003: This file is part of deegree.
004: Copyright (C) 2001-2008 by:
005: Department of Geography, University of Bonn
006: http://www.giub.uni-bonn.de/deegree/
007: lat/lon GmbH
008: http://www.lat-lon.de
009:
010: This library is free software; you can redistribute it and/or
011: modify it under the terms of the GNU Lesser General Public
012: License as published by the Free Software Foundation; either
013: version 2.1 of the License, or (at your option) any later version.
014: This library is distributed in the hope that it will be useful,
015: but WITHOUT ANY WARRANTY; without even the implied warranty of
016: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
017: Lesser General Public License for more details.
018: You should have received a copy of the GNU Lesser General Public
019: License along with this library; if not, write to the Free Software
020: Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
021: Contact:
022:
023: Andreas Poth
024: lat/lon GmbH
025: Aennchenstr. 19
026: 53177 Bonn
027: Germany
028: E-Mail: poth@lat-lon.de
029:
030: Prof. Dr. Klaus Greve
031: Department of Geography
032: University of Bonn
033: Meckenheimer Allee 166
034: 53115 Bonn
035: Germany
036: E-Mail: greve@giub.uni-bonn.de
037: ---------------------------------------------------------------------------*/
038:
039: package org.deegree.crs.projections.azimuthal;
040:
041: import javax.vecmath.Point2d;
042:
043: import org.deegree.crs.Identifiable;
044: import org.deegree.crs.components.Unit;
045: import org.deegree.crs.coordinatesystems.GeographicCRS;
046: import org.deegree.crs.projections.ProjectionUtils;
047: import org.deegree.crs.projections.Projection;
048:
049: /**
050: * The <code>AzimuthalProjection</code> class functions as a super class to all azimuthal projections.
051: * <p>
052: * (From wikipedia) Azimuthal projections have the property that directions from a central point are preserved (and
053: * hence, great circles through the central point are represented by straight lines on the map). Usually these
054: * projections also have radial symmetry in the scales and hence in the distortions: map distances from the central
055: * point are computed by a function r(d) of the true distance d, independent of the angle; correspondingly, circles with
056: * the central point as center are mapped into circles which have as center the central point on the map.
057: * </p>
058: *
059: * <p>
060: * The mapping of radial lines can be visualized by imagining a plane tangent to the Earth, with the central point as
061: * tangent point.
062: * </p>
063: *
064: * @author <a href="mailto:bezema@lat-lon.de">Rutger Bezema</a>
065: *
066: * @author last edited by: $Author:$
067: *
068: * @version $Revision:$, $Date:$
069: *
070: */
071:
072: public abstract class AzimuthalProjection extends Projection {
073:
074: /**
075: * Defining that the center of this azimuthal projection is at the north pole
076: */
077: public final static int NORTH_POLE = 0;
078:
079: /**
080: * Defining that the center of this azimuthal projection is at the south pole
081: */
082: public final static int SOUTH_POLE = 1;
083:
084: /**
085: * Defining that the center of this azimuthal projection is at the equator
086: */
087: public final static int EQUATOR = 2;
088:
089: /**
090: * Defining that the center of this azimuthal projection is oblique
091: */
092: public final static int OBLIQUE = 3;
093:
094: private int mode;
095:
096: /**
097: * @param geographicCRS
098: * @param falseNorthing
099: * @param falseEasting
100: * @param naturalOrigin
101: * @param units
102: * @param scale
103: * @param conformal
104: * @param equalArea
105: * @param id to get the identifiable values from may not be <code>null</code>
106: */
107: public AzimuthalProjection(GeographicCRS geographicCRS,
108: double falseNorthing, double falseEasting,
109: Point2d naturalOrigin, Unit units, double scale,
110: boolean conformal, boolean equalArea, Identifiable id) {
111: this (geographicCRS, falseNorthing, falseEasting, naturalOrigin,
112: units, scale, conformal, equalArea,
113: id.getIdentifiers(), id.getNames(), id.getVersions(),
114: id.getDescriptions(), id.getAreasOfUse());
115: }
116:
117: /**
118: * @param geographicCRS
119: * @param falseNorthing
120: * @param falseEasting
121: * @param naturalOrigin
122: * @param units
123: * @param scale
124: * @param conformal
125: * @param equalArea
126: * @param identifiers
127: * @param names
128: * @param versions
129: * @param descriptions
130: * @param areasOfUse
131: */
132: public AzimuthalProjection(GeographicCRS geographicCRS,
133: double falseNorthing, double falseEasting,
134: Point2d naturalOrigin, Unit units, double scale,
135: boolean conformal, boolean equalArea, String[] identifiers,
136: String[] names, String[] versions, String[] descriptions,
137: String[] areasOfUse) {
138: super (geographicCRS, falseNorthing, falseEasting,
139: naturalOrigin, units, scale, conformal, equalArea,
140: identifiers, names, versions, descriptions, areasOfUse);
141: if (Math.abs(Math.abs(getProjectionLatitude())
142: - ProjectionUtils.HALFPI) < ProjectionUtils.EPS10) {
143: mode = getProjectionLatitude() < 0. ? SOUTH_POLE
144: : NORTH_POLE;
145: } else if (Math.abs(getProjectionLatitude()) > ProjectionUtils.EPS10) {
146: mode = OBLIQUE;
147: } else {
148: mode = EQUATOR;
149: }
150: }
151:
152: /**
153: * @return the mode.
154: */
155: public final int getMode() {
156: return mode;
157: }
158:
159: /**
160: * Implementation as proposed by Joshua Block in Effective Java (Addison-Wesley 2001), which supplies an even
161: * distribution and is relatively fast. It is created from field <b>f</b> as follows:
162: * <ul>
163: * <li>boolean -- code = (f ? 0 : 1)</li>
164: * <li>byte, char, short, int -- code = (int)f </li>
165: * <li>long -- code = (int)(f ^ (f >>>32))</li>
166: * <li>float -- code = Float.floatToIntBits(f);</li>
167: * <li>double -- long l = Double.doubleToLongBits(f); code = (int)(l ^ (l >>> 32))</li>
168: * <li>all Objects, (where equals( ) calls equals( ) for this field) -- code = f.hashCode( )</li>
169: * <li>Array -- Apply above rules to each element</li>
170: * </ul>
171: * <p>
172: * Combining the hash code(s) computed above: result = 37 * result + code;
173: * </p>
174: *
175: * @return (int) ( result >>> 32 ) ^ (int) result;
176: *
177: * @see java.lang.Object#hashCode()
178: */
179: @Override
180: public int hashCode() {
181: // the 2nd millionth prime, :-)
182: long code = 32452843;
183: code = code * 37 + super .hashCode();
184: code = code * 37 + getMode();
185: return (int) (code >>> 32) ^ (int) code;
186: }
187: }
|