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 FilterFactory
static final PropertyName
static final PropertyName
-
Method Summary
Modifier and TypeMethodDescriptionstatic double
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 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:
TransformException
SchemaException
-
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:
TransformException
FactoryRegistryException
SchemaException
-
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 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
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
-