uk.ac.leeds.ccg.andyt.grids.process
Class Grid2DSquareCellProcessor

java.lang.Object
  extended by uk.ac.leeds.ccg.andyt.grids.process.Grid2DSquareCellProcessor
Direct Known Subclasses:
GenerateRoofData, GenerateTestData, Grid2DSquareCellProcessorDEM, Grid2DSquareCellProcessorGWS, UtilitiesRuns

public class Grid2DSquareCellProcessor
extends java.lang.Object

A class holding methods for processing an individual AbstractGrid2DSquareCell or multiple Grid2DSquareCellAbstracts. TODO: Implement a general replace method ( depricate/replace mask methods ).


Field Summary
protected  java.io.File _Directory
          Workspace directory for the processing.
 Grid2DSquareCellDoubleChunk64CellMapFactory _Grid2DSquareCellDoubleChunk64CellMapFactory
          Grid2DSquareCellDoubleChunk64CellMapFactory
 Grid2DSquareCellDoubleChunkArrayFactory _Grid2DSquareCellDoubleChunkArrayFactory
          Grid2DSquareCellDoubleChunkArrayFactory
 AbstractGrid2DSquareCellDoubleChunkFactory _Grid2DSquareCellDoubleChunkFactory
          Default AbstractGrid2DSquareCellDoubleChunkFactory
 Grid2DSquareCellDoubleChunkJAIFactory _Grid2DSquareCellDoubleChunkJAIFactory
          Grid2DSquareCellDoubleChunkJAIFactory
 Grid2DSquareCellDoubleChunkMapFactory _Grid2DSquareCellDoubleChunkMapFactory
          Grid2DSquareCellDoubleChunkMapFactory
 Grid2DSquareCellDoubleChunkRAFFactory _Grid2DSquareCellDoubleChunkRAFFactory
          Grid2DSquareCellDoubleChunkRAFFactory
 Grid2DSquareCellDoubleFactory _Grid2DSquareCellDoubleFactory
          Grid2DSquareCellDoubleFactory
 Grid2DSquareCellIntChunk64CellMapFactory _Grid2DSquareCellIntChunk64CellMapFactory
          Grid2DSquareCellIntChunk64CellMapFactory
 Grid2DSquareCellIntChunkArrayFactory _Grid2DSquareCellIntChunkArrayFactory
          Grid2DSquareCellIntChunkArrayFactory
 Grid2DSquareCellIntChunkJAIFactory _Grid2DSquareCellIntChunkJAIFactory
          Grid2DSquareCellIntChunkJAIFactory
 Grid2DSquareCellIntChunkMapFactory _Grid2DSquareCellIntChunkMapFactory
          Grid2DSquareCellIntChunkMapFactory
 Grid2DSquareCellIntChunkRAFFactory _Grid2DSquareCellIntChunkRAFFactory
          Grid2DSquareCellIntChunkRAFFactory
 Grid2DSquareCellIntFactory _Grid2DSquareCellIntFactory
          Grid2DSquareCellIntFactory
 AbstractGrid2DSquareCellIntChunkFactory _Grid2DSquareCelllIntChunkFactory
          Default AbstractGrid2DSquareCellIntChunkFactory
 AbstractGridStatistics _GridStatistics
          GridStatistics1
 GridStatistics0 _GridStatistics0
          GridStatistics0
 GridStatistics1 _GridStatistics1
          GridStatistics1
protected  java.io.PrintWriter log
          The log for recording progress and information about the processing.
protected  int logIndentation
          The log indentation (how many spaces before a log message line is output).
protected  long startTime
          For storing the start time of the processing.
 
Constructor Summary
Grid2DSquareCellProcessor()
          Creates a new instance of Grid2DSquareCellDoubleProcessor
Grid2DSquareCellProcessor(java.io.File _Directory)
          Creates a new instance of Grid2DSquareCellDoubleProcessor.
Grid2DSquareCellProcessor(java.io.File _Directory, boolean appendToLogFile)
          Creates a new instance of Grid2DSquareCellDoubleProcessor.
