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