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


001:        package org.geotools.data.store;
002:
003:        import java.io.IOException;
004:        import java.util.Collections;
005:        import java.util.Set;
006:        import java.util.logging.Level;
007:        import java.util.logging.Logger;
008:
009:        import org.geotools.data.DataSourceException;
010:        import org.geotools.data.DataStore;
011:        import org.geotools.data.DataUtilities;
012:        import org.geotools.data.FeatureListener;
013:        import org.geotools.data.FeatureSource;
014:        import org.geotools.data.Query;
015:        import org.geotools.feature.FeatureCollection;
016:        import org.geotools.feature.FeatureType;
017:        import org.geotools.feature.SchemaException;
018:        import org.opengis.filter.Filter;
019:        import org.opengis.referencing.crs.CoordinateReferenceSystem;
020:
021:        import com.vividsolutions.jts.geom.Coordinate;
022:        import com.vividsolutions.jts.geom.Envelope;
023:
024:        public abstract class AbstractFeatureSource2 implements  FeatureSource {
025:
026:            /** The logger for the data module. */
027:            protected static final Logger LOGGER = org.geotools.util.logging.Logging
028:                    .getLogger("org.geotools.data");
029:
030:            /**
031:             * the type entry
032:             */
033:            protected ActiveTypeEntry entry;
034:
035:            public AbstractFeatureSource2(ActiveTypeEntry entry) {
036:                this .entry = entry;
037:            }
038:
039:            public DataStore getDataStore() {
040:                return entry.parent;
041:            }
042:
043:            public void addFeatureListener(FeatureListener listener) {
044:                entry.listenerManager.addFeatureListener(this , listener);
045:            }
046:
047:            public void removeFeatureListener(FeatureListener listener) {
048:                entry.listenerManager.removeFeatureListener(this , listener);
049:            }
050:
051:            public FeatureCollection getFeatures(Query query)
052:                    throws IOException {
053:                FeatureType featureType = entry.getFeatureType();
054:
055:                Filter filter = query.getFilter();
056:                if (filter == null) {
057:                    throw new NullPointerException(
058:                            "getFeatureReader requires Filter: "
059:                                    + "did you mean Filter.INCLUDE?");
060:                }
061:                String propertyNames[] = query.getPropertyNames();
062:
063:                if (filter == Filter.EXCLUDE || filter.equals(Filter.EXCLUDE)) {
064:                    //return new EmptyFeatureReader(featureType);
065:                    return new EmptyFeatureCollection(featureType);
066:                }
067:                //GR: allow subclases to implement as much filtering as they can,
068:                //by returning just it's unsupperted filter
069:                //         filter = getUnsupportedFilter( filter);
070:                //         if(filter == null){
071:                //             throw new NullPointerException("getUnsupportedFilter shouldn't return null. Do you mean Filter.INCLUDE?");
072:                //         }
073:
074:                //filter
075:                FeatureCollection features = getFeatures(filter);
076:
077:                //retyping
078:                if (propertyNames != null
079:                        || query.getCoordinateSystem() != null) {
080:                    try {
081:                        FeatureType target = DataUtilities.createSubType(
082:                                featureType, propertyNames, query
083:                                        .getCoordinateSystem());
084:                        if (!featureType.equals(target)) {
085:                            LOGGER
086:                                    .fine("Recasting feature type to subtype by using a ReTypeFeatureReader");
087:                            features = new ReTypingFeatureCollection(features,
088:                                    target);
089:                        }
090:                    } catch (SchemaException e) {
091:                        LOGGER.log(Level.FINEST, e.getMessage(), e);
092:                        throw new DataSourceException(
093:                                "Could not create Feature Type for query", e);
094:
095:                    }
096:                }
097:
098:                //reprojection 
099:                if (query.getCoordinateSystemReproject() != null) {
100:                    if (query.getCoordinateSystem() != null) {
101:                        features = reproject(features, query
102:                                .getCoordinateSystem(), query
103:                                .getCoordinateSystemReproject());
104:                    } else {
105:                        features = new ReprojectingFeatureCollection(features,
106:                                query.getCoordinateSystemReproject());
107:                    }
108:                }
109:
110:                //max feature cap
111:                if (query.getMaxFeatures() != Query.DEFAULT_MAX) {
112:                    features = new MaxFeaturesFeatureCollection(features, query
113:                            .getMaxFeatures());
114:                }
115:
116:                return features;
117:            }
118:
119:            public FeatureCollection getFeatures(Filter filter)
120:                    throws IOException {
121:                //filter
122:                if (filter != null && !filter.equals(Filter.INCLUDE)) {
123:                    return new FilteringFeatureCollection(getFeatures(), filter);
124:                }
125:
126:                return getFeatures();
127:            }
128:
129:            public FeatureType getSchema() {
130:                return entry.getFeatureType();
131:            }
132:
133:            public Envelope getBounds() throws IOException {
134:                return getFeatures().getBounds();
135:            }
136:
137:            public Envelope getBounds(Query query) throws IOException {
138:                return getFeatures(query).getBounds();
139:            }
140:
141:            public int getCount(Query query) throws IOException {
142:                return getFeatures(query).size();
143:            }
144:
145:            /**
146:             * Template method for reprojecting a feature collection from a source crs to a target crs.
147:             * <p>
148:             * Subclasses may override, the default implementation wraps <param>features</param> in a 
149:             * {@link ReprojectingFeatureCollection}.
150:             * </p>
151:             * @param features The feature collection to be reprojected.
152:             * 
153:             * @return the reprojected feature collection.
154:             */
155:            protected FeatureCollection reproject(FeatureCollection features,
156:                    CoordinateReferenceSystem source,
157:                    CoordinateReferenceSystem target) {
158:                return new ReprojectingFeatureCollection(features, source,
159:                        target);
160:            }
161:
162:            /**
163:             * By default, no Hints are supported
164:             */
165:            public Set getSupportedHints() {
166:                return Collections.EMPTY_SET;
167:            }
168:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.