Class Window
- java.lang.Object
-
- org.hortonmachine.gears.io.grasslegacy.utils.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
-
-
Field Summary
Fields Modifier and Type Field Description static StringBLACKBOARD_KEYstatic StringBLANK_WINDOW
-
Constructor Summary
Constructors Constructor Description Window(double west, double east, double south, double north, double weres, double nsres)Creates a new instance of WindowWindow(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 colsWindow(String windowFile)Creates a new instance of Window by supplying a JGrass workspace WIND fileWindow(String west, String east, String south, String north, int rows, int cols)Window(String west, String east, String south, String north, String ewres, String nsres)Window(Window win)Creates a new instance of Window from another window object
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static WindowadaptActiveRegionToEnvelope(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.voidfixResolution()fix the resolution with the integer rounded rows and colsvoidfixRowsAndCols()calculate rows and cols from the region and its resolution.static WindowgetActiveWindowFromMapset(String mapsetPath)Get the active region window from the mapsetLinkedHashMap<String,String>getAdditionalGrassEntries()intgetCols()doublegetEast()org.locationtech.jts.geom.EnvelopegetEnvelope()doublegetNorth()doublegetNSResolution()intgetProj()Rectangle2D.DoublegetRectangle()intgetRows()doublegetSouth()doublegetWEResolution()doublegetWest()doublegetXExtent()doublegetYExtent()intgetZone()voidlimitRowsCols(int _rows, int _cols)voidsetAdditionalGrassEntries(LinkedHashMap<String,String> adds)voidsetCols(int cols)voidsetEast(double e)voidsetExtent(Window win)Sets the extent of this window using another window.voidsetNorth(double n)voidsetNSResolution(double ns_res)voidsetProj(int _proj)voidsetRows(int rows)voidsetSouth(double s)voidsetWEResolution(double we_res)voidsetWest(double w)voidsetZone(int _zone)static Point2D.DoublesnapToNextHigherInActiveRegionResolution(double x, double y, Window activeWindow)Moves the point given by X and Y to be on the grid of the active region.StringtoString()static voidwriteActiveWindowToMapset(String mapsetPath, Window window)Write active region window to the mapsetstatic voidwriteDefaultWindowToLocation(String locationPath, Window window)Write default region window to the PERMANENT mapset
-
-
-
Field Detail
-
BLACKBOARD_KEY
public static final String BLACKBOARD_KEY
- See Also:
- Constant Field Values
-
BLANK_WINDOW
public static final String BLANK_WINDOW
- See Also:
- Constant Field Values
-
-
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 coordeast- east coordsouth- south coordnorth- 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
-
Window
public Window(String west, String east, String south, String north, String ewres, String nsres)
-
-
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)
-
setAdditionalGrassEntries
public void setAdditionalGrassEntries(LinkedHashMap<String,String> adds)
-
getAdditionalGrassEntries
public LinkedHashMap<String,String> getAdditionalGrassEntries()
-
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 pointy- the northing of the arbitrary pointactiveWindow- 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 folderthe- 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 folderthe- 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-
-
-