Class FeatureUtilities


  • public final class FeatureUtilities
    extends Object
    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 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).
      • isWrappedCoverage

        public static boolean isWrappedCoverage​(SimpleFeatureType featureType)
        Checks if the feature type specified is a GridCoverage wrapper
      • 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 JTS Polygon, which represents a ROI, int an AWT Polygon by means of the provided MathTransform.
        Parameters:
        roiInput - the input ROI as a JTS Polygon.
        worldToGridTransform - the MathTransform to apply to the input ROI.
        Returns:
        an AWT Polygon.
        Throws:
        TransformException - in case the provided MathTransform chokes.
      • convertPolygonToPointArray

        public static Polygon convertPolygonToPointArray​(Polygon roiInput,
                                                         MathTransform worldToGridTransform,
                                                         List<Point2D> points)
                                                  throws TransformException
        Converts a JTS Polygon, which represents a ROI, int an AWT Polygon by means of the provided MathTransform.

        It also stores the points for this polygon into the provided List.

        Parameters:
        roiInput - the input ROI as a JTS Polygon.
        worldToGridTransform - the MathTransform to apply to the input ROI.
        points - a List that should hold the transformed points.
        Returns:
        an AWT Polygon.
        Throws:
        TransformException - in case the provided MathTransform chokes.
      • 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