Grid2DSquareCellProcessor(Grids_Environment _Grids_Environment)
           
 
Method Summary
 void _Output(AbstractGrid2DSquareCell _Grid2DSquareCell, java.io.File _Output_Directory, ImageExporter _ImageExporter, java.lang.String[] _ImageTypes, ESRIAsciiGridExporter _ESRIAsciiGridExporter, boolean handleOutOfMemoryError)
           For outputting _Grid2DSquareCell to various formats of file.
 void _OutputESRIAsciiGrid(AbstractGrid2DSquareCell _Grid2DSquareCell, java.io.File _Output_Directory, ESRIAsciiGridExporter _ESRIAsciiGridExporter, boolean handleOutOfMemoryError)
           
 void _OutputImage(AbstractGrid2DSquareCell _Grid2DSquareCell, java.io.File _Output_Directory, ImageExporter _ImageExporter, java.lang.String[] _ImageTypes, boolean handleOutOfMemoryError)
           
 Grid2DSquareCellDouble _Rescale(AbstractGrid2DSquareCell _InputGrid, java.lang.String type, double min, double max, boolean handleOutOfMemoryError)
           
 void addToGrid(Grid2DSquareCellDouble grid, AbstractGrid2DSquareCell.CellID[] _CellIDs, double value, boolean handleOutOfMemoryError)
          Adds value to grid for cells with CellID in _CellIDs
 void addToGrid(Grid2DSquareCellDouble grid, double value, boolean handleOutOfMemoryError)
          Adds value to every cell of grid.
 void addToGrid(Grid2DSquareCellDouble grid, java.io.File file, java.lang.String type, boolean handleOutOfMemoryError)
          Returns grid with values added from a file.
 void addToGrid(Grid2DSquareCellDouble grid, Grid2DSquareCellDouble gridToAdd, boolean handleOutOfMemoryError)
          Add gridToAdd to grid
 void addToGrid(Grid2DSquareCellDouble grid, Grid2DSquareCellDouble gridToAdd, double weight, boolean handleOutOfMemoryError)
          Add gridToAdd to grid with values from gridToAdd multiplied by weight.
 void addToGrid(Grid2DSquareCellDouble grid, Grid2DSquareCellDouble gridToAdd, long startRowIndex, long startColIndex, long endRowIndex, long endColIndex, java.math.BigDecimal[] dimensionConstraints, double weight, boolean handleOutOfMemoryError)
          Returns a Grid2DSquareCellDouble with values of grid added with values from gridToAdd (with row index between startRowIndex, endRowIndex and column index between startColIndex, endColIndex) multiplied by weight.
 void addToGrid(Grid2DSquareCellDouble grid, Grid2DSquareCellDouble gridToAdd, long startRowIndex, long startColIndex, long endRowIndex, long endColIndex, double weight, boolean handleOutOfMemoryError)
          Add gridToAdd to grid with values from gridToAdd multiplied by weight.
 void addToGrid(Grid2DSquareCellDouble grid, java.util.HashSet _CellIDs, double value, boolean handleOutOfMemoryError)
          Adds value to grid for cells with CellID in _CellIDs
 Grid2DSquareCellDouble aggregate(AbstractGrid2DSquareCell grid, int cellFactor, java.lang.String statistic, int rowOffset, int colOffset, Grid2DSquareCellDoubleFactory gridFactory, boolean handleOutOfMemoryError)
          Returns an Grid2DSquareCellDouble at a lower level of resolution than grid.
 Grid2DSquareCellDouble aggregate(AbstractGrid2DSquareCell grid, java.lang.String statistic, java.math.BigDecimal[] resultDimensions, Grid2DSquareCellDoubleFactory gridFactory, boolean handleOutOfMemoryError)
          Returns an Grid2DSquareCellDouble at a lower level of resolution than grid.
protected  double angle(double x1, double y1, double x2, double y2)
          Returns the clockwise angle in radians to the y axis of the line from (x1,y1) to (x2,y2).
 double angle(double x1, double y1, double x2, double y2, boolean handleOutOfMemoryError)
          Returns the clockwise angle in radians to the y axis of the line from (x1,y1) to (x2,y2).
 double angle(double x1, double y1, double x2, double y2, int nChunkCols, int _ChunkRowIndex, int _ChunkColIndex, boolean handleOutOfMemoryError)
          Returns the clockwise angle in radians to the y axis of the line from (x1,y1) to (x2,y2).
 void copyAndSetUpNewLog(java.io.File newLog, boolean handleOutOfMemoryError)
          Copies and sets up a new log.
protected  double distance(double x1, double y1, double x2, double y2)
          Returns the distance between a pair of coordinates
 double distance(double x1, double y1, double x2, double y2, boolean handleOutOfMemoryError)
          Returns the distance between a pair of coordinates
 double distance(double x1, double y1, double x2, double y2, int nChunkCols, int _ChunkRowIndex, int _ChunkColIndex, boolean handleOutOfMemoryError)
          Returns the distance between a pair of coordinates
 java.io.File get_Directory(boolean handleOutOfMemoryError)
          Returns a copy of this._Directory
protected  AbstractGrid2DSquareCell getGrid2DSquareCell()
          Returns a AbstractGrid2DSquareCell from this._AbstractGrid2DSquareCell_HashSet.
 AbstractGrid2DSquareCell getGrid2DSquareCell(boolean handleOutOfMemoryError)
          Returns a AbstractGrid2DSquareCell from this._AbstractGrid2DSquareCell_HashSet.
protected  double[][] getRowProcessData(Grid2DSquareCellDouble grid, double[][] previous, int cellDistance, long row, long col)
          Returns a double[][] based on previous which has been shuffled
protected  double[][] getRowProcessInitialData(Grid2DSquareCellDouble grid, int cellDistance, long row)
          Returns a double[][] of grid values
protected  long getTime0()
          Returns a copy of this.startTime.
 long getTime0(boolean handleOutOfMemoryError)
           
