Source Code Cross Referenced for ArcGridVisualizationTest.java in  » GIS » GeoTools-2.4.1 » org » geotools » gce » arcgrid » 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.gce.arcgrid 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *    Geotools2 - OpenSource mapping toolkit
003:         *    http://geotools.org
004:         *    (C) 2002, Geotools Project Managment Committee (PMC)
005:         *
006:         *    This library is free software; you can redistribute it and/or
007:         *    modify it under the terms of the GNU Lesser General Public
008:         *    License as published by the Free Software Foundation;
009:         *    version 2.1 of the License.
010:         *
011:         *    This library is distributed in the hope that it will be useful,
012:         *    but WITHOUT ANY WARRANTY; without even the implied warranty of
013:         *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
014:         *    Lesser General Public License for more details.
015:         *
016:         */
017:        package org.geotools.gce.arcgrid;
018:
019:        import java.awt.Rectangle;
020:        import java.io.File;
021:        import java.io.FileInputStream;
022:        import java.io.IOException;
023:        import java.util.zip.GZIPInputStream;
024:
025:        import javax.imageio.ImageIO;
026:        import javax.imageio.stream.ImageInputStream;
027:
028:        import org.geotools.coverage.grid.GeneralGridRange;
029:        import org.geotools.coverage.grid.GridCoverage2D;
030:        import org.geotools.coverage.grid.GridGeometry2D;
031:        import org.geotools.coverage.grid.io.AbstractGridFormat;
032:        import org.geotools.geometry.GeneralEnvelope;
033:        import org.geotools.referencing.CRS;
034:        import org.geotools.test.TestData;
035:        import org.geotools.resources.coverage.CoverageUtilities;
036:        import org.opengis.coverage.grid.GridCoverageReader;
037:        import org.opengis.parameter.GeneralParameterValue;
038:        import org.opengis.parameter.ParameterValueGroup;
039:
040:        /**
041:         * <p>
042:         * Title: TestArcGridClass
043:         * </p>
044:         * 
045:         * <p>
046:         * Description: Testing ArcGrid ascii grids related classes.
047:         * </p>
048:         * 
049:         * <p>
050:         * Copyright: Copyright (c) 2005 Simone Giannecchini
051:         * </p>
052:         * 
053:         * <p>
054:         * Company:
055:         * </p>
056:         * 
057:         * @author <a href="mailto:simboss1@gmil.com">Simone Giannecchini (simboss)</a>
058:         * @source $URL: http://svn.geotools.org/geotools/tags/2.4.1/modules/plugin/arcgrid/src/test/java/org/geotools/gce/arcgrid/ArcGridVisualizationTest.java $
059:         * @version 1.0
060:         */
061:        public final class ArcGridVisualizationTest extends
062:                ArcGridTestCaseAdapter {
063:
064:            /**
065:             * Creates a new instance of ArcGridReadWriteTest
066:             * 
067:             * @param name
068:             */
069:            public ArcGridVisualizationTest(String name) {
070:                super (name);
071:
072:            }
073:
074:            public static final void main(String[] args) throws Exception {
075:                junit.textui.TestRunner.run(ArcGridVisualizationTest.class);
076:            }
077:
078:            public void testVisualization() throws Exception {
079:
080:                LOGGER.info("testing visualization of precip30min.asc");
081:                // read in the grid coverage
082:                final GridCoverageReader reader = new ArcGridReader(TestData
083:                        .file(this , "arcgrid/precip30min.asc"));
084:
085:                ParameterValueGroup params;
086:                params = reader.getFormat().getReadParameters();
087:
088:                final GeneralEnvelope envelope = new GeneralEnvelope(
089:                        new double[] { -180, -90 }, new double[] { 180, 90 });
090:                envelope.setCoordinateReferenceSystem(CRS.decode("EPSG:4326"));
091:                params.parameter(
092:                        AbstractGridFormat.READ_GRIDGEOMETRY2D.getName()
093:                                .toString()).setValue(
094:                        new GridGeometry2D(new GeneralGridRange(new Rectangle(
095:                                0, 0, 400, 300)), envelope));
096:                GeneralParameterValue[] gpv = { params
097:                        .parameter(AbstractGridFormat.READ_GRIDGEOMETRY2D
098:                                .getName().toString()) };
099:
100:                GridCoverage2D gc = (GridCoverage2D) reader.read(gpv);
101:
102:                assertTrue(CoverageUtilities.hasRenderingCategories(gc));
103:
104:                if (TestData.isInteractiveTest()) {
105:                    gc.show();
106:                } else
107:                    gc.getRenderedImage().getData();
108:                if (TestData.isInteractiveTest()) {
109:                    // printing CRS information
110:                    LOGGER.info(gc.getCoordinateReferenceSystem().toWKT());
111:                    LOGGER.info(gc.getEnvelope().toString());
112:                }
113:
114:            }
115:
116:            /**
117:             * This test tries to read GZipped ascii grids first by supplying the
118:             * {@link ArcGridReader} with a {@link File} that points to a gzipped
119:             * coverage, second by opening up a {@link GZIPInputStream} and asking
120:             * {@link ImageIO} to wrap it with an {@link ImageInputStream}.
121:             * 
122:             * @throws IOException
123:             */
124:            public void testReadFileGZip() throws IOException {
125:                LOGGER.info("Reading the coverage through a file");
126:                // get a gzipped ascii grid
127:                final File f = TestData.file(this , "arcgrid/spearfish.asc.gz");
128:                // Reading the coverage through a file
129:                GridCoverageReader reader = new ArcGridReader(f);
130:                final GridCoverage2D gc1 = (GridCoverage2D) reader.read(null);
131:
132:                LOGGER
133:                        .info("Reading the gzipped coverage through an ImageInputStream");
134:                // Reading the coverage through an ImageInputStream
135:                final ImageInputStream iiStream = ImageIO
136:                        .createImageInputStream(new GZIPInputStream(
137:                                new FileInputStream(f)));
138:                reader = new ArcGridReader(iiStream);
139:                final GridCoverage2D gc2 = (GridCoverage2D) reader.read(null);
140:
141:                LOGGER
142:                        .info(" Reading the gzipped coverage through an InputStream");
143:                // Reading the coverage through an InputStream
144:                reader = new ArcGridReader(new GZIPInputStream(
145:                        new FileInputStream(f)));
146:                final GridCoverage2D gc3 = (GridCoverage2D) reader.read(null);
147:
148:                LOGGER.info("Reading the gzipped coverage through a URL");
149:                // Reading the coverage through a URL
150:                reader = new ArcGridReader(f.toURL());
151:                final GridCoverage2D gc4 = (GridCoverage2D) reader.read(null);
152:
153:                // show the coverage or try to load the data
154:                if (TestData.isInteractiveTest()) {
155:                    gc1.show();
156:                    gc2.show();
157:                    gc3.show();
158:                    gc4.show();
159:                } else {
160:                    gc1.getRenderedImage().getData();
161:                    gc2.getRenderedImage().getData();
162:                    gc3.getRenderedImage().getData();
163:                    gc4.getRenderedImage().getData();
164:                }
165:            }
166:
167:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.