Class CoverageUtilities


  • public class CoverageUtilities
    extends Object
    A set of utilities methods for the Grid Coverage package. Those methods are not really rigorous; must of them should be seen as temporary implementations.
    Author:
    Simone Giannecchini, GeoSolutions
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static String COLS  
      static String EAST  
      static String MINX  
      static String MINY  
      static String NORTH  
      static String ROWS  
      static String SOUTH  
      static String WEST  
      static String XRES  
      static String YRES  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static Number convert​(Number val, Class<? extends Number> type)  
      static SimpleFeatureType createFeatureType​(GridCoverage2D gc2d, Class<? extends Geometry> geometryClass)
      Creates a SimpleFeatureType that exposes a coverage as a collections of feature points, mapping the centre of each pixel as a point plus all the bands as attributes.
      static RangeLookupTable getRangeLookupTable​(List<Range> classificationRanges, int[] outputPixelValues, Number noDataValue)  
      static RangeLookupTable getRangeLookupTable​(List<Range> classificationRanges, int[] outputPixelValues, Number noDataValue, Class<? extends Number> clazz)  
      static RangeLookupTable getRangeLookupTable​(List<Range> classificationRanges, Number noDataValue)  
      static RangeLookupTable getRangeLookupTable​(List<Range> classificationRanges, Number noDataValue, Class clazz)  
      static RangeLookupTable getRangeLookupTableJAIEXT​(List<Range> classificationRanges, int[] outputPixelValues, Number noDataValue, int transferType)  
      static HashMap<String,​Double> getRegionParamsFromGridCoverage​(GridCoverage2D gridCoverage)
      Get the parameters of the region covered by the coverage.
      static ROI prepareROI​(Geometry roi, AffineTransform mt2d)
      Utility method for transforming a geometry ROI into the raster space, using the provided affine transformation.
      • Methods inherited from class Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • prepareROI

        public static ROI prepareROI​(Geometry roi,
                                     AffineTransform mt2d)
                              throws ProcessException
        Utility method for transforming a geometry ROI into the raster space, using the provided affine transformation.
        Parameters:
        roi - a Geometry in model space.
        mt2d - an AffineTransform that maps from raster to model space. This is already referred to the pixel corner.
        Returns:
        a ROI suitable for using with JAI.
        Throws:
        ProcessException - in case there are problems with ivnerting the provided AffineTransform. Very unlikely to happen.
      • createFeatureType

        public static SimpleFeatureType createFeatureType​(GridCoverage2D gc2d,
                                                          Class<? extends Geometry> geometryClass)
        Creates a SimpleFeatureType that exposes a coverage as a collections of feature points, mapping the centre of each pixel as a point plus all the bands as attributes.

        The FID is the long that combines x+y*width.

        Parameters:
        gc2d - the GridCoverage2D to wrap.
        geometryClass - the class for the geometry.
        Returns:
        a SimpleFeatureType or null in case we are unable to wrap the coverage
      • getRangeLookupTable

        public static RangeLookupTable getRangeLookupTable​(List<Range> classificationRanges,
                                                           Number noDataValue)
      • getRangeLookupTable

        public static RangeLookupTable getRangeLookupTable​(List<Range> classificationRanges,
                                                           Number noDataValue,
                                                           Class clazz)
      • getRangeLookupTable

        public static RangeLookupTable getRangeLookupTable​(List<Range> classificationRanges,
                                                           int[] outputPixelValues,
                                                           Number noDataValue)
      • getRangeLookupTable

        public static RangeLookupTable getRangeLookupTable​(List<Range> classificationRanges,
                                                           int[] outputPixelValues,
                                                           Number noDataValue,
                                                           Class<? extends Number> clazz)
      • getRangeLookupTableJAIEXT

        public static RangeLookupTable getRangeLookupTableJAIEXT​(List<Range> classificationRanges,
                                                                 int[] outputPixelValues,
                                                                 Number noDataValue,
                                                                 int transferType)
      • convert

        public static Number convert​(Number val,
                                     Class<? extends Number> type)
      • getRegionParamsFromGridCoverage

        public static HashMap<String,​Double> getRegionParamsFromGridCoverage​(GridCoverage2D gridCoverage)
        Get the parameters of the region covered by the coverage.
        Parameters:
        gridCoverage - the coverage.
        Returns:
        the map of parameters. ( NORTH and the other static vars can be used to retrieve them.