GRASS Programmer's Manual  6.5.svn(2014)-r66266
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
gis/format.c File Reference
#include <grass/gis.h>
#include <grass/glocale.h>
#include <unistd.h>
#include <stdlib.h>
#include <grass/config.h>
#include "G.h"
Include dependency graph for gis/format.c:

Go to the source code of this file.

Functions

int G__check_format (int fd)
 
int G__read_row_ptrs (int fd)
 
int G__write_row_ptrs (int fd)
 

Function Documentation

int G__check_format ( int  fd)

GRASS Raster Format

Small example to illustrate the raster format:

A file may contain the following 3x3 floating point matrix:

10.000 20.000 30.000
20.000 40.000 50.000
30.000 50.000 60.000

The header is a single byte, equal to sizeof(off_t) (typically 4 on a 32-bit platform, 8 on a 64-bit platform). Then, NROWS+1 offsets are written as off_t's (i.e. 4 or 8 bytes, depending upon platform) in big-endian (Motorola) byte order.

Thus, above example is actually interpreted as:

4               sizeof(off_t)
0 0 0 17        offset of row 0
0 0 0 36        offset of row 1
0 0 0 55        offset of row 2
0 0 0 74        offset of end of data

See G__write_row_ptrs() below for the code which writes this data. However, note that the row offsets are initially zero; they get overwritten later (if you are writing compressed data, you don't know how much space it will require until you've compressed it).

As for the format of the actual row data, see put_fp_data() in src/libes/gis/put_row.c and RFC 1014 (the XDR specification): http://www.faqs.org/rfcs/rfc1014.html

Definition at line 66 of file gis/format.c.

References fileinfo::cellhd, fd, G__::fileinfo, G__read_row_ptrs(), and fileinfo::row_ptr.

Referenced by G__open_cell_old().

int G__read_row_ptrs ( int  fd)
int G__write_row_ptrs ( int  fd)

Definition at line 162 of file gis/format.c.

References b, buf, fileinfo::cellhd, fd, G__::fileinfo, G_free(), fileinfo::nbytes, and fileinfo::row_ptr.