Source Code Cross Referenced for LazyRasterLayer.java in  » GIS » deegree » org » deegree » graphics » 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 » deegree » org.deegree.graphics 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        //$HeadURL: https://svn.wald.intevation.org/svn/deegree/base/trunk/src/org/deegree/graphics/LazyRasterLayer.java $
002:        /*----------------    FILE HEADER  ------------------------------------------
003:
004:         This file is part of deegree.
005:         Copyright (C) 2001-2008 by:
006:         EXSE, Department of Geography, University of Bonn
007:         http://www.giub.uni-bonn.de/deegree/
008:         lat/lon GmbH
009:         http://www.lat-lon.de
010:
011:         This library is free software; you can redistribute it and/or
012:         modify it under the terms of the GNU Lesser General Public
013:         License as published by the Free Software Foundation; either
014:         version 2.1 of the License, or (at your option) any later version.
015:
016:         This library is distributed in the hope that it will be useful,
017:         but WITHOUT ANY WARRANTY; without even the implied warranty of
018:         MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
019:         Lesser General Public License for more details.
020:
021:         You should have received a copy of the GNU Lesser General Public
022:         License along with this library; if not, write to the Free Software
023:         Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
024:
025:         Contact:
026:
027:         Andreas Poth
028:         lat/lon GmbH
029:         Aennchenstr. 19
030:         53177 Bonn
031:         Germany
032:         E-Mail: poth@lat-lon.de
033:
034:         Prof. Dr. Klaus Greve
035:         Department of Geography
036:         University of Bonn
037:         Meckenheimer Allee 166
038:         53115 Bonn
039:         Germany
040:         E-Mail: greve@giub.uni-bonn.de
041:
042:         ---------------------------------------------------------------------------*/
043:        package org.deegree.graphics;
044:
045:        import java.io.IOException;
046:        import java.util.ArrayList;
047:        import java.util.List;
048:
049:        import org.deegree.framework.log.ILogger;
050:        import org.deegree.framework.log.LoggerFactory;
051:        import org.deegree.io.JDBCConnection;
052:        import org.deegree.io.oraclegeoraster.GeoRasterDescription;
053:        import org.deegree.model.coverage.grid.Format;
054:        import org.deegree.model.coverage.grid.GridCoverage;
055:        import org.deegree.model.coverage.grid.GridCoverageExchange;
056:        import org.deegree.model.coverage.grid.GridCoverageReader;
057:        import org.deegree.model.crs.CRSFactory;
058:        import org.deegree.model.crs.CoordinateSystem;
059:        import org.deegree.model.crs.UnknownCRSException;
060:        import org.deegree.model.spatialschema.Envelope;
061:        import org.deegree.model.spatialschema.GeometryFactory;
062:        import org.deegree.ogcwebservices.InvalidParameterValueException;
063:        import org.deegree.ogcwebservices.wcs.configuration.Directory;
064:        import org.deegree.ogcwebservices.wcs.configuration.DirectoryResolution;
065:        import org.deegree.ogcwebservices.wcs.configuration.Extension;
066:        import org.deegree.ogcwebservices.wcs.configuration.File;
067:        import org.deegree.ogcwebservices.wcs.configuration.FileResolution;
068:        import org.deegree.ogcwebservices.wcs.configuration.OracleGeoRasterResolution;
069:        import org.deegree.ogcwebservices.wcs.configuration.Resolution;
070:        import org.deegree.ogcwebservices.wcs.configuration.Shape;
071:        import org.deegree.ogcwebservices.wcs.configuration.ShapeResolution;
072:        import org.deegree.ogcwebservices.wcs.describecoverage.CoverageOffering;
073:
074:        /**
075:         * 
076:         * 
077:         * 
078:         * @author <a href="mailto:poth@lat-lon.de">Andreas Poth</a>
079:         * @author last edited by: $Author: apoth $
080:         * 
081:         * @version $Revision: 10225 $, $Date: 2008-02-21 05:42:03 -0800 (Thu, 21 Feb 2008) $
082:         */
083:        public class LazyRasterLayer extends AbstractLayer {
084:
085:            private ILogger LOG = LoggerFactory
086:                    .getLogger(LazyRasterLayer.class);
087:
088:            private Extension resource;
089:
090:            private CoverageOffering coverageOffering;
091:
092:            /**
093:             * 
094:             * @param name
095:             * @param coverageOffering
096:             * @throws Exception
097:             */
098:            public LazyRasterLayer(String name,
099:                    CoverageOffering coverageOffering) throws Exception {
100:                super (name);
101:                this .coverageOffering = coverageOffering;
102:                resource = coverageOffering.getExtension();
103:            }
104:
105:            /**
106:             * 
107:             * @param name
108:             * @param crs
109:             * @param coverageOffering
110:             * @throws Exception
111:             */
112:            public LazyRasterLayer(String name, CoordinateSystem crs,
113:                    CoverageOffering coverageOffering) throws Exception {
114:                super (name, crs);
115:                this .coverageOffering = coverageOffering;
116:                if (coverageOffering != null) {
117:                    resource = coverageOffering.getExtension();
118:                }
119:            }
120:
121:            /**
122:             * @param crs
123:             * @throws Exception
124:             * 
125:             */
126:            public void setCoordinatesSystem(CoordinateSystem crs)
127:                    throws Exception {
128:                // not supported yet
129:            }
130:
131:            /*
132:             * (non-Javadoc)
133:             * 
134:             * @see org.deegree.graphics.AbstractLayer#getBoundingBox()
135:             */
136:            @Override
137:            public Envelope getBoundingBox() {
138:                return coverageOffering.getDomainSet().getSpatialDomain()
139:                        .getEnvelops()[0];
140:            }
141:
142:            /**
143:             * 
144:             * @param envelope
145:             * @param resolution
146:             * @return
147:             * @throws IOException
148:             * @throws InvalidParameterValueException
149:             */
150:            public GridCoverage getRaster(Envelope envelope, double resolution)
151:                    throws InvalidParameterValueException, IOException {
152:
153:                Resolution[] resolutions = resource.getResolutions(resolution);
154:
155:                String nativeCRS = coverageOffering.getSupportedCRSs()
156:                        .getNativeSRSs()[0].getCodes()[0];
157:                CoordinateSystem crs;
158:                try {
159:                    crs = CRSFactory.create(nativeCRS);
160:                } catch (UnknownCRSException e) {
161:                    throw new InvalidParameterValueException(e);
162:                }
163:                envelope = GeometryFactory.createEnvelope(envelope.getMin(),
164:                        envelope.getMax(), crs);
165:
166:                GridCoverageReader reader = null;
167:                if (resolutions[0] instanceof  FileResolution) {
168:                    reader = getFileReader(resolutions, envelope);
169:                } else if (resolutions[0] instanceof  ShapeResolution) {
170:                    reader = getShapeReader(resolutions, envelope);
171:                } else if (resolutions[0] instanceof  DirectoryResolution) {
172:                    reader = getDirectoryReader(resolutions, envelope);
173:                } else if (resolutions[0] instanceof  OracleGeoRasterResolution) {
174:                    reader = getOracleGeoRasterReader(resolutions, envelope);
175:                } else {
176:                    throw new InvalidParameterValueException(
177:                            "not supported coverage resolution: "
178:                                    + resolutions[0].getClass().getName());
179:                }
180:                return reader.read(null);
181:            }
182:
183:            /**
184:             * 
185:             * @param resolutions
186:             * @param env
187:             * @return
188:             * @throws IOException
189:             * @throws InvalidParameterValueException
190:             */
191:            private GridCoverageReader getDirectoryReader(
192:                    Resolution[] resolutions, Envelope env) throws IOException,
193:                    InvalidParameterValueException {
194:
195:                LOG.logInfo("reading coverage from directories");
196:
197:                Directory[] dirs = ((DirectoryResolution) resolutions[0])
198:                        .getDirectories(env);
199:
200:                GridCoverageExchange gce = new GridCoverageExchange(null);
201:                Format format = new Format(coverageOffering
202:                        .getSupportedFormats().getNativeFormat());
203:
204:                return gce.getReader(dirs, coverageOffering, env, format);
205:            }
206:
207:            /**
208:             * 
209:             * @param resolutions
210:             * @param env
211:             * @return
212:             * @throws IOException
213:             * @throws InvalidParameterValueException
214:             */
215:            private GridCoverageReader getFileReader(Resolution[] resolutions,
216:                    Envelope env) throws IOException,
217:                    InvalidParameterValueException {
218:
219:                LOG.logInfo("reading coverage from files");
220:
221:                File[] files = ((FileResolution) resolutions[0]).getFiles();
222:                List<File> list = new ArrayList<File>();
223:                for (int i = 0; i < files.length; i++) {
224:                    Envelope fileEnv = files[i].getEnvelope();
225:                    if (fileEnv.intersects(env)) {
226:                        list.add(files[i]);
227:                    }
228:                }
229:                files = list.toArray(new File[list.size()]);
230:
231:                GridCoverageExchange gce = new GridCoverageExchange(null);
232:                Format format = new Format(coverageOffering
233:                        .getSupportedFormats().getNativeFormat());
234:
235:                return gce.getReader(files, coverageOffering, env, format);
236:            }
237:
238:            /**
239:             * 
240:             * @param resolutions
241:             * @param env
242:             * @return
243:             * @throws InvalidParameterValueException
244:             * @throws IOException
245:             */
246:            private GridCoverageReader getOracleGeoRasterReader(
247:                    Resolution[] resolutions, Envelope env)
248:                    throws InvalidParameterValueException, IOException {
249:
250:                LOG.logInfo("reading coverage from oracle georaster");
251:
252:                JDBCConnection jdbc = ((OracleGeoRasterResolution) resolutions[0])
253:                        .getJDBCConnection();
254:                String table = ((OracleGeoRasterResolution) resolutions[0])
255:                        .getTable();
256:                String rdtTable = ((OracleGeoRasterResolution) resolutions[0])
257:                        .getRdtTable();
258:                String column = ((OracleGeoRasterResolution) resolutions[0])
259:                        .getColumn();
260:                String identification = ((OracleGeoRasterResolution) resolutions[0])
261:                        .getIdentification();
262:                int level = ((OracleGeoRasterResolution) resolutions[0])
263:                        .getLevel();
264:                GeoRasterDescription grd = new GeoRasterDescription(jdbc,
265:                        table, rdtTable, column, identification, level);
266:
267:                GridCoverageExchange gce = new GridCoverageExchange(null);
268:                Format format = new Format(coverageOffering
269:                        .getSupportedFormats().getNativeFormat());
270:
271:                return gce.getReader(grd, coverageOffering, env, format);
272:
273:            }
274:
275:            /**
276:             * 
277:             * @param resolutions
278:             * @param env
279:             * @return
280:             * @throws IOException
281:             * @throws InvalidParameterValueException
282:             */
283:            private GridCoverageReader getShapeReader(Resolution[] resolutions,
284:                    Envelope env) throws IOException,
285:                    InvalidParameterValueException {
286:
287:                LOG.logInfo("reading coverage from shapes");
288:
289:                Shape shape = ((ShapeResolution) resolutions[0]).getShape();
290:
291:                GridCoverageExchange gce = new GridCoverageExchange(null);
292:                Format format = new Format(coverageOffering
293:                        .getSupportedFormats().getNativeFormat());
294:                return gce.getReader(shape, coverageOffering, env, format);
295:
296:            }
297:
298:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.