org.geotools.data.store
Class ReprojectingFeatureCollection

Object
  extended by DecoratingFeatureCollection<SimpleFeatureType,SimpleFeature>
      extended by ReprojectingFeatureCollection
All Implemented Interfaces:
FeatureCollection<SimpleFeatureType,SimpleFeature>

public class ReprojectingFeatureCollection
extends DecoratingFeatureCollection<SimpleFeatureType,SimpleFeature>

FeatureCollection decorator that reprojects the default geometry.

Author:
Justin
Module:
modules/library/main (gt-main.jar)

Field Summary
 
Fields inherited from class DecoratingFeatureCollection
delegate
 
Constructor Summary
ReprojectingFeatureCollection(FeatureCollection<SimpleFeatureType,SimpleFeature> delegate, CoordinateReferenceSystem target)
           
ReprojectingFeatureCollection(FeatureCollection<SimpleFeatureType,SimpleFeature> delegate, CoordinateReferenceSystem source, CoordinateReferenceSystem target)
           
 
Method Summary
 boolean add(SimpleFeature o)
          Add object to this collection.
 void close(FeatureIterator<SimpleFeature> close)
          Clean up after any resources associated with this FeatureIterator in a manner similar to JDO collections.
 void close(Iterator close)
          Clean up after any resources associated with this itterator in a manner similar to JDO collections.
 FeatureIterator<SimpleFeature> features()
          Obtain a FeatureIterator of the Features within this collection.
 ReferencedEnvelope getBounds()
          This method computes reprojected bounds the hard way, but computing them feature by feature.
 SimpleFeatureType getSchema()
          The schema for the child features of this collection.
 Iterator<SimpleFeature> iterator()
          An iterator over this collection, which must be closed after use.
 FeatureReader<SimpleFeatureType,SimpleFeature> reader()
           
 void setTransformer(GeometryCoordinateSequenceTransformer transformer)
           
 FeatureCollection<SimpleFeatureType,SimpleFeature> sort(SortBy order)
          collection.subCollection( myFilter ).sort( {"foo","bar"} ); collection.subCollection( myFilter ).sort( "bar" ).sort("foo")
 FeatureCollection<SimpleFeatureType,SimpleFeature> subCollection(Filter filter)
          FeatureCollection "view" indicated by provided filter.
 Object[] toArray()
           
 Object[] toArray(Object[] a)
           
 
Methods inherited from class DecoratingFeatureCollection
accepts, accepts, addAll, addAll, addListener, clear, contains, containsAll, equals, getID, hashCode, isEmpty, purge, remove, removeAll, removeListener, retainAll, size
 
Methods inherited from class Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ReprojectingFeatureCollection

public ReprojectingFeatureCollection(FeatureCollection<SimpleFeatureType,SimpleFeature> delegate,
                                     CoordinateReferenceSystem target)

ReprojectingFeatureCollection

