GRASS 8 Programmer's Manual  8.5.0dev(2025)-52c8278fcf
wr_cellhd.c
Go to the documentation of this file.
1 /*!
2  * \file lib/gis/wr_cellhd.c
3  *
4  * \brief GIS Library - Write Cell Header functions.
5  *
6  * (C) 2001-2014 by the GRASS Development Team
7  *
8  * This program is free software under the GNU General Public License
9  * (>=v2). Read the file COPYING that comes with GRASS for details.
10  *
11  * \author GRASS Development Team
12  *
13  * \date 1999-2014
14  */
15 
16 #include <stdio.h>
17 #include <grass/gis.h>
18 
19 /**
20  * \brief Write cell header or window.
21  *
22  * \param[in,out] fd header file
23  * \param[in] cellhd pointed to cell header structure
24  * \param[in] is_cellhd 1 cell header; 0 window
25  * \return
26  */
27 void G__write_Cell_head(FILE *fd, const struct Cell_head *cellhd, int is_cellhd)
28 {
29  char buf[1024];
30  int fmt;
31 
32  fmt = cellhd->proj;
33 
34  fprintf(fd, "proj: %d\n", cellhd->proj);
35  fprintf(fd, "zone: %d\n", cellhd->zone);
36 
37  G_format_northing(cellhd->north, buf, fmt);
38  fprintf(fd, "north: %s\n", buf);
39 
40  G_format_northing(cellhd->south, buf, fmt);
41  fprintf(fd, "south: %s\n", buf);
42 
43  G_format_easting(cellhd->east, buf, fmt);
44  fprintf(fd, "east: %s\n", buf);
45 
46  G_format_easting(cellhd->west, buf, fmt);
47  fprintf(fd, "west: %s\n", buf);
48 
49  fprintf(fd, "cols: %d\n", cellhd->cols);
50  fprintf(fd, "rows: %d\n", cellhd->rows);
51 
52  G_format_resolution(cellhd->ew_res, buf, fmt);
53  fprintf(fd, "e-w resol: %s\n", buf);
54 
55  G_format_resolution(cellhd->ns_res, buf, fmt);
56  fprintf(fd, "n-s resol: %s\n", buf);
57 
58  if (is_cellhd) {
59  fprintf(fd, "format: %d\n", cellhd->format);
60  fprintf(fd, "compressed: %d\n", cellhd->compressed);
61  }
62 }
63 
64 /**
65  * \brief Write 3D cell header or window.
66  *
67  * \param[in,out] fd header file
68  * \param[in] cellhd pointer to cell header structure
69  * \param[in] is_cellhd 1 cell header; 0 window
70  * \return
71  */
72 void G__write_Cell_head3(FILE *fd, const struct Cell_head *cellhd,
73  int is_cellhd)
74 {
75  char buf[1024];
76  int fmt;
77 
78  fmt = cellhd->proj;
79 
80  G__write_Cell_head(fd, cellhd, is_cellhd);
81 
82  fprintf(fd, "top: %.15f\n", cellhd->top);
83  fprintf(fd, "bottom: %.15f\n", cellhd->bottom);
84 
85  fprintf(fd, "cols3: %d\n", cellhd->cols3);
86  fprintf(fd, "rows3: %d\n", cellhd->rows3);
87  fprintf(fd, "depths: %d\n", cellhd->depths);
88 
89  G_format_resolution(cellhd->ew_res3, buf, fmt);
90  fprintf(fd, "e-w resol3: %s\n", buf);
91 
92  G_format_resolution(cellhd->ns_res3, buf, fmt);
93  fprintf(fd, "n-s resol3: %s\n", buf);
94 
95  G_format_resolution(cellhd->tb_res, buf, -1);
96  fprintf(fd, "t-b resol: %s\n", buf);
97 }
void G_format_northing(double north, char *buf, int projection)
Northing to ASCII.
Definition: wind_format.c:29
void G_format_resolution(double res, char *buf, int projection)
Resolution to ASCII.
Definition: wind_format.c:69
void G_format_easting(double east, char *buf, int projection)
Easting to ASCII.
Definition: wind_format.c:49
void G__write_Cell_head(FILE *fd, const struct Cell_head *cellhd, int is_cellhd)
Write cell header or window.
Definition: wr_cellhd.c:27
void G__write_Cell_head3(FILE *fd, const struct Cell_head *cellhd, int is_cellhd)
Write 3D cell header or window.
Definition: wr_cellhd.c:72