protected  void log(int logIndentation, java.lang.String string)
          Writes string to log file and the console (standard output) indenting string by logIndentation amount of white-space.
 void log(int logIndentation, java.lang.String string, boolean handleOutOfMemoryError)
          Writes string to log file and the console (standard output) indenting string by logIndentation amount of white-space.
 void log(java.lang.String string, boolean handleOutOfMemoryError)
          Writes string to log file and the console (standard output)
 void mask(AbstractGrid2DSquareCell grid, AbstractGrid2DSquareCell mask, boolean handleOutOfMemoryError)
          Modifies grid by setting to grid.noDataValue those cells coincident with mask.noDataValue cells.
 void mask(AbstractGrid2DSquareCell grid, double min, double max, boolean handleOutOfMemoryError)
          Modifies grid with the values of cells in the range [min,max] set to its noDataValue.
 void mask(AbstractGrid2DSquareCell grid, double xmin, double ymin, double xmax, double ymax, boolean handleOutOfMemoryError)
          Modifies grid by setting to grid.noDataValue those cells that's centroids intersect the rectangle given by: (xmin,ymin,xmax,ymax).
 void mask(AbstractGrid2DSquareCell grid, long startRowIndex, long startColIndex, long endRowIndex, long endColIndex, boolean handleOutOfMemoryError)
          Modifies grid by setting to grid.noDataValue those cells that intersect the rectangle given by: (startRowIndex,startColIndex,endRowIndex,endColIndex).
protected  void set_Directory(java.io.File _Directory)
          Changes this._Directory, this._Grid2DSquareCellDoubleFactory._Directory, this._Grid2DSquareCellIntFactory._Directory to _Directory.
protected  void set_Directory(java.io.File _Directory, boolean handleOutOfMemoryError)
          Changes _Directory to that passed in if it can be created.
 void set_Directory(java.io.File _Directory, boolean copyLogFile, boolean handleOutOfMemoryError)
          Changes this._Directory to that passed in if it can be created.
 void setValueALittleBitLarger(Grid2DSquareCellDouble grid, java.util.HashSet _CellIDs, boolean handleOutOfMemoryError)
          Modifies grid so value of cells with CellIDs in _CellIDs are set to a value a little bit larger.
 void setValueALittleBitSmaller(Grid2DSquareCellDouble grid, java.util.HashSet _CellIDs, boolean handleOutOfMemoryError)
          Modifies grid so value of cells with CellIDs in _CellIDs are set to a value a little bit smaller.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

startTime

protected long startTime
For storing the start time of the processing.


log

protected java.io.PrintWriter log
The log for recording progress and information about the processing.


logIndentation

protected int logIndentation
The log indentation (how many spaces before a log message line is output).


_Directory

protected java.io.File _Directory
Workspace directory for the processing.


_Grid2DSquareCelllIntChunkFactory

public AbstractGrid2DSquareCellIntChunkFactory _Grid2DSquareCelllIntChunkFactory
Default AbstractGrid2DSquareCellIntChunkFactory


_Grid2DSquareCellIntChunk64CellMapFactory

public Grid2DSquareCellIntChunk64CellMapFactory _Grid2DSquareCellIntChunk64CellMapFactory
Grid2DSquareCellIntChunk64CellMapFactory


_Grid2DSquareCellIntChunkArrayFactory

public Grid2DSquareCellIntChunkArrayFactory _Grid2DSquareCellIntChunkArrayFactory
Grid2DSquareCellIntChunkArrayFactory


_Grid2DSquareCellIntChunkJAIFactory

public Grid2DSquareCellIntChunkJAIFactory _Grid2DSquareCellIntChunkJAIFactory
Grid2DSquareCellIntChunkJAIFactory


_Grid2DSquareCellIntChunkMapFactory

public Grid2DSquareCellIntChunkMapFactory _Grid2DSquareCellIntChunkMapFactory
Grid2DSquareCellIntChunkMapFactory


_Grid2DSquareCellIntChunkRAFFactory

public Grid2DSquareCellIntChunkRAFFactory _Grid2DSquareCellIntChunkRAFFactory
Grid2DSquareCellIntChunkRAFFactory


_Grid2DSquareCellIntFactory

public Grid2DSquareCellIntFactory _Grid2DSquareCellIntFactory
Grid2DSquareCellIntFactory


_Grid2DSquareCellDoubleChunkFactory

public AbstractGrid2DSquareCellDoubleChunkFactory _Grid2DSquareCellDoubleChunkFactory
Default AbstractGrid2DSquareCellDoubleChunkFactory


_Grid2DSquareCellDoubleChunk64CellMapFactory

public Grid2DSquareCellDoubleChunk64CellMapFactory _Grid2DSquareCellDoubleChunk64CellMapFactory
Grid2DSquareCellDoubleChunk64CellMapFactory


_Grid2DSquareCellDoubleChunkArrayFactory

public Grid2DSquareCellDoubleChunkArrayFactory _Grid2DSquareCellDoubleChunkArrayFactory
Grid2DSquareCellDoubleChunkArrayFactory


_Grid2DSquareCellDoubleChunkJAIFactory

