001 // $HeadURL: svn+ssh://jwilden@svn.wald.intevation.org/deegree/base/branches/2.5_testing/src/org/deegree/ogcwebservices/wcs/configuration/AbstractResolution.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 package org.deegree.ogcwebservices.wcs.configuration; 037 038 import java.util.ArrayList; 039 import java.util.Arrays; 040 import java.util.List; 041 042 /** 043 * A concrete Resolution must implement accessor methods for either Shape, Directory or File (or 044 * additional descriptions available in future) which will be used is no Range is persent. 045 * 046 * @version $Revision: 18195 $ 047 * @author <a href="mailto:poth@lat-lon.de">Andreas Poth</a> 048 * @author last edited by: $Author: mschneider $ 049 * 050 * @version 1.0. $Revision: 18195 $, $Date: 2009-06-18 17:55:39 +0200 (Do, 18 Jun 2009) $ 051 * 052 * @since 2.0 053 */ 054 abstract class AbstractResolution implements Resolution { 055 056 private double minScale = 0; 057 058 private double maxScale = 9E99; 059 060 private List<Range> ranges = null; 061 062 /** 063 * @param minScale 064 * @param maxScale 065 * @param range 066 */ 067 public AbstractResolution( double minScale, double maxScale, Range[] range ) throws IllegalArgumentException { 068 if ( minScale >= maxScale ) { 069 throw new IllegalArgumentException( "minScale must be > maxScale" ); 070 } 071 this.minScale = minScale; 072 this.maxScale = maxScale; 073 setRange( range ); 074 } 075 076 /** 077 * @see #getMaxScale() 078 * @param maxScale 079 * The maxScale to set. 080 * 081 */ 082 public void setMaxScale( double maxScale ) 083 throws IllegalArgumentException { 084 if ( minScale >= maxScale ) { 085 throw new IllegalArgumentException( "minScale must be > maxScale" ); 086 } 087 this.maxScale = maxScale; 088 } 089 090 /** 091 * @see #getMinScale() 092 * @param minScale 093 * The minScale to set. 094 * 095 */ 096 public void setMinScale( double minScale ) 097 throws IllegalArgumentException { 098 if ( minScale >= maxScale ) { 099 throw new IllegalArgumentException( "minScale must be > maxScale" ); 100 } 101 this.minScale = minScale; 102 } 103 104 /** 105 * @see #getRanges() 106 * @param ranges 107 * The range to set. 108 */ 109 public void setRange( Range[] ranges ) { 110 this.ranges = new ArrayList<Range>( Arrays.asList( ranges ) ); 111 } 112 113 /** 114 * @see #getRanges() 115 * @param range 116 */ 117 public void addRange( Range range ) { 118 ranges.add( range ); 119 } 120 121 /** 122 * removes a range from a <tt>Resolution</tt> 123 * 124 * @param range 125 */ 126 public void removeRange( Range range ) { 127 ranges.remove( range ); 128 } 129 130 /** 131 * returns the minimum scale (inculding) the <tt>Resolution</tt> is valid for. 132 * 133 * @return the minimum scale (inculding) the <tt>Resolution</tt> is valid for. 134 * 135 */ 136 public double getMinScale() { 137 return minScale; 138 } 139 140 /** 141 * returns the maximum scale (exculding) the <tt>Resolution</tt> is valid for. 142 * 143 * @return the maximum scale (exculding) the <tt>Resolution</tt> is valid for. 144 * 145 */ 146 public double getMaxScale() { 147 return maxScale; 148 } 149 150 /** 151 * returns the <tt>Range</tt>s included with in resolution. A range is similar to those 152 * defined in OGC WCS 1.0.0 specification for CoverageOffering. But it is reduced to the 153 * elements required for identifying the coverages resources assigned to a specific combination 154 * of parameter (values). 155 * <p> 156 * The return value maybe is <tt>null</tt> if the <tt>Resolution</tt> just describes data 157 * from one parameter dimension (missing Range in CoverageOffering). In this case there is 158 * direct access to the data source describing element(s). 159 * 160 * @return the <tt>Range</tt>s included with in resolution. 161 * 162 */ 163 public Range[] getRanges() { 164 return ranges.toArray( new Range[ranges.size()] ); 165 } 166 167 /** 168 * minScale is used for comparing. If this.minScale < o.getMinScale -1 will be ruturned; vice 169 * versa 1 will be returned. only is this.minScale == o.minScale 0 will be returned. 170 * 171 * @see java.lang.Comparable#compareTo(java.lang.Object) 172 * 173 * @param o 174 * @return integer 175 * 176 */ 177 public int compareTo( Object o ) 178 throws IllegalArgumentException { 179 if ( !( o instanceof Resolution ) ) { 180 throw new IllegalArgumentException( "o must be an instance of Resolution" ); 181 } 182 Resolution res = (Resolution) o; 183 if ( getMinScale() < res.getMinScale() ) { 184 return -1; 185 } 186 if ( getMinScale() > res.getMinScale() ) { 187 return 1; 188 } 189 return 0; 190 } 191 192 }