Class JGTProcessingRegion


  • public class JGTProcessingRegion
    extends Object
    Represents the processing region.

    Calculations always work against a particular geographic region, which contains the boundaries of the region as well as the information of the region's resolution and the number of rows and cols of the region.

    Warning: since the rows and cols have to be integers, the resolution is may be recalculated to fulfill this constraint. Users should not wonder if the asked resolution is not available in the supplied boundaries.

    Since:
    1.2.1
    Author:
    Andrea Antonello - www.hydrologis.com
    • Constructor Detail

      • JGTProcessingRegion

        public JGTProcessingRegion​(double west,
                                   double east,
                                   double south,
                                   double north,
                                   int rows,
                                   int cols)
        Creates a new instance of JGTProcessingRegion.

        This constructor may be used when boundaries and number of rows and columns are available.

        Parameters:
        west - the western boundary.
        east - the eastern boundary.
        south - the southern boundary.
        north - the nothern boundary.
        rows - the number of rows.
        cols - the number of cols.
      • JGTProcessingRegion

        public JGTProcessingRegion​(double west,
                                   double east,
                                   double south,
                                   double north,
                                   double weres,
                                   double nsres)
        Creates a new instance of JGTProcessingRegion.

        This constructor may be used when boundaries and the resolution is available.

        Parameters:
        west - the western boundary.
        east - the eastern boundary.
        south - the southern boundary.
        north - the northern boundary.
        weres - the east-west resolution.
        nsres - the north -south resolution.
      • JGTProcessingRegion

        public JGTProcessingRegion​(JGTProcessingRegion region)
        Creates a new instance of JGTProcessingRegion by duplicating an existing region.
        Parameters:
        region - a region from which to take the setting from.
      • JGTProcessingRegion

        public JGTProcessingRegion​(org.geotools.geometry.Envelope2D envelope2D)
        Creates a new instance of JGTProcessingRegion from an Envelope2D .
        Parameters:
        envelope2D - the envelope2D from which to take the setting from.
      • JGTProcessingRegion

        public JGTProcessingRegion​(org.geotools.coverage.grid.GridCoverage2D gridCoverage)
        Creates a new instance of JGTProcessingRegion from a coverage.
        Parameters:
        gridCoverage - the gridcoverage from which to take the region.
      • JGTProcessingRegion

        public JGTProcessingRegion​(String west,
                                   String east,
                                   String south,
                                   String north,
                                   String ewres,
                                   String nsres)
        Creates a new instance of JGTProcessingRegion from given strings.
        Parameters:
        west - the western boundary string.
        east - the eastern boundary string.
        south - the southern boundary string.
        north - the nothern boundary string.
        ewres - the x resolution string.
        nsres - the y resolution string.
      • JGTProcessingRegion

        public JGTProcessingRegion​(String west,
                                   String east,
                                   String south,
                                   String north,
                                   int rows,
                                   int cols)
        Creates a new instance of JGTProcessingRegion from given strings.
        Parameters:
        west - the western boundary string.
        east - the eastern boundary string.
        south - the southern boundary string.
        north - the nothern boundary string.
        rows - the string of rows.
        cols - the string of cols.
    • Method Detail

      • setExtent

        public void setExtent​(JGTProcessingRegion region)
        Sets the extent of this window using another window.
        Parameters:
        win - another window object
      • getEnvelope

        public org.locationtech.jts.geom.Envelope getEnvelope()
        Creates JTS envelope from the current region.
        Returns:
        the JTS envelope wrapping the current region.
      • getRectangle

        public Rectangle2D.Double getRectangle()
        Creates a rectangle from the current region.

        Note that the rectangle width and height are world coordinates.

        Returns:
        the rectangle wrapping the current region.
      • reproject

        public JGTProcessingRegion reproject​(org.opengis.referencing.crs.CoordinateReferenceSystem sourceCRS,
                                             org.opengis.referencing.crs.CoordinateReferenceSystem targetCRS,
                                             boolean lenient)
                                      throws Exception
        Reprojects a region.
        Parameters:
        sourceCRS - the original crs of the region.
        targetCRS - the target crs of the region.
        lenient - defines whether to apply a lenient transformation or not.
        Returns:
        a new region.
        Throws:
        Exception - exception that may be thrown when applying the transformation.
      • snapToNextHigherInRegionResolution

        public static org.locationtech.jts.geom.Coordinate snapToNextHigherInRegionResolution​(double x,
                                                                                              double y,
                                                                                              JGTProcessingRegion region)
        Snaps a geographic point to be on the region grid.

        Moves the point given by X and Y to be on the grid of the supplied region.

        Parameters:
        x - the easting of the arbitrary point.
        y - the northing of the arbitrary point.
        region - the active window from which to take the grid.
        Returns:
        the snapped coordinate.
      • toSubRegions

        public List<JGTProcessingRegion> toSubRegions​(int subregionsNum)
        Parameters:
        subregionsNum -
        Returns:
      • getNorth

        public double getNorth()
        Getter for north
        Returns:
        the north
      • setNorth

        public void setNorth​(double north)
        Setter for north
        Parameters:
        north - the north to set
      • getSouth

        public double getSouth()
        Getter for south
        Returns:
        the south
      • setSouth

        public void setSouth​(double south)
        Setter for south
        Parameters:
        south - the south to set
      • getWest

        public double getWest()
        Getter for west
        Returns:
        the west
      • setWest

        public void setWest​(double west)
        Setter for west
        Parameters:
        west - the west to set
      • getEast

        public double getEast()
        Getter for east
        Returns:
        the east
      • setEast

        public void setEast​(double east)
        Setter for east
        Parameters:
        east - the east to set
      • getNSResolution

        public double getNSResolution()
        Getter for ns_res
        Returns:
        the ns_res
      • setNSResolution

        public void setNSResolution​(double ns_res)
        Setter for ns_res
        Parameters:
        ns_res - the ns_res to set
      • getWEResolution

        public double getWEResolution()
        Getter for we_res
        Returns:
        the we_res
      • setWEResolution

        public void setWEResolution​(double we_res)
        Setter for we_res
        Parameters:
        we_res - the we_res to set
      • getRows

        public int getRows()
        Getter for rows
        Returns:
        the rows
      • setRows

        public void setRows​(int rows)
        Setter for rows
        Parameters:
        rows - the rows to set
      • getCols

        public int getCols()
        Getter for cols.
        Returns:
        the cols.
      • setCols

        public void setCols​(int cols)
        Setter for cols.
        Parameters:
        cols - the cols to set.
      • getGridGeometry

        public org.geotools.coverage.grid.GridGeometry2D getGridGeometry​(org.opengis.referencing.crs.CoordinateReferenceSystem crs)
        Transform the current region into a GridGeometry2D.
        Parameters:
        crs - the CoordinateReferenceSystem to apply.
        Returns:
        the gridgeometry.