GRASS
Class Cellhead

java.lang.Object
  |
  +--GRASS.Cellhead

public class Cellhead
extends java.lang.Object
implements java.lang.Cloneable

Class to mimic behaviour of struct Cell_head from gis.h. The raster header data structure is used for two purposes. It is used for raster header information for map layers. It also used to hold region values. Wraps GRASS library struct:

 struct Cell_head
 {
     int format;     -- number of bytes per cell --
     int compressed; -- compressed(1) or not compressed(0) --
     int rows, cols; -- number of rows and columns --
     int proj;       -- projection --
     int zone;       -- zone --
     double ew_res;  -- east-west resolution -- 
     double ns_res;  -- north-south resolution --
     double north;   -- northern edge --
     double south;   -- southern edge --
     double east;    -- eastern edge --
     double west;    -- western edge --
 };
 
See the GRASS 4.2 Programmer's Manual, Section 12.20.1 struct Cell_head

See Also:
libgis.G_get_set_window()

Constructor Summary
Cellhead()
          Constructs an empty object and allocates memory for Cellhead structure.
 
Method Summary
 java.lang.Object clone()
          Creates a new object of the same class as this object.
 int cols()
          Returns value of the field 'cols' corresponding to the Cellhead.
 boolean compressed()
          Returns value of the field 'compressed' corresponding to the Cellhead.
 double east()
          Returns value of the field 'east' corresponding to the Cellhead.
 double ew_res()
          Returns value of the field 'ew_res' corresponding to the Cellhead.
 int format()
          Returns value of the field 'format' corresponding to the Cellhead.
 void G_adjust_Cell_head(boolean rflag, boolean cflag)
          This method fills in missing parts of the input cell header (or region).
 double G_col_to_easting(double col)
          Converts a column relative to a region to an easting.
 double G_easting_to_col(double east)
          Converts an easting relative to a region to a column.
 double G_northing_to_row(double north)
          Converts a northing relative to a region to a row.
 double G_row_to_northing(double row)
          Converts a row relative to a region to a northing.
 double north()
          Returns value of the field 'north' corresponding to the Cellhead.
 double ns_res()
          Returns value of the field 'ns_res' corresponding to the Cellhead.
 int proj()
          Returns value of the field 'proj' corresponding to the Cellhead.
 int rows()
          Returns value of the field 'rows' corresponding to the Cellhead.
 void setCols(int cols)
          Sets value of the field 'cols' corresponding to the Cellhead.
 void setCompressed(boolean compressed)
          Sets value of the field 'compressed' corresponding to the Cellhead.
 void setEast(double east)
          Sets value of the field 'east' corresponding to the Cellhead.
 void setEw_res(double ew_res)
          Sets value of the field 'ew_res' corresponding to the Cellhead.
 void setFormat(int format)
          Sets value of the field 'format' corresponding to the Cellhead.
 void setNorth(double north)
          Sets value of the field 'north' corresponding to the Cellhead.
 void setNs_res(double ns_res)
          Sets value of the field 'ns_res' corresponding to the Cellhead.
 void setProj(int proj)
          Sets value of the field 'proj' corresponding to the Cellhead.
 void setRows(int rows)
          Sets value of the field 'rows' corresponding to the Cellhead.
 void setSouth(double south)
          Sets value of the field 'south' corresponding to the Cellhead.
 void setWest(double west)
          Sets value of the field 'west' corresponding to the Cellhead.
 void setZone(int zone)
          Sets value of the field 'zone' corresponding to the Cellhead.
 double south()
          Returns value of the field 'south' corresponding to the Cellhead.
 java.lang.String toString()
          Returns a string representation of the object.
 double west()
          Returns value of the field 'west' corresponding to the Cellhead.
 int zone()
          Returns value of the field 'zone' corresponding to the Cellhead.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Cellhead

public Cellhead()
Constructs an empty object and allocates memory for Cellhead structure.
Method Detail

format

public int format()
Returns value of the field 'format' corresponding to the Cellhead.
Returns:
value of the field 'format'

setFormat

public void setFormat(int format)
Sets value of the field 'format' corresponding to the Cellhead.
Parameters:
format - format value to set to

compressed

public boolean compressed()
Returns value of the field 'compressed' corresponding to the Cellhead.
Returns:
value of the field 'compressed'

setCompressed

public void setCompressed(boolean compressed)
Sets value of the field 'compressed' corresponding to the Cellhead.
Parameters:
compressed - compressed value to set to

rows

public int rows()
Returns value of the field 'rows' corresponding to the Cellhead.
Returns:
value of the field 'rows'

setRows

public void setRows(int rows)
Sets value of the field 'rows' corresponding to the Cellhead.
Parameters:
rows - rows value to set to

cols

public int cols()
Returns value of the field 'cols' corresponding to the Cellhead.
Returns:
value of the field 'cols'

setCols

public void setCols(int cols)
Sets value of the field 'cols' corresponding to the Cellhead.
Parameters:
cols - cols value to set to

proj

public int proj()
Returns value of the field 'proj' corresponding to the Cellhead.
Returns:
value of the field 'proj'

setProj

public void setProj(int proj)
Sets value of the field 'proj' corresponding to the Cellhead.
Parameters:
proj - proj value to set to

zone

