Package org.geotools.coverage.util
Class FeatureUtilities
- Object
-
- FeatureUtilities
-
public final class FeatureUtilities extends Object
A set of utilities methods for interactions betweenGridCoverageandFeature. Those methods are not really rigorous; must of them should be seen as temporary implementations.- Since:
- 2.4
- Author:
- Simone Giannecchini
-
-
Field Summary
Fields Modifier and Type Field Description static FilterFactoryDEFAULT_FILTER_FACTORYstatic PropertyNameGRID_PROPERTY_NAMEstatic PropertyNamePARAMS_PROPERTY_NAME
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static doublearea(Point2D[] polyPoints)Function 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 Detail
-
DEFAULT_FILTER_FACTORY
public static final FilterFactory DEFAULT_FILTER_FACTORY
-
GRID_PROPERTY_NAME
public static final PropertyName GRID_PROPERTY_NAME
-
PARAMS_PROPERTY_NAME
public static final PropertyName PARAMS_PROPERTY_NAME
-
-
Method Detail
-
getPolygon
public static Polygon getPolygon(Rectangle2D rect, int srid)
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
public static boolean isWrappedCoverage(SimpleFeatureType featureType)
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
public static boolean isWrappedCoverageReader(SimpleFeatureType featureType)
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
public static double area(Point2D[] polyPoints)
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
-
-