13 Rast3d_tile2xdrTile(
RASTER3D_Map * map,
const void *tile,
int rows,
int cols,
14 int depths,
int xRedundant,
int yRedundant,
int zRedundant,
20 Rast3d_error(
"Rast3d_tile2xdrTile: error in Rast3d_init_copy_to_xdr");
27 Rast3d_error(
"Rast3d_tile2xdrTile: error in Rast3d_copy_to_xdr");
34 for (z = 0; z < depths; z++) {
35 for (y = 0; y < rows; y++) {
37 Rast3d_error(
"Rast3d_tile2xdrTile: error in Rast3d_copy_to_xdr");
45 map->
tileX * yRedundant *
52 for (z = 0; z < depths; z++) {
54 Rast3d_error(
"Rast3d_tile2xdrTile: error in Rast3d_copy_to_xdr");
63 Rast3d_error(
"Rast3d_tile2xdrTile: error in Rast3d_copy_to_xdr");
71 static int Rast3d_writeTileUncompressed(
RASTER3D_Map * map,
int nofNum)
75 Rast3d_error(
"Rast3d_writeTileUncompressed: can't write file.");
84 static int Rast3d_writeTileCompressed(
RASTER3D_Map * map,
int nofNum)
89 (
"Rast3d_writeTileCompressed: error in Rast3d_fpcompress_write_xdr_nums");
129 int rows, cols, depths, xRedundant, yRedundant, zRedundant, nofNum;
132 if ((tileIndex > map->
nTiles) || (tileIndex < 0))
136 if (map->
index[tileIndex] != -1)
140 map->
index[tileIndex] = lseek(map->
data_fd, (
long)0, SEEK_END);
141 if (map->
index[tileIndex] == -1) {
147 &rows, &cols, &depths,
148 &xRedundant, &yRedundant,
152 xRedundant, yRedundant, zRedundant, nofNum,
155 if (!Rast3d_tile2xdrTile(map, tile, rows, cols, depths,
156 xRedundant, yRedundant, zRedundant, nofNum, type)) {
157 Rast3d_error(
"Rast3d_write_tile: error in Rast3d_tile2xdrTile");
162 if (!Rast3d_writeTileUncompressed(map, nofNum)) {
163 Rast3d_error(
"Rast3d_write_tile: error in Rast3d_writeTileUncompressed");
167 else {
if (!Rast3d_writeTileCompressed(map, nofNum)) {
168 Rast3d_error(
"Rast3d_write_tile: error in Rast3d_writeTileCompressed");
175 map->
index[tileIndex];
201 Rast3d_error(
"Rast3d_write_tile_float: error in Rast3d_write_tile");
226 Rast3d_error(
"Rast3d_write_tile_double: error in Rast3d_write_tile");
260 Rast3d_error(
"Rast3d_flush_tile: error in Rast3d_get_tile_ptr");
265 Rast3d_error(
"Rast3d_flush_tile: error in Rast3d_write_tile");
270 Rast3d_error(
"Rast3d_flush_tile: error in Rast3d__remove_tile");
280 #define MIN(a,b) (a < b ? a : b) 281 #define MAX(a,b) (a > b ? a : b) 313 (
"Rast3d_flush_tile_cube: function invalid in non-cache mode");
315 for (x = xMin; x <= xMax; x++)
316 for (y = yMin; y <= yMax; y++)
317 for (z = zMin; z <= zMax; z++)
319 Rast3d_error(
"Rast3d_flush_tile_cube: error in Rast3d_flush_tile");
355 int xTileMin, yTileMin, zTileMin, xTileMax, yTileMax, zTileMax;
356 int xOffs, yOffs, zOffs;
357 int regionMaxX, regionMaxY, regionMaxZ;
361 (
"Rast3d_flush_tiles_in_cube: function invalid in non-cache mode");
372 if ((xMin < 0) && (xMax < 0))
374 if ((xMin >= regionMaxX) && (xMax >= regionMaxX))
377 xMin =
MIN(
MAX(0, xMin), regionMaxX - 1);
379 if ((yMin < 0) && (yMax < 0))
381 if ((yMin >= regionMaxY) && (yMax >= regionMaxY))
384 yMin =
MIN(
MAX(0, yMin), regionMaxY - 1);
386 if ((zMin < 0) && (zMax < 0))
388 if ((zMin >= regionMaxZ) && (zMax >= regionMaxZ))
391 zMin =
MIN(
MAX(0, zMin), regionMaxZ - 1);
394 &xTileMin, &yTileMin, &zTileMin,
395 &xOffs, &yOffs, &zOffs);
405 &xTileMax, &yTileMax, &zTileMax,
406 &xOffs, &yOffs, &zOffs);
413 xTileMax, yTileMax, zTileMax)) {
414 Rast3d_error(
"Rast3d_flush_tiles_in_cube: error in Rast3d_flush_tile_cube");
void Rast3d_get_coords_map(RASTER3D_Map *, int *, int *, int *)
Returns the size of the region of map in cells.
void * Rast3d_get_tile_ptr(RASTER3D_Map *, int)
This function returns a pointer to a tile which contains the data for the tile with index tileIndex...
int Rast3d_init_copy_to_xdr(RASTER3D_Map *, int)
int Rast3d_write_tile(RASTER3D_Map *map, int tileIndex, const void *tile, int type)
Writes tile with index tileIndex to the file corresponding to map. It is assumed that the cells in ti...
#define G_incr_void_ptr(ptr, size)
void Rast3d_range_update_from_tile(RASTER3D_Map *, const void *, int, int, int, int, int, int, int, int)
void Rast3d_fatal_error(const char *,...) __attribute__((format(printf
void Rast3d_error(const char *,...) __attribute__((format(printf
int Rast3d_flush_tile_cube(RASTER3D_Map *map, int xMin, int yMin, int zMin, int xMax, int yMax, int zMax)
Writes the tiles with tile-coordinates contained in the axis-parallel cube with vertices (xMin...
int Rast3d__remove_tile(RASTER3D_Map *, int)
int Rast3d_write_tile_double(RASTER3D_Map *map, int tileIndex, const void *tile)
Is equivalent to Rast3d_write_tile (map, tileIndex, tile, DCELL_TYPE).
int Rast3d_write_tile_float(RASTER3D_Map *map, int tileIndex, const void *tile)
Is equivalent to Rast3d_write_tile (map, tileIndex, tile, FCELL_TYPE).
#define RASTER3D_NO_COMPRESSION
int Rast3d_compute_clipped_tile_dimensions(RASTER3D_Map *, int, int *, int *, int *, int *, int *, int *)
Computes the dimensions of the tile when clipped to fit the region of map. The clipped dimensions are...
int Rast3d_flush_tiles_in_cube(RASTER3D_Map *map, int xMin, int yMin, int zMin, int xMax, int yMax, int zMax)
Writes those tiles for which every cell has coordinate contained in the axis-parallel cube defined by...
int Rast3d_fpcompress_write_xdr_nums(int, char *, int, int, char *, int)
int Rast3d_flush_tile(RASTER3D_Map *map, int tileIndex)
Writes the tile with tileIndex to the file corresponding to map and removes the tile from the cache (...
int Rast3d_copy_to_xdr(const void *, int)
void Rast3d_coord2tile_coord(RASTER3D_Map *, int, int, int, int *, int *, int *, int *, int *, int *)
Converts cell-coordinates (x, y, z) into tile-coordinates (xTile, yTile, zTile) and the coordinate of...
int Rast3d_tile2tile_index(RASTER3D_Map *, int, int, int)
Returns tile-index corresponding to tile-coordinates (xTile, yTile, zTile).