001 //$HeadURL: svn+ssh://rbezema@svn.wald.intevation.org/deegree/base/tags/2.1/src/org/deegree/model/csct/cs/AxisInfo.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 // Miscellaneous 054 import java.io.Serializable; 055 import java.util.Locale; 056 057 import org.deegree.model.csct.resources.Utilities; 058 import org.deegree.model.csct.resources.css.ResourceKeys; 059 import org.deegree.model.csct.units.resources.Resources; 060 061 /** 062 * Details of axis. This is used to label axes, and indicate the orientation. 063 * 064 * @version 1.00 065 * @author OpenGIS (www.opengis.org) 066 * @author Martin Desruisseaux 067 * 068 * @author last edited by: $Author: bezema $ 069 * 070 * @version $Revision: 6259 $, $Date: 2007-03-20 10:15:15 +0100 (Di, 20 Mär 2007) $ 071 * 072 * @see "org.opengis.cs.CS_AxisInfo" 073 */ 074 public class AxisInfo implements Serializable { 075 /** 076 * Serial number for interoperability with different versions. 077 */ 078 private static final long serialVersionUID = 6799874182734710227L; 079 080 /** 081 * Default axis info for <var>x</var> values. Increasing ordinates values go East. This is 082 * usually used with projected coordinate systems. 083 */ 084 public static final AxisInfo X = new AxisInfo( "x", AxisOrientation.EAST ); 085 086 /** 087 * Default axis info for <var>y</var> values. Increasing ordinates values go North. This is 088 * usually used with projected coordinate systems. 089 */ 090 public static final AxisInfo Y = new AxisInfo( "y", AxisOrientation.NORTH ); 091 092 /** 093 * Default axis info for longitudes. Increasing ordinates values go East. This is usually used 094 * with geographic coordinate systems. 095 */ 096 public static final AxisInfo LONGITUDE = new AxisInfo.Localized( "Longitude", 097 ResourceKeys.LONGITUDE, 098 AxisOrientation.EAST ); 099 100 /** 101 * Default axis info for latitudes. Increasing ordinates values go North. This is usually used 102 * with geographic coordinate systems. 103 */ 104 public static final AxisInfo LATITUDE = new AxisInfo.Localized( "Latitude", 105 ResourceKeys.LATITUDE, 106 AxisOrientation.NORTH ); 107 108 /** 109 * The default axis for altitude values. Increasing ordinates values go up. 110 */ 111 public static final AxisInfo ALTITUDE = new AxisInfo.Localized( "Altitude", 112 ResourceKeys.ALTITUDE, 113 AxisOrientation.UP ); 114 115 /** 116 * A default axis for time values. Increasing time go toward future. 117 */ 118 public static final AxisInfo TIME = new AxisInfo.Localized( "Time", ResourceKeys.TIME, 119 AxisOrientation.FUTURE ); 120 121 /** 122 * Human readable name for axis. Possible values are <code>X</code>, <code>Y</code>, 123 * <code>Long</code>, <code>Lat</code> or any other short string. 124 * 125 * @see "org.opengis.cs.CS_AxisInfo#name" 126 */ 127 public final String name; 128 129 /** 130 * Enumerated value for orientation. 131 * 132 * @see "org.opengis.cs.CS_AxisInfo#orientation" 133 */ 134 public final AxisOrientation orientation; 135 136 /** 137 * Construct an AxisInfo. 138 * 139 * @param name 140 * The axis name. Possible values are <code>X</code>, <code>Y</code>, 141 * <code>Long</code>, <code>Lat</code> or any other short string. 142 * @param orientation 143 * The axis orientation. 144 */ 145 public AxisInfo( final String name, final AxisOrientation orientation ) { 146 this.name = name; 147 this.orientation = orientation; 148 Info.ensureNonNull( "name", name ); 149 Info.ensureNonNull( "orientation", orientation ); 150 } 151 152 /** 153 * Returns the localized name of this axis. The default implementation returns {@link #name}. 154 * 155 * @param locale 156 * The locale, or <code>null</code> for the default locale. 157 * @return The localized string. 158 */ 159 public String getName() { 160 return name; 161 } 162 163 /** 164 * Returns a hash value for this axis. 165 * 166 * @return a hash value for this axis. 167 */ 168 public int hashCode() { 169 int code = 36972167; 170 if ( orientation != null ) 171 code = code * 37 + orientation.hashCode(); 172 if ( name != null ) 173 code = code * 37 + name.hashCode(); 174 return code; 175 } 176 177 /** 178 * Compares the specified object with this axis for equality. 179 * 180 * @return 181 */ 182 public boolean equals( final Object object ) { 183 if ( object != null && object.getClass().equals( getClass() ) ) { 184 final AxisInfo that = (AxisInfo) object; 185 return Utilities.equals( this.orientation, that.orientation ) 186 && Utilities.equals( this.name, that.name ); 187 } 188 return false; 189 } 190 191 /** 192 * Returns the Well Know Text (WKT) for this axis. The WKT is part of OpenGIS's specification 193 * and looks like <code>AXIS["name",NORTH]</code>. 194 * 195 * @return the Well Know Text (WKT) for this axis. 196 */ 197 public String toString() { 198 final StringBuffer buffer = new StringBuffer( "AXIS[\"" ); 199 buffer.append( name ); 200 buffer.append( '"' ); 201 if ( orientation != null ) { 202 buffer.append( ',' ); 203 buffer.append( orientation.getName() ); 204 } 205 buffer.append( ']' ); 206 return buffer.toString(); 207 } 208 209 /** 210 * Localized {@link AxisInfo}. 211 * 212 * @version 1.0 213 * @author Martin Desruisseaux 214 */ 215 private static final class Localized extends AxisInfo { 216 /** 217 * Serial number for interoperability with different versions. 218 */ 219 private static final long serialVersionUID = 7625005531024599865L; 220 221 /** 222 * The key for localization. 223 */ 224 private final int key; 225 226 /** 227 * Construct a localized axis info. 228 * 229 * @param name 230 * @param key 231 * @param orientation 232 */ 233 public Localized( final String name, final int key, final AxisOrientation orientation ) { 234 super( name, orientation ); 235 this.key = key; 236 } 237 238 /** 239 * Returns a localized string. 240 * 241 * @param locale 242 * @return a localized string. 243 */ 244 public String getName( final Locale locale ) { 245 return Resources.getResources( locale ).getString( key ); 246 } 247 } 248 }