GRASS GIS 7 Programmer's Manual  7.5.svn(2017)-r71942
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
open2.c
Go to the documentation of this file.
1 #include <grass/gis.h>
2 #include <grass/raster3d.h>
3 
4 /*----------------------------------------------------------------------------*/
5 
6 /*!
7  * \brief
8  *
9  * Opens new g3d-file with <em>name</em> in the current mapset. Tiles
10  * are stored in memory with <em>typeIntern</em> which must be one of FCELL_TYPE,
11  * DCELL_TYPE, or RASTER3D_TILE_SAME_AS_FILE. <em>cache</em> specifies the
12  * cache-mode used and must be either RASTER3D_NO_CACHE, RASTER3D_USE_CACHE_DEFAULT,
13  * RASTER3D_USE_CACHE_X, RASTER3D_USE_CACHE_Y, RASTER3D_USE_CACHE_Z,
14  * RASTER3D_USE_CACHE_XY, RASTER3D_USE_CACHE_XZ, RASTER3D_USE_CACHE_YZ,
15  * RASTER3D_USE_CACHE_XYZ, the result of <tt>Rast3d_cache_size_encode ()</tt>
16  * (cf.{g3d:G3d.cacheSizeEncode}), or any positive integer which
17  * specifies the number of tiles buffered in the cache. <em>region</em> specifies
18  * the 3d region.
19  * The map is created using the <em>type</em> which must be of FCELL_TYPE or DCELL_TYPE.
20  * The methods for compression can be specified LZW or RLE. The digits of the floating point mantissa
21  * can be specified. In case of FCELL_TYPE 0-23 and 0-52 in case of DCELL_TYPE.
22  * The number cells in X, Y and Z direction defines the size of each tile.
23  * Returns a pointer to the cell structure ... if successful,
24  * NULL ... otherwise.
25  *
26  * \param name The name of the map
27  * \param typeIntern The internal storage type for in memory chached tiles
28  * \param cache The type of the caching
29  * \param region The region of the map
30  * \param type The type of the map (FCELL_TYPE, or DCELL_TYPE)
31  * \param doLzw Use the LZW compression algorithm
32  * \param doRle Use the Run-Length-Encoding algroithm for compression
33  * \param precision The precision used for the mantissa (0 - 52) or RASTER3D_MAX_PRECISION
34  * \param tileX The number of cells in X direction of a tile
35  * \param tileY The number of cells in Y direction of a tile
36  * \param tileZ The number of cells in Z direction of a tile
37  * \return void *
38  */
39 
40 
41 void *Rast3d_open_new_param(const char *name, int typeIntern, int cache,
42  RASTER3D_Region * region, int type, int compression,
43  int precision, int tileX, int tileY, int tileZ)
44 {
45  void *map;
46  int oldCompress, oldPrecision, oldTileX, oldTileY,
47  oldTileZ;
48  int oldType;
49 
51 
52  Rast3d_get_compression_mode(&oldCompress, &oldPrecision);
53  Rast3d_set_compression_mode(compression, precision);
54 
55  Rast3d_get_tile_dimension(&oldTileX, &oldTileY, &oldTileZ);
56  Rast3d_set_tile_dimension(tileX, tileY, tileZ);
57 
58  oldType = Rast3d_get_file_type();
60 
61  map = Rast3d_open_cell_new(name, typeIntern, cache, region);
62 
63  Rast3d_set_compression_mode(oldCompress, oldPrecision);
64  Rast3d_set_tile_dimension(oldTileX, oldTileY, oldTileZ);
65  Rast3d_set_file_type(oldType);
66 
67  return map;
68 }
69 
70 /*----------------------------------------------------------------------------*/
71 
72 /*!
73  * \brief
74  *
75  * Opens new g3d-file with <em>name</em> in the current mapset. This method tries to compute
76  * optimal tile size based on the number of rows, cols and depths and the maximum allowed tile size in KB.
77  * Tiles are stored in memory using RASTER3D_TILE_SAME_AS_FILE method. <em>cache</em> specifies the
78  * cache-mode used and must be either RASTER3D_NO_CACHE, RASTER3D_USE_CACHE_DEFAULT,
79  * RASTER3D_USE_CACHE_X, RASTER3D_USE_CACHE_Y, RASTER3D_USE_CACHE_Z,
80  * RASTER3D_USE_CACHE_XY, RASTER3D_USE_CACHE_XZ, RASTER3D_USE_CACHE_YZ,
81  * RASTER3D_USE_CACHE_XYZ, the result of <tt>Rast3d_cache_size_encode ()</tt>
82  * (cf.{g3d:G3d.cacheSizeEncode}), or any positive integer which
83  * specifies the number of tiles buffered in the cache. <em>region</em> specifies
84  * the 3d region.
85  * The map is created using the <em>type</em> which must be of FCELL_TYPE or DCELL_TYPE.
86  * Returns a pointer to the cell structure ... if successful,
87  * NULL ... otherwise.
88  *
89  * \param name The name of the map
90  * \param cache The type of the caching
91  * \param region The region of the map
92  * \param type The type of the map (FCELL_TYPE, or DCELL_TYPE)
93  * \param maxSize The maximum size of a tile in kilo bytes
94  * \return void *
95  */
96 
97 
98 void *Rast3d_open_new_opt_tile_size(const char *name, int cache, RASTER3D_Region * region, int type, int maxSize)
99 {
100  void *map;
101  int oldTileX, oldTileY, oldTileZ, oldType;
102  int tileX, tileY, tileZ;
103 
105 
106 
107  Rast3d_get_tile_dimension(&oldTileX, &oldTileY, &oldTileZ);
108 
109  Rast3d_compute_optimal_tile_dimension(region, type, &tileX, &tileY, &tileZ, maxSize);
110 
111  G_debug(1, "New tile dimension X %i Y %i Z %i\n", tileX, tileY, tileZ);
112 
113  Rast3d_set_tile_dimension(tileX, tileY, tileZ);
114 
115  oldType = Rast3d_get_file_type();
116  Rast3d_set_file_type(type);
117 
118  map = Rast3d_open_cell_new(name, RASTER3D_TILE_SAME_AS_FILE, cache, region);
119 
120  Rast3d_set_tile_dimension(oldTileX, oldTileY, oldTileZ);
121  Rast3d_set_file_type(oldType);
122 
123  return map;
124 }
void * Rast3d_open_new_opt_tile_size(const char *name, int cache, RASTER3D_Region *region, int type, int maxSize)
Opens new g3d-file with name in the current mapset. This method tries to compute optimal tile size ba...
Definition: open2.c:98
unsigned short compression
Definition: gsd_img_tif.c:42
void Rast3d_set_file_type(int type)
set G3d file type
Definition: defaults.c:210
void Rast3d_set_compression_mode(int doCompress, int precision)
set compression mode
Definition: defaults.c:96
struct Format_info_cache cache
Lines cache for reading feature.
Definition: dig_structs.h:683
void Rast3d_compute_optimal_tile_dimension(RASTER3D_Region *region, int type, int *tileX, int *tileY, int *tileZ, int maxSize)
Compute the optimal tile size.
Definition: tilemath.c:332
int G_debug(int level, const char *msg,...)
Print debugging message.
Definition: debug.c:65
void Rast3d_init_defaults(void)
Initializes the default values described in RASTER3D Defaults. Applications have to use this function...
Definition: defaults.c:305
void Rast3d_get_compression_mode(int *doCompress, int *precision)
Gets compression mode.
Definition: defaults.c:128
#define RASTER3D_TILE_SAME_AS_FILE
Definition: raster3d.h:12
void Rast3d_set_tile_dimension(int tileX, int tileY, int tileZ)
set Tile Dimension
Definition: defaults.c:244
void * Rast3d_open_new_param(const char *name, int typeIntern, int cache, RASTER3D_Region *region, int type, int compression, int precision, int tileX, int tileY, int tileZ)
Opens new g3d-file with name in the current mapset. Tiles are stored in memory with typeIntern which ...
Definition: open2.c:41
void * Rast3d_open_cell_new(const char *name, int typeIntern, int cache, RASTER3D_Region *region)
Opens new g3d-file with name in the current mapset. Tiles are stored in memory with type which must b...
const char * name
Definition: named_colr.c:7
void Rast3d_get_tile_dimension(int *tileX, int *tileY, int *tileZ)
get Tile Dimension
Definition: defaults.c:271
int Rast3d_get_file_type()
get G3d file type
Definition: defaults.c:227