001 // $HeadURL: svn+ssh://rbezema@svn.wald.intevation.org/deegree/base/tags/2.1/src/org/deegree/ogcwebservices/wcs/configuration/AbstractResolution.java $ 002 /*---------------- FILE HEADER ------------------------------------------ 003 004 This file is part of deegree. 005 Copyright (C) 2001-2007 by: 006 EXSE, Department of Geography, University of Bonn 007 http://www.giub.uni-bonn.de/deegree/ 008 lat/lon GmbH 009 http://www.lat-lon.de 010 011 This library is free software; you can redistribute it and/or 012 modify it under the terms of the GNU Lesser General Public 013 License as published by the Free Software Foundation; either 014 version 2.1 of the License, or (at your option) any later version. 015 016 This library is distributed in the hope that it will be useful, 017 but WITHOUT ANY WARRANTY; without even the implied warranty of 018 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 019 Lesser General Public License for more details. 020 021 You should have received a copy of the GNU Lesser General Public 022 License along with this library; if not, write to the Free Software 023 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 024 025 Contact: 026 027 Andreas Poth 028 lat/lon GmbH 029 Aennchenstr. 19 030 53115 Bonn 031 Germany 032 E-Mail: poth@lat-lon.de 033 034 Prof. Dr. Klaus Greve 035 Department of Geography 036 University of Bonn 037 Meckenheimer Allee 166 038 53115 Bonn 039 Germany 040 E-Mail: greve@giub.uni-bonn.de 041 042 043 ---------------------------------------------------------------------------*/ 044 package org.deegree.ogcwebservices.wcs.configuration; 045 046 import java.util.ArrayList; 047 import java.util.Arrays; 048 import java.util.List; 049 050 /** 051 * A concrete Resolution must implement accessor methods for either Shape, Directory or File (or 052 * additional descriptions available in future) which will be used is no Range is persent. 053 * 054 * @version $Revision: 6709 $ 055 * @author <a href="mailto:poth@lat-lon.de">Andreas Poth</a> 056 * @author last edited by: $Author: apoth $ 057 * 058 * @version 1.0. $Revision: 6709 $, $Date: 2007-04-27 15:07:54 +0200 (Fr, 27 Apr 2007) $ 059 * 060 * @since 2.0 061 */ 062 abstract class AbstractResolution implements Resolution { 063 064 private double minScale = 0; 065 066 private double maxScale = 9E99; 067 068 private List<Range> ranges = null; 069 070 /** 071 * @param minScale 072 * @param maxScale 073 * @param range 074 */ 075 public AbstractResolution( double minScale, double maxScale, Range[] range ) throws IllegalArgumentException { 076 if ( minScale >= maxScale ) { 077 throw new IllegalArgumentException( "minScale must be > maxScale" ); 078 } 079 this.minScale = minScale; 080 this.maxScale = maxScale; 081 setRange( range ); 082 } 083 084 /** 085 * @see #getMaxScale() 086 * @param maxScale 087 * The maxScale to set. 088 * 089 */ 090 public void setMaxScale( double maxScale ) 091 throws IllegalArgumentException { 092 if ( minScale >= maxScale ) { 093 throw new IllegalArgumentException( "minScale must be > maxScale" ); 094 } 095 this.maxScale = maxScale; 096 } 097 098 /** 099 * @see #getMinScale() 100 * @param minScale 101 * The minScale to set. 102 * 103 */ 104 public void setMinScale( double minScale ) 105 throws IllegalArgumentException { 106 if ( minScale >= maxScale ) { 107 throw new IllegalArgumentException( "minScale must be > maxScale" ); 108 } 109 this.minScale = minScale; 110 } 111 112 /** 113 * @see #getRanges() 114 * @param ranges 115 * The range to set. 116 */ 117 public void setRange( Range[] ranges ) { 118 this.ranges = new ArrayList<Range>( Arrays.asList( ranges ) ); 119 } 120 121 /** 122 * @see #getRanges() 123 * @param range 124 */ 125 public void addRange( Range range ) { 126 ranges.add( range ); 127 } 128 129 /** 130 * removes a range from a <tt>Resolution</tt> 131 * 132 * @param range 133 */ 134 public void removeRange( Range range ) { 135 ranges.remove( range ); 136 } 137 138 /** 139 * returns the minimum scale (inculding) the <tt>Resolution</tt> is valid for. 140 * 141 * @return the minimum scale (inculding) the <tt>Resolution</tt> is valid for. 142 * 143 */ 144 public double getMinScale() { 145 return minScale; 146 } 147 148 /** 149 * returns the maximum scale (exculding) the <tt>Resolution</tt> is valid for. 150 * 151 * @return the maximum scale (exculding) the <tt>Resolution</tt> is valid for. 152 * 153 */ 154 public double getMaxScale() { 155 return maxScale; 156 } 157 158 /** 159 * returns the <tt>Range</tt>s included with in resolution. A range is similar to those 160 * defined in OGC WCS 1.0.0 specification for CoverageOffering. But it is reduced to the 161 * elements required for identifying the coverages resources assigned to a specific combination 162 * of parameter (values). 163 * <p> 164 * The return value maybe is <tt>null</tt> if the <tt>Resolution</tt> just describes data 165 * from one parameter dimension (missing Range in CoverageOffering). In this case there is 166 * direct access to the data source describing element(s). 167 * 168 * @return the <tt>Range</tt>s included with in resolution. 169 * 170 */ 171 public Range[] getRanges() { 172 return ranges.toArray( new Range[ranges.size()] ); 173 } 174 175 /** 176 * minScale is used for comparing. If this.minScale < o.getMinScale -1 will be ruturned; vice 177 * versa 1 will be returned. only is this.minScale == o.minScale 0 will be returned. 178 * 179 * @see java.lang.Comparable#compareTo(java.lang.Object) 180 * 181 * @param o 182 * @return integer 183 * 184 */ 185 public int compareTo( Object o ) 186 throws IllegalArgumentException { 187 if ( !( o instanceof Resolution ) ) { 188 throw new IllegalArgumentException( "o must be an instance of Resolution" ); 189 } 190 Resolution res = (Resolution) o; 191 if ( getMinScale() < res.getMinScale() ) { 192 return -1; 193 } 194 if ( getMinScale() > res.getMinScale() ) { 195 return 1; 196 } 197 return 0; 198 } 199 200 }