public Grid2DSquareCellDoubleChunkJAIFactory _Grid2DSquareCellDoubleChunkJAIFactory
Grid2DSquareCellDoubleChunkJAIFactory


_Grid2DSquareCellDoubleChunkMapFactory

public Grid2DSquareCellDoubleChunkMapFactory _Grid2DSquareCellDoubleChunkMapFactory
Grid2DSquareCellDoubleChunkMapFactory


_Grid2DSquareCellDoubleChunkRAFFactory

public Grid2DSquareCellDoubleChunkRAFFactory _Grid2DSquareCellDoubleChunkRAFFactory
Grid2DSquareCellDoubleChunkRAFFactory


_Grid2DSquareCellDoubleFactory

public Grid2DSquareCellDoubleFactory _Grid2DSquareCellDoubleFactory
Grid2DSquareCellDoubleFactory


_GridStatistics0

public GridStatistics0 _GridStatistics0
GridStatistics0


_GridStatistics1

public GridStatistics1 _GridStatistics1
GridStatistics1


_GridStatistics

public AbstractGridStatistics _GridStatistics
GridStatistics1

Constructor Detail

Grid2DSquareCellProcessor

public Grid2DSquareCellProcessor()
Creates a new instance of Grid2DSquareCellDoubleProcessor


Grid2DSquareCellProcessor

public Grid2DSquareCellProcessor(java.io.File _Directory)
Creates a new instance of Grid2DSquareCellDoubleProcessor. By default the logs are appended to the end of the log file if it exists. To overwrite the log file use: Grid2DSquareCellDoubleProcessor( _Directory, false );

Parameters:
_Directory -

Grid2DSquareCellProcessor

public Grid2DSquareCellProcessor(Grids_Environment _Grids_Environment)

Grid2DSquareCellProcessor

public Grid2DSquareCellProcessor(java.io.File _Directory,
                                 boolean appendToLogFile)
Creates a new instance of Grid2DSquareCellDoubleProcessor. The log file in _Directory will be overwritten if appendToLogFile is false.

Parameters:
_Directory -
appendToLogFile -
Method Detail

getTime0

protected long getTime0()
Returns a copy of this.startTime.


getTime0

public long getTime0(boolean handleOutOfMemoryError)
Parameters:
handleOutOfMemoryError - If true then OutOfMemoryErrors are caught in this method then swap operations are initiated prior to retrying. If false then OutOfMemoryErrors are caught and thrown.
Returns:
A copy of this.startTime.

get_Directory

public java.io.File get_Directory(boolean handleOutOfMemoryError)
Returns a copy of this._Directory


getGrid2DSquareCell

public AbstractGrid2DSquareCell getGrid2DSquareCell(boolean handleOutOfMemoryError)
Returns a AbstractGrid2DSquareCell from this._AbstractGrid2DSquareCell_HashSet.

Parameters:
handleOutOfMemoryError - If true then OutOfMemoryErrors are caught in this method then swap operations are initiated prior to retrying. If false then OutOfMemoryErrors are caught and thrown.

getGrid2DSquareCell

protected AbstractGrid2DSquareCell getGrid2DSquareCell()
Returns a AbstractGrid2DSquareCell from this._AbstractGrid2DSquareCell_HashSet.


set_Directory

protected void set_Directory(java.io.File _Directory,
                             boolean handleOutOfMemoryError)
Changes _Directory to that passed in if it can be created. By default this does not copy the logfile from the existing _Directory when it sets up a log in the new location. To do this use: set_Directory( _Directory, true )

Parameters:
_Directory - The _Directory to change to.
handleOutOfMemoryError - If true then OutOfMemoryErrors are caught in this method then swap operations are initiated prior to retrying. If false then OutOfMemoryErrors are caught and thrown.

set_Directory

protected void set_Directory(java.io.File _Directory)
Changes this._Directory, this._Grid2DSquareCellDoubleFactory._Directory, this._Grid2DSquareCellIntFactory._Directory to _Directory. Does not copy the logfile from the existing _Directory. To do this use: set_Directory( _Directory, true )

Parameters:
_Directory - The _Directory to change to.

set_Directory

public void set_Directory(java.io.File _Directory,
                          boolean copyLogFile,
                          boolean handleOutOfMemoryError)
Changes this._Directory to that passed in if it can be created. If copyLogFile is true, this copies the logfile from the existing _Directory and sets up the log to append in the new location.

Parameters:
_Directory - The _Directory to change to.
handleOutOfMemoryError - If true then OutOfMemoryErrors are caught in this method then swap operations are initiated prior to retrying. If false then OutOfMemoryErrors are caught and thrown.

copyAndSetUpNewLog

public void copyAndSetUpNewLog(java.io.File newLog,
                               boolean handleOutOfMemoryError)
                        throws java.io.IOException
Copies and sets up a new log.

Parameters:
handleOutOfMemoryError - If true then OutOfMemoryErrors are caught in this method then swap operations are initiated prior to retrying. If false then OutOfMemoryErrors are caught and thrown.
Throws:
java.io.IOException

log

public void log(java.lang.String string,
                boolean handleOutOfMemoryError)
