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

Go to the source code of this file.

Functions

void G3d_tileIndex2tile (G3D_Map *map, int tileIndex, int *xTile, int *yTile, int *zTile)
 Converts index tileIndex into tile-coordinates (xTile, yTile, zTile).
int G3d_tile2tileIndex (G3D_Map *map, int xTile, int yTile, int zTile)
 Returns tile-index corresponding to tile-coordinates (xTile, yTile, zTile).
void G3d_tileCoordOrigin (G3D_Map *map, int xTile, int yTile, int zTile, int *x, int *y, int *z)
 Computes the cell-coordinates (x, y, z) which correspond to the origin of the tile with tile-coordinates (xTile, yTile, zTile).
void G3d_tileIndexOrigin (G3D_Map *map, int tileIndex, int *x, int *y, int *z)
 Computes the cell-coordinates (x, y, z) which correspond to the origin of the tile with tileIndex.
void G3d_coord2tileCoord (G3D_Map *map, int x, int y, int z, int *xTile, int *yTile, int *zTile, int *xOffs, int *yOffs, int *zOffs)
 Converts cell-coordinates (x, y, z) into tile-coordinates (xTile, yTile, zTile) and the coordinate of the cell (xOffs, yOffs, zOffs) within the tile.
void G3d_coord2tileIndex (G3D_Map *map, int x, int y, int z, int *tileIndex, int *offset)
 Converts cell-coordinates (x, y, z) into tileIndex and the offset of the cell within the tile.
int G3d_coordInRange (G3D_Map *map, int x, int y, int z)
 Returns 1 if cell-coordinate (x, y, z) is a coordinate inside the region. Returns 0 otherwise.
int G3d_tileIndexInRange (G3D_Map *map, int tileIndex)
 Returns 1 if tileIndex is a valid index for map. Returns 0 otherwise.
int G3d_tileInRange (G3D_Map *map, int x, int y, int z)
 Returns 1 if tile-coordinate (x, y, z) is a coordinate inside tile cube. Returns 0 otherwise.
int G3d_computeClippedTileDimensions (G3D_Map *map, int tileIndex, int *rows, int *cols, int *depths, int *xRedundant, int *yRedundant, int *zRedundant)
 Computes the dimensions of the tile when clipped to fit the region of map. The clipped dimensions are returned in rows, cols, depths. The complement is returned in xRedundant, yRedundant, and zRedundant. This function returns the number of cells in the clipped tile.
int G3d_isValidLocation (G3D_Map *map, double north, double east, double top)
 Returns 1 if region-coordinates (north, west, bottom) are inside the region of map. Returns 0 otherwise.
void G3d_location2coord (G3D_Map *map, double north, double east, double top, int *x, int *y, int *z)
 Converts region-coordinates (north, west, bottom) into cell-coordinates (x, y, z).

Function Documentation

int G3d_computeClippedTileDimensions ( G3D_Map *  map,
int  tileIndex,
int *  rows,
int *  cols,
int *  depths,
int *  xRedundant,
int *  yRedundant,
int *  zRedundant 
)

Computes the dimensions of the tile when clipped to fit the region of map. The clipped dimensions are returned in rows, cols, depths. The complement is returned in xRedundant, yRedundant, and zRedundant. This function returns the number of cells in the clipped tile.

Parameters:
map
tileIndex
rows
cols
depths
xRedundant
yRedundant
zRedundant
Returns:
int

Definition at line 267 of file tilemath.c.

References G3d_tileIndex2tile().

Referenced by G3d_initIndex(), G3d_maskTile(), G3d_readTile(), and G3d_writeTile().

void G3d_coord2tileCoord ( G3D_Map *  map,
int  x,
int  y,
int  z,
int *  xTile,
int *  yTile,
int *  zTile,
int *  xOffs,
int *  yOffs,
int *  zOffs 
)

Converts cell-coordinates (x, y, z) into tile-coordinates (xTile, yTile, zTile) and the coordinate of the cell (xOffs, yOffs, zOffs) within the tile.

Parameters:
map
x
y
z
xTile
yTile
zTile
xOffs
yOffs
zOffs
Returns:
void

Definition at line 136 of file tilemath.c.

Referenced by G3d_compareFiles(), G3d_coord2tileIndex(), G3d_flushTilesInCube(), G3d_getBlockNocache(), and G3d_retile().

