Interface SimpleFeatureCollection
-
- All Superinterfaces:
FeatureCollection<SimpleFeatureType,SimpleFeature>
- All Known Subinterfaces:
RandomFeatureAccess
,XmlFeatureCollection
- All Known Implementing Classes:
AbstractFeatureCollection
,AdaptorFeatureCollection
,BaseSimpleFeatureCollection
,ClippedFeatureCollection
,ClippingFeatureCollection
,CollectionFeatureSource.SubCollection
,CompositeFeatureCollection
,ContentFeatureCollection
,DataFeatureCollection
,DecoratingSimpleFeatureCollection
,DefaultFeatureCollection
,DefaultFeatureResults
,EmptyFeatureCollection
,FilteringSimpleFeatureCollection
,ForceCoordinateSystemFeatureResults
,GMLFeatureCollection
,IndexedFeatureResults
,ListFeatureCollection
,MaxSimpleFeatureCollection
,MemoryFeatureCollection
,PagingFeatureCollection
,PreGeneralizedFeatureCollection
,ReprojectFeatureResults
,ReprojectingFeatureCollection
,ReTypingFeatureCollection
,SimpleProcessingCollection
,SortedSimpleFeatureCollection
,SpatialIndexFeatureCollection
,SubFeatureCollection
,SubFeatureList
,TreeSetFeatureCollection
public interface SimpleFeatureCollection extends FeatureCollection<SimpleFeatureType,SimpleFeature>
Access to "simple" Feature content where each feature has the same SimpleFeatureType.Please keep in mind that a SimpleFeatureCollection is similar to a result set; and may not necessarily load everything in to memory. Treat each iterator as a forward only cursor in the JDBC sense; and take care to FeatureIterator.close() after use.
SimpleFeatureIterator close
SimpleFeatureCollection provides streaming access with the following restrictions on use of
SimpleFeatureIterator
: You must callFeatureIterator.close()
. This allows FeatureCollection to clean up any operating system resources used to access information.Example (safe) use:
And in Java 7:SimpleFeatureIterator iterator = simpleFeatureCollection.features(); try { while( iterator.hasNext() ){ SimpleFeature feature = iterator.next(); System.out.println( feature.getID() ); } } finally { iterator.close(); }
try ( SimpleFeatureIterator iterator = simpleFeatureCollection.features() ){ while( iterator.hasNext() ){ SimpleFeature feature = iterator.next(); System.out.println( feature.getID() ); } }
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description SimpleFeatureIterator
features()
Obtain a SimpleFeatureIterator of the Features within this SimpleFeatureCollection.SimpleFeatureCollection
sort(SortBy order)
Obtained sorted contents.SimpleFeatureCollection
subCollection(Filter filter)
SimpleFeatureCollection "view" indicated by provided filter.
-
-
-
Method Detail
-
features
SimpleFeatureIterator features()
Obtain a SimpleFeatureIterator of the Features within this SimpleFeatureCollection.The implementation of FeatureIterator must adhere to the rules of fail-fast concurrent modification. In addition (to allow for resource backed collections) the
SimpleFeatureIterator.close()
method must be called.Example use:
SimpleFeatureIterator iterator=collection.features(); try { while( iterator.hasNext() ){ SimpleFeature feature = iterator.next(); System.out.println( feature.getID() ); } } finally { iterator.close(); }
- Specified by:
features
in interfaceFeatureCollection<SimpleFeatureType,SimpleFeature>
- Returns:
- A FeatureIterator.
-
subCollection
SimpleFeatureCollection subCollection(Filter filter)
Description copied from interface:FeatureCollection
SimpleFeatureCollection "view" indicated by provided filter.The contents of the returned SimpleFeatureCollection are determined by applying the provider Filter to the entire contents of this FeatureCollection. The result is "live" and modifications will be shared.
This method is used cut down on the number of filter based methods required for a useful SimpleFeatureCollection construct. The FeatureCollections returned really should be considered as a temporary "view" used to control the range of a removeAll, or modify operation.
Example Use:
The above recommended use is agreement with the Collections API precident of List.subList( start, end ).collection.subCollection( filter ).clear();
The results of subCollection:
- are to be considered unordered
- may be an ordered FeatureList if requested when sortBy is indicated
- Specified by:
subCollection
in interfaceFeatureCollection<SimpleFeatureType,SimpleFeature>
- Returns:
- SimpleFeatureCollection identified as subset.
- See Also:
FeatureList
-
sort
SimpleFeatureCollection sort(SortBy order)
Description copied from interface:FeatureCollection
Obtained sorted contents.This method may not be supported by all implementations, consider the use of FeatureSource.features( Query ).
- Specified by:
sort
in interfaceFeatureCollection<SimpleFeatureType,SimpleFeature>
- Parameters:
order
- Sort order- Returns:
- FeatureCollection sorted in the indicated order
-
-