12 static int Rast3d_tile2xdrTile(
RASTER3D_Map *map,
const void *tile,
int rows,
13 int cols,
int depths,
int xRedundant,
14 int yRedundant,
int zRedundant
UNUSED,
20 Rast3d_error(
"Rast3d_tile2xdrTile: error in Rast3d_init_copy_to_xdr");
26 Rast3d_error(
"Rast3d_tile2xdrTile: error in Rast3d_copy_to_xdr");
33 for (z = 0; z < depths; z++) {
34 for (y = 0; y < rows; y++) {
37 "Rast3d_tile2xdrTile: error in Rast3d_copy_to_xdr");
50 for (z = 0; z < depths; z++) {
53 "Rast3d_tile2xdrTile: error in Rast3d_copy_to_xdr");
62 Rast3d_error(
"Rast3d_tile2xdrTile: error in Rast3d_copy_to_xdr");
70 static int Rast3d_writeTileUncompressed(
RASTER3D_Map *map,
int nofNum)
74 Rast3d_error(
"Rast3d_writeTileUncompressed: can't write file.");
83 static int Rast3d_writeTileCompressed(
RASTER3D_Map *map,
int nofNum)
89 "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 &cols, &depths, &xRedundant,
148 &yRedundant, &zRedundant);
151 yRedundant, zRedundant, nofNum, type);
153 if (!Rast3d_tile2xdrTile(map, tile, rows, cols, depths, xRedundant,
154 yRedundant, zRedundant, nofNum, type)) {
155 Rast3d_error(
"Rast3d_write_tile: error in Rast3d_tile2xdrTile");
160 if (!Rast3d_writeTileUncompressed(map, nofNum)) {
162 "Rast3d_write_tile: error in Rast3d_writeTileUncompressed");
167 if (!Rast3d_writeTileCompressed(map, nofNum)) {
169 "Rast3d_write_tile: error in Rast3d_writeTileCompressed");
176 lseek(map->
data_fd, (
long)0, SEEK_END) - map->
index[tileIndex];
202 Rast3d_error(
"Rast3d_write_tile_float: error in Rast3d_write_tile");
227 Rast3d_error(
"Rast3d_write_tile_double: error in Rast3d_write_tile");
259 Rast3d_error(
"Rast3d_flush_tile: error in Rast3d_get_tile_ptr");
264 Rast3d_error(
"Rast3d_flush_tile: error in Rast3d_write_tile");
269 Rast3d_error(
"Rast3d_flush_tile: error in Rast3d__remove_tile");
299 int xMax,
int yMax,
int zMax)
305 "Rast3d_flush_tile_cube: function invalid in non-cache mode");
307 for (
x = xMin;
x <= xMax;
x++)
308 for (y = yMin; y <= yMax; y++)
309 for (z = zMin; z <= zMax; z++)
313 "Rast3d_flush_tile_cube: error in Rast3d_flush_tile");
345 int xMax,
int yMax,
int zMax)
347 int xTileMin, yTileMin, zTileMin, xTileMax, yTileMax, zTileMax;
348 int xOffs, yOffs, zOffs;
349 int regionMaxX, regionMaxY, regionMaxZ;
353 "Rast3d_flush_tiles_in_cube: function invalid in non-cache mode");
364 if ((xMin < 0) && (xMax < 0))
366 "Rast3d_flush_tiles_in_cube: coordinate out of Range");
367 if ((xMin >= regionMaxX) && (xMax >= regionMaxX))
369 "Rast3d_flush_tiles_in_cube: coordinate out of Range");
371 xMin =
MIN(
MAX(0, xMin), regionMaxX - 1);
373 if ((yMin < 0) && (yMax < 0))
375 "Rast3d_flush_tiles_in_cube: coordinate out of Range");
376 if ((yMin >= regionMaxY) && (yMax >= regionMaxY))
378 "Rast3d_flush_tiles_in_cube: coordinate out of Range");
380 yMin =
MIN(
MAX(0, yMin), regionMaxY - 1);
382 if ((zMin < 0) && (zMax < 0))
384 "Rast3d_flush_tiles_in_cube: coordinate out of Range");
385 if ((zMin >= regionMaxZ) && (zMax >= regionMaxZ))
387 "Rast3d_flush_tiles_in_cube: coordinate out of Range");
389 zMin =
MIN(
MAX(0, zMin), regionMaxZ - 1);
392 &zTileMin, &xOffs, &yOffs, &zOffs);
402 &yTileMax, &zTileMax, &xOffs, &yOffs, &zOffs);
409 yTileMax, zTileMax)) {
411 "Rast3d_flush_tiles_in_cube: error in Rast3d_flush_tile_cube");
#define G_incr_void_ptr(ptr, size)
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_tile2tile_index(RASTER3D_Map *, int, int, int)
Returns tile-index corresponding to tile-coordinates (xTile, yTile, zTile).
void Rast3d_range_update_from_tile(RASTER3D_Map *, const void *, int, int, int, int, int, int, int, 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_copy_to_xdr(const void *, int)
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...
void Rast3d_error(const char *,...) __attribute__((format(printf
int Rast3d__remove_tile(RASTER3D_Map *, int)
void Rast3d_fatal_error(const char *,...) __attribute__((format(printf
int Rast3d_init_copy_to_xdr(RASTER3D_Map *, int)
int Rast3d_fpcompress_write_xdr_nums(int, char *, int, int, char *, int)
#define UNUSED
A macro for an attribute, if attached to a variable, indicating that the variable is not used.
#define RASTER3D_NO_COMPRESSION
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_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_write_tile_float(RASTER3D_Map *map, int tileIndex, const void *tile)
Is equivalent to Rast3d_write_tile (map, tileIndex, tile, FCELL_TYPE).
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_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...
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...