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