001 //$HeadURL: svn+ssh://jwilden@svn.wald.intevation.org/deegree/base/branches/2.5_testing/src/org/deegree/crs/coordinatesystems/CompoundCRS.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 037 package org.deegree.crs.coordinatesystems; 038 039 import org.deegree.crs.Identifiable; 040 import org.deegree.crs.components.Axis; 041 import org.deegree.crs.components.Unit; 042 043 /** 044 * A <code>CompoundCRS</code> is a {@link GeographicCRS} with a third axis (the height axis) attached. This axis denotes 045 * a vertical axis, which defines a unit for a given height above or below the datums surface. 046 * 047 * @author <a href="mailto:bezema@lat-lon.de">Rutger Bezema</a> 048 * 049 * @author last edited by: $Author: mschneider $ 050 * 051 * @version $Revision: 18195 $, $Date: 2009-06-18 17:55:39 +0200 (Do, 18 Jun 2009) $ 052 * 053 */ 054 public class CompoundCRS extends CoordinateSystem { 055 056 private static final long serialVersionUID = 2861500959374690669L; 057 058 private CoordinateSystem underlyingCRS; 059 060 private final Axis[] axis; 061 062 private final double defaultHeight; 063 064 /** 065 * @param heightAxis 066 * defining the name and the units of the 'vertical' axis 067 * @param underlyingCRS 068 * the crs to which the height axis is added, only geographic, geocentric or projected crs are valid. 069 * @param defaultHeight 070 * of the any coordinate which does not have a height-axis-value. 071 * @param identity 072 * containing the identifiable values. 073 * @throws IllegalArgumentException 074 * if the underlying crs is not of type geographic, geocentric or projected or one of the other values 075 * is <code>null</code>. 076 */ 077 public CompoundCRS( Axis heightAxis, CoordinateSystem underlyingCRS, double defaultHeight, Identifiable identity ) 078 throws IllegalArgumentException { 079 super( underlyingCRS.getGeodeticDatum(), underlyingCRS.getAxis(), identity ); 080 int tmp = underlyingCRS.getType(); 081 if ( tmp != CoordinateSystem.GEOCENTRIC_CRS && tmp != CoordinateSystem.PROJECTED_CRS 082 && tmp != CoordinateSystem.GEOGRAPHIC_CRS ) { 083 throw new IllegalArgumentException( 084 "A compound crs can only have a geographic, projected or geocentric crs as underlying coordinate system." ); 085 } 086 checkForNullObject( heightAxis, "CompoundCRS", "heightAxis" ); 087 this.underlyingCRS = underlyingCRS; 088 axis = new Axis[3]; 089 axis[0] = underlyingCRS.getAxis()[0]; 090 axis[1] = underlyingCRS.getAxis()[1]; 091 axis[2] = heightAxis; 092 this.defaultHeight = defaultHeight; 093 } 094 095 @Override 096 public int getDimension() { 097 return 3; 098 } 099 100 @Override 101 public final int getType() { 102 return COMPOUND_CRS; 103 } 104 105 /** 106 * @return the heightAxis. 107 */ 108 public final Axis getHeightAxis() { 109 return axis[2]; 110 } 111 112 /** 113 * @return the units of the heightAxis. 114 */ 115 public final Unit getHeightUnits() { 116 return axis[2].getUnits(); 117 } 118 119 /** 120 * @return the geographic Axis and the heightAxis as the third component. 121 */ 122 @Override 123 public Axis[] getAxis() { 124 return axis; 125 } 126 127 /** 128 * @return the underlyingCRS. 129 */ 130 public final CoordinateSystem getUnderlyingCRS() { 131 return underlyingCRS; 132 } 133 134 /** 135 * @return the defaultHeight or 0 if it was not set. 136 */ 137 public double getDefaultHeight() { 138 return defaultHeight; 139 } 140 141 }