Writes string to log file and the console (standard output)

Parameters:
string - The message to log.
handleOutOfMemoryError - If true then OutOfMemoryErrors are caught in this method then swap operations are initiated prior to retrying. If false then OutOfMemoryErrors are caught and thrown.

log

public void log(int logIndentation,
                java.lang.String string,
                boolean handleOutOfMemoryError)
Writes string to log file and the console (standard output) indenting string by logIndentation amount of white-space.

Parameters:
logIndentation - The indentation of string.
string - The message to log.
handleOutOfMemoryError - If true then OutOfMemoryErrors are caught in this method then swap operations are initiated prior to retrying. If false then OutOfMemoryErrors are caught and thrown.

log

protected void log(int logIndentation,
                   java.lang.String string)
Writes string to log file and the console (standard output) indenting string by logIndentation amount of white-space.

Parameters:
logIndentation - The indentation of string.
string - The message to log.

distance

public final double distance(double x1,
                             double y1,
                             double x2,
                             double y2,
                             boolean handleOutOfMemoryError)
Returns the distance between a pair of coordinates

Parameters:
x1 - The x coordinte of one point.
y1 - The y coordinte of one point.
x2 - The x coordinte of another point.
y2 - The y coordinte of another point.
handleOutOfMemoryError - If true then OutOfMemoryErrors are caught in this method then swap operations are initiated prior to retrying. If false then OutOfMemoryErrors are caught and thrown.

distance

public final double distance(double x1,
                             double y1,
                             double x2,
                             double y2,
                             int nChunkCols,
                             int _ChunkRowIndex,
                             int _ChunkColIndex,
                             boolean handleOutOfMemoryError)
Returns the distance between a pair of coordinates

Parameters:
x1 - The x coordinte of one point.
y1 - The y coordinte of one point.
x2 - The x coordinte of another point.
y2 - The y coordinte of another point.
nChunkCols - The number of Grid2DSquareCellChunkAbstract columns in theAbstractGrid2DSquareCelll that's Grid2DSquareCellChunkAbstract could be swapped if an OutOfMemoryError is thrown.
_ChunkRowIndex - The chunk row index of the Grid2DSquareCellChunkAbstract not to be swapped if an OutOfMemoryError is thrown.
_ChunkColIndex - The chunk column index of the Grid2DSquareCellChunkAbstract not to be swapped if an OutOfMemoryError is thrown.
handleOutOfMemoryError - If true then OutOfMemoryErrors are caught in this method then swap operations are initiated prior to retrying. If false then OutOfMemoryErrors are caught and thrown.

distance

protected final double distance(double x1,
                                double y1,
                                double x2,
                                double y2)
Returns the distance between a pair of coordinates

Parameters:
x1 - The x coordinte of one point.
y1 - The y coordinte of one point.
x2 - The x coordinte of another point.
y2 - The y coordinte of another point.

angle

public final double angle(double x1,
                          double y1,
                          double x2,
                          double y2,
                          boolean handleOutOfMemoryError)
Returns the clockwise angle in radians to the y axis of the line from (x1,y1) to (x2,y2).

Parameters:
x1 - The x coordinte of one point.
y1 - The y coordinte of one point.
x2 - The x coordinte of another point.
y2 - The y coordinte of another point.
handleOutOfMemoryError - If true then OutOfMemoryErrors are caught in this method and swap operations are initiated prior to retrying. If false then OutOfMemoryErrors are caught and thrown.

angle

public final double angle(double x1,
                          double y1,
                          double x2,
                          double y2,
                          int nChunkCols,
                          int _ChunkRowIndex,
                          int _ChunkColIndex,
                          boolean handleOutOfMemoryError)
Returns the clockwise angle in radians to the y axis of the line from (x1,y1) to (x2,y2).

Parameters:
x1 - The x coordinte of one point.
y1 - The y coordinte of one point.
x2 - The x coordinte of another point.
y2 - The y coordinte of another point.
nChunkCols - The number of Grid2DSquareCellChunkAbstract columns in theAbstractGrid2DSquareCelll that's Grid2DSquareCellChunkAbstract could be swapped if an OutOfMemoryError is thrown.
_ChunkRowIndex - The chunk row index of the Grid2DSquareCellChunkAbstract not to be swapped if an OutOfMemoryError is thrown.
_ChunkColIndex - The chunk column index of the Grid2DSquareCellChunkAbstract not to be swapped if an OutOfMemoryError is thrown.
handleOutOfMemoryError - If true then OutOfMemoryErrors are caught in this method and swap operations are initiated prior to retrying. If false then OutOfMemoryErrors are caught and thrown.

angle

protected final double angle(double x1,
                             double y1,
                             double x2,
                             double y2)
Returns the clockwise angle in radians to the y axis of the line from (x1,y1) to (x2,y2).

Parameters:
x1 - The x coordinte of one point.
y1 - The y coordinte of one point.
x2 - The x coordinte of another point.
y2 - The y coordinte of another point.

mask

