Source Code Cross Referenced for Extrema.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) 2005-2007, Geotools Project Managment Committee (PMC)
005:         *    (C) 2007, GeoSolutions S.A.S.
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:        package org.geotools.coverage.processing.operation;
018:
019:        import java.awt.Shape;
020:        import java.awt.image.RenderedImage;
021:        import java.util.Collections;
022:        import java.util.HashMap;
023:        import java.util.Map;
024:        import java.util.logging.Logger;
025:
026:        import javax.media.jai.JAI;
027:        import javax.media.jai.RenderedOp;
028:        import javax.media.jai.operator.ExtremaDescriptor;
029:
030:        import org.geotools.coverage.grid.GridCoverage2D;
031:        import org.geotools.coverage.processing.AbstractStatisticsOperationJAI;
032:        import org.opengis.coverage.processing.OperationNotFoundException;
033:        import org.opengis.parameter.ParameterValueGroup;
034:        import org.opengis.referencing.crs.CoordinateReferenceSystem;
035:        import org.opengis.referencing.operation.MathTransform;
036:        import org.opengis.util.InternationalString;
037:
038:        /**
039:         * This operation simply wraps JAI Extrema operations described by
040:         * {@link ExtremaDescriptor} inside a GeoTools operation in order to make it
041:         * spatial-aware.
042:         * 
043:         * <p>
044:         * For the moment this is a very simple wrap. Plans on the 2.4 na successive
045:         * versions of this operation are to add the ability to to use spatial ROIs and
046:         * to specific Spatial subsampling. As of now, ROI has to be a Java2D
047:         * {@link Shape} subclass and the parameters to control x and y subsamplings got
048:         * to be Integer, which means pixel-aware.
049:         * 
050:         * <p>
051:         * For more information on how the underlying {@link JAI} operators works you
052:         * can have a look here: <a
053:         * href="http://download.java.net/media/jai/javadoc/1.1.3/jai-apidocs/javax/media/jai/operator/ExtremaDescriptor.html">ExtremaDescriptor</a>
054:         * 
055:         * <p>
056:         * <strong>How to use this operation</strong> Here is a very simple example on
057:         * how to use this operation in order to the minimum and maixumum of the source
058:         * coverage.
059:         * 
060:         * <code>
061:         * final OperationJAI op=new OperationJAI("Extrema");
062:         * ParameterValueGroup params = op.getParameters();
063:         * params.parameter("Source").setValue(coverage);
064:         * coverage=(GridCoverage2D) op.doOperation(params,null);
065:         * System.out.println(((double[])coverage.getProperty("minimum"))[0]);
066:         * System.out.println(((double[])coverage.getProperty("minimum"))[1]);
067:         * System.out.println(((double[])coverage.getProperty("minimum"))[2]);
068:         * System.out.println(((double[])coverage.getProperty("maximum"))[0]);
069:         * System.out.println(((double[])coverage.getProperty("maximum"))[1]);
070:         * System.out.println(((double[])coverage.getProperty("maximum"))[2]);
071:         * </code>
072:         * 
073:         * @author Simone Giannecchini
074:         * @since 2.4
075:         * 
076:         */
077:        public class Extrema extends AbstractStatisticsOperationJAI {
078:
079:            /**
080:             * Serial number for interoperability with different versions.
081:             */
082:            private static final long serialVersionUID = 7731039381590398047L;
083:
084:            /** {@link Logger} for this class. */
085:            public final static Logger LOGGER = org.geotools.util.logging.Logging
086:                    .getLogger("org.geotools.coverage.processing.operation");
087:
088:            /** {@link String} key for getting the minimum vector. */
089:            public final static String GT_SYNTHETIC_PROPERTY_MINIMUM = "minimum";
090:
091:            /** {@link String} key for getting the maximum vector. */
092:            public final static String GT_SYNTHETIC_PROPERTY_MAXIMUM = "maximum";
093:
094:            /**
095:             * Constructs a default {@code "Extrema"} operation.
096:             */
097:            public Extrema() throws OperationNotFoundException {
098:                super (getOperationDescriptor("Extrema"));
099:
100:            }
101:
102:            /**
103:             * This operation MUST be performed on the geophysics data for this
104:             * {@link GridCoverage2D}.
105:             * 
106:             * @param parameters
107:             *            {@link ParameterValueGroup} that describes this operation
108:             * @return always true.
109:             */
110:            protected boolean computeOnGeophysicsValues(
111:                    ParameterValueGroup parameters) {
112:                return true;
113:            }
114:
115:            /**
116:             * Prepare the minimum and maximum properties for this extream operation.
117:             * 
118:             * <p>
119:             * See <a
120:             * href="http://download.java.net/media/jai/javadoc/1.1.3/jai-apidocs/javax/media/jai/operator/ExtremaDescriptor.html">ExtremaDescriptor</a>
121:             * for more info.
122:             * 
123:             * @see OperationJAI#getProperties(RenderedImage, CoordinateReferenceSystem,
124:             *      InternationalString, MathTransform, GridCoverage2D[],
125:             *      org.geotools.coverage.processing.OperationJAI.Parameters),
126:             */
127:            protected Map getProperties(RenderedImage data,
128:                    CoordinateReferenceSystem crs, InternationalString name,
129:                    MathTransform toCRS, GridCoverage2D[] sources,
130:                    Parameters parameters) {
131:                // /////////////////////////////////////////////////////////////////////
132:                //
133:                // If and only if data is a RenderedOp we prepara the properties for
134:                // minimum and maximum as the output of the extrema operation.
135:                //
136:                // /////////////////////////////////////////////////////////////////////
137:                if (data instanceof  RenderedOp) {
138:                    // XXX remove me with 1.5
139:                    final RenderedOp result = (RenderedOp) data;
140:
141:                    // get the properties
142:                    final double[] maximums = (double[]) result
143:                            .getProperty(GT_SYNTHETIC_PROPERTY_MAXIMUM);
144:                    final double[] minimums = (double[]) result
145:                            .getProperty(GT_SYNTHETIC_PROPERTY_MINIMUM);
146:
147:                    // return the map
148:                    final Map synthProp = new HashMap(2);
149:                    synthProp.put(GT_SYNTHETIC_PROPERTY_MINIMUM, minimums);
150:                    synthProp.put(GT_SYNTHETIC_PROPERTY_MAXIMUM, maximums);
151:                    return Collections.unmodifiableMap(synthProp);
152:
153:                }
154:                return super.getProperties(data, crs, name, toCRS, sources,
155:                        parameters);
156:            }
157:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.