Class GridExtent

java.lang.Object
org.openjump.core.rasterimage.sextante.rasterWrappers.GridExtent

public class GridExtent extends Object
This class defines a grid system (coordinates and cellsize)
Author:
Victor Olaya
  • Constructor Summary

    Constructors
    Constructor
    Description
     
    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 Type
    Method
    Description
    void
    Modifies this extent to incorporate another one into its boundaries
    boolean
    contains(double x, double y)
    Returns true if the given point falls within the area covered by this extent
    boolean
    containsCell(int x, int y)
    Returns true if the cell is within the limits of this grid extent
    void
    Enlarges this grid extent one cell in each direction
    boolean
    Returns true if this extent has them same characteristics as a given one
    boolean
    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 Rectangle2D
    Returns the cellsize of this extent
    org.locationtech.jts.geom.Envelope
    Returns the extension of Grid as org.locationtech.jts.geom.Envelope
    getGridCoordsFromWorldCoords(double x, double y)
    Converts a world coordinate to grid coordinates
    Converts a world coordinate to grid coordinates
    getGridCoordsFromWorldCoords(org.locationtech.jts.geom.Coordinate coordinate)
    Convert World coordinates to grid coordinates
    double
    Returns the real Y distance spanned by this extent
    int
    Returns the number of columns in the extent
    int
    Returns the number of rows in the extent
     
    double
    Returns the real X distance spanned by this extent
    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 cell
    double
    Return the maximum x coordinate of the extent.
    double
    Return the minimum x coordinate of the extent.
    double
    Return the maximum y coordinate of the extent.
    double
    Return the minimum x coordinateof the extent.
    void
    setCellSize(double cellSizeX, double cellSizeY)
     
    void
    setValuesAndRaster(double cellSizeX, double cellSizeY, org.locationtech.jts.geom.Envelope envelope, double nodata)
    Method to build a GridExtent with a defined Raster
    void
    setXRange(double dXMin, double dXMax)
    Sets a new range for X coordinates.
    void
    setYRange(double dYMin, double dYMax)
    Sets a new range for Y coordinates.
     

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • GridExtent

      public GridExtent()
    • GridExtent

      public GridExtent(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
      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

      public Point2D.Double 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 X
      cellSizeY - cell size along Y
      envelope - envelope of this GridExtent
      nodata - nodata value
    • getRaster

      public WritableRaster 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 point
      y - the y coordinate of the point
      Returns:
      whether the given point falls within the area covered by this extent
    • fitsIn

      public boolean fitsIn(GridExtent extent)
      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

      public boolean equals(GridExtent extent)
      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

      public void addExtent(GridExtent extent)
      Modifies this extent to incorporate another one into its boundaries
      Parameters:
      extent - the extent to add
    • getGridCoordsFromWorldCoords

      public GridCell getGridCoordsFromWorldCoords(Point2D pt)
      Converts a world coordinate to grid coordinates
      Parameters:
      pt - a point in world coordinates
      Returns:
      a grid cell with coordinates of the given point in grid coordinates referred to this grid extent
    • getGridCoordsFromWorldCoords

      public GridCell getGridCoordsFromWorldCoords(double x, double y)
      Converts a world coordinate to grid coordinates
      Parameters:
      x - the x coordinate of the point
      y - the y coordinate of the point
      Returns:
      a grid cell representing the given point in grid coordinates referred to this grid extent
    • getWorldCoordsFromGridCoords

      public Point2D getWorldCoordsFromGridCoords(GridCell cell)
      /** Converts a grid cell into a world coordinate representing the center of that cell
      Parameters:
      cell - the cell to convert
      Returns:
      a point representing the given cell in world coordinates
    • getWorldCoordsFromGridCoords

      public Point2D getWorldCoordsFromGridCoords(int x, int y)
      Converts a grid cell into a world coordinate representing the center of that cell
      Parameters:
      x - the x coordinate (col) of the cell
      y - the y coordinate (row) of the cell
      Returns:
      a point representing the given cell in world coordinates
    • getGridCoordsFromWorldCoords

      public Point getGridCoordsFromWorldCoords(org.locationtech.jts.geom.Coordinate coordinate)
      Convert World coordinates to grid coordinates
      Parameters:
      coordinate - the model Coordinate to convert to image Coordinate
      Returns:
      java.awt.Point
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • enlargeOneCell

      public void enlargeOneCell()
      Enlarges this grid extent one cell in each direction
    • getAsRectangle2D

      public Rectangle2D 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 cell
      y - the y coordinate (row) of the cell
      Returns:
      whether the cell is within the limits of this grid extent