public void mask(AbstractGrid2DSquareCell grid,
                 AbstractGrid2DSquareCell mask,
                 boolean handleOutOfMemoryError)
Modifies grid by setting to grid.noDataValue those cells coincident with mask.noDataValue cells. Warning!!! The grid and mask are assumed to be coincident and have the same origin.

Parameters:
grid - TheAbstractGrid2DSquareCelll that masked.
mask - TheAbstractGrid2DSquareCelll to use as a mask.

mask

public void mask(AbstractGrid2DSquareCell grid,
                 double min,
                 double max,
                 boolean handleOutOfMemoryError)
Modifies grid with the values of cells in the range [min,max] set to its noDataValue. (Existing noDataValue cells in grid remain as noDataValue.)

Parameters:
grid - The Grid2DSquareCellDouble to be masked.
min - The minimum value in the range.
max - The maximum value in the range.
handleOutOfMemoryError - If true then OutOfMemoryErrors are caught in this method then swap operations are initiated prior to retrying. If false then OutOfMemoryErrors are caught and thrown.

mask

public void mask(AbstractGrid2DSquareCell grid,
                 double xmin,
                 double ymin,
                 double xmax,
                 double ymax,
                 boolean handleOutOfMemoryError)
Modifies grid by setting to grid.noDataValue those cells that's centroids intersect the rectangle given by: (xmin,ymin,xmax,ymax).

Parameters:
grid - TheAbstractGrid2DSquareCelll to be masked
xmin - The minimum x-coordinate of the masking rectangle.
ymin - The minimum y-coordinate of the masking rectangle.
xmax - The maximum x-coordinate of the masking rectangle.
ymax - The maximum y-coordinate of the masking rectangle.
handleOutOfMemoryError - If true then OutOfMemoryErrors are caught in this method then swap operations are initiated prior to retrying. If false then OutOfMemoryErrors are caught and thrown.

mask

public void mask(AbstractGrid2DSquareCell grid,
                 long startRowIndex,
                 long startColIndex,
                 long endRowIndex,
                 long endColIndex,
                 boolean handleOutOfMemoryError)
Modifies grid by setting to grid.noDataValue those cells that intersect the rectangle given by: (startRowIndex,startColIndex,endRowIndex,endColIndex).

Parameters:
grid - the Grid2DSquareCellDouble to be masked
startRowIndex - the index of the first row to be masked
startColIndex - the index of the first column to be masked
endRowIndex - the index of the final row to be masked
endColIndex - the index of the final column to be masked
handleOutOfMemoryError - If true then OutOfMemoryErrors are caught in this method then swap operations are initiated prior to retrying. If false then OutOfMemoryErrors are caught and thrown.

_Rescale

public Grid2DSquareCellDouble _Rescale(AbstractGrid2DSquareCell _InputGrid,
                                       java.lang.String type,
                                       double min,
                                       double max,
                                       boolean handleOutOfMemoryError)
Parameters:
grid - the Grid2DSquareCellDouble to be processed.
type - If type == null then a linear rescale is done. If type == "log" then a log rescale is done.
min - The minimum value in the rescaled range.
max - The maximum value in the rescaled range.
handleOutOfMemoryError - If true then OutOfMemoryErrors are caught in this method then swap operations are initiated prior to retrying. If false then OutOfMemoryErrors are caught and thrown.

setValueALittleBitLarger

public void setValueALittleBitLarger(Grid2DSquareCellDouble grid,
                                     java.util.HashSet _CellIDs,
                                     boolean handleOutOfMemoryError)
Modifies grid so value of cells with CellIDs in _CellIDs are set to a value a little bit larger.

Parameters:
grid - The Grid2DSquareCellDouble to be processed.
_CellIDs - The CellIDs of the cells to be processed.
handleOutOfMemoryError - If true then OutOfMemoryErrors are caught in this method then swap operations are initiated prior to retrying. If false then OutOfMemoryErrors are caught and thrown.

setValueALittleBitSmaller

public void setValueALittleBitSmaller(Grid2DSquareCellDouble grid,
                                      java.util.HashSet _CellIDs,
                                      boolean handleOutOfMemoryError)
Modifies grid so value of cells with CellIDs in _CellIDs are set to a value a little bit smaller.

Parameters:
grid - The Grid2DSquareCellDouble to be processed.
_CellIDs - The CellIDs of the cells to be processed.
handleOutOfMemoryError - If true then OutOfMemoryErrors are caught in this method then swap operations are initiated prior to retrying. If false then OutOfMemoryErrors are caught and thrown.

addToGrid

public void addToGrid(Grid2DSquareCellDouble grid,
                      java.util.HashSet _CellIDs,
                      double value,
                      boolean handleOutOfMemoryError)
Adds value to grid for cells with CellID in _CellIDs

Parameters:
grid - The Grid2DSquareCellDouble to be processed
_CellIDs - A HashSet containing CellIDs.
value - The value to be added.
handleOutOfMemoryError - If true then OutOfMemoryErrors are caught in this method then swap operations are initiated prior to retrying. If false then OutOfMemoryErrors are caught and thrown.

addToGrid

