001 //$HeadURL: svn+ssh://rbezema@svn.wald.intevation.org/deegree/base/tags/2.1/src/org/deegree/model/coverage/SampleDimension.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: fitzke@giub.uni-bonn.de 041 042 043 ---------------------------------------------------------------------------*/ 044 package org.deegree.model.coverage; 045 046 import java.io.Serializable; 047 import java.util.HashMap; 048 import java.util.Iterator; 049 050 import org.deegree.datatypes.parameter.ParameterValueIm; 051 052 /** 053 * Contains information for an individual sample dimension of coverage. This interface is applicable 054 * to any coverage type. For grid coverages, the sample dimension refers to an individual band. 055 * 056 * 057 * @author <a href="mailto:poth@lat-lon.de">Andreas Poth </a> 058 * @author last edited by: $Author: apoth $ 059 * 060 * @version $Revision: 7842 $, $Date: 2007-07-25 09:44:14 +0200 (Mi, 25 Jul 2007) $ 061 */ 062 public class SampleDimension implements Serializable { 063 064 private ColorInterpretation colorInterpretation = null; 065 066 private String[] categoryNames = null; 067 068 private String description = null; 069 070 private double maximumValue = 0; 071 072 private double minimumValue = 0; 073 074 private HashMap<String, Object> metadata = null; 075 076 private double[] noData = null; 077 078 private int offset = -1; 079 080 private int[][] colorPalette = null; 081 082 private PaletteInterpretation paletteInterpretation = null; 083 084 private SampleDimensionType sampleDimensionType = null; 085 086 private double scale = -1; 087 088 private String units = null; 089 090 /** 091 * @param categoryNames 092 * @param description 093 * @param minimumValue 094 * @param maximumValue 095 * @param metadata 096 * @param noData 097 * @param offset 098 * @param colorPalette 099 * @param scale 100 * @param units 101 * @param colorInterpretation 102 * @param paletteInterpretation 103 * @param sampleDimensionType 104 */ 105 public SampleDimension( String[] categoryNames, String description, double minimumValue, double maximumValue, 106 ParameterValueIm[] metadata, double[] noData, int offset, int[][] colorPalette, 107 double scale, String units, ColorInterpretation colorInterpretation, 108 PaletteInterpretation paletteInterpretation, SampleDimensionType sampleDimensionType ) { 109 this.categoryNames = categoryNames; 110 this.maximumValue = maximumValue; 111 this.minimumValue = minimumValue; 112 this.scale = scale; 113 this.noData = noData; 114 this.offset = offset; 115 this.colorPalette = colorPalette; 116 this.description = description; 117 this.metadata = new HashMap<String, Object>(); 118 if ( metadata != null ) { 119 for ( int i = 0; i < metadata.length; i++ ) { 120 this.metadata.put( metadata[i].getDescriptor().getName(), metadata[i].getValue() ); 121 } 122 } 123 this.units = units; 124 if ( colorInterpretation == null ) { 125 this.colorInterpretation = ColorInterpretation.UNDEFINED; 126 } else { 127 this.colorInterpretation = colorInterpretation; 128 } 129 if ( paletteInterpretation == null ) { 130 this.paletteInterpretation = PaletteInterpretation.GRAY; 131 } else { 132 this.paletteInterpretation = paletteInterpretation; 133 } 134 this.sampleDimensionType = sampleDimensionType; 135 136 } 137 138 /** 139 * Sequence of category names for the values contained in a sample dimension. This allows for 140 * names to be assigned to numerical values. The first entry in the sequence relates to a cell 141 * value of zero. For grid coverages, category names are only valid for a classified grid data. 142 * 143 * For example:<br> 144 * <UL> 145 * <li>0 Background</li> 146 * <li>1 Water</li> 147 * <li>2 Forest</li> 148 * <li>3 Urban</li> 149 * </UL> 150 * Note: If no category names exist, an empty sequence is returned. 151 * 152 * @return the sequence of category names for the values contained in a sample dimension. 153 * 154 */ 155 public String[] getCategoryNames() { 156 return categoryNames; 157 } 158 159 /** 160 * Color interpretation of the sample dimension. A sample dimension can be an index into a color 161 * palette or be a color model component. If the sample dimension is not assigned a color 162 * interpretation the value is {@link ColorInterpretation#UNDEFINED Undefined}. 163 * 164 * @return the color interpretation of the sample dimension. 165 * 166 */ 167 public ColorInterpretation getColorInterpretation() { 168 return colorInterpretation; 169 } 170 171 /** 172 * Sample dimension title or description. This string may be null or empty if no description is 173 * present. 174 * 175 * @return the sample dimension title or description. 176 * 177 */ 178 public String getDescription() { 179 return description; 180 } 181 182 /** 183 * The maximum value occurring in the sample dimension. If this value is not available, this 184 * value can be determined from the {@link "org.opengis"} operation. This value can be empty if 185 * this value is not provided by the implementation. 186 * 187 * @return the maximum value occurring in the sample dimension. 188 * 189 */ 190 public double getMaximumValue() { 191 return maximumValue; 192 } 193 194 /** 195 * The list of metadata keywords for a sample dimension. If no metadata is available, the 196 * sequence will be empty. 197 * 198 * @return the list of metadata keywords for a sample dimension. 199 * 200 */ 201 public String[] getMetaDataNames() { 202 Iterator iterator = metadata.keySet().iterator(); 203 String[] names = new String[metadata.size()]; 204 int i = 0; 205 while ( iterator.hasNext() ) { 206 names[i++] = (String) iterator.next(); 207 } 208 return names; 209 } 210 211 /** 212 * Retrieve the metadata value for a given metadata name. 213 * 214 * @param name 215 * Metadata keyword for which to retrieve metadata. 216 * @return the metadata value for a given metadata name. 217 * 218 */ 219 public String getMetadataValue( String name ) { 220 return (String) metadata.get( name ); 221 } 222 223 /** 224 * The minimum value occurring in the sample dimension. This value can be empty if this value is 225 * not provided by the implementation. 226 * 227 * @return the minimum value occurring in the sample dimension. 228 * 229 */ 230 public double getMinimumValue() { 231 return minimumValue; 232 } 233 234 /** 235 * Values to indicate no data values for the sample dimension. For low precision sample 236 * dimensions, this will often be no data values. 237 * 238 * @return the values to indicate no data values for the sample dimension. 239 * 240 */ 241 public double[] getNoDataValues() { 242 return noData; 243 } 244 245 /** 246 * Offset is the value to add to grid values for this sample dimension. This attribute is 247 * typically used when the sample dimension represents elevation data. The default for this 248 * value is 0. 249 * 250 * @return the offset is the value to add to grid values for this sample dimension. 251 * 252 */ 253 public double getOffset() { 254 return offset; 255 } 256 257 /** 258 * Color palette associated with the sample dimension. A color palette can have any number of 259 * colors. See palette interpretation for meaning of the palette entries. If the grid coverage 260 * has no color palette, an empty sequence will be returned. 261 * 262 * @return the color palette associated with the sample dimension. 263 * 264 */ 265 public int[][] getPalette() { 266 return colorPalette; 267 } 268 269 /** 270 * Indicates the type of color palette entry for sample dimensions which have a palette. If a 271 * sample dimension has a palette, the color interpretation must be 272 * {@link ColorInterpretation#GRAY_INDEX GrayIndex} or 273 * {@link ColorInterpretation#PALETTE_INDEX PaletteIndex}. A palette entry type can be Gray, 274 * RGB, CMYK or HLS. 275 * 276 * @return the type of color palette entry for sample dimensions which have a palette. 277 * 278 */ 279 public PaletteInterpretation getPaletteInterpretation() { 280 return paletteInterpretation; 281 } 282 283 /** 284 * A code value indicating grid value data type. This will also indicate the number of bits for 285 * the data type. 286 * 287 * @return a code value indicating grid value data type. 288 * 289 */ 290 public SampleDimensionType getSampleDimensionType() { 291 return sampleDimensionType; 292 } 293 294 /** 295 * Scale is the value which is multiplied to grid values for this sample dimension. This 296 * attribute is typically used when the sample dimension represents elevation data. The default 297 * for this value is 1. 298 * 299 * @return the scale. 300 * 301 */ 302 public double getScale() { 303 return scale; 304 } 305 306 /** 307 * The unit information for this sample dimension. This interface typically is provided with 308 * grid coverages which represent digital elevation data. This value will be <code>null</code> 309 * if no unit information is available. 310 * 311 * @return the unit information for this sample dimension. 312 * 313 */ 314 public String getUnits() { 315 return units; 316 } 317 318 }