001: //$HeadURL: https://svn.wald.intevation.org/svn/deegree/base/trunk/src/org/deegree/model/coverage/SampleDimension.java $
002: /*---------------- FILE HEADER ------------------------------------------
003:
004: This file is part of deegree.
005: Copyright (C) 2001-2008 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.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: 9343 $, $Date: 2007-12-27 05:30:32 -0800 (Thu, 27 Dec 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,
106: double minimumValue, double maximumValue,
107: ParameterValueIm[] metadata, double[] noData, int offset,
108: int[][] colorPalette, double scale, String units,
109: ColorInterpretation colorInterpretation,
110: PaletteInterpretation paletteInterpretation,
111: SampleDimensionType sampleDimensionType) {
112: this .categoryNames = categoryNames;
113: this .maximumValue = maximumValue;
114: this .minimumValue = minimumValue;
115: this .scale = scale;
116: this .noData = noData;
117: this .offset = offset;
118: this .colorPalette = colorPalette;
119: this .description = description;
120: this .metadata = new HashMap<String, Object>();
121: if (metadata != null) {
122: for (int i = 0; i < metadata.length; i++) {
123: this .metadata.put(
124: metadata[i].getDescriptor().getName(),
125: metadata[i].getValue());
126: }
127: }
128: this .units = units;
129: if (colorInterpretation == null) {
130: this .colorInterpretation = ColorInterpretation.UNDEFINED;
131: } else {
132: this .colorInterpretation = colorInterpretation;
133: }
134: if (paletteInterpretation == null) {
135: this .paletteInterpretation = PaletteInterpretation.GRAY;
136: } else {
137: this .paletteInterpretation = paletteInterpretation;
138: }
139: this .sampleDimensionType = sampleDimensionType;
140:
141: }
142:
143: /**
144: * Sequence of category names for the values contained in a sample dimension. This allows for
145: * names to be assigned to numerical values. The first entry in the sequence relates to a cell
146: * value of zero. For grid coverages, category names are only valid for a classified grid data.
147: *
148: * For example:<br>
149: * <UL>
150: * <li>0 Background</li>
151: * <li>1 Water</li>
152: * <li>2 Forest</li>
153: * <li>3 Urban</li>
154: * </UL>
155: * Note: If no category names exist, an empty sequence is returned.
156: *
157: * @return the sequence of category names for the values contained in a sample dimension.
158: *
159: */
160: public String[] getCategoryNames() {
161: return categoryNames;
162: }
163:
164: /**
165: * Color interpretation of the sample dimension. A sample dimension can be an index into a color
166: * palette or be a color model component. If the sample dimension is not assigned a color
167: * interpretation the value is {@link ColorInterpretation#UNDEFINED Undefined}.
168: *
169: * @return the color interpretation of the sample dimension.
170: *
171: */
172: public ColorInterpretation getColorInterpretation() {
173: return colorInterpretation;
174: }
175:
176: /**
177: * Sample dimension title or description. This string may be null or empty if no description is
178: * present.
179: *
180: * @return the sample dimension title or description.
181: *
182: */
183: public String getDescription() {
184: return description;
185: }
186:
187: /**
188: * The maximum value occurring in the sample dimension. If this value is not available, this
189: * value can be determined from the {@link "org.opengis"} operation. This value can be empty if
190: * this value is not provided by the implementation.
191: *
192: * @return the maximum value occurring in the sample dimension.
193: *
194: */
195: public double getMaximumValue() {
196: return maximumValue;
197: }
198:
199: /**
200: * The list of metadata keywords for a sample dimension. If no metadata is available, the
201: * sequence will be empty.
202: *
203: * @return the list of metadata keywords for a sample dimension.
204: *
205: */
206: public String[] getMetaDataNames() {
207: Iterator iterator = metadata.keySet().iterator();
208: String[] names = new String[metadata.size()];
209: int i = 0;
210: while (iterator.hasNext()) {
211: names[i++] = (String) iterator.next();
212: }
213: return names;
214: }
215:
216: /**
217: * Retrieve the metadata value for a given metadata name.
218: *
219: * @param name
220: * Metadata keyword for which to retrieve metadata.
221: * @return the metadata value for a given metadata name.
222: *
223: */
224: public String getMetadataValue(String name) {
225: return (String) metadata.get(name);
226: }
227:
228: /**
229: * The minimum value occurring in the sample dimension. This value can be empty if this value is
230: * not provided by the implementation.
231: *
232: * @return the minimum value occurring in the sample dimension.
233: *
234: */
235: public double getMinimumValue() {
236: return minimumValue;
237: }
238:
239: /**
240: * Values to indicate no data values for the sample dimension. For low precision sample
241: * dimensions, this will often be no data values.
242: *
243: * @return the values to indicate no data values for the sample dimension.
244: *
245: */
246: public double[] getNoDataValues() {
247: return noData;
248: }
249:
250: /**
251: * Offset is the value to add to grid values for this sample dimension. This attribute is
252: * typically used when the sample dimension represents elevation data. The default for this
253: * value is 0.
254: *
255: * @return the offset is the value to add to grid values for this sample dimension.
256: *
257: */
258: public double getOffset() {
259: return offset;
260: }
261:
262: /**
263: * Color palette associated with the sample dimension. A color palette can have any number of
264: * colors. See palette interpretation for meaning of the palette entries. If the grid coverage
265: * has no color palette, an empty sequence will be returned.
266: *
267: * @return the color palette associated with the sample dimension.
268: *
269: */
270: public int[][] getPalette() {
271: return colorPalette;
272: }
273:
274: /**
275: * Indicates the type of color palette entry for sample dimensions which have a palette. If a
276: * sample dimension has a palette, the color interpretation must be
277: * {@link ColorInterpretation#GRAY_INDEX GrayIndex} or
278: * {@link ColorInterpretation#PALETTE_INDEX PaletteIndex}. A palette entry type can be Gray,
279: * RGB, CMYK or HLS.
280: *
281: * @return the type of color palette entry for sample dimensions which have a palette.
282: *
283: */
284: public PaletteInterpretation getPaletteInterpretation() {
285: return paletteInterpretation;
286: }
287:
288: /**
289: * A code value indicating grid value data type. This will also indicate the number of bits for
290: * the data type.
291: *
292: * @return a code value indicating grid value data type.
293: *
294: */
295: public SampleDimensionType getSampleDimensionType() {
296: return sampleDimensionType;
297: }
298:
299: /**
300: * Scale is the value which is multiplied to grid values for this sample dimension. This
301: * attribute is typically used when the sample dimension represents elevation data. The default
302: * for this value is 1.
303: *
304: * @return the scale.
305: *
306: */
307: public double getScale() {
308: return scale;
309: }
310:
311: /**
312: * The unit information for this sample dimension. This interface typically is provided with
313: * grid coverages which represent digital elevation data. This value will be <code>null</code>
314: * if no unit information is available.
315: *
316: * @return the unit information for this sample dimension.
317: *
318: */
319: public String getUnits() {
320: return units;
321: }
322:
323: }
|