GGrid Class Reference

[libgfc Index] [libgfc Hierarchy] [Headers]


GGrid This is the class for grids which are regular 2D arrays of cells More...

#include <src/gadt_grid.h>

Inherits: GSpatial

Public Members

Protected Members


Detailed Description

GGrid This is the class for grids which are regular 2D arrays of cells. GFC grids are automatically decomposed into slabs (GSlab) when stored to permanent media, although this fact is largely hidden from general GGrid user. GGrid cells always contain values of the C float type.

GGrid is composed of a meta information struct (GGridMeta), a custom grid header (an opaque block of data supplied by the user), and the actual body of the cell values. The physical access to the cells is performed through an GGridIO object, which maintains a global cache of grid slabs to optimize the I/O. GFC provides a subclass of GGridIO which performs file based grid I/O. Other types of grid I/O, such as those based on database access methods, can also be plugged in by implementing differnt subclasses of GGridIO. GGridIO associates the slabs (hence the cells) in the cache with the grids through grid tags. Grid tags are strings that uniquely identify a grid when the program runs. Tags are automatically set to the name of the grid file when file-based grid I/O is used. Tags may also be database keys when database access methods are used for grid I/O, in which case the user is responsible for setting up the tags. The default grid I/O class is GGridIOFile. This can however be changed by calling the global function installGridIOHandler().

The physical layout of a grid (when stored to a file etc) is: GGridMeta meta_info; int custom_header_size; char* custom_header; int num_slabs; GSlabDesc *slab_descriptors; GSlab *slabs; Everything before the actual slab data ('slabs') is collectively refered as GGridHeader.

Many existing image and GIS raster data can also be imported as GGrid objects. The importing interface is defined by the generic GGridImporter class. In order to support a particular data format, such as USGS DEM, one only needs to implement a subclass of GGridImporter, (say GGridImporter_DEM), and install an instance of such a custom importer in the GGrid object prior to calling the generic GGrid::importFromFile() method.


friend ostream& operator<<(ostream& s, const GGrid& grid) [public]

print (only) the grid header

Result input(const char* in) [public virtual]

generate a grid object out of a user string; the format of the string: "w h V00 V01 V02... V10 V11 V12... Vwh" where w and h are the width and height of the user supplied grid

Result output(char*& out) [public virtual]

output the grid object into a user string. the format is the same as for input.

Result pack(DataPipe& p) [public virtual]

pack the (zipped) grid data into a pipe

Result unpack(DataPipe& p) [public virtual]

unpack the (zipped) data from a pipe

Result create(int cols, int rows) [public virtual]

create a blank grid with the given size.

Result saveToFile(const char* fname) [public virtual]

store the (zipped) grid data into a file

Result loadFromFile(const char* fname) [public virtual]

load grid data from a previously stored grid file

Result installImporter(GGridImporter* imp) [public]

install a differnt importer object. The new importer will be used when importing data through the import methods.

Result importFromFile(const char* file) [public]

imports a data file. the currently installed importer is used to open/read/import/close the data file. delegated to io_guy for the actual work.

Result importFromData(const char* stream) [public]

imports a (in-memory) data stream. The currently installed importer is used to read/import the data stream. A temporary file will be created to hold the grid. delegated to io_guy for the actual work.

inline GCellType cellType() const [public]

return the value type of cells.

float setCell(float val, int x, int y) [public virtual]

set a cell value. returns the old cell value.

float cell(int x, int y) const [public virtual]

get the value of a cell.

Result scanline(int row, char* line_buf) const [public virtual]

return a scan line of the grid. The line_buf must be preallocated with enough space (n_columns*Cell_Size)

void setSize(int columns, int rows) [public]

set number of columns and rows of the grid.

inline int columns() const [public]

return number of columns

inline int rows() const [public]

return number of rows

inline float max() const [public]

return the maximum value

float max(GRect& r) const [public]

return maximum value for given region

inline float min() const [public]

return minimum value

float min(GRect& r) const [public]

return min value for given region

inline float avg() const [public]

return average val. Note that cells with ignore_val are not counted when averaing.

float avg(GRect& r) const [public]

return average value for given region

inline float ignore() const [public]

return the value to be ignored (for background/non-value)

inline void setIgnoreValue(float v) [public]

set ignorant value

inline void setEasting(int e) [public]

set easting value

inline int easting() const [public]

return the easting value

inline void setNorthing(int n) [public]

set northing value

inline int northing() const [public]

return the northing value

inline void setGeoLow(double glx, double gly) [public]

set geographic coordinates for lower corner

inline void setCellSizeX(double sz) [public]

set the size of a cell

inline int cellValueSize() const [public]

get the size of a cell

Result updateStats() [public virtual]

calculate the statistics (min, max, average) of the grid. These statistics are updated and stored permanantly in the grid header.


Documentation generated by lqian@lqian-sun on Wed Jul 14 09:36:10 EDT 1999
Kdoc