org.geotools.data.crs
Class ReprojectFeatureResults

java.lang.Object
  extended by org.geotools.feature.collection.AbstractFeatureCollection
      extended by org.geotools.data.crs.ReprojectFeatureResults
All Implemented Interfaces:
FeatureCollection<org.opengis.feature.simple.SimpleFeatureType,org.opengis.feature.simple.SimpleFeature>

public class ReprojectFeatureResults
extends AbstractFeatureCollection

ReprojectFeatureReader provides a reprojection for FeatureTypes.

ReprojectFeatureResults is a wrapper used to reproject GeometryAttributes to a user supplied CoordinateReferenceSystem from the original CoordinateReferenceSystem supplied by the original FeatureResults.

Example Use:


 ReprojectFeatureResults results =
     new ReprojectFeatureResults( originalResults, reprojectCS );
 
 CoordinateReferenceSystem originalCS =
     originalResults.getFeatureType().getDefaultGeometry().getCoordinateSystem();
 
 CoordinateReferenceSystem newCS =
     results.getFeatureType().getDefaultGeometry().getCoordinateSystem();
 
 assertEquals( reprojectCS, newCS );
 

Version:
$Id: ReprojectFeatureResults.java 31085 2008-07-28 07:58:00Z jgarnett $ TODO: handle the case where there is more than one geometry and the other geometries have a different CS than the default geometry
Author:
aaime, $Author: jive $ (last modification)

Field Summary
 
Fields inherited from class org.geotools.feature.collection.AbstractFeatureCollection
id, listeners, open, schema
 
Constructor Summary
ReprojectFeatureResults(FeatureCollection<org.opengis.feature.simple.SimpleFeatureType,org.opengis.feature.simple.SimpleFeature> results, org.opengis.referencing.crs.CoordinateReferenceSystem destinationCS)
          Creates a new reprojecting feature results
 
Method Summary
 void closeIterator(java.util.Iterator close)
          Please override to cleanup after your own iterators, and any used resources.
 ReferencedEnvelope getBounds()
          This method computes reprojected bounds the hard way, but computing them feature by feature.
 FeatureCollection<org.opengis.feature.simple.SimpleFeatureType,org.opengis.feature.simple.SimpleFeature> getOrigin()
          Returns the feature results wrapped by this reprojecting feature results
 java.util.Iterator openIterator()
          Open a resource based Iterator, we will call close( iterator ).
 int size()
          Returns the number of elements in this collection.
 
Methods inherited from class org.geotools.feature.collection.AbstractFeatureCollection
accepts, accepts, add, addAll, addAll, addListener, clear, close, close, contains, containsAll, features, getID, getOpenIterators, getSchema, isEmpty, iterator, purge, remove, removeAll, removeListener, retainAll, sort, subCollection, subList, toArray, toArray
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ReprojectFeatureResults

public ReprojectFeatureResults(FeatureCollection<org.opengis.feature.simple.SimpleFeatureType,org.opengis.feature.simple.SimpleFeature> results,
                               org.opengis.referencing.crs.CoordinateReferenceSystem destinationCS)
                        throws java.io.IOException,
                               SchemaException,
                               org.opengis.referencing.operation.TransformException,
                               org.opengis.referencing.operation.OperationNotFoundException,
                               java.util.NoSuchElementException,
                               org.opengis.referencing.FactoryException
Creates a new reprojecting feature results

Parameters:
results -
destinationCS -
Throws:
java.io.IOException
SchemaException
org.opengis.referencing.operation.TransformException
org.opengis.referencing.FactoryException
java.util.NoSuchElementException
org.opengis.referencing.operation.OperationNotFoundException
CannotCreateTransformException
java.lang.NullPointerException - DOCUMENT ME!
java.lang.IllegalArgumentException
Method Detail

openIterator

public java.util.Iterator openIterator()
Description copied from class: AbstractFeatureCollection
Open a resource based Iterator, we will call close( iterator ).

Please subclass to provide your own iterator for the the ResourceCollection, note iterator() is implemented to call open() and track the results in for later purge().

Specified by:
openIterator in class AbstractFeatureCollection
Returns:
Iterator based on resource use

closeIterator

public void closeIterator(java.util.Iterator close)
Description copied from class: AbstractFeatureCollection
Please override to cleanup after your own iterators, and any used resources.

As an example if the iterator was working off a File then the inputstream should be closed.

Subclass must call super.close( close ) to allow the list of open iterators to be adjusted.

Specified by:
closeIterator in class AbstractFeatureCollection
Parameters:
close - Iterator, will not be null

size

public int size()
Description copied from class: AbstractFeatureCollection
Returns the number of elements in this collection.

Specified by:
size in interface FeatureCollection<org.opengis.feature.simple.SimpleFeatureType,org.opengis.feature.simple.SimpleFeature>
Specified by:
size in class AbstractFeatureCollection
Returns:
Number of items, or Interger.MAX_VALUE
See Also:
Collection.size()

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 minumum and maximum coordinates of that new shape. The result would not a true representation of the new bounds, but it would be guaranteed to be larger that the true representation.

Specified by:
getBounds in interface FeatureCollection<org.opengis.feature.simple.SimpleFeatureType,org.opengis.feature.simple.SimpleFeature>
Overrides:
getBounds in class AbstractFeatureCollection
Returns:
An Envelope containing the total bounds of this collection.
See Also:
org.geotools.data.FeatureResults#getBounds()

getOrigin

public FeatureCollection<org.opengis.feature.simple.SimpleFeatureType,org.opengis.feature.simple.SimpleFeature> getOrigin()
Returns the feature results wrapped by this reprojecting feature results



Copyright © 1996-2010 Geotools. All Rights Reserved.