org.geotools.feature.iso.collection

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.feature.iso.collection 
org.geotools.feature.iso.collection
package org.geotools.feature.collection Helper classes for implementing FeatureCollections. Please note that this is mostly of interest to DataStore implementors who can use these classes as a starting point for their providing their own content (backed by a resultset or disk file etc.).

Meaning of FeatureCollections

FeatureCollections can be grouped into the following categories:

  • FeatureCollection - providing access to a set of Features, both bounds and count are supported (although you are warned that both may be O(N))
  • RandomFeatureAccess - provides access to Feature by ID
  • FeatureList - provides access to sorted set of Features
You can use the instanceof operator to check before casting although the API will be explicit where appropriate. Please note that the API may be explicit in Javadocs due to the limitations of Java 1.4.
  • Explicit: FeatureCollection.sort( SortBy ) returns a FeatureList
  • Explict: FeatureCollection.filter( Filter ) returns a FeatureCollection
  • Implicit: FeatureList.filter( Filter ) returns a FeatureCollection, impled that this instance also is an instnaceof FeatureList
Where possible we have placed this kind of thing into the GeoAPI FeatureCollection interface where Java5 can make these ideas exact.

Use of SortBy and Filter

You can explicitly obtain a FeatureList by using a sort( SortBy ) on an FeatureCollection. You can also obtain a "sub" feature collection by using a filter( Filter ). In both these cases the resulting construct is considered a "view" onto the origional FeatureCollection (which in the case of a DataStore will represent contents located externally).

  FeatureList list = featureCollection.filter( filter ).sort( sort );  
  

In addition to working directly with a "view" you can often use this technique to stage an opperation such as addAll or remove.


  collection.addAll( list.filter( filter ) );
  list.filter( filter ).remove();
  

Seperation Of Concerns

By using the sub collection opperations such as sort and filter you can carefully define set of data you wish to query against. This seperation of concerns can be maintained by ensuring the use of Expression when accessing content, and not acceing content directly.

This seperation of concerns is manditory for geotools library code, and is strongly recommended for client code.

Choosing a FeatureCollection Implementation for Client Code

The most basic FeatureCollection available in this package is the one that store information completly in memory. This is designed to be used by end users and is available for construction via a FeatureFactory (or SimpleFeatureFactory as required).

A common request involves using a MemoryFeatureCollection to cache information for display. You are warned that this approach will often fail in real GIS useage where the quantity of information can not be limited by memory.

Implementing a FeatureCollection Implementation as a Data Provider

As a Data provideder you are expected to extend the AbstractFeatureCollection classes provided here to make the most performant implementation of feature access you can.

You are responsible for providing the following:
  • All FeatureCollection Implementation: required to represent all content on accessed with Transaction.AUTO_COMMIT, bounds and count information provided by metadata. This implementation is mostly used to defined sub collections via filter and sort methods.
  • "Sub"FeatureCollection Implementation: produced in response to a filter or sort method should be either lazy, or backed by a result set obtained by the first opperation. A cache may be emplyed for information such as bounds and count.
  • FeatureList Implementation: if for file or feature result can be sorted (either via an initial SQL request or via consulting an attribute index file) you can "out" this capability to your end users by use of a FeatureList.
  • Getting Spatial with your Collections: many spatial file formats can make use of a spatial index (or SFSQL class) to provide an optimized experience. If possible please engage this early and often as we are spatial library, on a related note GeometryAttribute and Feature both support the settings of bounds, if this information is available please make use of it to prevent the running an expensive bounds calculation in software.
Although not recommended as general practice some implementations will be forced to "burn memory" by making use of the FeatureCollection Implementations intented for client code for manipulations such as sorting. If this applies to use please try to set yourself up to be lazy - it may be that the user will perform additional sub collection calls.

A word about Simple Features

The SimpleFeature interface is by no means required, it only represents a set of additional methods that can be defined safely when the content is a flat ordered list of atomic types with no multiplicity as dictated exactly in agreement with their type definition.

What does this mean for a FeatureCollection? For a SimpleFeatureCollection no attributes are supported at the SimpleFeatureCollectionType level, and the content members are restricted to a belonging single SimpleFeatureType.

References

The following links will be of interest:
  • Simple Features for SQL
@author Jody Garnett, Refractions Research @since GeoTools 2.2.
Java Source File NameTypeComment
AbstractFeatureCollection.javaClass Abstract feature collection to be used as base for FeatureCollection implementations.
AbstractFeatureList.javaClass Abstract feature list to be used as base for FeatureList implementations.

Subclasses must implement the following methods:


This implementation of FeatureList uses a delegate to satisfy the methods of the Feature interface.

AbstractResourceCollection.javaClass Collection supporting close( Iterator ).

This implementation is a port of java.util.Collection with support for the use of close( Iterator ).

AbstractResourceList.javaClass Starter for resource based list implementations.

Same deal as ResouceCollections - iterators that need to be closed.

AbstractSimpleFeatureCollection.javaClass Pure implementation of SimpleFeatureCollection.
FeatureState.javaClass This is *not* a Feature - it is a Delegate used by FeatureCollection implementations as "mix-in", provides implementation of featureCollection events, featureType, and attribute access.
FilteredIterator.javaClass Provides an implementation of Iterator that will filter contents using the provided filter.

This is a *Generic* iterator not limited to Feature, this will become more interesting as Filter is able to evaulate itself with more things then just Features.

This also explains the use of Collection (where you may have expected a FeatureCollection).

MemorySimpleFeatureCollection.javaClass Implement a SimpleFeatureCollection by burning memory!

Contents are maintained in a sorted TreeMap by FID, this serves as a reference implementation when exploring the FeatureCollection api.

RandomFeatureAccess.javaInterface Access Feature content using Feature "Id".

Many FeatureCollection classes will make use of this API to avoid unnecessary caching of content.

SubFeatureCollection.javaClass Used as a reasonable default implementation for subCollection.
SubFeatureList.javaClass
SubResourceList.javaClass Simple SubList based on from, to index.
SubSimpleFeatureCollection.javaClass Used as a reasonable default implementation for a subCollection of simple features.
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.