GRASS GIS 8 Programmer's Manual 8.4.1(2025)-45ca3179ab
Loading...
Searching...
No Matches
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 GIS 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
28void G__write_Cell_head(FILE *fd, const struct Cell_head *cellhd, int is_cellhd)
29{
30 char buf[1024];
31 int fmt;
32
33 fmt = cellhd->proj;
34
35 fprintf(fd, "proj: %d\n", cellhd->proj);
36 fprintf(fd, "zone: %d\n", cellhd->zone);
37
38 G_format_northing(cellhd->north, buf, fmt);
39 fprintf(fd, "north: %s\n", buf);
40
41 G_format_northing(cellhd->south, buf, fmt);
42 fprintf(fd, "south: %s\n", buf);
43
44 G_format_easting(cellhd->east, buf, fmt);
45 fprintf(fd, "east: %s\n", buf);
46
47 G_format_easting(cellhd->west, buf, fmt);
48 fprintf(fd, "west: %s\n", buf);
49
50 fprintf(fd, "cols: %d\n", cellhd->cols);
51 fprintf(fd, "rows: %d\n", cellhd->rows);
52
53 G_format_resolution(cellhd->ew_res, buf, fmt);
54 fprintf(fd, "e-w resol: %s\n", buf);
55
56 G_format_resolution(cellhd->ns_res, buf, fmt);
57 fprintf(fd, "n-s resol: %s\n", buf);
58
59 if (is_cellhd) {
60 fprintf(fd, "format: %d\n", cellhd->format);
61 fprintf(fd, "compressed: %d\n", cellhd->compressed);
62 }
63}
64
65/**
66 * \brief Write 3D cell header or window.
67 *
68 * \param[in,out] fd header file
69 * \param[in] cellhd pointer to cell header structure
70 * \param[in] is_cellhd 1 cell header; 0 window
71 * \return
72 */
73
74void G__write_Cell_head3(FILE *fd, const struct Cell_head *cellhd,
75 int is_cellhd)
76{
77 char buf[1024];
78 int fmt;
79
80 fmt = cellhd->proj;
81
82 G__write_Cell_head(fd, cellhd, is_cellhd);
83
84 fprintf(fd, "top: %.15f\n", cellhd->top);
85 fprintf(fd, "bottom: %.15f\n", cellhd->bottom);
86
87 fprintf(fd, "cols3: %d\n", cellhd->cols3);
88 fprintf(fd, "rows3: %d\n", cellhd->rows3);
89 fprintf(fd, "depths: %d\n", cellhd->depths);
90
91 G_format_resolution(cellhd->ew_res3, buf, fmt);
92 fprintf(fd, "e-w resol3: %s\n", buf);
93
94 G_format_resolution(cellhd->ns_res3, buf, fmt);
95 fprintf(fd, "n-s resol3: %s\n", buf);
96
97 G_format_resolution(cellhd->tb_res, buf, -1);
98 fprintf(fd, "t-b resol: %s\n", buf);
99}
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:28
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:74