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.components.Unit; 044 import org.deegree.crs.coordinatesystems.GeographicCRS; 045 import org.deegree.crs.projections.ProjectionUtils; 046 import org.deegree.crs.projections.Projection; 047 048 /** 049 * The <code>AzimuthalProjection</code> class functions as a super class to all azimuthal projections. 050 * <p> 051 * (From wikipedia) Azimuthal projections have the property that directions from a central point are preserved (and 052 * hence, great circles through the central point are represented by straight lines on the map). Usually these 053 * projections also have radial symmetry in the scales and hence in the distortions: map distances from the central 054 * point are computed by a function r(d) of the true distance d, independent of the angle; correspondingly, circles with 055 * the central point as center are mapped into circles which have as center the central point on the map. 056 * </p> 057 * 058 * <p> 059 * The mapping of radial lines can be visualized by imagining a plane tangent to the Earth, with the central point as 060 * tangent point. 061 * </p> 062 * 063 * @author <a href="mailto:bezema@lat-lon.de">Rutger Bezema</a> 064 * 065 * @author last edited by: $Author:$ 066 * 067 * @version $Revision:$, $Date:$ 068 * 069 */ 070 071 public abstract class AzimuthalProjection extends Projection { 072 073 /** 074 * Defining that the center of this azimuthal projection is at the north pole 075 */ 076 public final static int NORTH_POLE = 0; 077 078 /** 079 * Defining that the center of this azimuthal projection is at the south pole 080 */ 081 public final static int SOUTH_POLE = 1; 082 083 /** 084 * Defining that the center of this azimuthal projection is at the equator 085 */ 086 public final static int EQUATOR = 2; 087 088 /** 089 * Defining that the center of this azimuthal projection is oblique 090 */ 091 public final static int OBLIQUE = 3; 092 093 private int mode; 094 095 /** 096 * @param geographicCRS 097 * @param falseNorthing 098 * @param falseEasting 099 * @param naturalOrigin 100 * @param units 101 * @param scale 102 * @param conformal 103 * @param equalArea 104 * @param identifiers 105 * @param names 106 * @param versions 107 * @param descriptions 108 * @param areasOfUse 109 */ 110 public AzimuthalProjection( GeographicCRS geographicCRS, double falseNorthing, double falseEasting, 111 Point2d naturalOrigin, Unit units, double scale, boolean conformal, boolean equalArea, String[] identifiers, 112 String[] names, String[] versions, String[] descriptions, String[] areasOfUse ) { 113 super( geographicCRS, 114 falseNorthing, 115 falseEasting, 116 naturalOrigin, 117 units, 118 scale, 119 conformal, 120 equalArea, 121 identifiers, 122 names, 123 versions, 124 descriptions, 125 areasOfUse ); 126 if ( Math.abs( Math.abs( getProjectionLatitude() ) - ProjectionUtils.HALFPI ) < ProjectionUtils.EPS10 ) { 127 mode = getProjectionLatitude() < 0. ? SOUTH_POLE : NORTH_POLE; 128 } else if ( Math.abs( getProjectionLatitude() ) > ProjectionUtils.EPS10 ) { 129 mode = OBLIQUE; 130 } else { 131 mode = EQUATOR; 132 } 133 } 134 135 /** 136 * @return the mode. 137 */ 138 public final int getMode() { 139 return mode; 140 } 141 142 /** 143 * Implementation as proposed by Joshua Block in Effective Java (Addison-Wesley 2001), which supplies an even 144 * distribution and is relatively fast. It is created from field <b>f</b> as follows: 145 * <ul> 146 * <li>boolean -- code = (f ? 0 : 1)</li> 147 * <li>byte, char, short, int -- code = (int)f </li> 148 * <li>long -- code = (int)(f ^ (f >>>32))</li> 149 * <li>float -- code = Float.floatToIntBits(f);</li> 150 * <li>double -- long l = Double.doubleToLongBits(f); code = (int)(l ^ (l >>> 32))</li> 151 * <li>all Objects, (where equals( ) calls equals( ) for this field) -- code = f.hashCode( )</li> 152 * <li>Array -- Apply above rules to each element</li> 153 * </ul> 154 * <p> 155 * Combining the hash code(s) computed above: result = 37 * result + code; 156 * </p> 157 * 158 * @return (int) ( result >>> 32 ) ^ (int) result; 159 * 160 * @see java.lang.Object#hashCode() 161 */ 162 @Override 163 public int hashCode() { 164 // the 2nd millionth prime, :-) 165 long code = 32452843; 166 code = code * 37 + super.hashCode(); 167 code = code * 37 + getMode(); 168 return (int) ( code >>> 32 ) ^ (int) code; 169 } 170 }