Package org.geotools.coverage.util
Class FeatureUtilities
- Object
-
- FeatureUtilities
-
public final class FeatureUtilities extends Object
A set of utilities methods for interactions betweenGridCoverage
andFeature
. 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 FilterFactory
DEFAULT_FILTER_FACTORY
static PropertyName
GRID_PROPERTY_NAME
static PropertyName
PARAMS_PROPERTY_NAME
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description 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/static Polygon
convertPolygon(Polygon roiInput, MathTransform worldToGridTransform)
Converts a JTSPolygon
, which represents a ROI, int an AWTPolygon
by means of the providedMathTransform
.static Polygon
convertPolygonToPointArray(Polygon roiInput, MathTransform worldToGridTransform, List<Point2D> points)
Converts a JTSPolygon
, which represents a ROI, int an AWTPolygon
by means of the providedMathTransform
.static Polygon
getPolygon(Rectangle2D rect, int srid)
Returns the polygon surrounding the specified rectangle.static Polygon
getPolygon(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 boolean
isWrappedCoverage(SimpleFeatureType featureType)
Checks if the feature type specified is a GridCoverage wrapperstatic boolean
isWrappedCoverageReader(SimpleFeatureType featureType)
Checks if the feature type specified is a GridCoverage2DReader wrapperstatic SimpleFeatureCollection
wrapGridCoverage(GridCoverage2D coverage)
Wraps a grid coverage into a Feature.static SimpleFeatureCollection
wrapGridCoverageReader(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:
TransformException
SchemaException
-
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:
TransformException
FactoryRegistryException
SchemaException
-
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 AWTPolygon
by means of the providedMathTransform
.- Parameters:
roiInput
- the input ROI as a JTSPolygon
.worldToGridTransform
- theMathTransform
to apply to the input ROI.- Returns:
- an AWT
Polygon
. - Throws:
TransformException
- in case the providedMathTransform
chokes.
-
convertPolygonToPointArray
public static Polygon convertPolygonToPointArray(Polygon roiInput, MathTransform worldToGridTransform, List<Point2D> points) throws TransformException
Converts a JTSPolygon
, which represents a ROI, int an AWTPolygon
by 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
- theMathTransform
to apply to the input ROI.points
- aList
that should hold the transformed points.- Returns:
- an AWT
Polygon
. - Throws:
TransformException
- in case the providedMathTransform
chokes.
-
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
-
-