001: /*
002: * GeoTools - OpenSource mapping toolkit
003: * http://geotools.org
004: * (C) 2005-2006, Geotools Project Managment Committee (PMC)
005: * (C) 2003, Institut de Recherche pour le Développement
006: *
007: * This library is free software; you can redistribute it and/or
008: * modify it under the terms of the GNU Lesser General Public
009: * License as published by the Free Software Foundation; either
010: * version 2.1 of the License, or (at your option) any later version.
011: *
012: * This library is distributed in the hope that it will be useful,
013: * but WITHOUT ANY WARRANTY; without even the implied warranty of
014: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015: * Lesser General Public License for more details.
016: *
017: * This package contains documentation from OpenGIS specifications.
018: * OpenGIS consortium's work is fully acknowledged here.
019: */
020: package org.geotools.coverage.processing.operation;
021:
022: // JAI dependencies (for javadoc)
023: import javax.media.jai.operator.BandSelectDescriptor;
024:
025: // OpenGIS dependencies
026: import org.opengis.coverage.Coverage;
027: import org.opengis.parameter.ParameterValueGroup;
028: import org.opengis.parameter.ParameterDescriptor;
029:
030: // Geotools dependencies
031: import org.geotools.factory.Hints;
032: import org.geotools.coverage.processing.Operation2D;
033: import org.geotools.metadata.iso.citation.Citations;
034: import org.geotools.parameter.DefaultParameterDescriptor;
035: import org.geotools.parameter.DefaultParameterDescriptorGroup;
036:
037: /**
038: * Chooses <var>N</var> {@linkplain org.geotools.coverage.GridSampleDimension sample dimensions}
039: * from a grid coverage and copies their sample data to the destination grid coverage in the order
040: * specified. The {@code "SampleDimensions"} parameter specifies the source
041: * {@link org.geotools.coverage.GridSampleDimension} indices, and its size
042: * ({@code SampleDimensions.length}) determines the number of sample dimensions of the destination
043: * grid coverage. The destination coverage may have any number of sample dimensions, and a particular
044: * sample dimension of the source coverage may be repeated in the destination coverage by specifying
045: * it multiple times in the {@code "SampleDimensions"} parameter.
046: * <p>
047: * <strong>Geotools extension:</strong><br>
048: * This operation can also be used for selecting a different "visible sample dimension". Some
049: * images may contain useful data in more than one sample dimension, but renderer the content
050: * using only 1 sample dimension at time. The {@code "VisibleSampleDimension"} parameter can be
051: * used for selecting this sample dimension. If ommited, then the new grid coverage will inherit
052: * its source's visible sample dimension.
053: *
054: * <P><STRONG>Name:</STRONG> <CODE>"SelectSampleDimension"</CODE><BR>
055: * <STRONG>JAI operator:</STRONG> <CODE>"{@linkplain BandSelectDescriptor BandSelect}"</CODE><BR>
056: * <STRONG>Parameters:</STRONG></P>
057: * <table border='3' cellpadding='6' bgcolor='F4F8FF'>
058: * <tr bgcolor='#B9DCFF'>
059: * <th>Name</th>
060: * <th>Class</th>
061: * <th>Default value</th>
062: * <th>Minimum value</th>
063: * <th>Maximum value</th>
064: * </tr>
065: * <tr>
066: * <td>{@code "Source"}</td>
067: * <td>{@link org.geotools.coverage.grid.GridCoverage2D}</td>
068: * <td align="center">N/A</td>
069: * <td align="center">N/A</td>
070: * <td align="center">N/A</td>
071: * </tr>
072: * <tr>
073: * <td>{@code "SampleDimensions"}</td>
074: * <td>{@code int[]}</td>
075: * <td align="center">Same as source</td>
076: * <td align="center">N/A</td>
077: * <td align="center">N/A</td>
078: * </tr>
079: * <tr>
080: * <td>{@code "VisibleSampleDimension"}</td>
081: * <td>{@link java.lang.Integer}</td>
082: * <td align="center">Same as source</td>
083: * <td align="center">0</td>
084: * <td align="center">N/A</td>
085: * </tr>
086: * </table>
087: *
088: * @since 2.2
089: * @source $URL: http://svn.geotools.org/geotools/tags/2.4.1/modules/library/coverage/src/main/java/org/geotools/coverage/processing/operation/SelectSampleDimension.java $
090: * @version $Id: SelectSampleDimension.java 20970 2006-08-11 07:53:22Z jgarnett $
091: * @author Martin Desruisseaux
092: *
093: * @see org.geotools.coverage.processing.Operations#selectSampleDimension
094: * @see BandSelectDescriptor
095: */
096: public class SelectSampleDimension extends Operation2D {
097: /**
098: * Serial number for interoperability with different versions.
099: */
100: private static final long serialVersionUID = 6889502343896409135L;
101:
102: /**
103: * The parameter descriptor for the sample dimension indices.
104: */
105: public static final ParameterDescriptor SAMPLE_DIMENSIONS = new DefaultParameterDescriptor(
106: Citations.OGC, "SampleDimensions", int[].class, // Value class (mandatory)
107: null, // Array of valid values
108: null, // Default value
109: null, // Minimal value
110: null, // Maximal value
111: null, // Unit of measure
112: false); // Parameter is optional
113:
114: /**
115: * The parameter descriptor for the visible dimension indice.
116: * This is a Geotools-specific parameter.
117: */
118: public static final ParameterDescriptor VISIBLE_SAMPLE_DIMENSION = new DefaultParameterDescriptor(
119: Citations.GEOTOOLS, "VisibleSampleDimension",
120: Integer.class, // Value class (mandatory)
121: null, // Array of valid values
122: null, // Default value
123: new Integer(0), // Minimal value
124: null, // Maximal value
125: null, // Unit of measure
126: false); // Parameter is optional
127:
128: /**
129: * Constructs a default {@code "SelectSampleDimension"} operation.
130: */
131: public SelectSampleDimension() {
132: super (new DefaultParameterDescriptorGroup(
133: "SelectSampleDimension", new ParameterDescriptor[] {
134: SOURCE_0, SAMPLE_DIMENSIONS,
135: VISIBLE_SAMPLE_DIMENSION }));
136: }
137:
138: /**
139: * Applies the band select operation to a grid coverage. This method is
140: * invoked by {@link org.geotools.coverage.processing.DefaultProcessor}
141: * for the {@code "SelectSampleDimension"} operation.
142: *
143: * @param parameters List of name value pairs for the parameters.
144: * @param hints A set of rendering hints, or {@code null} if none.
145: * @return The result as a grid coverage.
146: */
147: public Coverage doOperation(final ParameterValueGroup parameters,
148: final Hints hints) {
149: return BandSelector2D.create(parameters, hints);
150: }
151: }
|