public ReprojectingFeatureCollection(FeatureCollection<SimpleFeatureType,SimpleFeature> 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 FeatureIterator<SimpleFeature> features()
Description copied from interface: FeatureCollection
Obtain a FeatureIterator of the Features within this collection.

The implementation of Collection must adhere to the rules of fail-fast concurrent modification. In addition (to allow for resource backed collections, the close( Iterator ) method must be called.

This is almost equivalent to:

  • a Type-Safe call to: getAttribute(getFeatureType().getAttributeType(0).getName()).iterator();.
  • A Java 5:Iterator<Feature>

Example (safe) use:

 FeatureIterator iterator=collection.features();
 try {
     while( iterator.hasNext()  ){
          Feature feature = iterator.next();
          System.out.println( feature.getID() );
     }
 }
 finally {
     collection.close( iterator );
 }
 

GML Note: The contents of this iterator are considered to be defined by featureMember tags (and/or the single allowed FeatureMembers tag). Please see getFeatureType for more details.

Specified by:
features in interface FeatureCollection<SimpleFeatureType,SimpleFeature>
Overrides:
features in class DecoratingFeatureCollection<SimpleFeatureType,SimpleFeature>
Returns:
A FeatureIterator.

close

public void close(FeatureIterator<SimpleFeature> close)
Description copied from interface: FeatureCollection
Clean up after any resources associated with this FeatureIterator in a manner similar to JDO collections.

Example (safe) use:

 Iterator iterator = collection.iterator();
 try {
     for( Iterator i=collection.iterator(); i.hasNext();){
          Feature feature = i.hasNext();
          System.out.println( feature.getID() );
     }
 }
 finally {
     collection.close( iterator );
 }
 

Specified by:
close in interface FeatureCollection<SimpleFeatureType,SimpleFeature>
Overrides:
close in class DecoratingFeatureCollection<SimpleFeatureType,SimpleFeature>

iterator

public Iterator<SimpleFeature> iterator()
Description copied from interface: FeatureCollection
An iterator over this collection, which must be closed after use.

Collection is not guaranteed to be ordered in any manner.

The implementation of Collection must adhere to the rules of fail-fast concurrent modification. In addition (to allow for resource backed collections, the close( Iterator ) method must be called.

Example (safe) use:

 Iterator iterator = collection.iterator();
 try {
     while( iterator.hasNext();){
          Feature feature = (Feature) iterator.hasNext();
          System.out.println( feature.getID() );
     }
 }
 finally {
     collection.close( iterator );
 }
 

Specified by:
iterator in interface FeatureCollection<SimpleFeatureType,SimpleFeature>
Overrides:
iterator in class DecoratingFeatureCollection<SimpleFeatureType,SimpleFeature>
Returns:
Iterator

close

public void close(Iterator close)
Description copied from interface: FeatureCollection
Clean up after any resources associated with this itterator in a manner similar to JDO collections.

Example (safe) use:

 Iterator iterator = collection.iterator();
 try {
     for( Iterator i=collection.iterator(); i.hasNext();){
          Feature feature = (Feature) i.hasNext();
          System.out.println( feature.getID() );
     }
 }
 finally {
     collection.close( iterator );
 }
 

Specified by:
close in interface FeatureCollection<SimpleFeatureType,SimpleFeature>
Overrides:
close in class DecoratingFeatureCollection<SimpleFeatureType,SimpleFeature>

getSchema

public SimpleFeatureType getSchema()
Description copied from interface: FeatureCollection
The schema for the child features of this collection.

There is a difference between getFeatureType() and getSchema()represents the LCD FeatureType that best represents the contents of this collection.

The method getSchema() is named for compatability with the geotools 2.0 API. In the Geotools 2.2 time frame we should be able to replace this method with a careful check of getFeatureType() and its attributes.

Specified by:
getSchema in interface FeatureCollection<SimpleFeatureType,SimpleFeature>
Overrides:
getSchema in class DecoratingFeatureCollection<SimpleFeatureType,SimpleFeature>
Returns:
FeatureType describing the "common" schema to all child features of this collection

subCollection

public FeatureCollection<SimpleFeatureType,SimpleFeature> subCollection(Filter filter)
Description copied from interface: FeatureCollection
FeatureCollection "view" indicated by provided filter.

The contents of the returned FeatureCollection 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 FeatureCollection 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:


 collection.subCollection( filter ).clear();
 
The above recommended use is agreement with the Collections API precident of List.subList( start, end ).

The results of subCollection:

  • are to be considered unordered
  • may be an ordered FeatureList if requested when sortBy is indicated

Specified by:
subCollection in interface FeatureCollection<SimpleFeatureType,SimpleFeature>
Overrides:
subCollection in class DecoratingFeatureCollection<SimpleFeatureType,SimpleFeature>
Returns:
FeatureCollection identified as subset.
See Also:
FeatureList

sort

public FeatureCollection<SimpleFeatureType,SimpleFeature> sort(SortBy order)
Description copied from interface: FeatureCollection
collection.subCollection( myFilter ).sort( {"foo","bar"} ); collection.subCollection( myFilter ).sort( "bar" ).sort("foo")

Specified by:
sort in interface FeatureCollection<SimpleFeatureType,SimpleFeature>
Overrides:
sort in class DecoratingFeatureCollection<SimpleFeatureType,SimpleFeature>
Returns:
FeatureCollection sorted in the indicated order

toArray

public Object[] toArray()
Specified by:
toArray in interface FeatureCollection<SimpleFeatureType,SimpleFeature>
Overrides:
toArray in class DecoratingFeatureCollection<SimpleFeatureType,SimpleFeature>
See Also:
Collection.toArray()

toArray

public Object[] toArray(Object[] a)
Specified by:
toArray in interface FeatureCollection<SimpleFeatureType,SimpleFeature>
Overrides:
toArray in class DecoratingFeatureCollection<SimpleFeatureType,SimpleFeature>
See Also:
Collection.toArray(Object[])

add

public boolean add(SimpleFeature o)
Description copied from interface: FeatureCollection
Add object to this collection.

This method is often not impelmented for collections produced as the result of a query.

Specified by:
add in interface FeatureCollection<SimpleFeatureType,SimpleFeature>
Overrides:
add in class DecoratingFeatureCollection<SimpleFeatureType,SimpleFeature>
Returns:
true of the element was added
See Also:
Collection.add(Object)

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 interface FeatureCollection<SimpleFeatureType,SimpleFeature>
Overrides:
getBounds in class DecoratingFeatureCollection<SimpleFeatureType,SimpleFeature>
Returns:
An Envelope containing the total bounds of this collection.
See Also:
org.geotools.data.FeatureResults#getBounds()


Copyright © 1996-2010 Geotools. All Rights Reserved.