GRASS 8 Programmer's Manual 8.6.0dev(2026)-1d1e47ad9d
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 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 */
27void 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 */
72void 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_resolution(double, char *, int)
Resolution to ASCII.
Definition wind_format.c:69
void G_format_easting(double, char *, int)
Easting to ASCII.
Definition wind_format.c:49
void G_format_northing(double, char *, int)
Northing to ASCII.
Definition wind_format.c:29
2D/3D raster map header (used also for region)
Definition gis.h:446
int cols3
Number of columns for 3D data.
Definition gis.h:467
double ew_res
Resolution - east to west cell size for 2D data.
Definition gis.h:482
double north
Extent coordinates (north)
Definition gis.h:492
double bottom
Extent coordinates (bottom) - 3D data.
Definition gis.h:502
int compressed
Compression mode (raster header only)
Definition gis.h:459
int format
Max number of bytes per raster data value minus 1 (raster header only)
Definition gis.h:452
int zone
Projection zone (UTM)
Definition gis.h:480
int depths
number of depths for 3D data
Definition gis.h:469
double east
Extent coordinates (east)
Definition gis.h:496
double ew_res3
Resolution - east to west cell size for 3D data.
Definition gis.h:484
double ns_res
Resolution - north to south cell size for 2D data.
Definition gis.h:486
double ns_res3
Resolution - north to south cell size for 3D data.
Definition gis.h:488
double top
Extent coordinates (top) - 3D data.
Definition gis.h:500
int rows3
Number of rows for 3D data.
Definition gis.h:463
int rows
Number of rows for 2D data.
Definition gis.h:461
int cols
Number of columns for 2D data.
Definition gis.h:465
int proj
Projection code.
Definition gis.h:478
double south
Extent coordinates (south)
Definition gis.h:494
double tb_res
Resolution - top to bottom cell size for 3D data.
Definition gis.h:490
double west
Extent coordinates (west)
Definition gis.h:498
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