public void addToGrid(Grid2DSquareCellDouble grid,
                      double value,
                      boolean handleOutOfMemoryError)
Adds value to every cell of grid.

Parameters:
grid - The Grid2DSquareCellDouble to be processed
value - The value to be added
handleOutOfMemoryError - If true then OutOfMemoryErrors are caught in this method then swap operations are initiated prior to retrying. If false then OutOfMemoryErrors are caught and thrown.

addToGrid

public void addToGrid(Grid2DSquareCellDouble grid,
                      AbstractGrid2DSquareCell.CellID[] _CellIDs,
                      double value,
                      boolean handleOutOfMemoryError)
Adds value to grid for cells with CellID in _CellIDs

Parameters:
grid - The Grid2DSquareCellDouble to be processed
_CellIDs - Array of CellIDs.
value - The value to be added.
handleOutOfMemoryError - If true then OutOfMemoryErrors are caught in this method then swap operations are initiated prior to retrying. If false then OutOfMemoryErrors are caught and thrown.

addToGrid

public void addToGrid(Grid2DSquareCellDouble grid,
                      Grid2DSquareCellDouble gridToAdd,
                      boolean handleOutOfMemoryError)
Add gridToAdd to grid

Parameters:
grid - The Grid2DSquareCellDouble to be processed/modified.
gridToAdd - The Grid2DSquareCellDouble from which values are added.
handleOutOfMemoryError - If true then OutOfMemoryErrors are caught in this method then swap operations are initiated prior to retrying. If false then OutOfMemoryErrors are caught and thrown.

addToGrid

public void addToGrid(Grid2DSquareCellDouble grid,
                      Grid2DSquareCellDouble gridToAdd,
                      double weight,
                      boolean handleOutOfMemoryError)
Add gridToAdd to grid with values from gridToAdd multiplied by weight.

Parameters:
grid - The Grid2DSquareCellDouble to be processed/modified.
gridToAdd - The Grid2DSquareCellDouble from which values are added.
weight - The value gridToAdd values are multiplied by.
handleOutOfMemoryError - If true then OutOfMemoryErrors are caught in this method then swap operations are initiated prior to retrying. If false then OutOfMemoryErrors are caught and thrown.

addToGrid

public void addToGrid(Grid2DSquareCellDouble grid,
                      Grid2DSquareCellDouble gridToAdd,
                      long startRowIndex,
                      long startColIndex,
                      long endRowIndex,
                      long endColIndex,
                      double weight,
                      boolean handleOutOfMemoryError)
Add gridToAdd to grid with values from gridToAdd multiplied by weight. Only values of gridToAdd with row index between startRowIndex and endRowIndex, and column index between startColIndex and endColIndex are added.

Parameters:
grid - The Grid2DSquareCellDouble to be processed.
gridToAdd - The Grid2DSquareCellDouble from which values are added.
startRowIndex - The index of the first row from which gridToAdd values are added.
startColIndex - the index of the first column from which gridToAdd values are added.
endRowIndex - the index of the final row from which gridToAdd values are added.
endColIndex - the index of the final column from which gridToAdd values are added.
weight - The value gridToAdd values are multiplied by.
handleOutOfMemoryError - If true then OutOfMemoryErrors are caught in this method then swap operations are initiated prior to retrying. If false then OutOfMemoryErrors are caught and thrown.

addToGrid

public void addToGrid(Grid2DSquareCellDouble grid,
                      Grid2DSquareCellDouble gridToAdd,
                      long startRowIndex,
                      long startColIndex,
                      long endRowIndex,
                      long endColIndex,
                      java.math.BigDecimal[] dimensionConstraints,
                      double weight,
                      boolean handleOutOfMemoryError)
Returns a Grid2DSquareCellDouble with values of grid added with values from gridToAdd (with row index between startRowIndex, endRowIndex and column index between startColIndex, endColIndex) multiplied by weight.

Parameters:
grid - The Grid2DSquareCellDouble to be processed.
gridToAdd - The Grid2DSquareCellDouble from which values are added.
startRowIndex - The index of the first row from which gridToAdd values are added.
startColIndex - The index of the first column from which gridToAdd values are added.
endRowIndex - The index of the final row from which gridToAdd values are added.
endColIndex - The index of the final column from which gridToAdd values are added.
dimensionConstraints -
weight - The value gridToAdd values are multiplied by.
handleOutOfMemoryError - If true then OutOfMemoryErrors are caught in this method then swap operations are initiated prior to retrying. If false then OutOfMemoryErrors are caught and thrown. TODO: Check that reasonable answers are returned for intersections and aggregations.

addToGrid

public void addToGrid(Grid2DSquareCellDouble grid,
                      java.io.File file,
                      java.lang.String type,
                      boolean handleOutOfMemoryError)
Returns grid with values added from a file.

Parameters:
grid - the Grid2DSquareCellDouble to be processed
file - the file contining values to be added.
type - the type of file. Supported types include "xyv", "xy", "idxy" )
handleOutOfMemoryError - If true then OutOfMemoryErrors are caught in this method then swap operations are initiated prior to retrying. If false then OutOfMemoryErrors are caught and thrown.

