Source Code Cross Referenced for GT30ReaderWriterTest.java in  » GIS » GeoTools-2.4.1 » org » geotools » gce » gtopo30 » 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.gtopo30 
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.gtopo30;
018:
019:        import java.io.File;
020:        import java.net.URL;
021:
022:        import javax.media.jai.JAI;
023:        import javax.media.jai.RecyclingTileFactory;
024:        import javax.media.jai.TileCache;
025:
026:        import org.geotools.coverage.grid.GridCoverage2D;
027:        import org.geotools.coverage.grid.io.AbstractGridFormat;
028:        import org.geotools.resources.TestData;
029:        import org.geotools.resources.image.CoverageUtilities;
030:        import org.opengis.coverage.grid.GridCoverageReader;
031:        import org.opengis.coverage.grid.GridCoverageWriter;
032:
033:        /**
034:         * Purpose of this class is testing the ability of this plug in to read and
035:         * write back the in gtopo30 format.
036:         * 
037:         * @author Simone Giannecchini
038:         * @source $URL:
039:         *         http://svn.geotools.org/geotools/trunk/gt/plugin/gtopo30/test/org/geotools/gce/gtopo30/GT30ReaderWriterTest.java $
040:         */
041:        public class GT30ReaderWriterTest extends GT30TestBase {
042:            /**
043:             * Constructor for GT30ReaderTest.
044:             * 
045:             * @param arg0
046:             */
047:            public GT30ReaderWriterTest(String arg0) {
048:                super (arg0);
049:            }
050:
051:            /**
052:             * Testing reader and writer for gtopo. This test first of all read an
053:             * existing gtopo tessel into a coverage object, therefore it writes it back
054:             * onto the disk. Once the coverage is written back\ it loads it again
055:             * building a new coverage which is finally visualized.
056:             * 
057:             * @throws Exception
058:             */
059:            public void test() throws Exception {
060:
061:                URL statURL = TestData.url(this , (new StringBuffer(
062:                        this .fileName).append(".DEM").toString()));
063:                AbstractGridFormat format = (AbstractGridFormat) new GTopo30FormatFactory()
064:                        .createFormat();
065:
066:                // using a big tile cache
067:                final JAI jaiDef = JAI.getDefaultInstance();
068:                final TileCache cache = jaiDef.getTileCache();
069:                cache.setMemoryCapacity(64 * 1024 * 1024);
070:                cache.setMemoryThreshold(1.0f);
071:                // final TCTool tool= new TCTool();
072:
073:                // setting JAI wide hints
074:                jaiDef.setRenderingHint(JAI.KEY_CACHED_TILE_RECYCLING_ENABLED,
075:                        Boolean.TRUE);
076:
077:                // tile factory and recycler
078:                final RecyclingTileFactory recyclingFactory = new RecyclingTileFactory();
079:                jaiDef.setRenderingHint(JAI.KEY_TILE_FACTORY, recyclingFactory);
080:                jaiDef
081:                        .setRenderingHint(JAI.KEY_TILE_RECYCLER,
082:                                recyclingFactory);
083:
084:                if (format.accepts(statURL)) {
085:
086:                    /**
087:                     * 
088:                     * STEP 1 Reading the coverage into memory in order to write it down
089:                     * again
090:                     * 
091:                     */
092:                    // get a reader
093:                    GridCoverageReader reader = format.getReader(statURL);
094:
095:                    // get a grid coverage
096:                    gc = ((GridCoverage2D) reader.read(null));
097:                    assertTrue(CoverageUtilities.hasRenderingCategories(gc));
098:                    if (TestData.isInteractiveTest())
099:                        gc.show();
100:
101:                    // preparing to write it down
102:                    File testDir = TestData.file(this , "");
103:                    newDir = new File(testDir.getAbsolutePath() + "/newDir");
104:                    newDir.mkdir();
105:
106:                    // writing it down
107:                    GridCoverageWriter writer = format.getWriter(newDir);
108:                    writer.write(gc, null);
109:
110:                    /**
111:                     * 
112:                     * STEP 2 Reading back into memory the previos coverage.
113:                     * 
114:                     */
115:                    // preparing the URL
116:                    statURL = TestData.getResource(this , "newDir/"
117:                            + this .fileName + ".DEM");
118:
119:                    // read it again
120:                    reader = format.getReader(statURL);
121:                    gc = ((GridCoverage2D) reader.read(null));
122:
123:                    /**
124:                     * 
125:                     * STEP 3 Visualizing the lcoverage we just read in order to see if
126:                     * everything is fine.
127:                     * 
128:                     */
129:                    // packed view for this coverage
130:                    GridCoverage2D gc1 = gc.geophysics(false);
131:                    if (TestData.isInteractiveTest()) {
132:                        gc1.show();
133:                        // logging some info
134:                        logger.info(gc.getCoordinateReferenceSystem2D().toWKT()
135:                                + "\n" + gc.toString());
136:                        logger.info(gc1.getCoordinateReferenceSystem2D()
137:                                .toWKT()
138:                                + "\n" + gc1.toString());
139:                    } else {
140:                        gc1.getRenderedImage().getData();
141:
142:                    }
143:
144:                }
145:            }
146:
147:            public static final void main(String[] args) throws Exception {
148:                junit.textui.TestRunner.run(GT30ReaderWriterTest.class);
149:            }
150:
151:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.