GRASS Programmer's Manual  6.5.svn(2014)-r66266
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
tileio.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <unistd.h>
#include "G3d_intern.h"
Include dependency graph for tileio.c:

Go to the source code of this file.

Functions

void * G3d_getTilePtr (G3D_Map *map, int tileIndex)
 This function returns a pointer to a tile which contains the data for the tile with index tileIndex. The type of the data stored in the tile depends on the type specified at the initialization time of map. The functionality is different depending on whether map is old or new and depending on the cache-mode of map.
If map is old and the cache is not used the tile with tileIndex is read from file and stored in the buffer provided by the map structure. The pointer to this buffer is returned. If the buffer already contains the tile with tileIndex reading is skipped. Data which was stored in earlier calls to G3d_getTilePtr is destroyed. If the tile with tileIndex is not stored on the file corresponding to map, and tileIndex is a valid index the buffer is filled with NULL-values.
If map is old and the cache is used the tile with tileIndex is read from file and stored in one of the cache buffers. The pointer to buffer is returned. If no free cache buffer is available an unlocked cache-buffer is freed up and the new tile is stored in its place. If the tile with tileIndex is not stored on the file corresponding to map, and tileIndex is a valid index the buffer is filled with NULL-values. If one of the cache buffers already contains the tile with tileIndex reading is skipped and the pointer to this buffer is returned.
If map is new and the cache is not used the functionality is the same as if map is old and the cache is not used. If the tile with tileIndex is already stored on file, it is read into the buffer, if not, the cells are set to null-values. If the buffer corresponding to the pointer is used for writing, subsequent calls to G3d_getTilePtr may destroy the values already stored in the buffer. Use G3d_flushTile to write the buffer to the file before reusing it for a different index. The use of this buffer as write buffer is discouraged.
If map is new and the cache is used the functionality is the same as if map is old and the cache is used with the following exception. If tileIndex is a valid index and the tile with this index is not found in the cache and is not stored on the file corresponding to map, then the file cache is queried next. If the file-cache contains the tile it is loaded into the cache (memory-cache). Only if the file-cache does not contain the tile it is filled with NULL-values. Tile contents of buffers are never destroyed. If a cache buffer needs to be freed up, and the tile stored in the buffer has not been written to the file corresponding to map yet, the tile is copied into the file-cache.
Care has to be taken if this function is used in non-cache mode since it is implicitly invoked every time a read or write request is issued. The only I/O-functions for which it is safe to assume that they do not invoke G3d_getTilePtr are G3d_readTile() and G3d_writeTile() and their corresponding type-specific versions. More...
 
int G3d_tileLoad (G3D_Map *map, int tileIndex)
 Same functionality as G3d_getTilePtr() but does not return the pointer. More...
 
int G3d__removeTile (G3D_Map *map, int tileIndex)
 
double G3d_getDoubleRegion ()
 Is equivalent to G3d_getValueRegion (map, x, y, z, &value, DCELL_TYPE); return value. More...
 
float G3d_getFloatRegion (G3D_Map *map, int x, int y, int z)
 Is equivalent to G3d_getValueRegion (map, x, y, z, &value, FCELL_TYPE); return value. More...
 
double G3d_getDoubleRegion (G3D_Map *map, int x, int y, int z)
 Is equivalent to G3d_getValueRegion (map, x, y, z, &value, DCELL_TYPE); return value. More...
 
void G3d_getValueRegion (G3D_Map *map, int x, int y, int z, void *value, int type)
 Returns in *value the cell-value of the cell with region-coordinate (x, y, z). The value returned is of type. Here region means the coordinate in the cube of data in the file, i.e. ignoring geographic coordinates. This function invokes a fatal error if an error occurs. More...
 

Function Documentation

int G3d__removeTile ( G3D_Map *  map,
int  tileIndex 
)

Definition at line 127 of file tileio.c.

References G3d_cache_remove_elt(), and G3d_error().

Referenced by G3d_flushTile().

double G3d_getDoubleRegion ( )

Is equivalent to G3d_getValueRegion (map, x, y, z, &value, DCELL_TYPE); return value.

Parameters
map
x
y
z
Returns
double

Referenced by G3d_getFloatRegion(), G3d_getValueRegion(), and G3d_getVolumeA().

double G3d_getDoubleRegion ( G3D_Map *  map,
int  x,
int  y,
int  z 
)

Is equivalent to G3d_getValueRegion (map, x, y, z, &value, DCELL_TYPE); return value.

Parameters
map
x
y
z
Returns
double

Definition at line 205 of file tileio.c.

