Source Code Cross Referenced for GTopo30Format.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:        /*
018:         * Created on Apr 12, 2005
019:         *
020:         * TODO To change the template for this generated file go to
021:         * Window - Preferences - Java - Code Style - Code Templates
022:         */
023:        package org.geotools.gce.gtopo30;
024:
025:        import java.io.File;
026:        import java.io.IOException;
027:        import java.net.MalformedURLException;
028:        import java.net.URL;
029:        import java.util.HashMap;
030:        import java.util.logging.Level;
031:        import java.util.logging.Logger;
032:
033:        import org.geotools.coverage.grid.io.AbstractGridFormat;
034:        import org.geotools.coverage.grid.io.imageio.GeoToolsWriteParams;
035:        import org.geotools.data.DataSourceException;
036:        import org.geotools.factory.Hints;
037:        import org.geotools.parameter.DefaultParameterDescriptorGroup;
038:        import org.geotools.parameter.ParameterGroup;
039:        import org.opengis.coverage.grid.Format;
040:        import org.opengis.coverage.grid.GridCoverageReader;
041:        import org.opengis.coverage.grid.GridCoverageWriter;
042:        import org.opengis.parameter.GeneralParameterDescriptor;
043:
044:        /**
045:         * Provides basic information about the GeoTIFF format IO.
046:         * 
047:         * @author Simone Giannecchini
048:         * @author mkraemer
049:         * @source $URL:
050:         *         http://svn.geotools.org/geotools/trunk/gt/plugin/gtopo30/src/org/geotools/gce/gtopo30/GTopo30Format.java $
051:         */
052:        public final class GTopo30Format extends AbstractGridFormat implements 
053:                Format {
054:
055:            /** Logger. */
056:            private final static Logger LOGGER = org.geotools.util.logging.Logging
057:                    .getLogger("org.geotools.gce.gtopo30");
058:
059:            /**
060:             * Creates an instance and sets the metadata.
061:             */
062:            public GTopo30Format() {
063:                mInfo = new HashMap();
064:                mInfo.put("name", "Gtopo30");
065:                mInfo.put("description", "Gtopo30 Coverage Format");
066:                mInfo.put("vendor", "Geotools");
067:                mInfo.put("docURL",
068:                        "http://edcdaac.usgs.gov/gtopo30/gtopo30.asp");
069:                mInfo.put("version", "1.0");
070:
071:                // reading parameters
072:                readParameters = new ParameterGroup(
073:                        new DefaultParameterDescriptorGroup(
074:                                mInfo,
075:                                new GeneralParameterDescriptor[] { READ_GRIDGEOMETRY2D }));
076:
077:                // reading parameters
078:                writeParameters = new ParameterGroup(
079:                        new DefaultParameterDescriptorGroup(
080:                                mInfo,
081:                                new GeneralParameterDescriptor[] { GEOTOOLS_WRITE_PARAMS }));
082:            }
083:
084:            /**
085:             * Returns a reader object which you can use to read GridCoverages from a
086:             * given source
087:             * 
088:             * @param o
089:             *            the the source object. This can be a File, an URL or a String
090:             *            (representing a filename or an URL)
091:             * 
092:             * @return a GridCoverageReader object or null if the source object could
093:             *         not be accessed.
094:             */
095:            public GridCoverageReader getReader(final Object o) {
096:                return getReader(o, null);
097:            }
098:
099:            /**
100:             * Returns a writer object which you can use to write GridCoverages to a
101:             * given destination.
102:             * 
103:             * @param destination
104:             *            The destination object
105:             * 
106:             * @return a GridCoverageWriter object
107:             */
108:            public GridCoverageWriter getWriter(final Object destination) {
109:                try {
110:                    return new GTopo30Writer(destination);
111:                } catch (DataSourceException e) {
112:                    if (LOGGER.isLoggable(Level.WARNING))
113:                        LOGGER.log(Level.WARNING, e.getLocalizedMessage(), e);
114:                    return null;
115:                }
116:            }
117:
118:            /**
119:             * Returns a writer object which you can use to write GridCoverages to a
120:             * given destination.
121:             * 
122:             * @param destination
123:             *            The destination object
124:             * 
125:             * @return a GridCoverageWriter object
126:             * @throws DataSourceException
127:             */
128:            public GridCoverageWriter getWriter(final Object destination,
129:                    Hints hints) {
130:                try {
131:                    return new GTopo30Writer(destination, hints);
132:                } catch (DataSourceException e) {
133:                    if (LOGGER.isLoggable(Level.WARNING))
134:                        LOGGER.log(Level.WARNING, e.getLocalizedMessage(), e);
135:                    return null;
136:                }
137:            }
138:
139:            /**
140:             * Checks if the GTopo30DataSource supports a given file
141:             * 
142:             * @param o
143:             *            the source object to test for compatibility with this format.
144:             *            This can be a File, an URL or a String (representing a
145:             *            filename or an URL)
146:             * 
147:             * @return if the source object is compatible
148:             */
149:            public boolean accepts(final Object o) {
150:                URL urlToUse;
151:
152:                if (o instanceof  File) {
153:                    try {
154:                        urlToUse = ((File) o).toURL();
155:                    } catch (MalformedURLException e) {
156:                        if (LOGGER.isLoggable(Level.FINE))
157:                            LOGGER.log(Level.FINE, e.getLocalizedMessage(), e);
158:                        return false;
159:                    }
160:                } else if (o instanceof  URL) {
161:                    // we only allow files
162:                    urlToUse = (URL) o;
163:                } else if (o instanceof  String) {
164:                    try {
165:                        // is it a filename?
166:                        urlToUse = new File((String) o).toURL();
167:                    } catch (MalformedURLException e) {
168:                        // is it a URL
169:                        try {
170:                            urlToUse = new URL((String) o);
171:                        } catch (MalformedURLException e1) {
172:                            if (LOGGER.isLoggable(Level.FINE))
173:                                LOGGER.log(Level.FINE, e.getLocalizedMessage(),
174:                                        e);
175:                            return false;
176:                        }
177:                    }
178:                } else {
179:                    return false;
180:                }
181:
182:                // trying to create a reader
183:                try {
184:                    final GTopo30Reader reader = new GTopo30Reader(urlToUse);
185:                } catch (IOException e) {
186:                    if (LOGGER.isLoggable(Level.FINE))
187:                        LOGGER.log(Level.FINE, e.getLocalizedMessage(), e);
188:                    return false;
189:                }
190:
191:                return true;
192:            }
193:
194:            /**
195:             * Returns a reader object which you can use to read GridCoverages from a
196:             * given source
197:             * 
198:             * @param o
199:             *            the the source object. This can be a File, an URL or a String
200:             *            (representing a filename or an URL)
201:             * 
202:             * @return a GridCoverageReader object or null if the source object could
203:             *         not be accessed.
204:             */
205:            public GridCoverageReader getReader(final Object o, Hints hints) {
206:
207:                try {
208:                    return new GTopo30Reader(o);
209:                } catch (IOException e) {
210:                    if (LOGGER.isLoggable(Level.SEVERE))
211:                        LOGGER.log(Level.SEVERE, e.getLocalizedMessage(), e);
212:                    return null;
213:                }
214:
215:            }
216:
217:            /**
218:             * Always returns null since for the moment there are no
219:             * {@link GeoToolsWriteParams} availaible for this format.
220:             * 
221:             * @return always null.
222:             */
223:            public GeoToolsWriteParams getDefaultImageIOWriteParameters() {
224:                return null;
225:            }
226:
227:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.