Class Window


  • public class Window
    extends Object

    The window object represents a particular geographic regione, containing also the information of the grid's resolution and therefore also the number of rows and cols of the region.

    Warning: since the rows and cols are integers, the resolution is recalculated to fulfill this. Therefore the asked resolution could not be exactly the one in the end is supplied.

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

      • Window

        public Window​(String windowFile)
        Creates a new instance of Window by supplying a JGrass workspace WIND file
        Parameters:
        windowFile - a JGrass workspace WIND file path
      • Window

        public Window​(double west,
                      double east,
                      double south,
                      double north,
                      int _rows,
                      int _cols)
        Creates a new instance of Window from the boundaries and the number of rows and cols
        Parameters:
        west - west coord
        east - east coord
        south - south coord
        north - north coord
        _rows - required number of rows
        _cols - required number of cols
      • Window

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

        public Window​(Window win)
        Creates a new instance of Window from another window object
        Parameters:
        win - a window object
    • Method Detail

      • getEnvelope

        public org.locationtech.jts.geom.Envelope getEnvelope()
        Returns:
        the JTS envelope from the window object
      • limitRowsCols

        public void limitRowsCols​(int _rows,
                                  int _cols)
      • setExtent

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

        public Rectangle2D.Double getRectangle()
        Returns:
        the rectangle wrapping the window object
      • fixResolution

        public void fixResolution()
        fix the resolution with the integer rounded rows and cols
      • fixRowsAndCols

        public void fixRowsAndCols()
        calculate rows and cols from the region and its resolution. Round if required.
      • getProj

        public int getProj()
      • setProj

        public void setProj​(int _proj)
      • getZone

        public int getZone()
      • setZone

        public void setZone​(int _zone)
      • getWest

        public double getWest()
      • getEast

        public double getEast()
      • getSouth

        public double getSouth()
      • getNorth

        public double getNorth()
      • getRows

        public int getRows()
      • getCols

        public int getCols()
      • getWEResolution

        public double getWEResolution()
      • getNSResolution

        public double getNSResolution()
      • getXExtent

        public double getXExtent()
      • getYExtent

        public double getYExtent()
      • setCols

        public void setCols​(int cols)
      • setEast

        public void setEast​(double e)
      • setNorth

        public void setNorth​(double n)
      • setNSResolution

        public void setNSResolution​(double ns_res)
      • setRows

        public void setRows​(int rows)
      • setSouth

        public void setSouth​(double s)
      • setWest

        public void setWest​(double w)
      • setWEResolution

        public void setWEResolution​(double we_res)
      • snapToNextHigherInActiveRegionResolution

        public static Point2D.Double snapToNextHigherInActiveRegionResolution​(double x,
                                                                              double y,
                                                                              Window activeWindow)
        Moves the point given by X and Y to be on the grid of the active region.
        Parameters:
        x - the easting of the arbitrary point
        y - the northing of the arbitrary point
        activeWindow - the active window from which to take the grid
        Returns:
        the snapped point
      • getActiveWindowFromMapset

        public static Window getActiveWindowFromMapset​(String mapsetPath)
        Get the active region window from the mapset
        Parameters:
        mapsetPath - the path to the mapset folder
        Returns:
        the active Window object of that mapset
      • writeActiveWindowToMapset

        public static void writeActiveWindowToMapset​(String mapsetPath,
                                                     Window window)
                                              throws IOException
        Write active region window to the mapset
        Parameters:
        mapsetPath - the path to the mapset folder
        the - active Window object
        Throws:
        IOException
      • writeDefaultWindowToLocation

        public static void writeDefaultWindowToLocation​(String locationPath,
                                                        Window window)
                                                 throws IOException
        Write default region window to the PERMANENT mapset
        Parameters:
        locationPath - the path to the location folder
        the - active Window object
        Throws:
        IOException
      • adaptActiveRegionToEnvelope

        public static Window adaptActiveRegionToEnvelope​(org.locationtech.jts.geom.Envelope bounds,
                                                         Window activeRegion)
        Takes an envelope and an active region and creates a new region to match the bounds of the envelope, but the resolutions of the active region. This is important if the region has to match some feature layer. The bounds are assured to contain completely the envelope.
        Parameters:
        bounds -
        activeRegion -