void G3d_coord2tileIndex ( G3D_Map *  map,
int  x,
int  y,
int  z,
int *  tileIndex,
int *  offset 
)

Converts cell-coordinates (x, y, z) into tileIndex and the offset of the cell within the tile.

Parameters:
map
x
y
z
tileIndex
offset
Returns:
void

Definition at line 167 of file tilemath.c.

References G3d_coord2tileCoord(), and G3d_tile2tileIndex().

Referenced by G3d_getDoubleRegion(), G3d_getFloatRegion(), G3d_putDouble(), and G3d_putFloat().

int G3d_coordInRange ( G3D_Map *  map,
int  x,
int  y,
int  z 
)

Returns 1 if cell-coordinate (x, y, z) is a coordinate inside the region. Returns 0 otherwise.

Parameters:
map
x
y
z
Returns:
int

Definition at line 195 of file tilemath.c.

int G3d_isValidLocation ( G3D_Map *  map,
double  north,
double  east,
double  top 
)

Returns 1 if region-coordinates (north, west, bottom) are inside the region of map. Returns 0 otherwise.

Parameters:
map
north
west
bottom
Returns:
int

Definition at line 327 of file tilemath.c.

Referenced by G3d_location2coord().

void G3d_location2coord ( G3D_Map *  map,
double  north,
double  east,
double  top,
int *  x,
int *  y,
int *  z 
)

Converts region-coordinates (north, west, bottom) into cell-coordinates (x, y, z).

Parameters:
map
north
west
bottom
x
y
z
Returns:
void

Definition at line 355 of file tilemath.c.

References G3d_fatalError(), and G3d_isValidLocation().

Referenced by G3d_getVolumeA().

int G3d_tile2tileIndex ( G3D_Map *  map,
int  xTile,
int  yTile,
int  zTile 
)

Returns tile-index corresponding to tile-coordinates (xTile, yTile, zTile).

Parameters:
map
xTile
yTile
zTile
Returns:
int

Definition at line 52 of file tilemath.c.

Referenced by G3d_changePrecision(), G3d_changeType(), G3d_coord2tileIndex(), G3d_flushTileCube(), and G3d_getBlockNocache().

void G3d_tileCoordOrigin ( G3D_Map *  map,
int  xTile,
int  yTile,
int  zTile,
int *  x,
int *  y,
int *  z 
)

Computes the cell-coordinates (x, y, z) which correspond to the origin of the tile with tile-coordinates (xTile, yTile, zTile).

Parameters:
map
xTile
yTile
zTile
x
y
z
Returns:
void

Definition at line 78 of file tilemath.c.

Referenced by G3d_tileIndexOrigin().

void G3d_tileIndex2tile ( G3D_Map *  map,
int  tileIndex,
int *  xTile,
int *  yTile,
int *  zTile 
)

Converts index tileIndex into tile-coordinates (xTile, yTile, zTile).

Parameters:
map
tileIndex
xTile
yTile
zTile
Returns:
void

Definition at line 25 of file tilemath.c.

Referenced by G3d_computeClippedTileDimensions(), and G3d_tileIndexOrigin().

int G3d_tileIndexInRange ( G3D_Map *  map,
int  tileIndex 
)

Returns 1 if tileIndex is a valid index for map. Returns 0 otherwise.

Parameters:
map
tileIndex
Returns:
int

Definition at line 215 of file tilemath.c.

Referenced by G3d_getBlockNocache().

void G3d_tileIndexOrigin ( G3D_Map *  map,
int  tileIndex,
int *  x,
int *  y,
int *  z 
)

Computes the cell-coordinates (x, y, z) which correspond to the origin of the tile with tileIndex.

Parameters:
map
tileIndex
x
y
z
Returns:
void

Definition at line 103 of file tilemath.c.

References G3d_tileCoordOrigin(), and G3d_tileIndex2tile().

Referenced by G3d_maskTile().

int G3d_tileInRange ( G3D_Map *  map,
int  x,
int  y,
int  z 
)

Returns 1 if tile-coordinate (x, y, z) is a coordinate inside tile cube. Returns 0 otherwise.

Parameters:
map
x
y
z
Returns:
int

Definition at line 237 of file tilemath.c.