org.geotools.data.crs
Class ForceCoordinateSystemFeatureResults

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

public class ForceCoordinateSystemFeatureResults
extends DataFeatureCollection

ForceCoordinateSystemFeatureResults provides a CoordinateReferenceSystem for FeatureTypes.

ForceCoordinateSystemFeatureReader is a wrapper used to force GeometryAttributes to a user supplied CoordinateReferenceSystem rather then the default supplied by the DataStore.

Example Use:


 ForceCoordinateSystemFeatureResults results =
     new ForceCoordinateSystemFeatureResults( originalResults, forceCS );
 
 CoordinateReferenceSystem originalCS =
     originalResults.getFeatureType().getDefaultGeometry().getCoordinateSystem();
 
 CoordinateReferenceSystem newCS =
     reader.getFeatureType().getDefaultGeometry().getCoordinateSystem();
 
 assertEquals( forceCS, newCS );
 

Version:
$Id: ForceCoordinateSystemFeatureResults.java 17701 2006-01-23 00:00:51Z desruisseaux $
Author:
aaime

Nested Class Summary
 
Nested classes inherited from class org.geotools.feature.Feature
Feature.NULL
 
Constructor Summary
ForceCoordinateSystemFeatureResults(FeatureResults results, org.opengis.referencing.crs.CoordinateReferenceSystem forcedCS)
           
 
Method Summary
 FeatureCollection collection()
          Convert this set of results to a FeatureCollection.
 com.vividsolutions.jts.geom.Envelope getBounds()
          Returns the bounding box of this FeatureResults.
 int getCount()
          Returns the number of Features in this FeatureResults.
 FeatureResults getOrigin()
          Returns the feature results wrapped by this ForceCoordinateSystemFeatureResults
 FeatureType getSchema()
          The schema for the child features 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

ForceCoordinateSystemFeatureResults

public ForceCoordinateSystemFeatureResults(FeatureResults results,
                                           org.opengis.referencing.crs.CoordinateReferenceSystem forcedCS)
                                    throws java.io.IOException,
                                           SchemaException
Method Detail

getSchema

public FeatureType 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
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()
Description copied from interface: FeatureResults
Returns the bounding box of this FeatureResults.

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

This method is logically the same as:
 
 public Envelope getBounds() throws IOException {
     Envelope newBBox = new Envelope();
     Envelope internal;
     Feature feature;
 
     for (FeatureReader r = reader(); r.hasNext();) {
         feature = r.next();
         internal = feature.getDefaultGeometry().getEnvelopeInternal();
         newBBox.expandToInclude(internal);
     }
     return newBBox;  
 }
 
 

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 ForceCoordinateSystemFeatureResults

Returns:


Copyright © GeoTools. All Rights Reserved.