GRASS GIS 7 Programmer's Manual  7.5.svn(2017)-r71933
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
tilemath.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <unistd.h>
#include "raster3d_intern.h"
Include dependency graph for tilemath.c:

Go to the source code of this file.

Functions

void Rast3d_tile_index2tile (RASTER3D_Map *map, int tileIndex, int *xTile, int *yTile, int *zTile)
 Converts index tileIndex into tile-coordinates (xTile, yTile, zTile). More...
 
int Rast3d_tile2tile_index (RASTER3D_Map *map, int xTile, int yTile, int zTile)
 Returns tile-index corresponding to tile-coordinates (xTile, yTile, zTile). More...
 
void Rast3d_tile_coord_origin (RASTER3D_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). More...
 
void Rast3d_tile_index_origin (RASTER3D_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. More...
 
void Rast3d_coord2tile_coord (RASTER3D_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. More...
 
void Rast3d_coord2tile_index (RASTER3D_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. More...
 
int Rast3d_coord_in_range (RASTER3D_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. More...
 
int Rast3d_tile_index_in_range (RASTER3D_Map *map, int tileIndex)
 Returns 1 if tileIndex is a valid index for map. Returns 0 otherwise. More...
 
int Rast3d_tile_in_range (RASTER3D_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. More...
 
int Rast3d_compute_clipped_tile_dimensions (RASTER3D_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. More...
 
void Rast3d_compute_optimal_tile_dimension (RASTER3D_Region *region, int type, int *tileX, int *tileY, int *tileZ, int maxSize)
 Compute the optimal tile size. More...
 

Function Documentation

int Rast3d_compute_clipped_tile_dimensions ( RASTER3D_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 RASTER3D_Map::clipX, RASTER3D_Map::clipY, RASTER3D_Map::clipZ, RASTER3D_Region::cols, RASTER3D_Region::depths, Rast3d_tile_index2tile(), RASTER3D_Map::region, RASTER3D_Region::rows, RASTER3D_Map::tileSize, RASTER3D_Map::tileX, RASTER3D_Map::tileY, RASTER3D_Map::tileZ, and x.

Referenced by Rast3d_init_index(), Rast3d_mask_tile(), Rast3d_read_tile(), and Rast3d_write_tile().

void Rast3d_compute_optimal_tile_dimension ( RASTER3D_Region region,
int  type,
int tileX,
int tileY,
int tileZ,
int  maxSize 
)

Compute the optimal tile size.

This function computes tile sizes with an optimal ratio between tile dimensions and minimized border tile overlapping. Large dimensions (in most cases x and y) will be reduced more often than small dimensions to fit the maxSize criteria.

Parameters
regionThe region of the map
typeThe type of the map (FCELL_TYPE or DCELL_TYPE)
tileXPointer of the tile size in x direction for result storage
tileYPointer of the tile size in y direction for result storage
tileZPointer of the tile size in z direction for result storage
maxSizeThe max size of the tile in kilo bytes
Returns
void

Definition at line 332 of file tilemath.c.

References RASTER3D_Region::cols, DCELL_TYPE, RASTER3D_Region::depths, FCELL_TYPE, G_debug(), int, RASTER3D_Region::rows, and x.

Referenced by Rast3d_open_new_opt_tile_size().

void Rast3d_coord2tile_coord ( RASTER3D_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.

References RASTER3D_Map::tileX, RASTER3D_Map::tileY, and RASTER3D_Map::tileZ.

Referenced by Rast3d_compare_files(), Rast3d_coord2tile_index(), Rast3d_flush_tiles_in_cube(), Rast3d_get_block_nocache(), and Rast3d_retile().

void Rast3d_coord2tile_index ( RASTER3D_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 Rast3d_coord2tile_coord(), Rast3d_tile2tile_index(), RASTER3D_Map::tileX, and RASTER3D_Map::tileXY.

Referenced by Rast3d_get_double_region(), Rast3d_get_float_region(), Rast3d_put_double(), and Rast3d_put_float().

int Rast3d_coord_in_range ( RASTER3D_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.

References RASTER3D_Region::cols, RASTER3D_Region::depths, RASTER3D_Map::region, and RASTER3D_Region::rows.

int Rast3d_tile2tile_index ( RASTER3D_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.

References RASTER3D_Map::nx, and RASTER3D_Map::nxy.

Referenced by Rast3d_change_precision(), Rast3d_change_type(), Rast3d_coord2tile_index(), Rast3d_flush_tile_cube(), and Rast3d_get_block_nocache().

void Rast3d_tile_coord_origin ( RASTER3D_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.

References RASTER3D_Map::tileX, RASTER3D_Map::tileY, and RASTER3D_Map::tileZ.

Referenced by Rast3d_tile_index_origin().

int Rast3d_tile_in_range ( RASTER3D_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.

References RASTER3D_Map::nx, RASTER3D_Map::ny, and RASTER3D_Map::nz.

void Rast3d_tile_index2tile ( RASTER3D_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.

References RASTER3D_Map::nx, and RASTER3D_Map::nxy.

Referenced by Rast3d_compute_clipped_tile_dimensions(), and Rast3d_tile_index_origin().

int Rast3d_tile_index_in_range ( RASTER3D_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 Rast3d_get_block_nocache().

void Rast3d_tile_index_origin ( RASTER3D_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 Rast3d_tile_coord_origin(), and Rast3d_tile_index2tile().

Referenced by Rast3d_mask_tile().