org.geotools.data.crs
Class ReprojectFeatureResults

java.lang.Object
  extended byorg.geotools.data.store.DataFeatureCollection
      extended byorg.geotools.data.crs.ReprojectFeatureResults
All Implemented Interfaces:
java.util.Collection, Feature, FeatureCollection, FeatureResults, ResourceCollection

public class ReprojectFeatureResults
extends DataFeatureCollection
implements FeatureResults

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 17701 2006-01-23 00:00:51Z desruisseaux $ 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)

Nested Class Summary
 
Nested classes inherited from class org.geotools.feature.Feature
Feature.NULL
 
Constructor Summary
ReprojectFeatureResults(FeatureResults results, org.opengis.referencing.crs.CoordinateReferenceSystem destinationCS)
          Creates a new reprojecting feature results
 
Method Summary
 FeatureCollection collection()
          Convert this set of results to a FeatureCollection.
 com.vividsolutions.jts.geom.Envelope getBounds()
          This method computes reprojected bounds the hard way, but computing them feature by feature.
 int getCount()
          Returns the number of Features in this FeatureResults.
 FeatureResults getOrigin()
          Returns the feature results wrapped by this reprojecting feature results
 FeatureType getSchema()
          Returns the FeatureType of the contents of this collection.
 FeatureReader reader()
          Provides access to the Features, please note that FeatureReader is a blocking api.
 
Methods inherited from class org.geotools.data.store.DataFeatureCollection
accepts, add, addAll, addListener, clear, close, close, closeIterator, contains, containsAll, features, fireChange, fireChange, fireChange, getAttribute, getAttribute, getAttributes, getDefaultGeometry, getFeatureType, getID, getNumberOfAttributes, getParent, isEmpty, iterator, openIteartor, purge, remove, removeAll, removeListener, retainAll, setAttribute, setAttribute, setDefaultGeometry, setParent, size, sort, sort, subCollection, toArray, toArray, writer
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.util.Collection
equals, hashCode
 

Constructor Detail

ReprojectFeatureResults

public ReprojectFeatureResults(FeatureResults 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

getSchema

public FeatureType getSchema()
Description copied from interface: FeatureResults
Returns the FeatureType of the contents of this collection.

Please note that for a collection with a mixed contents the FeatureType may be degenerate (ie very generic). For many applications (like shapefiles or tables) the FeatureType can safely be used to describe all the Features in the result set.

Specified by:
getSchema in interface FeatureResults
Specified by:
getSchema in class DataFeatureCollection
See Also:
FeatureResults.getSchema()

reader

public FeatureReader reader()
                     throws java.io.IOException
Description copied from interface: FeatureResults
Provides access to the Features, please note that FeatureReader is a blocking api.

Specified by:
reader in interface FeatureResults
Specified by:
reader in class DataFeatureCollection
Throws:
java.io.IOException
See Also:
FeatureResults.reader()

getBounds

public com.vividsolutions.jts.geom.Envelope 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 FeatureResults
Specified by:
getBounds in class DataFeatureCollection
See Also:
FeatureResults.getBounds()

getCount

public int getCount()
             throws java.io.IOException
Description copied from interface: FeatureResults
Returns the number of Features in this FeatureResults.

This opperation may be expensive. Consider FeatureSource.getCount( Query ) as an alternative.

This method is logically the same as:
 
 public int getCount() throws IOException {
     int count = 0;
     for (FeatureReader r = reader(); r.hasNext(); count++) {
         r.next();
     }
     return count;  
 }
 
 

Specified by:
getCount in interface FeatureResults
Specified by:
getCount in class DataFeatureCollection
Throws:
java.io.IOException
See Also:
FeatureResults.getCount()

collection

public FeatureCollection collection()
                             throws java.io.IOException
Description copied from interface: FeatureResults
Convert this set of results to a FeatureCollection.

This method is logically the same as:


 public FeatureCollection collection() throws IOException {
     FeatureCollection collection = FeatureCollections.newCollection()
     for (FeatureReader r = reader(); r.hasNext();) {
         collection.add( r.next() );
     }
     return collection;  
 }
 

Specified by:
collection in interface FeatureResults
Specified by:
collection in class DataFeatureCollection
Throws:
java.io.IOException
See Also:
FeatureResults.collection()

getOrigin

public FeatureResults getOrigin()
Returns the feature results wrapped by this reprojecting feature results

Returns:


Copyright © GeoTools. All Rights Reserved.