GRASS GIS 8 Programmer's Manual  8.5.0dev(2024)-b4e4cb0fe9
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

◆ Rast3d_compute_clipped_tile_dimensions()

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 253 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_compute_optimal_tile_dimension()

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 317 of file tilemath.c.

◆ Rast3d_coord2tile_coord()

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 129 of file tilemath.c.

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

Referenced by Rast3d_coord2tile_index(), and Rast3d_flush_tiles_in_cube().

◆ Rast3d_coord2tile_index()

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 158 of file tilemath.c.

References Rast3d_coord2tile_coord(), Rast3d_tile2tile_index(), RASTER3D_Map::tileX, RASTER3D_Map::tileXY, and x.

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

◆ Rast3d_coord_in_range()

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 185 of file tilemath.c.

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

◆ Rast3d_tile2tile_index()

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 49 of file tilemath.c.

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

Referenced by Rast3d_coord2tile_index(), and Rast3d_flush_tile_cube().

◆ Rast3d_tile_coord_origin()

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 73 of file tilemath.c.

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

Referenced by Rast3d_tile_index_origin().

◆ Rast3d_tile_in_range()

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 225 of file tilemath.c.

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

◆ Rast3d_tile_index2tile()

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 23 of file tilemath.c.

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

Referenced by Rast3d_compute_clipped_tile_dimensions(), and Rast3d_tile_index_origin().

◆ Rast3d_tile_index_in_range()

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 204 of file tilemath.c.

◆ Rast3d_tile_index_origin()

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 97 of file tilemath.c.

References Rast3d_tile_coord_origin(), Rast3d_tile_index2tile(), and x.