Class ListFeatureCollection
- All Implemented Interfaces:
Iterable<SimpleFeature>
,Collection<SimpleFeature>
,SimpleFeatureCollection
,FeatureCollection<SimpleFeatureType,
SimpleFeature>
This implementation wraps around a java.util.List and is suitable for quickly getting something on screen.
Usage notes:
- This implementation does not use a spatial index, please do not expect spatial operations to be fast.
- FeatureCollections are not allowed to have duplicates
This implementation is intended to quickly wrap up a list of features and get them on screen; as such it respects various hints about the copying of internal content as provided by the renderer.
- Author:
- Oliver Gottwald, Jody
- See Also:
-
Hints#FEATURE_DETACHED
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected ReferencedEnvelope
Cached boundsprotected List<SimpleFeature>
wrapped list of features containing the contentsFields inherited from class AbstractFeatureCollection
id, schema
-
Constructor Summary
ConstructorsConstructorDescriptionCreate a ListFeatureCollection for the provided schema An ArrayList is used internally.ListFeatureCollection
(SimpleFeatureType schema, List<SimpleFeature> list) Create a ListFeatureCollection around the provided list.ListFeatureCollection
(SimpleFeatureType schema, SimpleFeature... array) Create a ListFeatureCollection around the provided array.Create a ListFeatureCollection around the provided list. -
Method Summary
Modifier and TypeMethodDescriptionboolean
add
(SimpleFeature f) boolean
addAll
(Collection<? extends SimpleFeature> c) protected ReferencedEnvelope
Calculate bounds from featuresvoid
clear()
features()
Obtain a SimpleFeatureIterator of the Features within this SimpleFeatureCollection.Subclasses need to override this.boolean
isEmpty()
Returns true if this feature collection contains no features.protected Iterator<SimpleFeature>
Factory method used to open an iterator over collection contents for use byAbstractFeatureCollection.iterator()
andAbstractFeatureCollection.features()
.boolean
boolean
removeAll
(Collection<?> c) boolean
retainAll
(Collection<?> c) int
size()
Returns the number of elements in this collection.Obtained sorted contents.subCollection
(Filter filter) SimpleFeatureCollection "view" indicated by provided filter.Methods inherited from class AbstractFeatureCollection
accepts, contains, containsAll, getID, getSchema, iterator, toArray, toArray
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface Collection
contains, containsAll, equals, hashCode, iterator, parallelStream, removeIf, spliterator, stream, toArray, toArray, toArray
-
Field Details
-
list
wrapped list of features containing the contents -
bounds
Cached bounds
-
-
Constructor Details
-
ListFeatureCollection
Create a ListFeatureCollection for the provided schema An ArrayList is used internally. -
ListFeatureCollection
Create a ListFeatureCollection around the provided list. The contents of the list should all be of the provided schema for this to make sense. Please keep in mind the feature collection constraints, no two Features in the list should have the same feature id, and you should not insert the same feature more then once.The provided list is directly used for storage, most feature collection operations just use a simple iterator so there is no performance advantaged to be gained over using an ArrayList vs a LinkedList (other then for the size() method of course).
-
ListFeatureCollection
Create a ListFeatureCollection around the provided array. The contents of the array should all be of the provided schema for this to make sense. Please keep in mind the feature collection constraints, no two Features in the list should have the same feature id, and you should not insert the same feature more then once.The provided array is directly used with a
CopyOnWriteArrayList
for storage. -
ListFeatureCollection
Create a ListFeatureCollection around the provided list. The contents of the list should all be of the provided schema for this to make sense. Please keep in mind the feature collection control, no two Features in the list should have the same feature id, and you should not insert the same feature more then once.The provided list is directly used for storage, most feature collection operations just use a simple iterator so there is no performance advantaged to be gained over using an ArrayList vs a LinkedList (other then for the size() method of course).
- Throws:
IOException
-
-
Method Details
-
size
public int size()Description copied from class:AbstractFeatureCollection
Returns the number of elements in this collection.- Specified by:
size
in interfaceCollection<SimpleFeature>
- Specified by:
size
in interfaceFeatureCollection<SimpleFeatureType,
SimpleFeature> - Specified by:
size
in classAbstractFeatureCollection
- Returns:
- Number of items, or Interger.MAX_VALUE
- See Also:
-
openIterator
Description copied from class:AbstractFeatureCollection
Factory method used to open an iterator over collection contents for use byAbstractFeatureCollection.iterator()
andAbstractFeatureCollection.features()
.If you return an instance of FeatureIterator some effort is taken to call the
FeatureIterator.close()
internally, however we cannot offer any assurance that client code usingAbstractFeatureCollection.iterator()
will perform the same check.- Specified by:
openIterator
in classAbstractFeatureCollection
- Returns:
- Iterator over collection contents
-
add
- Specified by:
add
in interfaceCollection<SimpleFeature>
-
clear
public void clear()- Specified by:
clear
in interfaceCollection<SimpleFeature>
-
features
Description copied from interface:SimpleFeatureCollection
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> - Specified by:
features
in interfaceSimpleFeatureCollection
- Overrides:
features
in classAbstractFeatureCollection
- Returns:
- A FeatureIterator.
-
getBounds
Description copied from class:AbstractFeatureCollection
Subclasses need to override this.- Specified by:
getBounds
in interfaceFeatureCollection<SimpleFeatureType,
SimpleFeature> - Specified by:
getBounds
in classAbstractFeatureCollection
- Returns:
- An Envelope containing the total bounds of this collection.
-
calculateBounds
Calculate bounds from features -
isEmpty
public boolean isEmpty()Description copied from interface:FeatureCollection
Returns true if this feature collection contains no features.- Specified by:
isEmpty
in interfaceCollection<SimpleFeature>
- Specified by:
isEmpty
in interfaceFeatureCollection<SimpleFeatureType,
SimpleFeature> - Overrides:
isEmpty
in classAbstractFeatureCollection
- Returns:
- true if this collection contains no elements.
-
subCollection
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> - Specified by:
subCollection
in interfaceSimpleFeatureCollection
- Overrides:
subCollection
in classAbstractFeatureCollection
- Returns:
- SimpleFeatureCollection identified as subset.
- See Also:
-
FeatureList
-
sort
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> - Specified by:
sort
in interfaceSimpleFeatureCollection
- Overrides:
sort
in classAbstractFeatureCollection
- Parameters:
order
- Sort order- Returns:
- FeatureCollection sorted in the indicated order
-
remove
- Specified by:
remove
in interfaceCollection<SimpleFeature>
-
addAll
- Specified by:
addAll
in interfaceCollection<SimpleFeature>
-
removeAll
- Specified by:
removeAll
in interfaceCollection<SimpleFeature>
-
retainAll
- Specified by:
retainAll
in interfaceCollection<SimpleFeature>
-