Package org.geotools.coverage.util
Class FeatureUtilities
Object
FeatureUtilities
A set of utilities methods for interactions between
GridCoverage and Feature. Those methods are not
really rigorous; must of them should be seen as temporary implementations.- Since:
- 2.4
- Author:
- Simone Giannecchini
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final FilterFactorystatic final PropertyNamestatic final PropertyName -
Method Summary
Modifier and TypeMethodDescriptionstatic doubleFunction to calculate the area of a polygon, according to the algorithm defined at http://local.wasp.uwa.edu.au/~pbourke/geometry/polyarea/static PolygonconvertPolygon(Polygon roiInput, MathTransform worldToGridTransform) Converts a JTSPolygon, which represents a ROI, int an AWTPolygonby means of the providedMathTransform.static PolygonconvertPolygonToPointArray(Polygon roiInput, MathTransform worldToGridTransform, List<Point2D> points) Converts a JTSPolygon, which represents a ROI, int an AWTPolygonby means of the providedMathTransform.static PolygongetPolygon(Rectangle2D rect, int srid) Returns the polygon surrounding the specified rectangle.static PolygongetPolygon(GeneralBounds env, GeometryFactory gf) Convert the crop envelope into a polygon and the use the world-to-grid transform to get a ROI for the source coverage.static booleanisWrappedCoverage(SimpleFeatureType featureType) Checks if the feature type specified is a GridCoverage wrapperstatic booleanisWrappedCoverageReader(SimpleFeatureType featureType) Checks if the feature type specified is a GridCoverage2DReader wrapperstatic SimpleFeatureCollectionwrapGridCoverage(GridCoverage2D coverage) Wraps a grid coverage into a Feature.static SimpleFeatureCollectionwrapGridCoverageReader(GridCoverage2DReader gridCoverageReader, GeneralParameterValue[] params) Wraps a grid coverage into a Feature.
-
Field Details
-
DEFAULT_FILTER_FACTORY
-
GRID_PROPERTY_NAME
-
PARAMS_PROPERTY_NAME
-
-
Method Details
-
getPolygon
Returns the polygon surrounding the specified rectangle. Code lifted from ArcGridDataSource (temporary). -
wrapGridCoverage
public static SimpleFeatureCollection wrapGridCoverage(GridCoverage2D coverage) throws TransformException, SchemaException Wraps a grid coverage into a Feature. Code lifted from ArcGridDataSource (temporary).- Parameters:
coverage- the grid coverage.- Returns:
- a feature with the grid coverage envelope as the geometry and the grid coverage itself in the "grid" attribute.
- Throws:
TransformExceptionSchemaException
-
isWrappedCoverage
Checks if the feature type specified is a GridCoverage wrapper -
wrapGridCoverageReader
public static SimpleFeatureCollection wrapGridCoverageReader(GridCoverage2DReader gridCoverageReader, GeneralParameterValue[] params) throws TransformException, FactoryRegistryException, SchemaException Wraps a grid coverage into a Feature. Code lifted from ArcGridDataSource (temporary).- Parameters:
gridCoverageReader- the grid coverage reader.- Returns:
- a feature with the grid coverage envelope as the geometry and the grid coverage itself in the "grid" attribute.
- Throws:
TransformExceptionFactoryRegistryExceptionSchemaException
-
isWrappedCoverageReader
Checks if the feature type specified is a GridCoverage2DReader wrapper -
convertPolygon
public static Polygon convertPolygon(Polygon roiInput, MathTransform worldToGridTransform) throws TransformException Converts a JTSPolygon, which represents a ROI, int an AWTPolygonby means of the providedMathTransform.- Parameters:
roiInput- the input ROI as a JTSPolygon.worldToGridTransform- theMathTransformto apply to the input ROI.- Returns:
- an AWT
Polygon. - Throws:
TransformException- in case the providedMathTransformchokes.
-
convertPolygonToPointArray
public static Polygon convertPolygonToPointArray(Polygon roiInput, MathTransform worldToGridTransform, List<Point2D> points) throws TransformException Converts a JTSPolygon, which represents a ROI, int an AWTPolygonby means of the providedMathTransform.It also stores the points for this polygon into the provided
List.- Parameters:
roiInput- the input ROI as a JTSPolygon.worldToGridTransform- theMathTransformto apply to the input ROI.points- aListthat should hold the transformed points.- Returns:
- an AWT
Polygon. - Throws:
TransformException- in case the providedMathTransformchokes.
-
getPolygon
public static Polygon getPolygon(GeneralBounds env, GeometryFactory gf) throws IllegalStateException, MismatchedDimensionException Convert the crop envelope into a polygon and the use the world-to-grid transform to get a ROI for the source coverage. -
area
Function to calculate the area of a polygon, according to the algorithm defined at http://local.wasp.uwa.edu.au/~pbourke/geometry/polyarea/- Parameters:
polyPoints- array of points in the polygon- Returns:
- area of the polygon defined by pgPoints
-