GRASS 8 Programmer's Manual 8.6.0dev(2026)-1878fdfec5
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 * SPDX-FileCopyrightText: 2001-2014 GRASS Development Team
7 * SPDX-License-Identifier: GPL-2.0-or-later
8 *
9 * \author GRASS Development Team
10 *
11 * \date 1999-2014
12 */
13
14#include <stdio.h>
15#include <grass/gis.h>
16
17/**
18 * \brief Write cell header or window.
19 *
20 * \param[in,out] fd header file
21 * \param[in] cellhd pointed to cell header structure
22 * \param[in] is_cellhd 1 cell header; 0 window
23 * \return
24 */
25void G__write_Cell_head(FILE *fd, const struct Cell_head *cellhd, int is_cellhd)
26{
27 char buf[1024];
28 int fmt;
29
30 fmt = cellhd->proj;
31
32 fprintf(fd, "proj: %d\n", cellhd->proj);
33 fprintf(fd, "zone: %d\n", cellhd->zone);
34
35 G_format_northing(cellhd->north, buf, fmt);
36 fprintf(fd, "north: %s\n", buf);
37
38 G_format_northing(cellhd->south, buf, fmt);
39 fprintf(fd, "south: %s\n", buf);
40
41 G_format_easting(cellhd->east, buf, fmt);
42 fprintf(fd, "east: %s\n", buf);
43
44 G_format_easting(cellhd->west, buf, fmt);
45 fprintf(fd, "west: %s\n", buf);
46
47 fprintf(fd, "cols: %d\n", cellhd->cols);
48 fprintf(fd, "rows: %d\n", cellhd->rows);
49
50 G_format_resolution(cellhd->ew_res, buf, fmt);
51 fprintf(fd, "e-w resol: %s\n", buf);
52
53 G_format_resolution(cellhd->ns_res, buf, fmt);
54 fprintf(fd, "n-s resol: %s\n", buf);
55
56 if (is_cellhd) {
57 fprintf(fd, "format: %d\n", cellhd->format);
58 fprintf(fd, "compressed: %d\n", cellhd->compressed);
59 }
60}
61
62/**
63 * \brief Write 3D cell header or window.
64 *
65 * \param[in,out] fd header file
66 * \param[in] cellhd pointer to cell header structure
67 * \param[in] is_cellhd 1 cell header; 0 window
68 * \return
69 */
70void G__write_Cell_head3(FILE *fd, const struct Cell_head *cellhd,
71 int is_cellhd)
72{
73 char buf[1024];
74 int fmt;
75
76 fmt = cellhd->proj;
77
78 G__write_Cell_head(fd, cellhd, is_cellhd);
79
80 fprintf(fd, "top: %.15f\n", cellhd->top);
81 fprintf(fd, "bottom: %.15f\n", cellhd->bottom);
82
83 fprintf(fd, "cols3: %d\n", cellhd->cols3);
84 fprintf(fd, "rows3: %d\n", cellhd->rows3);
85 fprintf(fd, "depths: %d\n", cellhd->depths);
86
87 G_format_resolution(cellhd->ew_res3, buf, fmt);
88 fprintf(fd, "e-w resol3: %s\n", buf);
89
90 G_format_resolution(cellhd->ns_res3, buf, fmt);
91 fprintf(fd, "n-s resol3: %s\n", buf);
92
93 G_format_resolution(cellhd->tb_res, buf, -1);
94 fprintf(fd, "t-b resol: %s\n", buf);
95}
void G_format_resolution(double, char *, int)
Resolution to ASCII.
Definition wind_format.c:67
void G_format_easting(double, char *, int)
Easting to ASCII.
Definition wind_format.c:47
void G_format_northing(double, char *, int)
Northing to ASCII.
Definition wind_format.c:27
2D/3D raster map header (used also for region)
Definition gis.h:443
int cols3
Number of columns for 3D data.
Definition gis.h:464
double ew_res
Resolution - east to west cell size for 2D data.
Definition gis.h:479
double north
Extent coordinates (north)
Definition gis.h:489
double bottom
Extent coordinates (bottom) - 3D data.
Definition gis.h:499
int compressed
Compression mode (raster header only)
Definition gis.h:456
int format
Max number of bytes per raster data value minus 1 (raster header only)
Definition gis.h:449
int zone
Projection zone (UTM)
Definition gis.h:477
int depths
number of depths for 3D data
Definition gis.h:466
double east
Extent coordinates (east)
Definition gis.h:493
double ew_res3
Resolution - east to west cell size for 3D data.
Definition gis.h:481
double ns_res
Resolution - north to south cell size for 2D data.
Definition gis.h:483
double ns_res3
Resolution - north to south cell size for 3D data.
Definition gis.h:485
double top
Extent coordinates (top) - 3D data.
Definition gis.h:497
int rows3
Number of rows for 3D data.
Definition gis.h:460
int rows
Number of rows for 2D data.
Definition gis.h:458
int cols
Number of columns for 2D data.
Definition gis.h:462
int proj
Projection code.
Definition gis.h:475
double south
Extent coordinates (south)
Definition gis.h:491
double tb_res
Resolution - top to bottom cell size for 3D data.
Definition gis.h:487
double west
Extent coordinates (west)
Definition gis.h:495
void G__write_Cell_head(FILE *fd, const struct Cell_head *cellhd, int is_cellhd)
Write cell header or window.
Definition wr_cellhd.c:25
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:70