Class JGTProcessingRegion
- java.lang.Object
-
- org.hortonmachine.gears.libs.modules.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 Summary
Constructors Constructor Description JGTProcessingRegion(double west, double east, double south, double north, double weres, double nsres)Creates a new instance ofJGTProcessingRegion.JGTProcessingRegion(double west, double east, double south, double north, int rows, int cols)Creates a new instance ofJGTProcessingRegion.JGTProcessingRegion(String west, String east, String south, String north, int rows, int cols)Creates a new instance ofJGTProcessingRegionfrom given strings.JGTProcessingRegion(String west, String east, String south, String north, String ewres, String nsres)Creates a new instance ofJGTProcessingRegionfrom given strings.JGTProcessingRegion(org.geotools.coverage.grid.GridCoverage2D gridCoverage)Creates a new instance ofJGTProcessingRegionfrom acoverage.JGTProcessingRegion(org.geotools.geometry.Envelope2D envelope2D)Creates a new instance ofJGTProcessingRegionfrom anEnvelope2D.JGTProcessingRegion(JGTProcessingRegion region)Creates a new instance ofJGTProcessingRegionby duplicating an existing region.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description intgetCols()Getter for cols.doublegetEast()Getter for eastorg.locationtech.jts.geom.EnvelopegetEnvelope()Creates JTS envelope from the current region.org.geotools.coverage.grid.GridGeometry2DgetGridGeometry(org.opengis.referencing.crs.CoordinateReferenceSystem crs)Transform the current region into aGridGeometry2D.doublegetNorth()Getter for northdoublegetNSResolution()Getter for ns_resRectangle2D.DoublegetRectangle()Creates a rectangle from the current region.HashMap<String,Double>getRegionParams()intgetRows()Getter for rowsdoublegetSouth()Getter for southdoublegetWEResolution()Getter for we_resdoublegetWest()Getter for westJGTProcessingRegionreproject(org.opengis.referencing.crs.CoordinateReferenceSystem sourceCRS, org.opengis.referencing.crs.CoordinateReferenceSystem targetCRS, boolean lenient)Reprojects aregion.voidsetCols(int cols)Setter for cols.voidsetEast(double east)Setter for eastvoidsetExtent(JGTProcessingRegion region)Sets the extent of this window using another window.voidsetNorth(double north)Setter for northvoidsetNSResolution(double ns_res)Setter for ns_resvoidsetRows(int rows)Setter for rowsvoidsetSouth(double south)Setter for southvoidsetWEResolution(double we_res)Setter for we_resvoidsetWest(double west)Setter for weststatic org.locationtech.jts.geom.CoordinatesnapToNextHigherInRegionResolution(double x, double y, JGTProcessingRegion region)Snaps a geographic point to be on the region grid.StringtoString()List<JGTProcessingRegion>toSubRegions(int subregionsNum)
-
-
-
Constructor Detail
-
JGTProcessingRegion
public JGTProcessingRegion(double west, double east, double south, double north, int rows, int cols)Creates a new instance ofJGTProcessingRegion.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 ofJGTProcessingRegion.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 ofJGTProcessingRegionby 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 ofJGTProcessingRegionfrom anEnvelope2D.- Parameters:
envelope2D- the envelope2D from which to take the setting from.
-
JGTProcessingRegion
public JGTProcessingRegion(org.geotools.coverage.grid.GridCoverage2D gridCoverage)
Creates a new instance ofJGTProcessingRegionfrom acoverage.- 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 ofJGTProcessingRegionfrom 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 ofJGTProcessingRegionfrom 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 aregion.
-
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 aGridGeometry2D.- Parameters:
crs- theCoordinateReferenceSystemto apply.- Returns:
- the gridgeometry.
-
-