GRASS GIS 8 Programmer's Manual  8.2.2dev(2023)-3d2c704037
headerinfo.c
Go to the documentation of this file.
1 #include <grass/raster3d.h>
2 #include "raster3d_intern.h"
3 
4 /*---------------------------------------------------------------------------*/
5 
6 
7 /*!
8  * \brief
9  *
10  * Returns the size of the region of <em>map</em> in cells.
11  *
12  * \param map
13  * \param rows
14  * \param cols
15  * \param depths
16  * \return void
17  */
18 
19 void Rast3d_get_coords_map(RASTER3D_Map * map, int *rows, int *cols, int *depths)
20 {
21  *rows = map->region.rows;
22  *cols = map->region.cols;
23  *depths = map->region.depths;
24 }
25 
26 /*---------------------------------------------------------------------------*/
27 
28 void Rast3d_get_coords_map_window(RASTER3D_Map * map, int *rows, int *cols, int *depths)
29 {
30  *rows = map->window.rows;
31  *cols = map->window.cols;
32  *depths = map->window.depths;
33 }
34 
35 /*---------------------------------------------------------------------------*/
36 
37 
38 /*!
39  * \brief
40  *
41  * Returns the dimensions of the tile-cube used to tile the region of <em>map</em>.
42  * These numbers include partial tiles.
43  *
44  * \param map
45  * \param nx
46  * \param ny
47  * \param nz
48  * \return void
49  */
50 
51 void Rast3d_get_nof_tiles_map(RASTER3D_Map * map, int *nx, int *ny, int *nz)
52 {
53  *nx = map->nx;
54  *ny = map->ny;
55  *nz = map->nz;
56 }
57 
58 /*---------------------------------------------------------------------------*/
59 
60 
61 /*!
62  * \brief
63  *
64  * Returns the size of the region.
65  *
66  * \param map
67  * \param north
68  * \param south
69  * \param east
70  * \param west
71  * \param top
72  * \param bottom
73  * \return void
74  */
75 
76 void
77 Rast3d_get_region_map(RASTER3D_Map * map, double *north, double *south, double *east,
78  double *west, double *top, double *bottom)
79 {
80  *north = map->region.north;
81  *south = map->region.south;
82  *east = map->region.east;
83  *west = map->region.west;
84  *top = map->region.top;
85  *bottom = map->region.bottom;
86 }
87 
88 /*---------------------------------------------------------------------------*/
89 
90 void
91 Rast3d_get_window_map(RASTER3D_Map * map, double *north, double *south, double *east,
92  double *west, double *top, double *bottom)
93 {
94  *north = map->window.north;
95  *south = map->window.south;
96  *east = map->window.east;
97  *west = map->window.west;
98  *top = map->window.top;
99  *bottom = map->window.bottom;
100 }
101 
102 /*---------------------------------------------------------------------------*/
103 
104 
105 /*!
106  * \brief
107  *
108  * Returns in <em>region</em> the region of <em>map</em>.
109  *
110  * \param map
111  * \param region
112  * \return void
113  */
114 
116 {
117  Rast3d_region_copy(region, &(map->region));
118 }
119 
120 /*---------------------------------------------------------------------------*/
121 
123 {
124  Rast3d_region_copy(window, &(map->window));
125 }
126 
127 /*---------------------------------------------------------------------------*/
128 
129 
130 /*!
131  * \brief
132  *
133  * Returns the tile dimensions used for <em>map</em>.
134  *
135  * \param map
136  * \param x
137  * \param y
138  * \param z
139  * \return void
140  */
141 
142 void Rast3d_get_tile_dimensions_map(RASTER3D_Map * map, int *x, int *y, int *z)
143 {
144  *x = map->tileX;
145  *y = map->tileY;
146  *z = map->tileZ;
147 }
148 
149 /*---------------------------------------------------------------------------*/
150 
151 
152 /*!
153  * \brief
154  *
155  * Returns the type in which tiles of <em>map</em> are stored in memory.
156  *
157  * \param map
158  * \return int
159  */
160 
162 {
163  return map->typeIntern;
164 }
165 
166 /*---------------------------------------------------------------------------*/
167 
168 /*!
169  * \brief
170  *
171  * Set the data unit defintiong
172  *
173  * \param map
174  * \param unit
175  * \return void
176  */
177 
178 void Rast3d_set_unit(RASTER3D_Map * map, const char *unit)
179 {
180  map->unit = G_store(unit);
181 }
182 
183 /*---------------------------------------------------------------------------*/
184 
185 /*!
186  * \brief
187  *
188  * set Vertical unit from integer value defined in gis.h (U_METERS, ...)
189  *
190  * \param map
191  * \param unit
192  * \return void
193  */
194 
195 void Rast3d_set_vertical_unit2(RASTER3D_Map * map, int vertical_unit)
196 {
197  map->vertical_unit = vertical_unit;
198 }
199 
200 /*---------------------------------------------------------------------------*/
201 
202 /*!
203  * \brief
204  *
205  * set Vertical unit from string
206  *
207  * \param map
208  * \param unit
209  * \return void
210  */
211 
212 void Rast3d_set_vertical_unit(RASTER3D_Map * map, const char *vertical_unit)
213 {
214  map->vertical_unit = G_units(vertical_unit);
215 }
216 
217 /*---------------------------------------------------------------------------*/
218 
219 /*!
220  * \brief
221  *
222  * Return the data unit definition of <em>map</em>.
223  *
224  * \param map
225  * \return int
226  */
227 
228 const char* Rast3d_get_unit(RASTER3D_Map * map)
229 {
230  return map->unit;
231 }
232 
233 /*---------------------------------------------------------------------------*/
234 
235 /*!
236  * \brief
237  *
238  * Returns the vertical unit of <em>map</em> as integer. Units are defined in gis.h.
239  *
240  * Vertical units may have temporal type
241  *
242  * \param map
243  * \return int
244  */
245 
247 {
248  return map->vertical_unit;
249 }
250 
251 /*---------------------------------------------------------------------------*/
252 
253 /*!
254  * \brief
255  *
256  * Return the name of the unit of <em>map</em>. Units are defined in gis.h.
257  *
258  * Vertical units may have temporal type
259  *
260  * \param map
261  * \return int
262  */
263 
265 {
266  return G_get_units_name(map->vertical_unit, 1, 0);
267 }
268 
269 /*---------------------------------------------------------------------------*/
270 
271 
272 /*!
273  * \brief
274  *
275  * Returns the type with which tiles of <em>map</em> are stored on file.
276  *
277  * \param map
278  * \return int
279  */
280 
282 {
283  return map->type;
284 }
285 
286 /*---------------------------------------------------------------------------*/
287 
288 
289 /*!
290  * \brief
291  *
292  * Returns the precision used to store <em>map</em>.
293  *
294  * \param map
295  * \return int
296  */
297 
299 {
300  return map->precision;
301 }
302 
303 /*---------------------------------------------------------------------------*/
304 
305 
306 /*!
307  * \brief
308  *
309  * Returns 1 if <em>map</em> uses cache, returns 0 otherwise.
310  *
311  * \param map
312  * \return int
313  */
314 
316 {
317  return map->useCache;
318 }
319 
320 
321 
322 /*!
323  * \brief
324  *
325  * Prints the header information of <em>map</em>.
326  *
327  * \param map
328  * \return void
329  */
330 
332 {
333  double rangeMin, rangeMax;
334 
335  printf("File %s open for %sing:\n", map->fileName,
336  (map->operation == RASTER3D_WRITE_DATA ? "writing" :
337  (map->operation == RASTER3D_READ_DATA ? "reading" : "unknown")));
338  printf("Version %i\n", map->version);
339  printf(" Fd = %d, Unit %s, Vertical Unit %s, Type: %s, ", map->data_fd,
340  map->unit, G_get_units_name(map->vertical_unit, 1, 0),
341  (map->type == FCELL_TYPE ? "float" :
342  (map->type == DCELL_TYPE ? "double" : "unknown")));
343  printf("Type intern: %s\n",
344  (map->typeIntern == FCELL_TYPE ? "float" :
345  (map->typeIntern == DCELL_TYPE ? "double" : "unknown")));
347  printf(" Compression: none\n");
348  else {
349  printf(" Compression:%s (%s%s) Precision: %s", (map->compression ? "on" : "off"),
350  (map->useLzw ? " lzw," : ""), (map->useRle ? " rle," : ""),
351  (map->precision == -1 ? "all bits used\n" : "using"));
352  if (map->precision != -1)
353  printf(" %d bits\n", map->precision);
354  }
355 
356  if (!map->useCache)
357  printf(" Cache: none\n");
358  else {
359  printf(" Cache: used%s\n",
360  (map->operation == RASTER3D_WRITE_DATA ? ", File Cache used" : ""));
361  }
362 
363  Rast3d_range_min_max(map, &rangeMin, &rangeMax);
364 
365  printf(" Region: (%f %f) (%f %f) (%f %f)\n",
366  map->region.south, map->region.north, map->region.west,
367  map->region.east, map->region.bottom, map->region.top);
368  printf(" (cols %5d rows %5d depths %5d)\n", map->region.cols, map->region.rows,
369  map->region.depths);
370  printf(" Num tiles (X %5d Y %5d Z %5d)\n", map->nx, map->ny, map->nz);
371  printf(" Tile size (X %5d Y %5d Z %5d)\n", map->tileX, map->tileY, map->tileZ);
372  printf(" Range (");
373  if (Rast3d_is_null_value_num(&rangeMin, DCELL_TYPE))
374  printf("NULL, ");
375  else
376  printf("%f, ", (double)rangeMin);
377  if (Rast3d_is_null_value_num(&rangeMax, DCELL_TYPE))
378  printf("NULL)\n");
379  else
380  printf("%f)\n", (double)rangeMax);
381  fflush(stdout);
382 }
double east
Definition: raster3d.h:51
int Rast3d_tile_precision_map(RASTER3D_Map *map)
Returns the precision used to store map.
Definition: headerinfo.c:298
void Rast3d_get_window_map(RASTER3D_Map *map, double *north, double *south, double *east, double *west, double *top, double *bottom)
Definition: headerinfo.c:91
void Rast3d_get_coords_map_window(RASTER3D_Map *map, int *rows, int *cols, int *depths)
Definition: headerinfo.c:28
void Rast3d_region_copy(RASTER3D_Region *, RASTER3D_Region *)
Copies the values of regionSrc into regionDst.
Definition: region.c:207
double top
Definition: raster3d.h:52
int Rast3d_file_type_map(RASTER3D_Map *map)
Returns the type with which tiles of map are stored on file.
Definition: headerinfo.c:281
char * fileName
Definition: raster3d.h:76
double bottom
Definition: raster3d.h:52
#define RASTER3D_WRITE_DATA
int typeIntern
Definition: raster3d.h:149
int operation
Definition: raster3d.h:81
int Rast3d_get_vertical_unit2(RASTER3D_Map *map)
Returns the vertical unit of map as integer. Units are defined in gis.h.
Definition: headerinfo.c:246
int Rast3d_tile_use_cache_map(RASTER3D_Map *map)
Returns 1 if map uses cache, returns 0 otherwise.
Definition: headerinfo.c:315
int useCache
Definition: raster3d.h:159
void Rast3d_get_region_map(RASTER3D_Map *map, double *north, double *south, double *east, double *west, double *top, double *bottom)
Returns the size of the region.
Definition: headerinfo.c:77
const char * Rast3d_get_unit(RASTER3D_Map *map)
Return the data unit definition of map.
Definition: headerinfo.c:228
void Rast3d_set_vertical_unit2(RASTER3D_Map *map, int vertical_unit)
set Vertical unit from integer value defined in gis.h (U_METERS, ...)
Definition: headerinfo.c:195
int version
Definition: raster3d.h:74
void Rast3d_set_unit(RASTER3D_Map *map, const char *unit)
Set the data unit defintiong.
Definition: headerinfo.c:178
#define x
void Rast3d_get_tile_dimensions_map(RASTER3D_Map *map, int *x, int *y, int *z)
Returns the tile dimensions used for map.
Definition: headerinfo.c:142
double north
Definition: raster3d.h:50
const char * G_get_units_name(int, int, int)
Get localized units name.
Definition: units.c:203
#define DCELL_TYPE
Definition: raster.h:13
double west
Definition: raster3d.h:51
void Rast3d_range_min_max(RASTER3D_Map *, double *, double *)
Returns in min and max the minimum and maximum values of the range.
Definition: d/range.c:135
int compression
Definition: raster3d.h:113
int vertical_unit
Definition: raster3d.h:94
char * unit
Definition: raster3d.h:93
int precision
Definition: raster3d.h:111
#define RASTER3D_NO_COMPRESSION
Definition: raster3d.h:14
void Rast3d_getWindowStructMap(RASTER3D_Map *map, RASTER3D_Region *window)
Definition: headerinfo.c:122
void Rast3d_get_nof_tiles_map(RASTER3D_Map *map, int *nx, int *ny, int *nz)
Returns the dimensions of the tile-cube used to tile the region of map. These numbers include partial...
Definition: headerinfo.c:51
void Rast3d_get_coords_map(RASTER3D_Map *map, int *rows, int *cols, int *depths)
Returns the size of the region of map in cells.
Definition: headerinfo.c:19
#define RASTER3D_READ_DATA
void Rast3d_get_region_struct_map(RASTER3D_Map *map, RASTER3D_Region *region)
Returns in region the region of map.
Definition: headerinfo.c:115
RASTER3D_Region region
Definition: raster3d.h:84
int Rast3d_tile_type_map(RASTER3D_Map *map)
Returns the type in which tiles of map are stored in memory.
Definition: headerinfo.c:161
#define FCELL_TYPE
Definition: raster.h:12
char * G_store(const char *)
Copy string to allocated memory.
Definition: strings.c:87
void Rast3d_set_vertical_unit(RASTER3D_Map *map, const char *vertical_unit)
set Vertical unit from string
Definition: headerinfo.c:212
int Rast3d_is_null_value_num(const void *, int)
Definition: null.c:12
int G_units(const char *)
Get units code by name.
Definition: units.c:319
double south
Definition: raster3d.h:50
RASTER3D_Region window
Definition: raster3d.h:87
const char * Rast3d_get_vertical_unit(RASTER3D_Map *map)
Return the name of the unit of map. Units are defined in gis.h.
Definition: headerinfo.c:264
void Rast3d_print_header(RASTER3D_Map *map)
Prints the header information of map.
Definition: headerinfo.c:331