Class GridExtent
java.lang.Object
org.openjump.core.rasterimage.sextante.rasterWrappers.GridExtent
This class defines a grid system (coordinates and cellsize)
- Author:
- Victor Olaya
-
Constructor Summary
ConstructorsConstructorDescriptionGridExtent(ISextanteLayer layer) Creates a new grid extent using the extent of a layer If it is a raster layer, it will also use its cellsize -
Method Summary
Modifier and TypeMethodDescriptionvoidaddExtent(GridExtent extent) Modifies this extent to incorporate another one into its boundariesbooleancontains(double x, double y) Returns true if the given point falls within the area covered by this extentbooleancontainsCell(int x, int y) Returns true if the cell is within the limits of this grid extentvoidEnlarges this grid extent one cell in each directionbooleanequals(GridExtent extent) Returns true if this extent has them same characteristics as a given onebooleanfitsIn(GridExtent extent) Returns true if the given extents matches the grid defined by this grid extent (has same size and cell boundaries match)Returns this extent as a Java Rectangle2DReturns the cellsize of this extentorg.locationtech.jts.geom.EnvelopeReturns the extension of Grid as org.locationtech.jts.geom.EnvelopegetGridCoordsFromWorldCoords(double x, double y) Converts a world coordinate to grid coordinatesConverts a world coordinate to grid coordinatesgetGridCoordsFromWorldCoords(org.locationtech.jts.geom.Coordinate coordinate) Convert World coordinates to grid coordinatesdoubleReturns the real Y distance spanned by this extentintgetNX()Returns the number of columns in the extentintgetNY()Returns the number of rows in the extentdoublegetWidth()Returns the real X distance spanned by this extentgetWorldCoordsFromGridCoords(int x, int y) Converts a grid cell into a world coordinate representing the center of that cell/** Converts a grid cell into a world coordinate representing the center of that celldoublegetXMax()Return the maximum x coordinate of the extent.doublegetXMin()Return the minimum x coordinate of the extent.doublegetYMax()Return the maximum y coordinate of the extent.doublegetYMin()Return the minimum x coordinateof the extent.voidsetCellSize(double cellSizeX, double cellSizeY) voidsetValuesAndRaster(double cellSizeX, double cellSizeY, org.locationtech.jts.geom.Envelope envelope, double nodata) Method to build a GridExtent with a defined RastervoidsetXRange(double dXMin, double dXMax) Sets a new range for X coordinates.voidsetYRange(double dYMin, double dYMax) Sets a new range for Y coordinates.toString()
-
Constructor Details
-
GridExtent
public GridExtent() -
GridExtent
Creates a new grid extent using the extent of a layer If it is a raster layer, it will also use its cellsize- Parameters:
layer- a layer
-
-
Method Details
-
setXRange
public void setXRange(double dXMin, double dXMax) Sets a new range for X coordinates. Coordinates are not center cell ones, but border ones. Note, the CellSize needs to be set first before this method is used.- Parameters:
dXMin- the minimum x coordinate of the extent.dXMax- the maximum x coordinate of the extent
-
setYRange
public void setYRange(double dYMin, double dYMax) Sets a new range for Y coordinates. Coordinates are not center cell ones, but border ones. Note, the CellSize needs to be set first before this method is used.- Parameters:
dYMin- the minimum Y coordinate of the extent.dYMax- the maximum Y coordinate of the extent
-
getCellSize
Returns the cellsize of this extent- Returns:
- the cells size of this extent
-
setCellSize
public void setCellSize(double cellSizeX, double cellSizeY) -
setValuesAndRaster
public void setValuesAndRaster(double cellSizeX, double cellSizeY, org.locationtech.jts.geom.Envelope envelope, double nodata) Method to build a GridExtent with a defined Raster- Parameters:
cellSizeX- cell size along XcellSizeY- cell size along Yenvelope- envelope of this GridExtentnodata- nodata value
-
getRaster
-
getEnvelope
public org.locationtech.jts.geom.Envelope getEnvelope()Returns the extension of Grid as org.locationtech.jts.geom.Envelope- Returns:
- Envelope
-
getNX
public int getNX()Returns the number of columns in the extent- Returns:
- the number of columns
-
getNY
public int getNY()Returns the number of rows in the extent- Returns:
- the number of rows
-
getXMin
public double getXMin()Return the minimum x coordinate of the extent. This is not the coordinate of the center of the left-most cell, but the the coordinate of its left border- Returns:
- the minimum x coordinate of the extent
-
getXMax
public double getXMax()Return the maximum x coordinate of the extent. This is not the coordinate of the center of the right-most cell, but the the coordinate of its right border- Returns:
- the maximum x coordinate of the extent
-
getYMin
public double getYMin()Return the minimum x coordinateof the extent. This is not the coordinate of the center of the lower cell, but the the coordinate of its lower border- Returns:
- the minimum y coordinate of the extent
-
getYMax
public double getYMax()Return the maximum y coordinate of the extent. This is not the coordinate of the center of the upper cell, but the the coordinate of its upper border- Returns:
- the maximum x coordinate of the extent
-
getWidth
public double getWidth()Returns the real X distance spanned by this extent- Returns:
- the real X distance spanned by this extent
-
getHeight
public double getHeight()Returns the real Y distance spanned by this extent- Returns:
- the real Y distance spanned by this extent
-
contains
public boolean contains(double x, double y) Returns true if the given point falls within the area covered by this extent- Parameters:
x- the x coordinate of the pointy- the y coordinate of the point- Returns:
- whether the given point falls within the area covered by this extent
-
fitsIn
Returns true if the given extents matches the grid defined by this grid extent (has same size and cell boundaries match)- Parameters:
extent- another gridExtent to compare this gridExtent to- Returns:
- whether the passed extent matches fits into this extent
-
equals
Returns true if this extent has them same characteristics as a given one- Parameters:
extent- another gridExtent to compare this gridExtent to- Returns:
- whether this extent equals the given extent
-
addExtent
Modifies this extent to incorporate another one into its boundaries- Parameters:
extent- the extent to add
-
getGridCoordsFromWorldCoords
-
getGridCoordsFromWorldCoords
Converts a world coordinate to grid coordinates- Parameters:
x- the x coordinate of the pointy- the y coordinate of the point- Returns:
- a grid cell representing the given point in grid coordinates referred to this grid extent
-
getWorldCoordsFromGridCoords
-
getWorldCoordsFromGridCoords
Converts a grid cell into a world coordinate representing the center of that cell- Parameters:
x- the x coordinate (col) of the celly- the y coordinate (row) of the cell- Returns:
- a point representing the given cell in world coordinates
-
getGridCoordsFromWorldCoords
Convert World coordinates to grid coordinates- Parameters:
coordinate- the model Coordinate to convert to image Coordinate- Returns:
- java.awt.Point
-
toString
-
enlargeOneCell
public void enlargeOneCell()Enlarges this grid extent one cell in each direction -
getAsRectangle2D
Returns this extent as a Java Rectangle2D- Returns:
- the extent of this grid extent as a Jave Rectangle2D
-
containsCell
public boolean containsCell(int x, int y) Returns true if the cell is within the limits of this grid extent- Parameters:
x- the x coordinate (col) of the celly- the y coordinate (row) of the cell- Returns:
- whether the cell is within the limits of this grid extent
-