aggregate

public Grid2DSquareCellDouble aggregate(AbstractGrid2DSquareCell grid,
                                        int cellFactor,
                                        java.lang.String statistic,
                                        int rowOffset,
                                        int colOffset,
                                        Grid2DSquareCellDoubleFactory gridFactory,
                                        boolean handleOutOfMemoryError)
Returns an Grid2DSquareCellDouble at a lower level of resolution than grid. The result values are either the sum, mean, max or min of values in grid depending on statistic.

Parameters:
grid - the Grid2DSquareCellDouble to be processed
cellFactor - the number of times wider/higher the aggregated grid cells are to be
statistic - "sum", "mean", "max", or "min" depending on what aggregate of values are wanted
rowOffset - the number of rows above or below the origin of grid where the aggregation is to start. > 0 result yllcorner will be above grid yllcorner < 0 result yllcorner will be below grid yllcorner
colOffset - the number of columns above or below the origin of grid where the aggregation is to start. > 0 result xllcorner will be right of grid xllcorner < 0 result xllcorner will be left of grid xllcorner
gridFactory - the Abstract2DSquareCellDoubleFactory used to create result and temporary AbstractGrid2DSquareCellDoubles.
handleOutOfMemoryError - If true then OutOfMemoryErrors are caught in this method then swap operations are initiated prior to retrying. If false then OutOfMemoryErrors are caught and thrown. NB. In the calculation of the sum and the mean if there is a cell in grid which has a data value then the result which incorporates that cell has a data value. For this result cell, any of the cells in grid which have noDataValues their value is taken as that of the average of its nearest cells with a value. In the calculation of the max and the min noDataValues are simply ignored. Formerly noDataValues were treated as the average of values within a result cell. TODO: implement median, mode and variance aggregations.

aggregate

public Grid2DSquareCellDouble aggregate(AbstractGrid2DSquareCell grid,
                                        java.lang.String statistic,
                                        java.math.BigDecimal[] resultDimensions,
                                        Grid2DSquareCellDoubleFactory gridFactory,
                                        boolean handleOutOfMemoryError)
Returns an Grid2DSquareCellDouble at a lower level of resolution than grid. The result values are either the sum, mean, max or min of values in grid depending on statistic.

Parameters:
grid - The Grid2DSquareCellDouble to be processed
statistic - "sum", "mean", "max", or "min" depending on what aggregate of values are wanted
resultDimensions -
gridFactory - The Abstract2DSquareCellDoubleFactory used to create _AbstractGrid2DSquareCell_HashSet
handleOutOfMemoryError - If true then OutOfMemoryErrors are caught in this method then swap operations are initiated prior to retrying. If false then OutOfMemoryErrors are caught and thrown. Use this aggregate method if result is to have a new spatial frame. NB. In the calculation of the sum and the mean if there is a cell in grid which has a data value then the result which incorporates that cell has a data value. For this result cell, any of the cells in grid which have noDataValues their value is taken as that of the average of its nearest cells with a value. In the calculation of the max and the min noDataValues are simply ignored. Formerly noDataValues were treated as the average of values within a result cell. TODO: implement median, mode and variance aggregations.

getRowProcessInitialData

protected double[][] getRowProcessInitialData(Grid2DSquareCellDouble grid,
                                              int cellDistance,
                                              long row)
Returns a double[][] of grid values


getRowProcessData

protected double[][] getRowProcessData(Grid2DSquareCellDouble grid,
                                       double[][] previous,
                                       int cellDistance,
                                       long row,
                                       long col)
Returns a double[][] based on previous which has been shuffled


_Output

public void _Output(AbstractGrid2DSquareCell _Grid2DSquareCell,
                    java.io.File _Output_Directory,
                    ImageExporter _ImageExporter,
                    java.lang.String[] _ImageTypes,
                    ESRIAsciiGridExporter _ESRIAsciiGridExporter,
                    boolean handleOutOfMemoryError)
             throws java.io.IOException
For outputting _Grid2DSquareCell to various formats of file. It might be better to have this in exchange.IO class.

Parameters:
_Grid2DSquareCell -
_Output_Directory -
_ImageExporter -
_ImageTypes -
_ESRIAsciiGridExporter -
handleOutOfMemoryError -
Throws:
java.io.IOException

_OutputImage

public void _OutputImage(AbstractGrid2DSquareCell _Grid2DSquareCell,
                         java.io.File _Output_Directory,
                         ImageExporter _ImageExporter,
                         java.lang.String[] _ImageTypes,
                         boolean handleOutOfMemoryError)
                  throws java.io.IOException
Throws:
java.io.IOException

_OutputESRIAsciiGrid

public void _OutputESRIAsciiGrid(AbstractGrid2DSquareCell _Grid2DSquareCell,
                                 java.io.File _Output_Directory,
                                 ESRIAsciiGridExporter _ESRIAsciiGridExporter,
                                 boolean handleOutOfMemoryError)
                          throws java.io.IOException
Throws:
java.io.IOException