Source Code Cross Referenced for GeoTiffReaderTest.java in  » GIS » GeoTools-2.4.1 » org » geotools » gce » geotiff » 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.geotiff 
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.geotiff;
018:
019:        import java.io.File;
020:        import java.io.IOException;
021:        import java.util.logging.Logger;
022:
023:        import junit.framework.TestCase;
024:        import junit.textui.TestRunner;
025:
026:        import org.geotools.TestData;
027:        import org.geotools.coverage.grid.GridCoverage2D;
028:        import org.geotools.coverage.grid.io.AbstractGridFormat;
029:        import org.geotools.coverage.grid.io.imageio.IIOMetadataDumper;
030:        import org.geotools.factory.Hints;
031:        import org.opengis.referencing.NoSuchAuthorityCodeException;
032:
033:        /*
034:         * GeoTools - OpenSource mapping toolkit http://geotools.org (C) 2005-2006,
035:         * GeoTools Project Managment Committee (PMC) This library is free software; you
036:         * can redistribute it and/or modify it under the terms of the GNU Lesser
037:         * General Public License as published by the Free Software Foundation; version
038:         * 2.1 of the License. This library is distributed in the hope that it will be
039:         * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
040:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
041:         * General Public License for more details.
042:         */
043:        /**
044:         * Testing {@link GeoTiffReader} as well as {@link IIOMetadataDumper}.
045:         * 
046:         * @author Simone Giannecchini
047:         * @source $URL:
048:         *         http://svn.geotools.org/geotools/trunk/gt/plugin/geotiff/test/org/geotools/gce/geotiff/GeoTiffReaderTest.java $
049:         */
050:        public class GeoTiffReaderTest extends TestCase {
051:            private final static Logger LOGGER = org.geotools.util.logging.Logging
052:                    .getLogger(GeoTiffReaderTest.class.toString());
053:
054:            /**
055:             * Constructor for GeoTiffReaderTest.
056:             * 
057:             * @param arg0
058:             */
059:            public GeoTiffReaderTest(String arg0) {
060:                super (arg0);
061:            }
062:
063:            public static void main(String[] args) {
064:                TestRunner.run(GeoTiffReaderTest.class);
065:
066:            }
067:
068:            /**
069:             * testReader
070:             * 
071:             * @throws IllegalArgumentException
072:             * @throws IOException
073:             * @throws NoSuchAuthorityCodeException
074:             */
075:            public void testReader() throws IllegalArgumentException,
076:                    IOException, NoSuchAuthorityCodeException {
077:
078:                final File file = TestData.file(GeoTiffReaderTest.class, "");
079:                final File files[] = file.listFiles();
080:                final int numFiles = files.length;
081:                final AbstractGridFormat format = new GeoTiffFormat();
082:                for (int i = 0; i < numFiles; i++) {
083:                    final StringBuffer buffer = new StringBuffer();
084:                    final String path = files[i].getAbsolutePath()
085:                            .toLowerCase();
086:                    if (!path.endsWith("tif") && !path.endsWith("tiff"))
087:                        continue;
088:
089:                    buffer.append(files[i].getAbsolutePath()).append("\n");
090:                    Object o;
091:                    if (i % 2 == 0)
092:                        // testing file
093:                        o = files[i];
094:                    else
095:                        // testing url
096:                        o = files[i].toURL();
097:                    if (format.accepts(o)) {
098:                        buffer.append("ACCEPTED").append("\n");
099:
100:                        // getting a reader
101:                        final GeoTiffReader reader = new GeoTiffReader(o,
102:                                new Hints(
103:                                        Hints.FORCE_LONGITUDE_FIRST_AXIS_ORDER,
104:                                        Boolean.TRUE));
105:
106:                        if (reader != null) {
107:
108:                            // reading the coverage
109:                            final GridCoverage2D coverage = (GridCoverage2D) reader
110:                                    .read(null);
111:
112:                            // Crs and envelope
113:                            if (TestData.isInteractiveTest()) {
114:                                buffer
115:                                        .append("CRS: ")
116:                                        .append(
117:                                                coverage
118:                                                        .getCoordinateReferenceSystem2D()
119:                                                        .toWKT()).append("\n");
120:                                buffer.append("Envelope: ").append(
121:                                        coverage.getEnvelope().toString())
122:                                        .append("\n");
123:                            }
124:                            // display metadata
125:                            final IIOMetadataDumper iIOMetadataDumper = new IIOMetadataDumper(
126:                                    ((GeoTiffReader) reader).getMetadata()
127:                                            .getRootNode());
128:                            buffer.append("TIFF metadata: ").append(
129:                                    iIOMetadataDumper.getMetadata()).append(
130:                                    "\n");
131:                            // showing it
132:                            if (TestData.isInteractiveTest())
133:                                coverage.show();
134:                            else
135:                                coverage.getRenderedImage().getData();
136:
137:                        }
138:
139:                    } else
140:                        buffer.append("NOT ACCEPTED").append("\n");
141:                    if (TestData.isInteractiveTest())
142:                        LOGGER.info(buffer.toString());
143:
144:                }
145:
146:            }
147:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.