Source Code Cross Referenced for Interpolate.java in  » GIS » GeoTools-2.4.1 » org » geotools » coverage » processing » operation » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » GIS » GeoTools 2.4.1 » org.geotools.coverage.processing.operation 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *    GeoTools - OpenSource mapping toolkit
003:         *    http://geotools.org
004:         *    (C) 2003-2006, Geotools Project Managment Committee (PMC)
005:         *    (C) 2001, 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:        // J2SE dependencies
023:        import java.lang.reflect.Array;
024:
025:        // JAI dependencies
026:        import javax.media.jai.Interpolation;
027:
028:        // OpenGIS dependencies
029:        import org.opengis.coverage.Coverage;
030:        import org.opengis.parameter.ParameterDescriptor;
031:        import org.opengis.parameter.ParameterValueGroup;
032:
033:        // Geotools dependencies
034:        import org.geotools.factory.Hints;
035:        import org.geotools.coverage.grid.GridCoverage2D;
036:        import org.geotools.coverage.grid.Interpolator2D;
037:        import org.geotools.coverage.processing.Operation2D;
038:        import org.geotools.metadata.iso.citation.Citations;
039:        import org.geotools.parameter.DefaultParameterDescriptor;
040:        import org.geotools.parameter.DefaultParameterDescriptorGroup;
041:        import org.geotools.resources.image.ImageUtilities;
042:
043:        /**
044:         * Specifies the interpolation type to be used to interpolate values for points which fall between
045:         * grid cells. The default value is nearest neighbor. The new interpolation type operates on all
046:         * sample dimensions. Possible values for type are: {@code "NearestNeighbor"}, {@code "Bilinear"}
047:         * and {@code "Bicubic"} (the {@code "Optimal"} interpolation type is currently not supported).
048:         * <p>
049:         * <strong>Geotools extension:</strong><br>
050:         * The Geotools implementation provides two extensions to OpenGIS specification: First, it accepts
051:         * also an {@link javax.media.jai.Interpolation} argument type, for interoperability with
052:         * <A HREF="http://java.sun.com/products/java-media/jai/">Java Advanced Imaging</A>. Second, it
053:         * accepts also an array of {@link java.lang.String} or {@link javax.media.jai.Interpolation}
054:         * objects. When an array is specified, the first interpolation in the array is applied. If this
055:         * interpolation returns a {@code NaN} value, then the second interpolation is tried as a fallback.
056:         * If the second interpolation returns also a {@code NaN} value, then the third one is tried and so
057:         * on until an interpolation returns a real number or until we reach the end of interpolation list.
058:         * This behavior is convenient when processing remote sensing images of geophysics data, for example
059:         * <cite>Sea Surface Temperature</cite> (SST), in which clouds may mask many pixels (i.e. set them
060:         * to some {@code NaN} values). Because {@code "Bicubic"} interpolation needs 4&times;4 pixels while
061:         * {@code "Bilinear"} interpolation needs only 2x2 pixels, the {@code "Bilinear"} interpolation is
062:         * less likely to fails because of clouds ({@code NaN} values) than the {@code "Bicubic"} one
063:         * (note: only one {@code NaN} value is enough to make an interpolation fails). One can workaround
064:         * the problem by trying a bicubic interpolation first, then a linear interpolation if
065:         * {@code "Bicubic"} failed at a particular location, <cite>etc.</cite> This behavior can be
066:         * specified with the following {@code "Type"} argument:
067:         * <code>new String[]{"Bicubic", "Bilinear", "NearestNeighbor"}</code>.
068:         *
069:         * <P><STRONG>Name:</STRONG>&nbsp;<CODE>"Interpolate"</CODE><BR>
070:         *    <STRONG>JAI operator:</STRONG>&nbsp;N/A<BR>
071:         *    <STRONG>Parameters:</STRONG></P>
072:         * <table border='3' cellpadding='6' bgcolor='F4F8FF'>
073:         *   <tr bgcolor='#B9DCFF'>
074:         *     <th>Name</th>
075:         *     <th>Class</th>
076:         *     <th>Default value</th>
077:         *     <th>Minimum value</th>
078:         *     <th>Maximum value</th>
079:         *   </tr>
080:         *   <tr>
081:         *     <td>{@code "Source"}</td>
082:         *     <td>{@link org.geotools.coverage.grid.GridCoverage2D}</td>
083:         *     <td align="center">N/A</td>
084:         *     <td align="center">N/A</td>
085:         *     <td align="center">N/A</td>
086:         *   </tr>
087:         *   <tr>
088:         *     <td>{@code "Type"}</td>
089:         *     <td>{@link java.lang.CharSequence}</td>
090:         *     <td>"NearestNeighbor"</td>
091:         *     <td align="center">N/A</td>
092:         *     <td align="center">N/A</td>
093:         *   </tr>
094:         * </table>
095:         *
096:         * @since 2.2
097:         * @source $URL: http://svn.geotools.org/geotools/tags/2.4.1/modules/library/coverage/src/main/java/org/geotools/coverage/processing/operation/Interpolate.java $
098:         * @version $Id: Interpolate.java 20970 2006-08-11 07:53:22Z jgarnett $
099:         * @author Martin Desruisseaux
100:         *
101:         * @see org.geotools.coverage.processing.Operations#interpolate
102:         * @see Interpolator2D
103:         */
104:        public class Interpolate extends Operation2D {
105:            /**
106:             * Serial number for interoperability with different versions.
107:             */
108:            private static final long serialVersionUID = 6742127682733620661L;
109:
110:            /**
111:             * The parameter descriptor for the interpolation type.
112:             */
113:            public static final ParameterDescriptor TYPE = new DefaultParameterDescriptor(
114:                    Citations.OGC, "Type", Object.class, // Value class (mandatory)
115:                    null, // Array of valid values
116:                    "NearestNeighbor", // Default value
117:                    null, // Minimal value
118:                    null, // Maximal value
119:                    null, // Unit of measure
120:                    true); // Parameter is mandatory
121:
122:            /**
123:             * Constructs an {@code "Interpolate"} operation.
124:             */
125:            public Interpolate() {
126:                super (new DefaultParameterDescriptorGroup(Citations.OGC,
127:                        "Interpolate", new ParameterDescriptor[] { SOURCE_0,
128:                                TYPE }));
129:            }
130:
131:            /**
132:             * Applies an interpolation to a grid coverage. This method is invoked
133:             * by {@link org.geotools.coverage.processing.DefaultProcessor} for the
134:             * {@code "Interpolate"} operation.
135:             */
136:            public Coverage doOperation(final ParameterValueGroup parameters,
137:                    final Hints hints) {
138:                final GridCoverage2D source = (GridCoverage2D) parameters
139:                        .parameter("Source").getValue();
140:                final Object type = parameters.parameter("Type").getValue();
141:                final Interpolation[] interpolations;
142:                if (type.getClass().isArray()) {
143:                    interpolations = new Interpolation[Array.getLength(type)];
144:                    for (int i = 0; i < interpolations.length; i++) {
145:                        interpolations[i] = ImageUtilities
146:                                .toInterpolation(Array.get(type, i));
147:                    }
148:                } else {
149:                    interpolations = new Interpolation[] { ImageUtilities
150:                            .toInterpolation(type) };
151:                }
152:                return Interpolator2D.create(source, interpolations);
153:            }
154:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.