public class JGrassRegion extends Object
JGrass 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.
JGrassMapEnvironment}
Modifier and Type | Field and Description |
---|---|
static String |
BLACKBOARD_KEY
The identifier string for the
JGrassRegion . |
static String |
BLANK_REGION
The representation of a dummy region.
|
Constructor and Description |
---|
JGrassRegion(double west,
double east,
double south,
double north,
double weres,
double nsres)
Creates a new instance of
JGrassRegion . |
JGrassRegion(double west,
double east,
double south,
double north,
int rows,
int cols)
Creates a new instance of
JGrassRegion . |
JGrassRegion(Envelope2D envelope2D)
Creates a new instance of
JGrassRegion from an Envelope2D . |
JGrassRegion(JGrassRegion region)
Creates a new instance of
JGrassRegion by duplicating an existing region. |
JGrassRegion(String regionFilePath)
Creates a new instance of
JGrassRegion . |
JGrassRegion(String west,
String east,
String south,
String north,
int rows,
int cols)
Creates a new instance of
JGrassRegion from given strings. |
JGrassRegion(String west,
String east,
String south,
String north,
String ewres,
String nsres)
Creates a new instance of
JGrassRegion from given strings. |
Modifier and Type | Method and Description |
---|---|
static JGrassRegion |
adaptActiveRegionToEnvelope(Envelope sourceEnvelope,
JGrassRegion sourceRegion)
Creates a region from envelope bounds snapped to a region grid.
|
static JGrassRegion |
getActiveRegionFromMapset(String mapsetPath)
Computes the active region from the supplied mapset path.
|
LinkedHashMap<String,String> |
getAdditionalGrassEntries()
Getter for additionalGrassEntries.
|
int |
getCols()
Getter for cols.
|
double |
getEast()
Getter for east
|
Envelope |
getEnvelope()
Creates JTS envelope from the current region.
|
double |
getNorth()
Getter for north
|
double |
getNSResolution()
Getter for ns_res
|
int |
getProj()
Getter for proj
|
Rectangle2D.Double |
getRectangle()
Creates a rectangle from the current region.
|
int |
getRows()
Getter for rows
|
double |
getSouth()
Getter for south
|
double |
getWEResolution()
Getter for we_res
|
double |
getWest()
Getter for west
|
int |
getZone()
Getter for zone
|
JGrassRegion |
reproject(CoordinateReferenceSystem sourceCRS,
CoordinateReferenceSystem targetCRS,
boolean lenient)
Reprojects a
region . |
void |
setAdditionalGrassEntries(LinkedHashMap<String,String> additionalGrassEntries)
Setter for additionalGrassEntries.
|
void |
setCols(int cols)
Setter for cols.
|
void |
setEast(double east)
Setter for east
|
void |
setExtent(JGrassRegion region)
Sets the extent of this window using another window.
|
void |
setNorth(double north)
Setter for north
|
void |
setNSResolution(double ns_res)
Setter for ns_res
|
void |
setProj(int proj)
Setter for proj
|
void |
setRows(int rows)
Setter for rows
|
void |
setSouth(double south)
Setter for south
|
void |
setWEResolution(double we_res)
Setter for we_res
|
void |
setWest(double west)
Setter for west
|
void |
setZone(int zone)
Setter for zone
|
static Coordinate |
snapToNextHigherInRegionResolution(double x,
double y,
JGrassRegion region)
Snaps a geographic point to be on the region grid.
|
String |
toString() |
List<JGrassRegion> |
toSubRegions(int subregionsNum) |
static void |
writeDEFAULTWINDToLocation(String locationPath,
JGrassRegion region)
Write default region to the PERMANENT mapset.
|
static void |
writeWINDToMapset(String mapsetPath,
JGrassRegion activeRegion)
Writes active region window to the supplied mapset.
|
public static final String BLACKBOARD_KEY
JGrassRegion
.
Useful for environments that work with blackboards. For example the Udig layers support blackboards.
public static final String BLANK_REGION
public JGrassRegion(String regionFilePath) throws IOException
JGrassRegion
.
The supplied path has to be of the format of a GRASS WIND file.
regionFilePath
- a GRASS region file path.IOException
public JGrassRegion(double west, double east, double south, double north, int rows, int cols)
JGrassRegion
.
This constructor may be used when boundaries and number of rows and columns are available.
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.public JGrassRegion(double west, double east, double south, double north, double weres, double nsres)
JGrassRegion
.
This constructor may be used when boundaries and the resolution is available.
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.public JGrassRegion(JGrassRegion region)
JGrassRegion
by duplicating an existing region.region
- a region from which to take the setting from.public JGrassRegion(Envelope2D envelope2D)
JGrassRegion
from an Envelope2D
.envelope2D
- the envelope2D from which to take the setting from.public JGrassRegion(String west, String east, String south, String north, String ewres, String nsres)
JGrassRegion
from given strings.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.public JGrassRegion(String west, String east, String south, String north, int rows, int cols)
JGrassRegion
from given strings.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.public void setExtent(JGrassRegion region)
win
- another window objectpublic Envelope getEnvelope()
public Rectangle2D.Double getRectangle()
Note that the rectangle width and height are world coordinates.
public JGrassRegion reproject(CoordinateReferenceSystem sourceCRS, CoordinateReferenceSystem targetCRS, boolean lenient) throws Exception
region
.public static Coordinate snapToNextHigherInRegionResolution(double x, double y, JGrassRegion region)
Moves the point given by X and Y to be on the grid of the supplied region.
x
- the easting of the arbitrary point.y
- the northing of the arbitrary point.region
- the active window from which to take the grid.public static JGrassRegion getActiveRegionFromMapset(String mapsetPath) throws IOException
mapsetPath
- the path to the mapset folder.IOException
public static void writeWINDToMapset(String mapsetPath, JGrassRegion activeRegion) throws IOException
mapsetPath
- the path to the mapset folder.activeRegion
- the active region.IOException
public static void writeDEFAULTWINDToLocation(String locationPath, JGrassRegion region) throws IOException
locationPath
- the path to the location folder.region
- a region.IOException
public static JGrassRegion adaptActiveRegionToEnvelope(Envelope sourceEnvelope, JGrassRegion sourceRegion)
This takes an envelope and a JGrass region and creates a new region to match the bounds of the envelope, but the grid of the region. This is important if the region has to match some feature layer.
The bounds of the new region contain completely the envelope.
sourceEnvelope
- the envelope to adapt.sourceRegion
- the region from which to take the grid to be snapped.public List<JGrassRegion> toSubRegions(int subregionsNum)
subregionsNum
- public int getProj()
public void setProj(int proj)
proj
- the proj to setpublic int getZone()
public void setZone(int zone)
zone
- the zone to setpublic double getNorth()
public void setNorth(double north)
north
- the north to setpublic double getSouth()
public void setSouth(double south)
south
- the south to setpublic double getWest()
public void setWest(double west)
west
- the west to setpublic double getEast()
public void setEast(double east)
east
- the east to setpublic double getNSResolution()
public void setNSResolution(double ns_res)
ns_res
- the ns_res to setpublic double getWEResolution()
public void setWEResolution(double we_res)
we_res
- the we_res to setpublic int getRows()
public void setRows(int rows)
rows
- the rows to setpublic int getCols()
public void setCols(int cols)
cols
- the cols to set.public LinkedHashMap<String,String> getAdditionalGrassEntries()
public void setAdditionalGrassEntries(LinkedHashMap<String,String> additionalGrassEntries)
additionalGrassEntries
- the additionalGrassEntries to set.Copyright © 1996–2019 Geotools. All rights reserved.