Class ReprojectingFeatureCollection
- Object
-
- DecoratingSimpleFeatureCollection
-
- ReprojectingFeatureCollection
-
- All Implemented Interfaces:
SimpleFeatureCollection
,FeatureCollection<SimpleFeatureType,SimpleFeature>
public class ReprojectingFeatureCollection extends DecoratingSimpleFeatureCollection
SimpleFeatureCollection decorator that reprojects all geometries of the features within the feature collection.- Author:
- Justin
-
-
Field Summary
-
Fields inherited from class DecoratingSimpleFeatureCollection
delegate
-
-
Constructor Summary
Constructors Constructor Description ReprojectingFeatureCollection(SimpleFeatureCollection delegate, CoordinateReferenceSystem target)
ReprojectingFeatureCollection(SimpleFeatureCollection delegate, CoordinateReferenceSystem source, CoordinateReferenceSystem target)
ReprojectingFeatureCollection(FeatureCollection<SimpleFeatureType,SimpleFeature> delegate, CoordinateReferenceSystem target)
ReprojectingFeatureCollection(FeatureCollection<SimpleFeatureType,SimpleFeature> delegate, CoordinateReferenceSystem source, CoordinateReferenceSystem target)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
add(SimpleFeature o)
protected boolean
canDelegate(FeatureVisitor visitor)
Methods for subclass to override in order to determine if the supplied visitor can be passed to the delegate collection.SimpleFeatureIterator
features()
Obtain a SimpleFeatureIterator of the Features within this SimpleFeatureCollection.ReferencedEnvelope
getBounds()
This method computes reprojected bounds the hard way, but computing them feature by feature.SimpleFeatureType
getSchema()
The schema for the child feature members of this collection.static boolean
isGeometryless(FeatureVisitor visitor, SimpleFeatureType schema)
Returns true if the visitor is geometryless, that is, it's not accessing a geometry field in the target schemaFeatureReader<SimpleFeatureType,SimpleFeature>
reader()
void
setTransformer(GeometryCoordinateSequenceTransformer transformer)
SimpleFeatureCollection
sort(SortBy order)
Obtained sorted contents.SimpleFeatureCollection
subCollection(Filter filter)
SimpleFeatureCollection "view" indicated by provided filter.Object[]
toArray()
<T> T[]
toArray(T[] a)
-
Methods inherited from class DecoratingSimpleFeatureCollection
accepts, contains, containsAll, equals, getID, hashCode, isEmpty, size
-
-
-
-
Constructor Detail
-
ReprojectingFeatureCollection
public ReprojectingFeatureCollection(FeatureCollection<SimpleFeatureType,SimpleFeature> delegate, CoordinateReferenceSystem target)
-
ReprojectingFeatureCollection
public ReprojectingFeatureCollection(SimpleFeatureCollection delegate, CoordinateReferenceSystem target)
-
ReprojectingFeatureCollection
public ReprojectingFeatureCollection(FeatureCollection<SimpleFeatureType,SimpleFeature> delegate, CoordinateReferenceSystem source, CoordinateReferenceSystem target)
-
ReprojectingFeatureCollection
public ReprojectingFeatureCollection(SimpleFeatureCollection delegate, CoordinateReferenceSystem source, CoordinateReferenceSystem target)
-
-
Method Detail
-
setTransformer
public void setTransformer(GeometryCoordinateSequenceTransformer transformer)
-
reader
public FeatureReader<SimpleFeatureType,SimpleFeature> reader() throws IOException
- Throws:
IOException
-
features
public SimpleFeatureIterator 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 classDecoratingSimpleFeatureCollection
- Returns:
- A FeatureIterator.
-
getSchema
public SimpleFeatureType getSchema()
Description copied from interface:FeatureCollection
The schema for the child feature members of this collection.Represents the most general FeatureType in common to all the features in this collection.
- For a collection backed by a shapefiles (or database tables) the FeatureType returned by getSchema() will complete describe each and every child in the collection.
- For mixed content FeatureCollections you will need to check the FeatureType of each Feature as it is retrived from the collection
- The degenerate case returns the "_Feature" FeatureType, where the only thing known is that the contents are Features.
- Specified by:
getSchema
in interfaceFeatureCollection<SimpleFeatureType,SimpleFeature>
- Overrides:
getSchema
in classDecoratingSimpleFeatureCollection
- Returns:
- FeatureType describing the "common" schema to all child features of this collection
-
subCollection
public 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>
- Specified by:
subCollection
in interfaceSimpleFeatureCollection
- Overrides:
subCollection
in classDecoratingSimpleFeatureCollection
- Returns:
- SimpleFeatureCollection identified as subset.
- See Also:
FeatureList
-
sort
public 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>
- Specified by:
sort
in interfaceSimpleFeatureCollection
- Overrides:
sort
in classDecoratingSimpleFeatureCollection
- Parameters:
order
- Sort order- Returns:
- FeatureCollection sorted in the indicated order
-
toArray
public Object[] toArray()
- Specified by:
toArray
in interfaceFeatureCollection<SimpleFeatureType,SimpleFeature>
- Overrides:
toArray
in classDecoratingSimpleFeatureCollection
- See Also:
Collection.toArray()
-
toArray
public <T> T[] toArray(T[] a)
- Specified by:
toArray
in interfaceFeatureCollection<SimpleFeatureType,SimpleFeature>
- Overrides:
toArray
in classDecoratingSimpleFeatureCollection
- See Also:
Collection.toArray(Object[])
-
add
public boolean add(SimpleFeature o)
-
getBounds
public ReferencedEnvelope getBounds()
This method computes reprojected bounds the hard way, but computing them feature by feature. This method could be faster if computed the reprojected bounds by reprojecting the original feature bounds a Shape object, thus getting the true shape of the reprojected envelope, and then computing the minimum and maximum coordinates of that new shape. The result would not a true representation of the new bounds.- Specified by:
getBounds
in interfaceFeatureCollection<SimpleFeatureType,SimpleFeature>
- Overrides:
getBounds
in classDecoratingSimpleFeatureCollection
- Returns:
- An Envelope containing the total bounds of this collection.
- See Also:
org.geotools.data.FeatureResults#getBounds()
-
canDelegate
protected boolean canDelegate(FeatureVisitor visitor)
Description copied from class:DecoratingSimpleFeatureCollection
Methods for subclass to override in order to determine if the supplied visitor can be passed to the delegate collection.The default is false and the visitor receives the decoraeted features.
- Overrides:
canDelegate
in classDecoratingSimpleFeatureCollection
-
isGeometryless
public static boolean isGeometryless(FeatureVisitor visitor, SimpleFeatureType schema)
Returns true if the visitor is geometryless, that is, it's not accessing a geometry field in the target schema
-
-