Package org.geotools.data.crs
Class ReprojectFeatureReader
Object
ReprojectFeatureReader
- All Implemented Interfaces:
Closeable
,AutoCloseable
,DelegatingFeatureReader<SimpleFeatureType,
,SimpleFeature> FeatureReader<SimpleFeatureType,
SimpleFeature>
public class ReprojectFeatureReader
extends Object
implements DelegatingFeatureReader<SimpleFeatureType,SimpleFeature>
ReprojectFeatureReader provides a reprojection for FeatureTypes.
ReprojectFeatureReader is a wrapper used to reproject GeometryAttributes to a user supplied CoordinateReferenceSystem from the original CoordinateReferenceSystem supplied by the original FeatureReader.
Example Use:
ReprojectFeatureReader reader =
new ReprojectFeatureReader( originalReader, reprojectCS );
CoordinateReferenceSystem originalCS =
originalReader.getFeatureType().getDefaultGeometry().getCoordinateSystem();
CoordinateReferenceSystem newCS =
reader.getFeatureType().getDefaultGeometry().getCoordinateSystem();
assertEquals( reprojectCS, newCS );
TODO: handle the case where there is more than one geometry and the other geometries have a different CS than the
default geometry- Author:
- jgarnett, Refractions Research, Inc., aaime, $Author: jive $ (last modification)
-
Constructor Summary
ConstructorsConstructorDescriptionReprojectFeatureReader
(FeatureReader<SimpleFeatureType, SimpleFeature> reader, SimpleFeatureType schema) Constructor that will generate mathTransforms for the results, based on target schema.ReprojectFeatureReader
(FeatureReader<SimpleFeatureType, SimpleFeature> reader, SimpleFeatureType schema, MathTransform transform) Direct constructor reprojecting the provided reader into the schema indicated (using the supplied math transformation).ReprojectFeatureReader
(FeatureReader<SimpleFeatureType, SimpleFeature> reader, CoordinateReferenceSystem cs) Constructor that will generate schema and mathTransforms for the results. -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Implement close.Implement getFeatureType.protected GeometryCoordinateSequenceTransformer
getTransformer
(Name attributeName) boolean
hasNext()
Implement hasNext.next()
Implement next.
-
Constructor Details
-
ReprojectFeatureReader
public ReprojectFeatureReader(FeatureReader<SimpleFeatureType, SimpleFeature> reader, SimpleFeatureType schema, MathTransform transform) Direct constructor reprojecting the provided reader into the schema indicated (using the supplied math transformation).Please note schema is that of the expected results, You may need to use FeatureTypes.transform( FeatureType, crs ) to create the schema provider.
- Parameters:
reader
- original reader with results in the original coordinate reference systemschema
- This is the target schema describing the results in the expected coordinate reference systemtransform
- the math transform used to go from reader coordinate reference system to the provided schema coordinate reference system
-
ReprojectFeatureReader
public ReprojectFeatureReader(FeatureReader<SimpleFeatureType, SimpleFeature> reader, CoordinateReferenceSystem cs) throws SchemaException, OperationNotFoundException, NoSuchElementException, FactoryExceptionConstructor that will generate schema and mathTransforms for the results.- Parameters:
reader
- original readercs
- Target coordinate reference system; will be used to create the target FeatureType and MathTransforms used to transform the data- Throws:
SchemaException
OperationNotFoundException
NoSuchElementException
FactoryException
-
ReprojectFeatureReader
public ReprojectFeatureReader(FeatureReader<SimpleFeatureType, SimpleFeature> reader, SimpleFeatureType schema) throws SchemaException, OperationNotFoundException, NoSuchElementException, FactoryExceptionConstructor that will generate mathTransforms for the results, based on target schema.- Parameters:
reader
- original readerschema
- Target schema; will be used to create the target MathTransforms used to transform the data- Throws:
SchemaException
OperationNotFoundException
NoSuchElementException
FactoryException
-
-
Method Details
-
getTransformer
-
getDelegate
- Specified by:
getDelegate
in interfaceDelegatingFeatureReader<SimpleFeatureType,
SimpleFeature> - Returns:
- The delegate feature reader.
-
getFeatureType
Implement getFeatureType.Description ...
- Specified by:
getFeatureType
in interfaceFeatureReader<SimpleFeatureType,
SimpleFeature> - Returns:
- the FeatureType of the Features this FeatureReader will create.
- See Also:
-
next
Implement next.Description ...
- Specified by:
next
in interfaceFeatureReader<SimpleFeatureType,
SimpleFeature> - Returns:
- The next feature in the reader.
- Throws:
IOException
- If an error occurs reading the Feature.NoSuchElementException
- If there are no more Features in the Reader.IllegalAttributeException
- See Also:
-
hasNext
Implement hasNext.Description ...
- Specified by:
hasNext
in interfaceFeatureReader<SimpleFeatureType,
SimpleFeature> - Returns:
- True if there are more Features to be read. In other words, true if calls to next would return a feature rather than throwing an exception.
- Throws:
IOException
- If an error occurs determining if there are more Features.- See Also:
-
close
Implement close.Description ...
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Specified by:
close
in interfaceFeatureReader<SimpleFeatureType,
SimpleFeature> - Throws:
IOException
- if an I/O error occurs- See Also:
-