public int zone()
Returns value of the field 'zone' corresponding to the Cellhead.
Returns:
value of the field 'zone'

setZone

public void setZone(int zone)
Sets value of the field 'zone' corresponding to the Cellhead.
Parameters:
zone - zone value to set to

ew_res

public double ew_res()
Returns value of the field 'ew_res' corresponding to the Cellhead.
Returns:
value of the field 'ew_res'

setEw_res

public void setEw_res(double ew_res)
Sets value of the field 'ew_res' corresponding to the Cellhead.
Parameters:
ew_res - ew_res value to set to

ns_res

public double ns_res()
Returns value of the field 'ns_res' corresponding to the Cellhead.
Returns:
value of the field 'ns_res'

setNs_res

public void setNs_res(double ns_res)
Sets value of the field 'ns_res' corresponding to the Cellhead.
Parameters:
ns_res - ns_res value to set to

north

public double north()
Returns value of the field 'north' corresponding to the Cellhead.
Returns:
value of the field 'north'

setNorth

public void setNorth(double north)
Sets value of the field 'north' corresponding to the Cellhead.
Parameters:
north - north value to set to

south

public double south()
Returns value of the field 'south' corresponding to the Cellhead.
Returns:
value of the field 'south'

setSouth

public void setSouth(double south)
Sets value of the field 'south' corresponding to the Cellhead.
Parameters:
south - south value to set to

east

public double east()
Returns value of the field 'east' corresponding to the Cellhead.
Returns:
value of the field 'east'

setEast

public void setEast(double east)
Sets value of the field 'east' corresponding to the Cellhead.
Parameters:
east - east value to set to

west

public double west()
Returns value of the field 'west' corresponding to the Cellhead.
Returns:
value of the field 'west'

setWest

public void setWest(double west)
Sets value of the field 'west' corresponding to the Cellhead.
Parameters:
west - west value to set to

G_adjust_Cell_head

public void G_adjust_Cell_head(boolean rflag,
                               boolean cflag)
                        throws GRASSException
This method fills in missing parts of the input cell header (or region). It also makes projection-specific adjustments. The cellhd structure must have its north, south, east, west, and proj fields set. If rflag is true, then the north-south resolution is computed from the number of rows in the cellhd structure. Otherwise the number of rows is computed from the north-south resolution in the structure, and similarly for cflag and the number of columns and the east-west resolution. Wraps GRASS library routine:
 char *
 G_adjust_Cell_head (cellhd, rflag, cflag) 
      struct Cell_head *cellhd;
      int rflag, cflag;
 
See the GRASS 4.2 Programmer's Manual, Section 12.10.1 Raster Header File
Parameters:
rflag - Flag to adjust north-south resolution from the number of rows
cflag - Flag to adjust east-west resolution from the number of columns
Throws:
GRASSException - Exception with appropriate error message is thrown if there was an error during execution

G_col_to_easting

public double G_col_to_easting(double col)
Converts a column relative to a region to an easting. Wraps GRASS library routine:
 double
 G_col_to_easting (col, region)
     double col;
     struct Cell_head *region;
 
See the GRASS 4.2 Programmer's Manual, Section 12.7.2 The Active Program Region
Note: col+0.5 will return the easting for the center of the column; col+0.0 will return the easting for the western edge of the column; and col+1.0 will return the easting for the eastern edge of the column.
Parameters:
col - column to find easting for
Returns:
easting for the specified column

G_row_to_northing

public double G_row_to_northing(double row)
Converts a row relative to a region to a northing. Wraps GRASS library routine:
 double
 G_row_to_northing (row, region)
     double row;
     struct Cell_head *region;
 
See the GRASS 4.2 Programmer's Manual, Section 12.7.2 The Active Program Region
Note: row is a double: row+0.5 will return the northing for the center of the row; row+0.0 will return the northing for the northern edge of the row; and row+1.0 will return the northing for the southern edge of the row.
Parameters:
row - row to find northing for
Returns:
northing for the specified row

G_easting_to_col

public double G_easting_to_col(double east)
Converts an easting relative to a region to a column. Wraps GRASS library routine:
 double
 G_easting_to_col (east, region)
      double east; 
      struct Cell_head *region;
 
See the GRASS 4.2 Programmer's Manual, Section 12.7.2 The Active Program Region
Note: the result is a double. Casting it to an integer will give the column number.
Parameters:
east - easting to find column number for
Returns:
column number for the specified easting

G_northing_to_row

public double G_northing_to_row(double north)
Converts a northing relative to a region to a row. Wraps GRASS library routine:
 double
 G_northing_to_row (north, region)
      double row;
      struct Cell_head *region;
 
See the GRASS 4.2 Programmer's Manual, Section 12.7.2 The Active Program Region Note: the result is a double. Casting it to an integer will give the row number.
Parameters:
north - northing to find row number for
Returns:
row number for the specified northing

clone

public java.lang.Object clone()
Creates a new object of the same class as this object. It then initializes each of the new object's fields by assigning it the same value as the corresponding field in this object. No constructor is called.
Returns:
Newly cloned Cellhead

toString

public java.lang.String toString()
Returns a string representation of the object.
Returns:
String that represents this object -- a rather long string with all fields listed with their names and values.
Overrides:
toString in class java.lang.Object


GRASS-JNI Home Page