References G3d_coord2tileIndex(), G3d_fatalError(), G3d_getFloatRegion(), G3d_getTilePtr(), NULL, and utils::tile.

float G3d_getFloatRegion ( G3D_Map *  map,
int  x,
int  y,
int  z 
)

Is equivalent to G3d_getValueRegion (map, x, y, z, &value, FCELL_TYPE); return value.

Parameters
map
x
y
z
Returns
float

Definition at line 172 of file tileio.c.

References G3d_coord2tileIndex(), G3d_fatalError(), G3d_getDoubleRegion(), G3d_getTilePtr(), NULL, and utils::tile.

Referenced by G3d_getDoubleRegion(), G3d_getValueRegion(), and G3d_getVolumeA().

void* G3d_getTilePtr ( G3D_Map *  map,
int  tileIndex 
)

This function returns a pointer to a tile which contains the data for the tile with index tileIndex. The type of the data stored in the tile depends on the type specified at the initialization time of map. The functionality is different depending on whether map is old or new and depending on the cache-mode of map.
If map is old and the cache is not used the tile with tileIndex is read from file and stored in the buffer provided by the map structure. The pointer to this buffer is returned. If the buffer already contains the tile with tileIndex reading is skipped. Data which was stored in earlier calls to G3d_getTilePtr is destroyed. If the tile with tileIndex is not stored on the file corresponding to map, and tileIndex is a valid index the buffer is filled with NULL-values.
If map is old and the cache is used the tile with tileIndex is read from file and stored in one of the cache buffers. The pointer to buffer is returned. If no free cache buffer is available an unlocked cache-buffer is freed up and the new tile is stored in its place. If the tile with tileIndex is not stored on the file corresponding to map, and tileIndex is a valid index the buffer is filled with NULL-values. If one of the cache buffers already contains the tile with tileIndex reading is skipped and the pointer to this buffer is returned.
If map is new and the cache is not used the functionality is the same as if map is old and the cache is not used. If the tile with tileIndex is already stored on file, it is read into the buffer, if not, the cells are set to null-values. If the buffer corresponding to the pointer is used for writing, subsequent calls to G3d_getTilePtr may destroy the values already stored in the buffer. Use G3d_flushTile to write the buffer to the file before reusing it for a different index. The use of this buffer as write buffer is discouraged.
If map is new and the cache is used the functionality is the same as if map is old and the cache is used with the following exception. If tileIndex is a valid index and the tile with this index is not found in the cache and is not stored on the file corresponding to map, then the file cache is queried next. If the file-cache contains the tile it is loaded into the cache (memory-cache). Only if the file-cache does not contain the tile it is filled with NULL-values. Tile contents of buffers are never destroyed. If a cache buffer needs to be freed up, and the tile stored in the buffer has not been written to the file corresponding to map yet, the tile is copied into the file-cache.
Care has to be taken if this function is used in non-cache mode since it is implicitly invoked every time a read or write request is issued. The only I/O-functions for which it is safe to assume that they do not invoke G3d_getTilePtr are G3d_readTile() and G3d_writeTile() and their corresponding type-specific versions.

Parameters
map
tileIndex
Returns
char * a pointer to a buffer ... if successful, NULL ... otherwise.

Definition at line 71 of file tileio.c.

References G3d_cache_elt_ptr(), G3d_error(), G3d_readTile(), and NULL.

Referenced by G3d_flushTile(), G3d_getBlockNocache(), G3d_getDoubleRegion(), G3d_getFloatRegion(), G3d_putDouble(), G3d_putFloat(), and G3d_tileLoad().

void G3d_getValueRegion ( G3D_Map *  map,
int  x,
int  y,
int  z,
void *  value,
int  type 
)

Returns in *value the cell-value of the cell with region-coordinate (x, y, z). The value returned is of type. Here region means the coordinate in the cube of data in the file, i.e. ignoring geographic coordinates. This function invokes a fatal error if an error occurs.

Parameters
map
x
y
z
value
type
Returns
void

Definition at line 244 of file tileio.c.

References G3d_getDoubleRegion(), and G3d_getFloatRegion().

Referenced by G3d_compareFiles(), G3d_getBlock(), G3d_nearestNeighbor(), G3d_retile(), and G3d_writeAscii().

int G3d_tileLoad ( G3D_Map *  map,
int  tileIndex 
)

Same functionality as G3d_getTilePtr() but does not return the pointer.

Parameters
map
tileIndex
Returns
1 ... if successful, 0 ... otherwise.

Definition at line 115 of file tileio.c.

References G3d_error(), G3d_getTilePtr(), and NULL.