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


001:        package org.geotools.data.ogr;
002:
003:        import java.io.IOException;
004:        import java.util.NoSuchElementException;
005:
006:        import org.gdal.ogr.DataSource;
007:        import org.gdal.ogr.Layer;
008:        import org.geotools.data.FeatureReader;
009:        import org.geotools.feature.Feature;
010:        import org.geotools.feature.FeatureType;
011:        import org.geotools.feature.IllegalAttributeException;
012:
013:        import com.vividsolutions.jts.geom.GeometryFactory;
014:
015:        /**
016:         * An OGR feature reader, reads data from the provided layer.<br>
017:         * It assumes eventual filters have already been set on it, and will extract
018:         * only the
019:         * 
020:         * @author aaime
021:         */
022:        public class OGRFeatureReader implements  FeatureReader {
023:
024:            DataSource ds;
025:
026:            Layer layer;
027:
028:            FeatureType schema;
029:
030:            org.gdal.ogr.Feature curr;
031:
032:            private FeatureMapper mapper;
033:
034:            boolean layerCompleted;
035:
036:            public OGRFeatureReader(DataSource ds, Layer layer,
037:                    FeatureType schema) {
038:                this .ds = ds;
039:                this .layer = layer;
040:                this .schema = schema;
041:                this .layer.ResetReading();
042:                this .layerCompleted = false;
043:                // TODO: use the most appropriate Geometry Factory once the SPI system
044:                // allows us to provide such an hint
045:                this .mapper = new FeatureMapper(new GeometryFactory());
046:            }
047:
048:            public void close() throws IOException {
049:                if (curr != null) {
050:                    curr.delete();
051:                    curr = null;
052:                }
053:                if (layer != null) {
054:                    layer.delete();
055:                    layer = null;
056:                }
057:                if (ds != null) {
058:                    ds.delete();
059:                    ds = null;
060:                }
061:                schema = null;
062:            }
063:
064:            protected void finalize() throws Throwable {
065:                close();
066:            }
067:
068:            public FeatureType getFeatureType() {
069:                return schema;
070:            }
071:
072:            public boolean hasNext() throws IOException {
073:                // ugly, but necessary to close the reader when getting to the end, because
074:                // it would break feature appending otherwise (the reader is used in feature
075:                // writing too)
076:                if (layerCompleted)
077:                    return false;
078:
079:                if (curr != null)
080:                    return true;
081:                boolean hasNext = (curr = layer.GetNextFeature()) != null;
082:                if (!hasNext)
083:                    layerCompleted = true;
084:                return hasNext;
085:            }
086:
087:            public Feature next() throws IOException,
088:                    IllegalAttributeException, NoSuchElementException {
089:                if (!hasNext())
090:                    throw new NoSuchElementException(
091:                            "There are no more Features to be read");
092:
093:                Feature f = mapper.convertOgrFeature(schema, curr);
094:
095:                // .. nullify curr, so that we can move to the next one
096:                curr.delete();
097:                curr = null;
098:
099:                return f;
100:            }
101:
102:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.